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; $this->name = $name;
} }
function getAllGrupps() { 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); $rez = $this->DB->QUR_SEL($sql_search);
return $rez; return $rez;
} }
@ -18,14 +18,69 @@ class attendancelog {
$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;
return json_decode(file_get_contents($url),1); 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() function mainPageAction()
{ {
$des = ''; if(isset($_GET['des'])) $des = $_GET['des']; $des = ''; if(isset($_GET['des'])) $des = $_GET['des'];
if ($des == 'show'){ if ($des == 'show'){
//получаем список студентов по группе //получаем список пар по имени группы
$sql_search = 'SELECT sokr, fo FROM acs_grupp WHERE id='. $_GET['id'] .' '; // $current_group = $this->getGroupNamebyID($_GET['id']);
$current_group = $this->DB->QUR_SEL($sql_search); // return $this->getStudentsByGroup($current_group[1]['sokr'], $current_group[1]['fo']);
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() function HTML()
@ -33,14 +88,19 @@ class attendancelog {
$html = ''; $html = '';
$groups = $this->getAllGrupps(); $groups = $this->getAllGrupps();
$actionResult = $this->mainPageAction(); $actionResult = $this->mainPageAction();
$currentTime = $this->currentTime();
//$html .= '<pre>'. print_r($groups,1) . '</pre>'; //$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($_GET,1) . '</pre>';
//$html .= '<pre>'. print_r($_POST,1) . '</pre>';
//$html .= '<pre>'. print_r($_SESSION,1) . '</pre>';
GLOBAL $smarty; 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);
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');
@ -52,7 +112,12 @@ class attendancelog {
} }
if ($page == 'main'){ if ($page == 'main'){
$smarty->assign('actionResult', $actionResult); 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->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');

View File

@ -14,8 +14,8 @@
<div class="navbar-inner"> <div class="navbar-inner">
<div class="container"> <div class="container">
<ul class="nav "> <ul class="nav ">
<li><a href="https://eios.mkgtu.ru/modul/attendancelog/">Главная</a></li> <li><a href="/modul/attendancelog/">Главная</a></li>
<li class="active" ><a href="https://eios.mkgtu.ru/modul/attendancelog/headman/">Старосты</a></li> <li class="active" ><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>

View File

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