Добавление логики назначения старост и отображения в списке групп. Проврека на наличие статуса старосты при заходе студента в систему
This commit is contained in:
parent
46ef2c85fb
commit
b3ceee1515
|
@ -6,11 +6,9 @@ class attendancelog {
|
|||
$this->DB = $DB;
|
||||
$this->name = $name;
|
||||
}
|
||||
public function currentUserInfo()
|
||||
{
|
||||
public function currentUserInfo(){
|
||||
$currentUserInfo = array();
|
||||
if(isset($_SESSION['user']['teacher']))
|
||||
{
|
||||
if(isset($_SESSION['user']['teacher'])) {
|
||||
$currentUserInfo['role'] = 'teacher';
|
||||
$currentUserInfo['user_id'] = $_SESSION['user']['id'];
|
||||
$currentUserInfo['teacher_id'] = $_SESSION['user']['teacher']['id'];
|
||||
|
@ -29,10 +27,14 @@ class attendancelog {
|
|||
|
||||
}
|
||||
return $currentUserInfo;
|
||||
}else if(isset($_SESSION['user']['student']))
|
||||
{
|
||||
}else if(isset($_SESSION['user']['student'])) {
|
||||
$currentUserInfo['role'] = 'student';
|
||||
$currentUserInfo['user_id'] = $_SESSION['user']['id'];
|
||||
$sql_search = 'SELECT * FROM acs_attendancelog_headmen WHERE user_id='. $currentUserInfo['user_id'] .' ';
|
||||
$rez = $this->DB->QUR_SEL($sql_search);
|
||||
if(!isset($rez[1])){
|
||||
return 0;
|
||||
}
|
||||
$currentUserInfo['student_id'] = $_SESSION['user']['student']['id'];
|
||||
$currentUserInfo['grupp_id'] = $_SESSION['user']['student']['grupp']['id'];
|
||||
if(isset($_SESSION['user']['student']['grupp'])){
|
||||
|
@ -108,18 +110,13 @@ class attendancelog {
|
|||
|
||||
function getGroupNameByID($id) {
|
||||
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' ';
|
||||
return $this->DB->QUR_SEL($sql_search);
|
||||
//$tmp = $this->DB->QUR_SEL($sql_search);
|
||||
// unset($tmp[0]);
|
||||
// return $tmp;
|
||||
$tmp = $this->DB->QUR_SEL($sql_search);
|
||||
return $tmp[1];
|
||||
}
|
||||
public function getWeekByDate($ts=0) {
|
||||
$url = 'https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur&ts=' . $ts;
|
||||
$awn = json_decode(file_get_contents($url),1);
|
||||
return $awn['week_cur'];
|
||||
}
|
||||
public function headmanAddEdit(){
|
||||
|
||||
}
|
||||
public function predmetsAddEdit($predmet_name){
|
||||
//принимает имя предмета. Делает запись в таблицу предметов, если такой нет. В любом случае возвращает айди предмета
|
||||
|
@ -159,16 +156,35 @@ class attendancelog {
|
|||
return $rez;
|
||||
}
|
||||
}
|
||||
public function headmanAddDelete(){
|
||||
if(isset($_POST['headman_request'])){
|
||||
$currentUserInfo = $this->currentUserInfo();
|
||||
$current_time = $this->currentTime();
|
||||
$current_group = $this->getGroupNamebyID((int)$_GET['id']);
|
||||
$students = $this->getStudentsByGroup($current_group['sokr'], $current_group['fo']);
|
||||
$sql_search = 'SELECT * FROM acs_attendancelog_headmen WHERE gruppa="'. $current_group['sokr'] .'" ';
|
||||
$rez = $this->DB->QUR_SEL($sql_search);
|
||||
if(isset($rez[1])){
|
||||
$rez = $rez[1];
|
||||
$sql_delete = 'DELETE FROM acs_attendancelog_headmen WHERE gruppa="'. $current_group['sokr'] .'" ';
|
||||
$rez = $this->DB->QUR($sql_delete);
|
||||
}
|
||||
$sql_insert = 'INSERT INTO acs_attendancelog_headmen (id, user_id, gruppa, date_add, added_by) VALUES (0, '. $this->DB->rescape($_POST['headman_request']) .', "'. $current_group['sokr'] .'", "'. $current_time['date'] .'", '. $currentUserInfo['user_id'] .' )';
|
||||
$rez = $this->DB->QUR($sql_insert);
|
||||
return $rez;
|
||||
|
||||
}
|
||||
}
|
||||
function mainPageAction()
|
||||
{
|
||||
$currentUserInfo = $this->currentUserInfo();
|
||||
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
||||
if ($des == 'show'){
|
||||
$current_group = $this->getGroupNamebyID((int)$_GET['id']);
|
||||
$current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
|
||||
$current_group_classes = $this->getClassesByGroup($current_group['sokr'], $current_group['fo']);
|
||||
$currentTime = $this->currentTime();
|
||||
$out = array();
|
||||
$tmp = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
|
||||
$tmp = $this->getStudentsByGroup($current_group['sokr'], $current_group['fo']);
|
||||
$out['students_all'] = $tmp['students'];
|
||||
if(isset($_POST['date_request'])) {
|
||||
$week_compare = $this->getWeekByDate(strtotime($_POST['date_request']));
|
||||
|
@ -205,6 +221,25 @@ class attendancelog {
|
|||
function headmanPageAction(){
|
||||
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
||||
if($des == 'add_edit'){
|
||||
$out = array();
|
||||
$current_group = $this->getGroupNamebyID((int)$_GET['id']);
|
||||
$students = $this->getStudentsByGroup($current_group['sokr'], $current_group['fo']);
|
||||
$out['current_group'] = $current_group;
|
||||
$sql_search = 'SELECT * FROM acs_attendancelog_headmen WHERE gruppa="'. $current_group['sokr'] .'" ';
|
||||
$rez = $this->DB->QUR_SEL($sql_search);
|
||||
if (isset($rez[1])){
|
||||
$rez = $rez[1];
|
||||
}
|
||||
foreach ($students['students'] as $user_id => $student_name){
|
||||
$out['students'][$user_id]['student_name'] = $student_name;
|
||||
if($rez['user_id'] == $user_id){
|
||||
$out['students'][$user_id]['headman'] = 1;
|
||||
$out['headman'] = $student_name;
|
||||
}else{
|
||||
$out['students'][$user_id]['headman'] = 0;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
function HTML()
|
||||
|
@ -214,15 +249,17 @@ class attendancelog {
|
|||
$currentUserInfo = $this->currentUserInfo();
|
||||
$currentTime = $this->currentTime();
|
||||
$AttendanceAddEdit = $this->AttendanceAddEdit();// должен вызываться перед mainPageAction
|
||||
$headmanAddDelete = $this->headmanAddDelete();
|
||||
$mainPageActionResult = $this->mainPageAction();
|
||||
$headmanPageActionResult = $this->headmanPageAction();
|
||||
$predmetsAddEdit = $this->predmetsAddEdit('Исследование операций и методы оптимизации');
|
||||
|
||||
|
||||
//$html .= '<pre>'. print_r($groups,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($currentUserInfo,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($mainPageActionResult,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($headmanPageActionResult,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($predmetsAddEdit,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($headmanAddDelete,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($currentTime,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
|
||||
//$html .= '<pre>'. print_r($AttendanceAddEdit,1) . '</pre>';
|
||||
|
|
Loading…
Reference in New Issue