добавлена функция, возвращющая текущие параметры времени + изменена структура массива в mainPageAction

This commit is contained in:
RomanGolienko 2024-11-14 17:00:33 +03:00
parent c63df969c4
commit 1968c77a6f
1 changed files with 37 additions and 4 deletions

View File

@ -7,7 +7,7 @@ class attendancelog {
$this->name = $name; $this->name = $name;
} }
function getAllGrupps() { function getAllGrupps() {
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp ORDER BY `sokr` DESC'; $sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp WHERE fo="ОФО" ORDER BY `sokr` DESC';
$rez = $this->DB->QUR_SEL($sql_search); $rez = $this->DB->QUR_SEL($sql_search);
return $rez; return $rez;
} }
@ -30,6 +30,31 @@ class attendancelog {
return json_decode(file_get_contents($url),1); return json_decode(file_get_contents($url),1);
//return $url; //return $url;
} }
function currentTime() { //возвращает информацию о текущем моменте для пользователя
$rez = array();
$moment = getdate();
$curr_minutes = $moment['hours'] * 60 + $moment['seconds'];
$minutes = 480;
for($i = 1; $i < 8; $i++) { //возвращает текущую пару в университете
if ($curr_minutes >= $minutes-10 AND $curr_minutes <= $minutes + 90){
$rez['time1'] = $i;
}
if ($i == 4){
$minutes = $minutes + 110;
}else{
$minutes = $minutes + 100;
}
}
$week = json_decode(file_get_contents('https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur'),1);
$rez['day1'] = $moment['wday'];
$rez['mday'] = $moment['mday'];
$rez['mon'] = $moment['mon'];
$rez['0'] = $moment['0'];
$rez['year'] = $moment['year'];
$rez['date'] = date("Y-m-d");
$rez['week1'] = $week['week_cur'];
return $rez;
}
function getGroupNameByID($id) { function getGroupNameByID($id) {
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' '; $sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' ';
@ -46,10 +71,14 @@ class attendancelog {
$current_group = $this->getGroupNamebyID($_GET['id']); $current_group = $this->getGroupNamebyID($_GET['id']);
$current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']); $current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
$currentTime = $this->currentTime();
$out = array(); $out = array();
foreach ($current_group_classes['raspis'] as $class) { foreach ($current_group_classes['raspis'] as $class) {
$out['info'][$class['week_name']][$class['day_name']][$class['time1']] = $class; if ($class['week1'] != $currentTime['week1']) {
$out['students'] = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); $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']);
}
} }
return $out; return $out;
} }
@ -59,15 +88,19 @@ class attendancelog {
$html = ''; $html = '';
$groups = $this->getAllGrupps(); $groups = $this->getAllGrupps();
$actionResult = $this->mainPageAction(); $actionResult = $this->mainPageAction();
$currentTime = $this->currentTime();
//$html .= '<pre>'. print_r($groups,1) . '</pre>'; //$html .= '<pre>'. print_r($groups,1) . '</pre>';
//$html .= '<pre>'. print_r($actionResult,1) . '</pre>'; $html .= '<pre>'. print_r($actionResult,1) . '</pre>';
$html .= '<pre>'. print_r($currentTime,1) . '</pre>';
//$html .= '<pre>'. print_r($_GET,1) . '</pre>'; //$html .= '<pre>'. print_r($_GET,1) . '</pre>';
//$html .= '<pre>'. print_r($_POST,1) . '</pre>';
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>'; //$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
GLOBAL $smarty; GLOBAL $smarty;
$page = ''; if(isset($_GET['page'])) $page = $_GET['page']; $page = ''; if(isset($_GET['page'])) $page = $_GET['page'];
$des = ''; if(isset($_GET['des'])) $des = $_GET['des']; $des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
$smarty->assign('des', $des); $smarty->assign('des', $des);
$smarty->assign('name', $this->name); $smarty->assign('name', $this->name);
$smarty->assign('currentTime', $currentTime);
if($page == 'headman') { if($page == 'headman') {
$smarty->clearCache('moduls/attendancelog/tpl/headman.html'); $smarty->clearCache('moduls/attendancelog/tpl/headman.html');
$html .= $smarty->fetch('moduls/attendancelog/tpl/headman.html'); $html .= $smarty->fetch('moduls/attendancelog/tpl/headman.html');