diff --git a/inc/attendancelog.php b/inc/attendancelog.php index d39cc0a..2d8176c 100644 --- a/inc/attendancelog.php +++ b/inc/attendancelog.php @@ -60,24 +60,33 @@ class attendancelog { $sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' '; return $this->DB->QUR_SEL($sql_search); } + public function getWeekByDate($ts=0) { + $url = 'https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur&ts=' . $ts; + $awn = json_decode(file_get_contents($url),1); + return $awn['week_cur']; + } function mainPageAction() { $des = ''; if(isset($_GET['des'])) $des = $_GET['des']; if ($des == 'show'){ - //получаем список пар по имени группы -// $current_group = $this->getGroupNamebyID($_GET['id']); -// return $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); - - $current_group = $this->getGroupNamebyID($_GET['id']); $current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']); $currentTime = $this->currentTime(); $out = array(); foreach ($current_group_classes['raspis'] as $class) { - if ($class['week1'] == $currentTime['week1']) { - $out['info'][$class['day1']]['day_name'] = $class['day_name']; - $out['info'][$class['day1']][$class['time1']] = $class; - $out['students'] = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); + if(isset($_POST['date_request'])) { + $week_compare = $this->getWeekByDate(strtotime($_POST['date_request'])); + $day_compare = date('w', strtotime($_POST['date_request'])); + }else { + $week_compare = $currentTime['week1']; + $day_compare = $currentTime['day1']; + } + if ($class['week1'] == $week_compare) { + if($class['day1'] == $day_compare){ + $out['day_name'] = $class['day_name']; + $out['day_info'][$class['time1']] = $class; + $out['students'] = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); + } } } return $out; @@ -90,8 +99,8 @@ class attendancelog { $actionResult = $this->mainPageAction(); $currentTime = $this->currentTime(); //$html .= '
'. print_r($groups,1) . ''; - $html .= '
'. print_r($actionResult,1) . ''; - $html .= '
'. print_r($currentTime,1) . ''; + //$html .= '
'. print_r($actionResult,1) . ''; + //$html .= '
'. print_r($currentTime,1) . ''; //$html .= '
'. print_r($_GET,1) . ''; //$html .= '
'. print_r($_POST,1) . ''; //$html .= '
'. print_r($_SESSION,1) . '';