Compare commits

...

7 Commits
main ... dev

3 changed files with 167 additions and 51 deletions

View File

@ -7,7 +7,7 @@ class attendancelog {
$this->name = $name;
}
function getAllGrupps() {
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp ORDER BY `sokr` DESC';
$sql_search = 'SELECT id, sokr, fo, kurs FROM acs_grupp WHERE fo="ОФО" ORDER BY `sokr` DESC';
$rez = $this->DB->QUR_SEL($sql_search);
return $rez;
}
@ -18,14 +18,69 @@ class attendancelog {
$url = 'https://eios.mkgtu.ru/api.php?des=studentsByGrupp&param1=' . $groupName . '&param2=' . $educationForm;
return json_decode(file_get_contents($url),1);
}
function getClassesByGroup($groupName,$educationForm)
{
$tmp = explode('-', $groupName);
$groupName = trim($tmp[0]);
$groupNumber = substr($tmp[1],0,2);
$educationForm = urlencode($educationForm);
$groupName = urlencode($groupName);
$groupNumber = urlencode($groupNumber);
$url = 'https://local.mkgtu.ru/raspisnew/api.php?des=raspis_grupp&name='. $groupName .'&number='. $groupNumber .'&fo=' . $educationForm;
return json_decode(file_get_contents($url),1);
//return $url;
}
function currentTime() { //возвращает информацию о текущем моменте для пользователя
$rez = array();
$moment = getdate();
$curr_minutes = $moment['hours'] * 60 + $moment['seconds'];
$minutes = 480;
for($i = 1; $i < 8; $i++) { //возвращает текущую пару в университете
if ($curr_minutes >= $minutes-10 AND $curr_minutes <= $minutes + 90){
$rez['time1'] = $i;
}
if ($i == 4){
$minutes = $minutes + 110;
}else{
$minutes = $minutes + 100;
}
}
$week = json_decode(file_get_contents('https://local.mkgtu.ru/raspisnew/api.php?des=raspis_week_cur'),1);
$rez['day1'] = $moment['wday'];
$rez['mday'] = $moment['mday'];
$rez['mon'] = $moment['mon'];
$rez['0'] = $moment['0'];
$rez['year'] = $moment['year'];
$rez['date'] = date("Y-m-d");
$rez['week1'] = $week['week_cur'];
return $rez;
}
function getGroupNameByID($id) {
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $id .' ';
return $this->DB->QUR_SEL($sql_search);
}
function mainPageAction()
{
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
if ($des == 'show'){
//получаем список студентов по группе
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $_GET['id'] .' ';
$current_group = $this->DB->QUR_SEL($sql_search);
return $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
//получаем список пар по имени группы
// $current_group = $this->getGroupNamebyID($_GET['id']);
// return $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
$current_group = $this->getGroupNamebyID($_GET['id']);
$current_group_classes = $this->getClassesByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
$currentTime = $this->currentTime();
$out = array();
foreach ($current_group_classes['raspis'] as $class) {
if ($class['week1'] == $currentTime['week1']) {
$out['info'][$class['day1']]['day_name'] = $class['day_name'];
$out['info'][$class['day1']][$class['time1']] = $class;
$out['students'] = $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
}
}
return $out;
}
}
function HTML()
@ -33,14 +88,19 @@ class attendancelog {
$html = '';
$groups = $this->getAllGrupps();
$actionResult = $this->mainPageAction();
$currentTime = $this->currentTime();
//$html .= '<pre>'. print_r($groups,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($_GET,1) . '</pre>';
//$html .= '<pre>'. print_r($_POST,1) . '</pre>';
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
GLOBAL $smarty;
$page = ''; if(isset($_GET['page'])) $page = $_GET['page'];
$des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
$smarty->assign('des', $des);
$smarty->assign('name', $this->name);
$smarty->assign('currentTime', $currentTime);
if($page == 'headman') {
$smarty->clearCache('moduls/attendancelog/tpl/headman.html');
$html .= $smarty->fetch('moduls/attendancelog/tpl/headman.html');
@ -52,7 +112,12 @@ class attendancelog {
}
if ($page == 'main'){
if ($des == 'show'){
$smarty->assign('actionResult', $actionResult);
$groupName = $this->getGroupNameByID($_GET['id']);
$groupName = $groupName[1]['sokr'];
$smarty->assign('groupName', $groupName);
}
$smarty->assign('groups',$groups);
$smarty->clearCache('moduls/attendancelog/tpl/main_page.html');
$html .= $smarty->fetch('moduls/attendancelog/tpl/main_page.html');

View File

@ -14,8 +14,8 @@
<div class="navbar-inner">
<div class="container">
<ul class="nav ">
<li><a href="https://eios.mkgtu.ru/modul/attendancelog/">Главная</a></li>
<li class="active" ><a href="https://eios.mkgtu.ru/modul/attendancelog/headman/">Старосты</a></li>
<li><a href="/modul/attendancelog/">Главная</a></li>
<li class="active" ><a href="/modul/attendancelog/headman/">Старосты</a></li>
</ul>
<ul class="nav pull-right">
<li><a href="#">{$name}</a></li>

View File

@ -14,8 +14,8 @@
<div class="navbar-inner">
<div class="container">
<ul class="nav ">
<li class="active" ><a href="https://eios.mkgtu.ru/modul/attendancelog/">Главная</a></li>
<li><a href="https://eios.mkgtu.ru/modul/attendancelog/headman/">Старосты</a></li>
<li class="active" ><a href="/modul/attendancelog/">Главная</a></li>
<li><a href="/modul/attendancelog/headman/">Старосты</a></li>
</ul>
<ul class="nav pull-right">
<li><a href="#">{$name}</a></li>
@ -27,53 +27,103 @@
</div>
{if $des == 'show'}
<a href="https://eios.mkgtu.ru/modul/attendancelog/" role="button" class="btn"> Вернуться </a>
<a href="/modul/attendancelog/" role="button" class="btn"> Вернуться </a>
<div class="row-fluid">
<div class="span9">
<div class="span12">
<div class="widget blue">
<div class="widget-title">
<h4><i class="icon-reorder"></i></h4>
<h4><i class="icon-reorder"></i> Посещение группы {$groupName} </h4>
<span class="tools"><a href="javascript:;" class="icon-chevron-down"></a></span>
</div>
<div class="widget-body">
<table class="table table-striped table-bordered">
<caption> Посещения группы </caption>
</table>
<div class="tabbable custom-tab">
<ul class="nav nav-tabs">
{foreach from=$actionResult.info key=key item=day}
<li {if $key == $currentTime.day1} class="active" {/if}><a href="#tab_1_{$key}" data-toggle="tab">{$day['day_name']}</a></li>
{/foreach}
</ul>
<div class="tab-content" style="overflow-x: scroll">
{foreach from=$actionResult.info key=key item=day}
<div class="tab-pane {if $key == $currentTime.day1} active {/if}" id="tab_1_{$key}">
<div class="accordion" id="accordion{$key}">
{foreach from=$day key=key item=class}
{if $key != 0}
<table class="table">
<tbody>
<tr>
<td style="vertical-align: middle; text-align: center;"><h3 class="text-warning">{$class.time1}</h3></td>
<td style="vertical-align: middle; "><div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle {if $key != $currentTime.time1 } collapsed {/if}" data-toggle="collapse" data-parent="#accordion{$day.day1}" href="#collapse_{$class.day1}-{$class.time1}">
{$class.predmet}
</a>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span9">
<div class="widget blue">
<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">
<table class="table table-striped table-bordered">
<caption> Студенты группы </caption>
<div id="collapse_{$class.day1}-{$class.time1}" class="accordion-body collapse {if $key == $currentTime.time1 } in {/if}">
<div class="accordion-inner">
<form action="" method="post">
<table class="table table-striped">
<thead>
<tr>
<th>Номер</th>
<th>Имя</th>
<th>No</th>
<th>ФИО</th>
<th>Присутствие</th>
<th>Примечание</th>
</tr>
</thead>
<tbody>
{foreach from=$actionResult['students'] key=key item=name}
{foreach from=$actionResult.students.students key=key item=student}
<tr>
<td>{$key +1 }</td>
<td>{$name}</td>
<td>{$key}</td>
<td>{$student}</td>
<td>
<input type="hidden" name="attendance_add_edit[attendance][{$student}]" value="off">
<input type="hidden" name="attendance_add_edit[info]['week1']" value="{$class.week1}">
<input type="hidden" name="attendance_add_edit[info]['day1']" value="{$class.day1}">
<input type="hidden" name="attendance_add_edit[info]['time1']" value="{$class.time1}">
<input type="hidden" name="attendance_add_edit[info]['predmet']" value="{$class.predmet}">
<input type="hidden" name="attendance_add_edit[info]['gruppa']" value="{$groupName}">
<input type="checkbox" name="attendance_add_edit[attendance][{$student}]" id="{$key}">
</td>
<td><input type="text" name="" id="" value=""></td>
</tr>
{/foreach}
</tbody>
</table>
<button type="submit" class="btn btn-success">Сохранить</button>
</form>
</div>
</div>
</div></td>
</tr>
</tbody>
</table>
{/if}
{/foreach}
</div>
</div>
{/foreach}
</div>
</div>
</div>
</div>
</div>
</div>
{else}
<div class="row-fluid">
<div class="span4">
<div class="widget yellow">
<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">
</div>
</div>
</div>
<div class="span8">
<div class="widget red">
<div class="widget-title">
@ -94,7 +144,7 @@
{foreach from=$groups key=key item=group}
{if $key != 0}
<tr>
<td><a href="https://eios.mkgtu.ru/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['kurs']}</td>
</tr>
@ -105,5 +155,6 @@
</div>
</div>
</div>
</div>
{/if}