Skip to content
Snippets Groups Projects
Commit cfd3f3bd authored by xamgore's avatar xamgore
Browse files

listOutput.twig is moved to /twig/handler/listOutput.twig

parent c78962c5
Branches
Tags
No related merge requests found
...@@ -10,6 +10,8 @@ abstract class SortingOptions { //extends SplEnum { // todo: think about usage ...@@ -10,6 +10,8 @@ abstract class SortingOptions { //extends SplEnum { // todo: think about usage
class Controller_Handler_AdmStudents extends Controller_Handler class Controller_Handler_AdmStudents extends Controller_Handler
{ {
const STUDENTS_LIST = '/handler/listOutput';
public function before() { public function before() {
$this->setAccessLevel(self::ACCESS_USER); $this->setAccessLevel(self::ACCESS_USER);
parent::before(); parent::before();
...@@ -102,33 +104,18 @@ class Controller_Handler_AdmStudents extends Controller_Handler ...@@ -102,33 +104,18 @@ class Controller_Handler_AdmStudents extends Controller_Handler
} }
} }
public function action_getStudentsList($option = SortingOptions::Name) public function action_getStudentsList($option = SortingOptions::Name) {
{ $twig = Twig::factory(self::STUDENTS_LIST);
$from = isset($this->get['dean']) ? 'dean_office' : 'admin';
$twig = Twig::factory($from . '/students/handler/listOutput');
$success = false;
$facultyID = $this->post['facultyID'];
$gradeID = $this->post['gradeID'];
$groupID = $this->post['groupID'];
$this->post-> rule('facultyID', 'not_empty') $facultyID = (int) $this->post['facultyID'];
-> rule('facultyID', 'digit') $gradeID = (int) $this->post['gradeID'];
-> rule('gradeID', 'not_empty') $groupID = (int) $this->post['groupID'];
-> rule('gradeID', 'digit')
-> rule('groupID', 'not_empty')
-> rule('groupID', 'digit');
if($this->post->check()) { if ($this->post->check()) {
$result = Model_Students::byFaculty($facultyID , $gradeID, $groupID); $result = Model_Students::byFaculty($facultyID , $gradeID, $groupID);
if (!empty($result)) {
$twig->List = $result; $twig->List = $result;
$success = true;
}
} }
//$this->response->body(json_encode($data));
$twig->Success = $success;
$this->response->body($twig); $this->response->body($twig);
} }
...@@ -137,7 +124,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler ...@@ -137,7 +124,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler
$groupID = $this->post['studyGroupID']; $groupID = $this->post['studyGroupID'];
if($groupID != 0) if($groupID != 0)
{ {
$twig = Twig::factory('admin/students/handler/listOutput'); $twig = Twig::factory(self::STUDENTS_LIST);
$twig->List = Model_Students::byStudyGroup($groupID); $twig->List = Model_Students::byStudyGroup($groupID);
$this->response->body($twig); $this->response->body($twig);
} }
...@@ -149,7 +136,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler ...@@ -149,7 +136,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler
$facultyID = $this->post['facultyID']; $facultyID = $this->post['facultyID'];
if($facultyID != 0) if($facultyID != 0)
{ {
$twig = Twig::factory('admin/students/handler/listOutput'); $twig = Twig::factory(self::STUDENTS_LIST);
// (Grade, Group) = (0,0), to ignore (search all students) // (Grade, Group) = (0,0), to ignore (search all students)
$twig->List = Model_Students::byFaculty($facultyID, 0, 0); $twig->List = Model_Students::byFaculty($facultyID, 0, 0);
$this->response->body($twig); $this->response->body($twig);
...@@ -157,8 +144,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler ...@@ -157,8 +144,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler
} }
public function action_getStudentsByName() { public function action_getStudentsByName() {
$from = isset($this->get['dean']) ? 'dean_office' : 'admin'; $twig = Twig::factory(self::STUDENTS_LIST);
$twig = Twig::factory($from . '/students/handler/listOutput');
$facultyID = (int) $this->post['facultyID']; $facultyID = (int) $this->post['facultyID'];
$gradeID = (int) $this->post['gradeID']; $gradeID = (int) $this->post['gradeID'];
......
{# Вывод списков студентов #}
{% set pageNum = 1 %}
<div id="listPage{{ pageNum }}" class='paginatorPage'>
{% for row in List %}
{% if loop.index % 16 == 0 %}
{% set pageNum = pageNum + 1 %}
</div>
<div id="listPage{{ pageNum }}" class='paginatorPage hiddenPage'>
{% endif %}
<div class="search_item">
<div class="search_item_info">
<div class="search_item_firstLine">{{ HTML.anchor('admin/profile/student/' ~ row.AccountID,
row.LastName ~ ' ' ~ row.FirstName ~ ' ' ~ row.SecondName)|raw }} ({{ row.Degree }}, {{ row.GradeNum }} курс, {{ row.GroupNum }} группа)</div>
</div>
<div class="search_item_actions">
<a href="#">Редактировать</a>
</div>
</div>
{% else %}
Нет результатов!
{% endfor %}
</div>
{% if pageNum > 1 %}
<div class="paginator">
<div class="paginator_title">Страницы:</div>
{% for i in range(1, pageNum) %}
{% if loop.first %}
<a href="#" class="paginatorLink" id='listPage{{ loop.index }}'><div class="paginator_item selectedPageNum">{{ loop.index }}</div></a>
{% else %}
<a href="#" class="paginatorLink" id='listPage{{ loop.index }}'><div class="paginator_item">{{ loop.index }}</div></a>
{% endif %}
{% endfor %}
</div>
{% endif %}
...@@ -97,9 +97,9 @@ $(function() ...@@ -97,9 +97,9 @@ $(function()
if (!arr.facultyID || !arr.gradeID) if (!arr.facultyID || !arr.gradeID)
return; return;
if (arr.name.length >= 3) if (arr.name.length >= 3)
updateStudentsList('admStudents/getStudentsByName?dean', arr); updateStudentsList('admStudents/getStudentsByName', arr);
else if (arr.groupID) else if (arr.groupID)
updateStudentsList('admStudents/getStudentsList?dean', arr); updateStudentsList('admStudents/getStudentsList', arr);
} }
function updateStudentsList(method, params) { function updateStudentsList(method, params) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment