From cfb09475b9ba14e484ec27670399e2ee6b87e8b6 Mon Sep 17 00:00:00 2001 From: RomanGolienko Date: Fri, 17 Jan 2025 13:16:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=B5=D0=BF=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D0=B5=D0=BC=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=B5=D1=89=D0=B0=D0=B5=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/attendancelog.php | 17 ++++++++++++----- tpl/main_page.html | 24 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/inc/attendancelog.php b/inc/attendancelog.php index a8c90b3..f1b4c03 100644 --- a/inc/attendancelog.php +++ b/inc/attendancelog.php @@ -145,13 +145,16 @@ class attendancelog { { if(isset($_POST['attendance_add_edit'])){ foreach ($_POST['attendance_add_edit']['attendance'] as $user_id => $student_att){ - $sql_search = 'SELECT id FROM acs_attendancelog_students_attendance WHERE user_id="'. $user_id .'" AND gruppa="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['gruppa']) .'" AND date1="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['date']) .'" AND time1='. $this->DB->rescape($_POST['attendance_add_edit']['info']['time1']) .' AND predmet_id="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet_id']) .'" '; + $sql_search = 'SELECT id, appr FROM acs_attendancelog_students_attendance WHERE user_id="'. $user_id .'" AND gruppa="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['gruppa']) .'" AND date1="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['date']) .'" AND time1='. $this->DB->rescape($_POST['attendance_add_edit']['info']['time1']) .' AND predmet_id="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet_id']) .'" '; $search = $this->DB->QUR_SEL($sql_search); if (isset($search[1])){ - $sql_update = 'UPDATE acs_attendancelog_students_attendance SET att=' . $student_att . ' WHERE id='. $search[1]['id'] .' '; - $rez = $this->DB->QUR($sql_update); + if(0 == $search[1]['appr']){ + $sql_update = 'UPDATE acs_attendancelog_students_attendance SET att=' . $student_att . ', appr='. $_POST['attendance_add_edit']['info']['approval'] .' WHERE id='. $search[1]['id'] .' '; + $rez = $this->DB->QUR($sql_update); + } + }else { - $sql_insert = 'INSERT INTO acs_attendancelog_students_attendance (id, user_id, gruppa, date1, att, time1, predmet_id) VALUES (0,"'.$user_id.'", "'. $this->DB->rescape($_POST['attendance_add_edit']['info']['gruppa']) .'", "'. $this->DB->rescape($_POST['attendance_add_edit']['info']['date']) .'", '. $student_att .', '. $this->DB->rescape($_POST['attendance_add_edit']['info']['time1']) .',"'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet_id']) . '")'; + $sql_insert = 'INSERT INTO acs_attendancelog_students_attendance (id, user_id, gruppa, date1, att, appr, time1, predmet_id) VALUES (0,"'.$user_id.'", "'. $this->DB->rescape($_POST['attendance_add_edit']['info']['gruppa']) .'", "'. $this->DB->rescape($_POST['attendance_add_edit']['info']['date']) .'", '. $student_att .','. $this->DB->rescape($_POST['attendance_add_edit']['info']['approval']) .', '. $this->DB->rescape($_POST['attendance_add_edit']['info']['time1']) .',"'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet_id']) . '")'; $rez = $this->DB->QUR($sql_insert); } @@ -206,10 +209,14 @@ class attendancelog { $out['day_name'] = $class['day_name']; $out['day_info'][$class['time1']] = $class; $out['day_info'][$class['time1']]['predmet_id'] = $this->predmetsAddEdit($class['predmet']); + $sql_search = 'SELECT appr FROM acs_attendancelog_students_attendance WHERE gruppa="'. $current_group[1]['sokr'] .'" AND date1="'. $db_date .'" AND time1='. $class['time1'] .' AND predmet_id='. $out['day_info'][$class['time1']]['predmet_id']; + $search = $this->DB->QUR_SEL($sql_search); + if(isset($search[1])){ + $out['day_info'][$class['time1']]['approval'] = $search[1]['appr']; + } foreach ($out['students_all'] as $student_id => $student_name){ $out['day_info'][$class['time1']]['students'][$student_id] = '0'; $sql_search = 'SELECT user_id, att FROM acs_attendancelog_students_attendance WHERE user_id="'. $student_id .'" AND gruppa="'. $current_group[1]['sokr'] .'" AND date1="'. $db_date .'" AND time1='. $class['time1'] .' AND predmet_id='. $out['day_info'][$class['time1']]['predmet_id']; - //$out['day_info'][$class['time1']]['search'] = $sql_search; $search = $this->DB->QUR_SEL($sql_search); if(isset($search[1])){ $out['day_info'][$class['time1']]['students'][$student_id] = $search[1]['att']; diff --git a/tpl/main_page.html b/tpl/main_page.html index d92eeae..5a49a1f 100644 --- a/tpl/main_page.html +++ b/tpl/main_page.html @@ -93,11 +93,11 @@
{$class.time_name.0} - {$class.time_name.1}
-
+
@@ -115,7 +115,7 @@ - + @@ -131,13 +131,25 @@ {/if} - + +
+
+ +
+ {if $currentUserInfo.role != 'student'} +
+ + +
+ {/if} +
+ + -