Отображение имен студентов через ссылку на их айди, изменение структуры бд

This commit is contained in:
RomanGolienko 2024-12-09 08:55:29 +03:00
parent 35f3825633
commit 704a52bf9f
2 changed files with 14 additions and 13 deletions

View File

@ -65,7 +65,7 @@ class attendancelog {
{
$educationForm = urlencode($educationForm);
$groupName = urlencode($groupName);
$url = 'https://eios.mkgtu.ru/api.php?des=studentsByGrupp&param1=' . $groupName . '&param2=' . $educationForm;
$url = 'https://eios.mkgtu.ru/api.php?des=studentsByGrupp&param1=' . $groupName . '&param2=' . $educationForm.'&param3=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'];
}
}

View File

@ -91,14 +91,14 @@
</tr>
</thead>
<tbody>
{foreach from=$class.students key=student item=att}
{foreach from=$class.students key=student_id item=att}
<tr>
<td>{$student}</td>
<td>{$actionResult.students_all[$student_id]}</td>
<td>
<input type="hidden" name="attendance_add_edit[attendance][{$student}]" value="0">
<input type="hidden" name="attendance_add_edit[attendance][{$student_id}]" value="0">
<label for="{$student|replace:' ':''}{$key}"></label>
<input class="custom-checkbox" type="checkbox" name="attendance_add_edit[attendance][{$student}]" id="{$student|replace:' ':''}{$key}" value="1" {if $att == '1'} checked {/if}>
<input class="custom-checkbox" type="checkbox" name="attendance_add_edit[attendance][{$student_id}]" id="{$student|replace:' ':''}{$key}" value="1" {if $att == '1'} checked {/if}>
</td>
</tr>