From 785cbd54fac32eeecc68aca27e3129e8ed0751b6 Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Sat, 30 May 2015 02:49:08 +0300
Subject: [PATCH] refs #106. Improves behaviour of the faculty select menu

---
 .../application/classes/Controller/Teacher/Discipline.php     | 3 ++-
 .../application/views/teacher/discipline/EditTeachers.twig    | 2 +-
 ~dev_rating/modules/account/classes/Model/Kohana/Account.php  | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php
index c6c4eb479..5450a5b51 100644
--- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php
+++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php
@@ -146,7 +146,8 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment {
         $twig->BindTeachersList = Model_Teachers::getNamesForDiscipline($id);
         $twig->FacultiesList = Model_Faculties::toArray();
         $twig->Departments = Model_Departments::byFaculty($this->user['FacultyID']);
-        
+        $twig->Author = Model_Account::getPersonalInfo($twig->Discipline['AuthorID']);
+
         $this->response->body($twig);
     }
     
diff --git a/~dev_rating/application/views/teacher/discipline/EditTeachers.twig b/~dev_rating/application/views/teacher/discipline/EditTeachers.twig
index 2549a4d82..46f0d16a3 100644
--- a/~dev_rating/application/views/teacher/discipline/EditTeachers.twig
+++ b/~dev_rating/application/views/teacher/discipline/EditTeachers.twig
@@ -29,7 +29,7 @@
 				<input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}">
 				<select class="SelectFaculty defaultForm">
 					{% for Faculty in FacultiesList %}
-						<option value="{{ Faculty.ID }}" {% if User.FacultyID == Faculty.ID %}selected{% endif %}>{{ Faculty.Name }}</option>
+						<option value="{{ Faculty.ID }}" {% if Author.FacultyID == Faculty.ID %}selected{% endif %}>{{ Faculty.Name }}</option>
 					{% endfor %}
 				</select>
 				<select class="SelectDepartment defaultForm">
diff --git a/~dev_rating/modules/account/classes/Model/Kohana/Account.php b/~dev_rating/modules/account/classes/Model/Kohana/Account.php
index d3af3cf27..b886486a1 100644
--- a/~dev_rating/modules/account/classes/Model/Kohana/Account.php
+++ b/~dev_rating/modules/account/classes/Model/Kohana/Account.php
@@ -113,14 +113,14 @@ class Model_Kohana_Account extends Model
         return $response->get('Num');
     }
 
-    public function getPersonalInfo($id)
+    public static function getPersonalInfo($id)
     {
         $sql = "CALL `GetPersonalInfo`('$id');";
         $query = DB::query(Database::SELECT, $sql)->execute();
         return $query[0];
     }
 
-    public function GetAccountInfo($id)
+    public static function GetAccountInfo($id)
     {
         $sql = "CALL GetAccountInfo('$id');";
         $query = DB::query(Database::SELECT, $sql)->execute();
-- 
GitLab