Skip to content
Snippets Groups Projects
Commit 2d20d329 authored by Andrew Rudenets's avatar Andrew Rudenets
Browse files

Отображение курсов из БД

parent e70d84ce
Branches
Tags
No related merge requests found
......@@ -14,6 +14,15 @@ class Controller_Admin_Accounts extends Controller_UserEnvi {
{
$model = new Model_Admin_Students();
Cookie::set('fD', 'true');
$twig = Twig::factory('admin/accounts/codes');
$twig->Faculties = $this->getFaculties();
$twig->Grades = $this->getGradess();
$twig->User = $this->UserInfo;
$this->response->body($twig);
}
public function getFaculties() {
$model = new Model_Admin_Students();
$faculties = $model->getFaculties();
$facultiesHandled = array(); $i = 0;
foreach($faculties as $row)
......@@ -23,10 +32,27 @@ class Controller_Admin_Accounts extends Controller_UserEnvi {
$facultiesHandled[$i]['Name'] = $row['FacultyName'];
$facultiesHandled[$i]['Abbr'] = $row['FacultyAbbr'];
}
$twig = Twig::factory('admin/accounts/codes');
$twig->Faculties = $facultiesHandled;
$twig->User = $this->UserInfo;
$this->response->body($twig);
return $facultiesHandled;
}
public function getGrades() {
$model = new Model_Admin_Students();
$grades = $model->getGrades();
$gradesHandled = array(); $i = $j = 0; $degree = 'null';
$degrees = array('bachelor' => 'Бакалавр', 'specialist' => 'Специалист', 'master' => 'Магистр');
foreach($grades as $row)
{
if($degree != $row['Degree'])
{
$degree = $row['Degree'] ;
$i++; $j = 0;
}
$j++;
$gradesHandled[$i]['Title'] = $degrees[$row['Degree']];
$gradesHandled[$i]['Grades'][$j]['ID'] = $row['GradeID'];
$gradesHandled[$i]['Grades'][$j]['Num'] = $row['Grade'];
}
return $gradesHandled;
}
}
\ No newline at end of file
......@@ -4,38 +4,19 @@ class Controller_Admin_Students extends Controller_UserEnvi {
public function action_index()
{
// LOGIC
$model = new Model_Admin_Students;
$faculties = $model->getFaculties();
$facultiesHandled = array(); $i = 0;
foreach($faculties as $row)
{
$i++;
$facultiesHandled[$i]['ID'] = $row['FacultyID'];
$facultiesHandled[$i]['Name'] = $row['FacultyName'];
$facultiesHandled[$i]['Abbr'] = $row['FacultyAbbr'];
}
// VIEW
$twig = Twig::factory('admin/students/index');
$twig->Faculties = $facultiesHandled;
$twig->Faculties = $this->getFaculties();
$twig->Grades = $this->getGrades();
$twig->User = $this->UserInfo;
$this->response->body($twig);
}
public function action_add()
{
$model = new Model_Admin_Students();
$faculties = $model->getFaculties();
$facultiesHandled = array(); $i = 0;
foreach($faculties as $row)
{
$i++;
$facultiesHandled[$i]['ID'] = $row['FacultyID'];
$facultiesHandled[$i]['Name'] = $row['FacultyName'];
$facultiesHandled[$i]['Abbr'] = $row['FacultyAbbr'];
}
$twig = Twig::factory('admin/students/add');
$twig->Faculties = $facultiesHandled;
$twig->Faculties = $this->getFaculties();
$twig->Grades = $this->getGrades();
$twig->User = $this->UserInfo;
$this->response->body($twig);
}
......@@ -47,19 +28,16 @@ class Controller_Admin_Students extends Controller_UserEnvi {
if($this->parseFile())
$this->redirect('admin/students', 302);
}
$model = new Model_Admin_Students;
$faculties = $model->getFaculties();
$facultiesHandled = array(); $i = 0;
foreach($faculties as $row)
{
$i++;
$facultiesHandled[$i]['ID'] = $row['FacultyID'];
$facultiesHandled[$i]['Name'] = $row['FacultyName'];
$facultiesHandled[$i]['Abbr'] = $row['FacultyAbbr'];
}
// VIEW
$twig = Twig::factory('admin/students/upload');
$twig->Faculties = $facultiesHandled;
$twig->Faculties = $this->getFaculties();
$twig->User = $this->UserInfo;
$this->response->body($twig);
}
public function action_edit()
{
$twig = Twig::factory('admin/students/edit');
$twig->User = $this->UserInfo;
$this->response->body($twig);
}
......@@ -115,12 +93,38 @@ class Controller_Admin_Students extends Controller_UserEnvi {
return true;
}
public function action_edit()
public function getFaculties() {
$model = new Model_Admin_Students();
$faculties = $model->getFaculties();
$facultiesHandled = array(); $i = 0;
foreach($faculties as $row)
{
$twig = Twig::factory('admin/students/edit');
$i++;
$facultiesHandled[$i]['ID'] = $row['FacultyID'];
$facultiesHandled[$i]['Name'] = $row['FacultyName'];
$facultiesHandled[$i]['Abbr'] = $row['FacultyAbbr'];
}
return $facultiesHandled;
}
$twig->User = $this->UserInfo;
$this->response->body($twig);
public function getGrades() {
$model = new Model_Admin_Students();
$grades = $model->getGrades();
$gradesHandled = array(); $i = $j = 0; $degree = 'null';
$degrees = array('bachelor' => 'Бакалавриат', 'specialist' => 'Специалитет', 'master' => 'Магистратура');
foreach($grades as $row)
{
if($degree != $row['Degree'])
{
$degree = $row['Degree'] ;
$i++; $j = 0;
}
$j++;
$gradesHandled[$i]['Title'] = $degrees[$row['Degree']];
$gradesHandled[$i]['Grades'][$j]['ID'] = $row['GradeID'];
$gradesHandled[$i]['Grades'][$j]['Num'] = $row['Grade'];
}
return $gradesHandled;
}
}
\ No newline at end of file
......@@ -81,7 +81,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler {
public function action_getStudyGroups()
{
$facultyID = $this->post->offsetGet('facultyID');
$gradeNum = $this->post->offsetGet('gradeID');
$gradeID = $this->post->offsetGet('gradeNum');
if(($facultyID && $gradeNum) != 0)
{
$studyGroups = $this->model->getStudyGroups($gradeID, $facultyID);
......
......@@ -20,6 +20,12 @@ class Model_Admin_Students extends Model
return DB::query(Database::SELECT, $sql)->execute();
}
public function getGrades()
{
$sql = "CALL `GetGrades`(); ";
return DB::query(Database::SELECT, $sql)->execute();
}
public function getStudentsByFaculty($facultyID)
{
$sql = "CALL `GetStudentsByFaculty`('$facultyID'); ";
......
......@@ -48,16 +48,13 @@
<div class="step_body">
<select id="gradeSelect">
<option value="0">--- Курс ---</option>
<optgroup label="Бакалавриат">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
<option value="3">3 курс</option>
<option value="4">4 курс</option>
</optgroup>
<optgroup label="Магистратура">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
{% for Degree in Grades %}
<optgroup label="{{ Degree.Title }}">
{% for Grade in Degree.Grades %}
<option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
</div>
</div>
......
......@@ -34,16 +34,13 @@
</select>
<select id="gradeSelect">
<option value="0">--- Курс ---</option>
<optgroup label="Бакалавриат">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
<option value="3">3 курс</option>
<option value="4">4 курс</option>
</optgroup>
<optgroup label="Магистратура">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
{% for Degree in Grades %}
<optgroup label="{{ Degree.Title }}">
{% for Grade in Degree.Grades %}
<option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
<select id="studyGroupSelect">
<option value="0">--- Учебная группа ---</option>
......
......@@ -28,16 +28,13 @@
<div class='filter'>
<select id="gradeSelect">
<option value="0">--- Курс ---</option>
<optgroup label="Бакалавриат">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
<option value="3">3 курс</option>
<option value="4">4 курс</option>
</optgroup>
<optgroup label="Магистратура">
<option value="1">1 курс</option>
<option value="2">2 курс</option>
{% for Degree in Grades %}
<optgroup label="{{ Degree.Title }}">
{% for Grade in Degree.Grades %}
<option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
</div>
<div class='filter'>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment