Отображение имен студентов через ссылку на их айди, изменение структуры бд
This commit is contained in:
parent
35f3825633
commit
704a52bf9f
|
@ -65,7 +65,7 @@ class attendancelog {
|
||||||
{
|
{
|
||||||
$educationForm = urlencode($educationForm);
|
$educationForm = urlencode($educationForm);
|
||||||
$groupName = urlencode($groupName);
|
$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);
|
return json_decode(file_get_contents($url),1);
|
||||||
}
|
}
|
||||||
function getClassesByGroup($groupName,$educationForm)
|
function getClassesByGroup($groupName,$educationForm)
|
||||||
|
@ -121,14 +121,14 @@ class attendancelog {
|
||||||
public function AttendanceAddEdit()
|
public function AttendanceAddEdit()
|
||||||
{
|
{
|
||||||
if(isset($_POST['attendance_add_edit'])){
|
if(isset($_POST['attendance_add_edit'])){
|
||||||
foreach ($_POST['attendance_add_edit']['attendance'] as $student_name => $student_att){
|
foreach ($_POST['attendance_add_edit']['attendance'] as $user_id => $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']) .'" ';
|
$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);
|
$search = $this->DB->QUR_SEL($sql_search);
|
||||||
if (isset($search[1])){
|
if (isset($search[1])){
|
||||||
$sql_update = 'UPDATE acs_attendancelog_students_attendance SET att=' . $student_att . ' WHERE id='. $search[1]['id'] .' ';
|
$sql_update = 'UPDATE acs_attendancelog_students_attendance SET att=' . $student_att . ' WHERE id='. $search[1]['id'] .' ';
|
||||||
$rez = $this->DB->QUR($sql_update);
|
$rez = $this->DB->QUR($sql_update);
|
||||||
}else {
|
}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);
|
$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']);
|
$current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
|
||||||
$currentTime = $this->currentTime();
|
$currentTime = $this->currentTime();
|
||||||
$out = array();
|
$out = array();
|
||||||
|
$tmp = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
|
||||||
|
$out['students_all'] = $tmp['students'];
|
||||||
if(isset($_POST['date_request'])) {
|
if(isset($_POST['date_request'])) {
|
||||||
$week_compare = $this->getWeekByDate(strtotime($_POST['date_request']));
|
$week_compare = $this->getWeekByDate(strtotime($_POST['date_request']));
|
||||||
$day_compare = date('w', strtotime($_POST['date_request']));
|
$day_compare = date('w', strtotime($_POST['date_request']));
|
||||||
|
@ -161,13 +163,12 @@ class attendancelog {
|
||||||
if($class['day1'] == $day_compare){
|
if($class['day1'] == $day_compare){
|
||||||
$out['day_name'] = $class['day_name'];
|
$out['day_name'] = $class['day_name'];
|
||||||
$out['day_info'][$class['time1']] = $class;
|
$out['day_info'][$class['time1']] = $class;
|
||||||
$students = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
|
foreach ($out['students_all'] as $student_id => $student_name){
|
||||||
foreach ($students['students'] as $student_name){
|
$out['day_info'][$class['time1']]['students'][$student_id] = '0';
|
||||||
$out['day_info'][$class['time1']]['students'][$student_name] = 'off';
|
$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'] .'" ';
|
||||||
$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'] .'" ';
|
|
||||||
$search = $this->DB->QUR_SEL($sql_search);
|
$search = $this->DB->QUR_SEL($sql_search);
|
||||||
if(isset($search[1])){
|
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'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,14 +91,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$class.students key=student item=att}
|
{foreach from=$class.students key=student_id item=att}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$student}</td>
|
<td>{$actionResult.students_all[$student_id]}</td>
|
||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue