From 55c9ddfe4526eb62999a6bfa2ae4ba1563b403ba Mon Sep 17 00:00:00 2001 From: RomanGolienko Date: Mon, 25 Nov 2024 12:42:55 +0300 Subject: [PATCH] manual calendar feature --- inc/attendancelog.php | 75 +++++++---------- tpl/main_page.html | 185 ++++++++++++++++++++++++++---------------- 2 files changed, 143 insertions(+), 117 deletions(-) diff --git a/inc/attendancelog.php b/inc/attendancelog.php index 4db344e..910f39a 100644 --- a/inc/attendancelog.php +++ b/inc/attendancelog.php @@ -55,11 +55,25 @@ class attendancelog { $rez['week1'] = $week['week_cur']; return $rez; } - function timeGroup() { - - $raspis = $this->mainPageAction(); + function getGroupNameByID($id) { + $sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' '; + return $this->DB->QUR_SEL($sql_search); + } + function mainPageAction() + { + $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']); + } + } + $currentTime = $this->currentTime(); $first_weekday_of_year = $currentTime['year'] .'-01-01'; $first_weekday_of_year= date('w', strtotime($first_weekday_of_year)); @@ -69,49 +83,20 @@ class attendancelog { $day = 1; $week = 1; for ($day; $day <= $day_in_month; $day++){ - if($weekday > 7){ - $weekday = 1; - $week++; - } $tmp1 = $currentTime['year'] . '-' . $month . '-' . '01'; $month_name = date('M',strtotime($tmp1)); - $out[$currentTime['year']][$month_name][$week . ' неделя'][$day] = $raspis['info'][$weekday]; - - - $weekday++; - - } - } - - return $out; - } - function getGroupNameByID($id) { - $sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' '; - return $this->DB->QUR_SEL($sql_search); - } - 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']); + $result[$currentTime['year']][$month_name][$week][$day] = $out['info'][$weekday]; + if($weekday > 6){ + $weekday = 1; + $week++; + }else{ + $weekday++; } } - return $out; - }elseif($des == 'calendar_show'){ - + } + $des = ''; if(isset($_GET['des'])) $des = $_GET['des']; + if ($des == 'show'){ + return $result; } } function HTML() @@ -120,12 +105,10 @@ class attendancelog { $groups = $this->getAllGrupps(); $actionResult = $this->mainPageAction(); $currentTime = $this->currentTime(); - $timeGroup = $this->timeGroup(); //$html .= '
'. print_r($groups,1) . '
'; - //$html .= '
'. print_r($actionResult,1) . '
'; - $html .= '
'. print_r($timeGroup,1) . '
'; + $html .= '
'. print_r($actionResult,1) . '
'; //$html .= '
'. print_r($currentTime,1) . '
'; - //$html .= '
'. print_r($_GET,1) . '
'; + $html .= '
'. print_r($_GET,1) . '
'; //$html .= '
'. print_r($_POST,1) . '
'; //$html .= '
'. print_r($_SESSION,1) . '
'; GLOBAL $smarty; diff --git a/tpl/main_page.html b/tpl/main_page.html index 240b987..dbc2df4 100644 --- a/tpl/main_page.html +++ b/tpl/main_page.html @@ -32,84 +32,127 @@
-

Посещение группы {$groupName}

+

Посещение группы

-
- -
- {foreach from=$actionResult.info key=key item=day} -
-
- {foreach from=$day key=key item=class} - {if $key != 0} - - - - - {/foreach} - - + + {/foreach} + +

{$class.time1}

- -
-
-
- - - - - - - - - - - {foreach from=$actionResult.students.students key=key item=student} - - - - - - - {/foreach} - -
NoФИОПрисутствиеПримечание
{$key}{$student} - - - - - - - -
- -
-
-
+ {foreach from=$actionResult[$currentTime['year']] key=month_key item=month} + + + + + + + + + + + + + {foreach from=$month key=week_key item=week} + + {if count($week) < 7 and $week_key == 1} + {for $foo=1 to (7 - count($week))} + + {/for} + {/if} - - - - -
{$month_key}
ПонедельникВторникСредаЧетвергПятницаСубботаВоскресенье
- {/if} - {/foreach} -
- + {foreach from=$week key=day_key item=day} +
{$day_key}
+ {/foreach}
+ +{else if $des == 'day_show'} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {else}
@@ -119,7 +162,6 @@
-
@@ -157,4 +199,5 @@
-{/if} \ No newline at end of file +{/if} + \ No newline at end of file