Добавлена функция для статуса пользователя, разделение функционала и вида для разных ролей.
This commit is contained in:
parent
2881642d7d
commit
35f3825633
|
@ -6,10 +6,60 @@ class attendancelog {
|
||||||
$this->DB = $DB;
|
$this->DB = $DB;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
function getAllGrupps() {
|
public function currentUserInfo()
|
||||||
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp WHERE fo="ОФО" ORDER BY `sokr` DESC';
|
{
|
||||||
$rez = $this->DB->QUR_SEL($sql_search);
|
$currentUserInfo = array();
|
||||||
return $rez;
|
if(isset($_SESSION['user']['teacher']))
|
||||||
|
{
|
||||||
|
$currentUserInfo['role'] = 'teacher';
|
||||||
|
$currentUserInfo['user_id'] = $_SESSION['user']['id'];
|
||||||
|
$currentUserInfo['teacher_id'] = $_SESSION['user']['teacher']['id'];
|
||||||
|
if(isset($_SESSION['user']['teacher']['fakultet'])){
|
||||||
|
$sql_search = 'SELECT id FROM acs_faculties WHERE name="'. $_SESSION['user']['teacher']['fakultet'] .'"';
|
||||||
|
$tmp = $this->DB->QUR_SEL($sql_search);
|
||||||
|
unset($tmp[0]);
|
||||||
|
$currentUserInfo['facult']['facult_name'] = $_SESSION['user']['teacher']['fakultet'];
|
||||||
|
$currentUserInfo['facult']['facult_id'] = $tmp[1]['id'];
|
||||||
|
$sql_search = 'SELECT id, sokr, fo FROM acs_grupp WHERE id_facult="'.$tmp[1]['id'] .'" AND sokr NOT LIKE "Выпуск%"';
|
||||||
|
$tmp = $this->DB->QUR_SEL($sql_search);
|
||||||
|
unset($tmp[0]);
|
||||||
|
foreach($tmp as $grupp){
|
||||||
|
$currentUserInfo['related_grupps'][$grupp['sokr']] = $grupp ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return $currentUserInfo;
|
||||||
|
}else if(isset($_SESSION['user']['student']))
|
||||||
|
{
|
||||||
|
$currentUserInfo['role'] = 'student';
|
||||||
|
$currentUserInfo['user_id'] = $_SESSION['user']['id'];
|
||||||
|
$currentUserInfo['student_id'] = $_SESSION['user']['student']['id'];
|
||||||
|
$currentUserInfo['grupp_id'] = $_SESSION['user']['student']['grupp']['id'];
|
||||||
|
if(isset($_SESSION['user']['student']['grupp'])){
|
||||||
|
$currentUserInfo['facult']['facult_id'] = $_SESSION['user']['student']['grupp']['id_facult'];
|
||||||
|
$sql_search = 'SELECT name FROM acs_faculties WHERE id='. $currentUserInfo['facult']['facult_id'] .' ';
|
||||||
|
$tmp = $this->DB->QUR_SEL($sql_search);
|
||||||
|
unset($tmp[0]);
|
||||||
|
}
|
||||||
|
return $currentUserInfo;
|
||||||
|
|
||||||
|
}
|
||||||
|
// else if(isset($_SESSION['user']['statuses']['25']))
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }else{
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
function getAllGrupps($facult = '') {
|
||||||
|
if($facult != ''){
|
||||||
|
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp WHERE fo="ОФО" AND id_facult="'. $facult .'" AND sokr NOT LIKE "Выпуск%" ORDER BY `sokr` DESC';
|
||||||
|
}else{
|
||||||
|
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp WHERE fo="ОФО" AND sokr NOT LIKE "Выпуск%" ORDER BY `sokr` DESC';
|
||||||
|
}
|
||||||
|
$tmp = $this->DB->QUR_SEL($sql_search);
|
||||||
|
unset($tmp[0]);
|
||||||
|
return $tmp;
|
||||||
}
|
}
|
||||||
function getStudentsByGroup($groupName,$educationForm)
|
function getStudentsByGroup($groupName,$educationForm)
|
||||||
{
|
{
|
||||||
|
@ -59,23 +109,19 @@ class attendancelog {
|
||||||
function getGroupNameByID($id) {
|
function getGroupNameByID($id) {
|
||||||
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' ';
|
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' ';
|
||||||
return $this->DB->QUR_SEL($sql_search);
|
return $this->DB->QUR_SEL($sql_search);
|
||||||
|
//$tmp = $this->DB->QUR_SEL($sql_search);
|
||||||
|
// unset($tmp[0]);
|
||||||
|
// return $tmp;
|
||||||
}
|
}
|
||||||
public function getWeekByDate($ts=0) {
|
public function getWeekByDate($ts=0) {
|
||||||
$url = 'https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur&ts=' . $ts;
|
$url = 'https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur&ts=' . $ts;
|
||||||
$awn = json_decode(file_get_contents($url),1);
|
$awn = json_decode(file_get_contents($url),1);
|
||||||
return $awn['week_cur'];
|
return $awn['week_cur'];
|
||||||
}
|
}
|
||||||
|
|
||||||
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 $student_name => $student_att){
|
||||||
if ($student_att == 'on'){
|
|
||||||
$student_att = 1;
|
|
||||||
}else{
|
|
||||||
$student_att = 0;
|
|
||||||
}
|
|
||||||
$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 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']) .'" ';
|
||||||
$search = $this->DB->QUR_SEL($sql_search);
|
$search = $this->DB->QUR_SEL($sql_search);
|
||||||
if (isset($search[1])){
|
if (isset($search[1])){
|
||||||
|
@ -88,14 +134,16 @@ class attendancelog {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$rez['date_cur'] = $_POST['attendance_add_edit']['info']['date'];
|
||||||
return $rez;
|
return $rez;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function mainPageAction()
|
function mainPageAction()
|
||||||
{
|
{
|
||||||
|
$currentUserInfo = $this->currentUserInfo();
|
||||||
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
||||||
if ($des == 'show'){
|
if ($des == 'show'){
|
||||||
$current_group = $this->getGroupNamebyID($_GET['id']);
|
$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[1]['sokr'], $current_group[1]['fo']);
|
||||||
$currentTime = $this->currentTime();
|
$currentTime = $this->currentTime();
|
||||||
$out = array();
|
$out = array();
|
||||||
|
@ -119,12 +167,7 @@ class attendancelog {
|
||||||
$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'] .'" ';
|
$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])){
|
||||||
if($search[1]['att'] == 1){
|
$out['day_info'][$class['time1']]['students'][$student_name] = $search[1]['att'];
|
||||||
$db_att = 'on';
|
|
||||||
}else{
|
|
||||||
$db_att = 'off';
|
|
||||||
}
|
|
||||||
$out['day_info'][$class['time1']]['students'][$student_name] = $db_att;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,42 +179,56 @@ class attendancelog {
|
||||||
}
|
}
|
||||||
function HTML()
|
function HTML()
|
||||||
{
|
{
|
||||||
|
GLOBAL $smarty;
|
||||||
$html = '';
|
$html = '';
|
||||||
$groups = $this->getAllGrupps();
|
$currentUserInfo = $this->currentUserInfo();
|
||||||
$currentTime = $this->currentTime();
|
$currentTime = $this->currentTime();
|
||||||
$AttendanceAddEdit = $this->AttendanceAddEdit();
|
$AttendanceAddEdit = $this->AttendanceAddEdit();// должен вызываться перед mainPageAction
|
||||||
$actionResult = $this->mainPageAction();
|
$actionResult = $this->mainPageAction();
|
||||||
|
|
||||||
|
|
||||||
//$html .= '<pre>'. print_r($groups,1) . '</pre>';
|
//$html .= '<pre>'. print_r($groups,1) . '</pre>';
|
||||||
|
//$html .= '<pre>'. print_r($currentUserInfo,1) . '</pre>';
|
||||||
//$html .= '<pre>'. print_r($actionResult,1) . '</pre>';
|
//$html .= '<pre>'. print_r($actionResult,1) . '</pre>';
|
||||||
//$html .= '<pre>'. print_r($currentTime,1) . '</pre>';
|
//$html .= '<pre>'. print_r($currentTime,1) . '</pre>';
|
||||||
|
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
|
||||||
//$html .= '<pre>'. print_r($AttendanceAddEdit,1) . '</pre>';
|
//$html .= '<pre>'. print_r($AttendanceAddEdit,1) . '</pre>';
|
||||||
//$html .= '<pre>'. print_r($_GET,1) . '</pre>';
|
//$html .= '<pre>'. print_r($_GET,1) . '</pre>';
|
||||||
//$html .= '<pre>'. print_r($_POST,1) . '</pre>';
|
//$html .= '<pre>'. print_r($_POST,1) . '</pre>';
|
||||||
$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
|
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
|
||||||
GLOBAL $smarty;
|
|
||||||
$page = ''; if(isset($_GET['page'])) $page = $_GET['page'];
|
$page = ''; if(isset($_GET['page'])) $page = $_GET['page'];
|
||||||
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
|
||||||
$smarty->assign('des', $des);
|
$smarty->assign('des', $des);
|
||||||
$smarty->assign('name', $this->name);
|
$smarty->assign('name', $this->name);
|
||||||
$smarty->assign('currentTime', $currentTime);
|
$smarty->assign('currentTime', $currentTime);
|
||||||
|
$smarty->assign('currentUserInfo', $currentUserInfo);
|
||||||
if($page == 'headman') {
|
if($page == 'headman') {
|
||||||
$smarty->clearCache('moduls/attendancelog/tpl/headman.html');
|
$smarty->clearCache('moduls/attendancelog/tpl/headman.html');
|
||||||
$html .= $smarty->fetch('moduls/attendancelog/tpl/headman.html');
|
$html .= $smarty->fetch('moduls/attendancelog/tpl/headman.html');
|
||||||
}
|
}
|
||||||
if ($page == ''){
|
if ($page == ''){
|
||||||
|
if($currentUserInfo['role'] == 'student'){
|
||||||
|
$header = "Location: https://eios.mkgtu.ru/modul/attendancelog/main/show/" . $currentUserInfo['grupp_id'] . '/';
|
||||||
|
header($header);
|
||||||
|
}
|
||||||
|
$groups = $this->getAllGrupps();
|
||||||
|
$facult_groups = $this->getAllGrupps($currentUserInfo['facult']['facult_id']);
|
||||||
$smarty->assign('groups',$groups);
|
$smarty->assign('groups',$groups);
|
||||||
|
$smarty->assign('facult_groups',$facult_groups);
|
||||||
$smarty->clearCache('moduls/attendancelog/tpl/main_page.html');
|
$smarty->clearCache('moduls/attendancelog/tpl/main_page.html');
|
||||||
$html .= $smarty->fetch('moduls/attendancelog/tpl/main_page.html');
|
$html .= $smarty->fetch('moduls/attendancelog/tpl/main_page.html');
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($page == 'main'){
|
if ($page == 'main'){//Староста
|
||||||
if ($des == 'show'){
|
if ($des == 'show'){
|
||||||
|
$smarty->assign('AttendanceAddEdit', $AttendanceAddEdit);
|
||||||
$smarty->assign('actionResult', $actionResult);
|
$smarty->assign('actionResult', $actionResult);
|
||||||
$groupName = $this->getGroupNameByID($_GET['id']);
|
$groupName = $this->getGroupNameByID((int)$_GET['id']);
|
||||||
$groupName = $groupName[1]['sokr'];
|
$groupName = $groupName[1]['sokr'];
|
||||||
$smarty->assign('groupName', $groupName);
|
$smarty->assign('groupName', $groupName);
|
||||||
}
|
}
|
||||||
$smarty->assign('groups',$groups);
|
//$smarty->assign('groups',$groups);
|
||||||
$smarty->clearCache('moduls/attendancelog/tpl/main_page.html');
|
$smarty->clearCache('moduls/attendancelog/tpl/main_page.html');
|
||||||
$html .= $smarty->fetch('moduls/attendancelog/tpl/main_page.html');
|
$html .= $smarty->fetch('moduls/attendancelog/tpl/main_page.html');
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span">
|
<div class="span">
|
||||||
<h3 class="page-title"> Посещаемость </h3>
|
<h3 class="page-title"> Посещаемость </h3>
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
<li><a href="/">Главная</a><span class="divider">/</span></li>
|
<li><a href="/">Главная</a><span class="divider">/</span></li>
|
||||||
<li class="active"><a href="/modul/attendancelog/">Посещаемость</a></li>
|
<li class="active"><a href="/modul/attendancelog/">Посещаемость</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span">
|
<div class="span">
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ul class="nav ">
|
<ul class="nav ">
|
||||||
<li class="active" ><a href="/modul/attendancelog/">Главная</a></li>
|
<li class="active" ><a href="/modul/attendancelog/">Главная</a></li>
|
||||||
<li><a href="/modul/attendancelog/headman/">Старосты</a></li>
|
<li><a href="/modul/attendancelog/headman/">Старосты</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><a href="#">{$name}</a></li>
|
<li><a href="#">{$name}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{if $des == 'show'}
|
{if $des == 'show'}
|
||||||
<a href="/modul/attendancelog/" role="button" class="btn"> Вернуться </a>
|
{if $currentUserInfo.role != 'student'}
|
||||||
|
<a href="/modul/attendancelog/" role="button" class="btn"> Вернуться </a>
|
||||||
|
{/if}
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="widget blue">
|
<div class="widget blue">
|
||||||
|
@ -95,10 +95,10 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$student}</td>
|
<td>{$student}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="attendance_add_edit[attendance][{$student}]" value="off">
|
<input type="hidden" name="attendance_add_edit[attendance][{$student}]" 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}" {if $att == 'on'} checked {/if}>
|
<input class="custom-checkbox" type="checkbox" name="attendance_add_edit[attendance][{$student}]" id="{$student|replace:' ':''}{$key}" value="1" {if $att == '1'} checked {/if}>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -134,50 +134,66 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{else}
|
{else}
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span4">
|
<div class="span7">
|
||||||
<div class="widget yellow">
|
<div class="widget yellow">
|
||||||
<div class="widget-title">
|
<div class="widget-title">
|
||||||
<h4><i class="icon-reorder"></i> Мои группы </h4>
|
<h4><i class="icon-reorder"></i>Группы моего факультета </h4>
|
||||||
<span class="tools"><a href="javascript:;" class="icon-chevron-down"></a></span>
|
<span class="tools"><a href="javascript:;" class="icon-chevron-down"></a></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget-body">
|
<div class="widget-body" style="height: 40em; overflow:scroll; overflow-x:hidden;">
|
||||||
<a href="/modul/attendancelog/main/show/{$myGrupps['id']}/">{$myGrupps.sokr}</a>
|
<table class="table table-striped table-bordered">
|
||||||
</div>
|
<caption><h4>{$currentUserInfo.facult.facult_name}</h4> </caption>
|
||||||
</div>
|
<thead>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="span8">
|
|
||||||
<div class="widget red">
|
|
||||||
<div class="widget-title">
|
|
||||||
<h4><i class="icon-reorder"></i> Все группы</h4>
|
|
||||||
<span class="tools"><a href="javascript:;" class="icon-chevron-down"></a></span>
|
|
||||||
</div>
|
|
||||||
<div class="widget-body" style="height: 40em; overflow:scroll; overflow-x:hidden;">
|
|
||||||
<table class="table table-striped table-bordered">
|
|
||||||
<caption><h4>Выберите группу для просмотра</h4> </caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Название</th>
|
<th>Название</th>
|
||||||
<th>Форма обучения</th>
|
<th>Форма обучения</th>
|
||||||
<th>Курс</th>
|
<th>Курс</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$groups key=key item=group}
|
{foreach from=$facult_groups key=key item=group}
|
||||||
{if $key != 0}
|
<tr>
|
||||||
<tr>
|
<td><a href="/modul/attendancelog/main/show/{$group['id']}/">{$group.sokr}</a></td>
|
||||||
<td><a href="/modul/attendancelog/main/show/{$group['id']}/">{$group.sokr}</a></td>
|
<td>{$group['fo']}</td>
|
||||||
<td>{$group['fo']}</td>
|
<td>{$group['kurs']}</td>
|
||||||
<td>{$group['kurs']}</td>
|
</tr>
|
||||||
</tr>
|
|
||||||
{/if}
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="span5">
|
||||||
|
<div class="widget red">
|
||||||
|
<div class="widget-title">
|
||||||
|
<h4><i class="icon-reorder"></i> Все группы</h4>
|
||||||
|
<span class="tools"><a href="javascript:;" class="icon-chevron-down"></a></span>
|
||||||
|
</div>
|
||||||
|
<div class="widget-body" style="height: 40em; overflow:scroll; overflow-x:hidden;">
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<caption><h4>Выберите группу для просмотра</h4> </caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Форма обучения</th>
|
||||||
|
<th>Курс</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach from=$groups key=key item=group}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/modul/attendancelog/main/show/{$group['id']}/">{$group.sokr}</a></td>
|
||||||
|
<td>{$group['fo']}</td>
|
||||||
|
<td>{$group['kurs']}</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
Loading…
Reference in New Issue