From 704a52bf9f3053d7ea097fac9db0cb33dafe49ba Mon Sep 17 00:00:00 2001 From: RomanGolienko Date: Mon, 9 Dec 2024 08:55:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BC=D0=B5=D0=BD=20=D1=81?= =?UTF-8?q?=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D1=83=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B8=D1=85=20=D0=B0=D0=B9=D0=B4=D0=B8,=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B=20=D0=B1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/attendancelog.php | 19 ++++++++++--------- tpl/main_page.html | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/inc/attendancelog.php b/inc/attendancelog.php index b4b0193..cf89625 100644 --- a/inc/attendancelog.php +++ b/inc/attendancelog.php @@ -65,7 +65,7 @@ class attendancelog { { $educationForm = urlencode($educationForm); $groupName = urlencode($groupName); - $url = 'https://eios.mkgtu.ru/api.php?des=studentsByGrupp¶m1=' . $groupName . '¶m2=' . $educationForm; + $url = 'https://eios.mkgtu.ru/api.php?des=studentsByGrupp¶m1=' . $groupName . '¶m2=' . $educationForm.'¶m3=1'; return json_decode(file_get_contents($url),1); } function getClassesByGroup($groupName,$educationForm) @@ -121,14 +121,14 @@ class attendancelog { public function AttendanceAddEdit() { if(isset($_POST['attendance_add_edit'])){ - foreach ($_POST['attendance_add_edit']['attendance'] as $student_name => $student_att){ - $sql_search = 'SELECT id FROM acs_attendancelog_students_attendance WHERE name="'. $student_name .'" 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="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet']) .'" '; + 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="'. $this->DB->rescape($_POST['attendance_add_edit']['info']['predmet']) .'" '; $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); }else { - $sql_insert = 'INSERT INTO acs_attendancelog_students_attendance (id, name, gruppa, date1, att, time1, predmet) VALUES (0,"'.$student_name.'", "'. $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']) . '")'; + $sql_insert = 'INSERT INTO acs_attendancelog_students_attendance (id, user_id, gruppa, date1, att, time1, predmet) 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']) . '")'; $rez = $this->DB->QUR($sql_insert); } @@ -147,6 +147,8 @@ class attendancelog { $current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']); $currentTime = $this->currentTime(); $out = array(); + $tmp = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); + $out['students_all'] = $tmp['students']; if(isset($_POST['date_request'])) { $week_compare = $this->getWeekByDate(strtotime($_POST['date_request'])); $day_compare = date('w', strtotime($_POST['date_request'])); @@ -161,13 +163,12 @@ class attendancelog { if($class['day1'] == $day_compare){ $out['day_name'] = $class['day_name']; $out['day_info'][$class['time1']] = $class; - $students = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']); - foreach ($students['students'] as $student_name){ - $out['day_info'][$class['time1']]['students'][$student_name] = 'off'; - $sql_search = 'SELECT name, att FROM acs_attendancelog_students_attendance WHERE name="'. $student_name .'" AND gruppa="'. $current_group[1]['sokr'] .'" AND date1="'. $db_date .'" AND time1='. $class['time1'] .' AND predmet="'. $class['predmet'] .'" '; + 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="'. $class['predmet'] .'" '; $search = $this->DB->QUR_SEL($sql_search); if(isset($search[1])){ - $out['day_info'][$class['time1']]['students'][$student_name] = $search[1]['att']; + $out['day_info'][$class['time1']]['students'][$student_id] = $search[1]['att']; } } diff --git a/tpl/main_page.html b/tpl/main_page.html index b2d2f93..40f2836 100644 --- a/tpl/main_page.html +++ b/tpl/main_page.html @@ -91,14 +91,14 @@ - {foreach from=$class.students key=student item=att} + {foreach from=$class.students key=student_id item=att} - {$student} + {$actionResult.students_all[$student_id]} - + - +