diff --git a/db/StoredFunctions.sql b/db/StoredFunctions.sql index 5ed75287b58945e8f8aca41d163ae6d27474a14c..a66e0a0e7f0b5756fb6325461c8c3b25fe09288f 100644 --- a/db/StoredFunctions.sql +++ b/db/StoredFunctions.sql @@ -1382,7 +1382,6 @@ END // DROP FUNCTION IF EXISTS RestrictAfterMilestone// CREATE FUNCTION `RestrictAfterMilestone` ( - `pTeacherID` INT, `pDisciplineID` INT, `pMilestone` INT ) RETURNS int(11) @@ -1399,7 +1398,6 @@ END // DROP FUNCTION IF EXISTS RestrictAfterMilestoneForCredits// CREATE FUNCTION `RestrictAfterMilestoneForCredits` ( - `pTeacherID` INT, `pFacultyID` INT, `pMilestone` INT, `pSemesterID` INT diff --git a/~dev_rating/application/classes/Controller/DeanOffice/Credits.php b/~dev_rating/application/classes/Controller/DeanOffice/Credits.php index d121682d239e6239095accd5d1c7dfe38ed8bf6c..5e74e1a6e0ca8a12ce73134367a9f5a5cb0e4a69 100644 --- a/~dev_rating/application/classes/Controller/DeanOffice/Credits.php +++ b/~dev_rating/application/classes/Controller/DeanOffice/Credits.php @@ -10,7 +10,7 @@ class Controller_DeanOffice_Credits extends Controller_Environment_DeanOffice } public function action_index() { - $disciplines = Model_Faculty::with($this->user->FacultyID)->getDisciplines(); + $disciplines = $this->user->Faculty->getDisciplines(); $list = array(); foreach ($disciplines as $dis) { @@ -18,8 +18,7 @@ class Controller_DeanOffice_Credits extends Controller_Environment_DeanOffice $list[] = $dis; } - // todo: check, does ->execute()[0] && ->execute()['Num'] have same behaviour - $milestone = Model_Discipline::getMilestone($this->user->FacultyID, $this->user->SemesterID)[0]; + $milestone = $this->user->Faculty->getMilestone($this->user->SemesterID); $this->twig->set([ 'DisciplinesList' => $list, diff --git a/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php b/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php index c4e96a7a0d041884ad231183bb97fadcaf6f6506..e781c75245c0ebef0e324f062bb0617d7e950c55 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php @@ -11,9 +11,9 @@ class Controller_Handler_AdmAccounts extends Controller_Handler public function action_getActivationForTeachers() { - $facultyID = $this->post['facultyID']; + $faculty = Model_Faculty::with($this->post['facultyID']); $departmentsHandled = array(); $i = 0; - $departments = Model_Departments::ofFaculty($facultyID); + $departments = $faculty->getDepartments(); foreach ($departments as $department) { $i++; $j = 0; @@ -52,7 +52,7 @@ class Controller_Handler_AdmAccounts extends Controller_Handler 'Version' => ASSEMBLY_VERSION ) )); - $Headers = PDFCreator::GetHeaders($File, 'ActivationTeachers'.$facultyID); + $Headers = PDFCreator::GetHeaders($File, 'ActivationTeachers'.$faculty->ID); foreach ($Headers as $key => $value) { $this->response->headers($key, $value); } diff --git a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php index 8519e3c5d4eace746f14e3da3a14b009b9b65a3a..ede892a7b3593e5d2a0eebbada9120189e32ea44 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php @@ -73,8 +73,8 @@ class Controller_Handler_AdmTeachers extends Controller_Handler { } public function action_getDepartmentsList() { - $facultyID = $this->post['facultyID']; - $departments = Model_Departments::byFaculty($facultyID); + $faculty = Model_Faculty::with($this->post['facultyID']); + $departments = $faculty->getDepartments(); $this->response->body(json_encode($departments)); } } \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/Handler/Credits.php b/~dev_rating/application/classes/Controller/Handler/Credits.php index 6b071c0ecc46867cd0667c03b97232b9697e0fe2..074c03758fdeb9652b44f0e44fa88c0d403cb342 100644 --- a/~dev_rating/application/classes/Controller/Handler/Credits.php +++ b/~dev_rating/application/classes/Controller/Handler/Credits.php @@ -12,8 +12,8 @@ class Controller_Handler_Credits extends Controller_Handler } public function action_getMilestone() { - $Milestone = Model_Discipline::getMilestone($this->user->FacultyID, $this->user->SemesterID)[0]; - $this->response->body($Milestone['Num']); + $milestone = $this->user->Faculty->getMilestone(); + $this->response->body($milestone); } public function action_getInfo() { @@ -24,18 +24,16 @@ class Controller_Handler_Credits extends Controller_Handler } public function action_setCreditMilestone() { - $id = (int)$this->request->param("param1"); - $stage = (int)$this->request->param("param2"); + $id = (int) $this->request->param("param1"); + $stage = (int) $this->request->param("param2"); - if ($stage >= 0 && $stage <= 3) - Model_Discipline::setMilestone(0, $id, $stage)[0]; + Model_Discipline::load($id)->setMilestone($stage); $this->response->body(''); } public function action_setMilestone() { - $stage = (int)$this->request->param("param1"); - if ($stage >= 0 && $stage <= 3) - Model_Discipline::setMilestoneForCredits(0, $this->user->FacultyID, $stage); + $stage = (int) $this->request->param("param1"); + $this->user->Faculty->setMilestoneForCredits($stage); $this->response->body(''); } } \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/Handler/GetData.php b/~dev_rating/application/classes/Controller/Handler/GetData.php index 637b683a8ef670ea03f4f793d53b1c57af1d190b..a8348d7d5b03ebdabb8c8a222288e97ce8d6d66f 100644 --- a/~dev_rating/application/classes/Controller/Handler/GetData.php +++ b/~dev_rating/application/classes/Controller/Handler/GetData.php @@ -12,11 +12,10 @@ class Controller_Handler_GetData extends Controller_Handler $data['success'] = false; $this->post -> rule('GradeID', 'not_empty') -> rule('GradeID', 'digit'); - if($this->post->check()) { - $data['data'] = Model_Faculty::with($this->user->FacultyID) - ->getGroups($this->post['GradeID']); - $data['success'] = true; + if ($this->post->check()) { + $data['data'] = $this->user->Faculty->getGroups($this->post['GradeID']); + $data['success'] = true; } $this->response->body(json_encode($data)); } diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index b5a45c35099e9cffdcb614788b24ead16ba8bb43..e78b96c05e966bcb966a9ff7c93ebb8a85d3f100 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -414,8 +414,8 @@ class Controller_Handler_Map extends Controller_Handler { $this->post -> rule('FacultyID', 'not_empty') -> rule('FacultyID', 'digit'); if($this->post->check()) { - $faculty = $this->post['FacultyID']; - $departments = Model_Departments::byFaculty($faculty); + $faculty = Model_Faculty::with($this->post['FacultyID']); + $departments = $faculty->getDepartments(); } $this->response->body(json_encode($departments)); } diff --git a/~dev_rating/application/classes/Controller/Handler/Settings.php b/~dev_rating/application/classes/Controller/Handler/Settings.php index 4ef96b5c221d67321ccbde50604a04c2e8736d1b..514d2f77e0bc1ebfbeeb21b68047422461e638f1 100644 --- a/~dev_rating/application/classes/Controller/Handler/Settings.php +++ b/~dev_rating/application/classes/Controller/Handler/Settings.php @@ -79,11 +79,12 @@ class Controller_Handler_Settings extends Controller_Handler { User::instance()->changeProfile($this->post->data()); } } - + + # todo: duplicate at handler/AdmTeachers public function action_getDepartmentsList() { - $facultyID = $this->post['facultyID']; - $departments = Model_Departments::byFaculty($facultyID); + $faculty = Model_Faculty::with($this->post['facultyID']); + $departments = $faculty->getDepartments(); $this->response->body(json_encode($departments)); } diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline/Create.php b/~dev_rating/application/classes/Controller/Teacher/Discipline/Create.php index a6c32e39f2a8c86a584450b8b329ec872e090205..96621f6fd4f959761ff284bccef9d0c35bbbe649 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline/Create.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline/Create.php @@ -5,7 +5,7 @@ class Controller_Teacher_Discipline_Create extends Controller_Environment_Teache public function action_create_discipline() { $this->twig->set([ 'FacultiesList' => Model_Faculties::load(), - 'SubjectsList' => Model_Faculty::with($this->user->FacultyID)->getSubjects(), + 'SubjectsList' => $this->user->Faculty->getSubjects(), 'GradesList' => Model_Grades::loadAll(), ])->set_filename('teacher/discipline/create'); } @@ -15,7 +15,7 @@ class Controller_Teacher_Discipline_Create extends Controller_Environment_Teache public function action_create_coursework() { $this->twig->set([ 'FacultiesList' => Model_Faculties::load(), - 'SubjectsList' => Model_Faculty::with($this->user->FacultyID)->getSubjects(), + 'SubjectsList' => $this->user->Faculty->getSubjects(), 'GradesList' => Model_Grades::loadAll(), ])->set_filename('teacher/coursework/create'); } diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline/Edit.php b/~dev_rating/application/classes/Controller/Teacher/Discipline/Edit.php index 704596e40b60784adebae03c930840fdac763628..fbb512805c45a64974d6a1ccf75ec4377677b243 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline/Edit.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline/Edit.php @@ -23,7 +23,7 @@ class Controller_Teacher_Discipline_Edit extends Controller_Environment_Teacher public function action_edit_settings() { - $this->twig->SubjectsList = Model_Faculty::with($this->user->FacultyID)->getSubjects(); + $this->twig->SubjectsList = $this->user->Faculty->getSubjects(); $this->twig->GradesList = Model_Grades::loadAll(); } @@ -35,8 +35,7 @@ class Controller_Teacher_Discipline_Edit extends Controller_Environment_Teacher public function action_edit_groups() { $this->twig->set([ 'GroupsForDiscipline' => $this->discipline->getGroups(), - 'Groups' => Model_Faculty::with($this->discipline->FacultyID) - ->getGroups($this->discipline->GradeID), + 'Groups' => $this->user->Faculty->getGroups($this->discipline->GradeID), ]); } @@ -55,7 +54,7 @@ class Controller_Teacher_Discipline_Edit extends Controller_Environment_Teacher public function action_edit_teachers() { $this->twig->set([ 'FacultiesList' => Model_Faculties::load(), - 'Departments' => Model_Departments::byFaculty($this->user->FacultyID), + 'Departments' => $this->user->Faculty->getDepartments(), 'BindTeachersList' => Model_Teachers::getNamesForDiscipline($this->discipline->ID), ]); } diff --git a/~dev_rating/application/classes/Controller/Teacher/Profile.php b/~dev_rating/application/classes/Controller/Teacher/Profile.php index 8e30fa84ba4b3a501f36fbfe7195f274481d9049..8693ab62d0b1b9e9e8a74a174e2b6b4284fbb5da 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Profile.php +++ b/~dev_rating/application/classes/Controller/Teacher/Profile.php @@ -6,7 +6,7 @@ class Controller_Teacher_Profile extends Controller_Environment_Teacher $this->twig->set([ 'JobPositions' => Model_Teachers::getJobPositions(), 'Faculties' => Model_Teachers::getFaculties(), - 'Departments' => Model_Departments::byFaculty($this->user->FacultyID), + 'Departments' => $this->user->Faculty->getDepartments(), ])->set_filename('profile/settings'); } } diff --git a/~dev_rating/application/classes/Model/Departments.php b/~dev_rating/application/classes/Model/Departments.php index 83f3a8e2f589d5652206536a85259ecf25b0d930..eb6a9b9d6c21c9dffed3022302514253f58b529e 100644 --- a/~dev_rating/application/classes/Model/Departments.php +++ b/~dev_rating/application/classes/Model/Departments.php @@ -2,26 +2,4 @@ class Model_Departments extends Model { - /** - * @param $faculty int faculty id - * @return Database_Result - */ - public static function ofFaculty($faculty) { // todo: move to Model_Faculty - $sql = "CALL `GetDepartments`(:faculty)"; - return DB::query(Database::SELECT, $sql) - ->param(':faculty', $faculty)->execute(); - } - - public static function byFaculty($facultyID) { // fixme: how this differs with ofFaculty method? - $list = []; - if ($facultyID > 0) { - $departments = self::ofFaculty($facultyID); - foreach ($departments as $row) { - if ($row['Name'] == null) - $row['Name'] = '<служебная кафедра>'; - $list[] = $row; - } - } - return $list; - } } diff --git a/~dev_rating/application/classes/Model/Discipline.php b/~dev_rating/application/classes/Model/Discipline.php index a3fed207e37e59dc6bbaf2293e14baa8980806a2..3b08ec8573663ce56f3e02ab463a6e3a7e96f367 100644 --- a/~dev_rating/application/classes/Model/Discipline.php +++ b/~dev_rating/application/classes/Model/Discipline.php @@ -131,52 +131,20 @@ class Model_Discipline extends Model_Container } /** - * @param $teacherID int - * @param $disciplineID int - * @param $milestone int - * @return Database_Result + * Time machine for discipline. + * @param $stage int number from 0 to 3 */ - public static function setMilestone($teacherID, $disciplineID, $milestone) { - $sql = "SELECT `RestrictAfterMilestone`(:teacher, :discipline, milestone) AS `Num`"; - return DB::query(Database::SELECT, $sql) - ->parameters([ - ':teacher' => $teacherID, - ':discipline' => $disciplineID, - ':milestone' => $milestone, - ])->execute(); - } + public function setMilestone($stage) { + if ($stage >= 0 && $stage <= 3) + throw new LogicException('Milestone argument is incorrect!'); - /** - * @param $facultyID int - * @param $semesterID int - * @return Database_Result - */ - public static function getMilestone($facultyID, $semesterID) { - $sql = "SELECT `GetMilestone`(:faculty, :semester) AS `Num`"; - return DB::query(Database::SELECT, $sql) - ->param(':faculty', $facultyID) - ->param(':semester', $semesterID) - ->execute(); - } + $this->Milestone = $stage; - - /** - * @param $teacherID int - * @param $facultyID int - * @param $milestone int - * @param $semesterID int - * @return Database_Result - */ - public static function setMilestoneForCredits($teacherID, $facultyID, $milestone, $semesterID = null) { - $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID; - $sql = "SELECT `RestrictAfterMilestoneForCredits`(:teacherID, :facultyID, :milestone, :semesterID) AS `Num`"; - return DB::query(Database::SELECT, $sql) + $sql = "SELECT `RestrictAfterMilestone`(:discipline, milestone)"; + DB::query(Database::SELECT, $sql) ->parameters([ - ':teacherID' => $teacherID, - ':facultyID' => $facultyID, - ':milestone' => $milestone, - ':semesterID' => $semesterID, + ':discipline' => $this->ID, + ':milestone' => $stage, ])->execute(); } - } \ No newline at end of file diff --git a/~dev_rating/application/classes/Model/Faculty.php b/~dev_rating/application/classes/Model/Faculty.php index 9466632933081c9edfe198d6c5a994c1fa1f59fe..4b08a830d00ac987e983a287dc276bd73196b540 100644 --- a/~dev_rating/application/classes/Model/Faculty.php +++ b/~dev_rating/application/classes/Model/Faculty.php @@ -22,6 +22,39 @@ class Model_Faculty extends Model return $f; } + + /** + * @param $semesterID int + * @return Database_Result + */ + public function getMilestone($semesterID = null) { + $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID; + $sql = "SELECT `GetMilestone`(:faculty, :semester) AS `Num`"; + return DB::query(Database::SELECT, $sql) + ->param(':faculty', $this->ID) + ->param(':semester', $semesterID) + ->execute()[0]['Num']; + } + + /** + * @param $stage int + * @param $semesterID int + */ + public function setMilestoneForCredits($stage, $semesterID = null) { + if ($stage >= 0 && $stage <= 3) + throw new LogicException('Milestone argument is incorrect!'); + + $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID; + $sql = "SELECT `RestrictAfterMilestoneForCredits`(:facultyID, :milestone, :semesterID)"; + DB::query(Database::SELECT, $sql) + ->parameters([ + ':facultyID' => $this->ID, + ':milestone' => $stage, + ':semesterID' => $semesterID, + ])->execute(); + } + + /** @return Model_Discipline[] */ public function getDisciplines($semesterID = null) { $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID; @@ -68,4 +101,11 @@ class Model_Faculty extends Model ->param(':faculty', $this->ID) ->execute()->as_array(); } + + public function getDepartments() { + $sql = "CALL `GetDepartments`(:faculty)"; + return DB::query(Database::SELECT, $sql) + ->param(':faculty', $this->ID) + ->execute()->as_array(); + } } diff --git a/~dev_rating/application/classes/Model/Student.php b/~dev_rating/application/classes/Model/Student.php index 43fc83de1195cab2cb2ea9fb463b1323a7f0c0bc..e794ff46b03ede512ca5500bf15add1196724a39 100644 --- a/~dev_rating/application/classes/Model/Student.php +++ b/~dev_rating/application/classes/Model/Student.php @@ -51,13 +51,9 @@ class Model_Student extends Model_Container ->execute(); $list = []; - // TODO: use TeacherID. Split fullName? foreach ($result as $row) { - $names =& $list[$row['DisciplineID']]; - $fullName = $row['LastName'] .' '. $row['FirstName'] .' '. $row['SecondName']; - if (!$names) - $names = []; - array_push($names, $fullName); + $id = $row['DisciplineID']; + $list[$id][] = $row; } return $list; } diff --git a/~dev_rating/application/classes/User.php b/~dev_rating/application/classes/User.php index f086804bb58720eace809897689a6e0f9eb355b5..369c83fafdcd3a265740fb30157ae1c9204df73e 100644 --- a/~dev_rating/application/classes/User.php +++ b/~dev_rating/application/classes/User.php @@ -5,7 +5,7 @@ * @property $LastName string * @property $FirstName string * @property $SecondName string - * @property $FacultyID int + * @property Model_Faculty $Faculty * @property $FacultyName string * @property $FacultyAbbr string * @@ -257,6 +257,7 @@ class User implements ArrayAccess return ( $res === 0 ); } + # todo: move to account public function changeLogin($login) { if (!$this->isSignedIn()) return false; @@ -269,6 +270,7 @@ class User implements ArrayAccess return false; } + # todo: move to account public function changeMail($email) { if (!$this->isSignedIn() || Account::isMailValid($email)) return false; @@ -290,6 +292,7 @@ class User implements ArrayAccess // return ( $res === 0 ); // } + # todo: move to account public function changeProfile($data) { if ($this->Type != 'teacher') return false; @@ -329,6 +332,10 @@ class User implements ArrayAccess } function __get($name) { + # todo: move to $_SESSION + if ($name == 'Faculty') + return Model_Faculty::with($this->_session['FacultyID']); + return $this->offsetGet($name); } diff --git a/~dev_rating/application/views/profile/settings.twig b/~dev_rating/application/views/profile/settings.twig index 3c3ffb1c3dea493d49493f4be505a0fd859df67a..af17c169a781bf52c7acc32a317c4189e861586f 100644 --- a/~dev_rating/application/views/profile/settings.twig +++ b/~dev_rating/application/views/profile/settings.twig @@ -34,7 +34,7 @@ </select> <select class="defaultForm" id="departmentSelect"> {% for row in Departments %} - <option value="{{ row.ID }}" {% if User.DepID == row.ID %}selected="selected"{% endif %}>{{ row.Name }}</option> + <option value="{{ row.ID }}" {% if User.DepID == row.ID %}selected="selected"{% endif %}>{{ row.Name | default('Служебная кафедра') }}</option> {% endfor %} </select> </div> diff --git a/~dev_rating/application/views/teacher/discipline/edit/teachers.twig b/~dev_rating/application/views/teacher/discipline/edit/teachers.twig index b5b6781e2327911c865be3f51fa0644b5b858876..f0e2d19b73f5727efa18572bd002672e229c56d2 100644 --- a/~dev_rating/application/views/teacher/discipline/edit/teachers.twig +++ b/~dev_rating/application/views/teacher/discipline/edit/teachers.twig @@ -35,7 +35,7 @@ <select class="SelectDepartment defaultForm"> <option value="0">Выберите кафедру (РЅРµ обязательно)</option> {% for Dep in Departments %} - <option value="{{ Dep.ID }}">{{ Dep.Name }}</option> + <option value="{{ Dep.ID }}">{{ Dep.Name|default('Служебная кафедра') }}</option> {% endfor %} </select> <input type="text" class="InputTeacherName defaultForm P1Width" placeholder="Фамилия РРјСЏ Отчество" value=""> diff --git a/~dev_rating/media/js/admin/accounts/codes.js b/~dev_rating/media/js/admin/accounts/codes.js index 4de5992e2706983f36003297f965d8288349c1a4..3fdd638f581aa7638bb28cb267a8adc695f4cf50 100644 --- a/~dev_rating/media/js/admin/accounts/codes.js +++ b/~dev_rating/media/js/admin/accounts/codes.js @@ -27,7 +27,9 @@ $(function() $("#departmentSelect").html('<option value="0">--- Кафедра ---</option>'); $.post(URLdir + 'handler/admTeachers/getDepartmentsList', {'facultyID': $('#facultySelect option:selected').val()}, function(data){ $.each(data, function(i){ - $("#departmentSelect").append('<option value="'+data[i].ID+'">'+data[i].Name+'</option>'); + var dep = data[i]; + if (!dep.Name) dep.Name = 'Служебная кафедра'; + $("#departmentSelect").append('<option value="'+dep.ID+'">'+dep.Name+'</option>'); }); $("#departmentSelect").removeAttr("disabled"); }, "json"); diff --git a/~dev_rating/media/js/admin/teachers/add.js b/~dev_rating/media/js/admin/teachers/add.js index 726557f3480111072820c64b0ac33ea95b6ca00a..0a8706eb0793b1cd2be9d7e68003e1757c0fb2c8 100644 --- a/~dev_rating/media/js/admin/teachers/add.js +++ b/~dev_rating/media/js/admin/teachers/add.js @@ -12,7 +12,9 @@ $(function() $('#departmentSelect').attr('disabled', 'disabled'); $.post(URLdir + 'handler/admTeachers/getDepartmentsList', {'facultyID': $('#facultySelect option:selected').val()}, function(data){ $.each(data, function(i){ - $("#departmentSelect").append('<option value="'+data[i].ID+'">'+data[i].Name+'</option>'); + var dep = data[i]; + if (!dep.Name) dep.Name = 'Служебная кафедра'; + $("#departmentSelect").append('<option value="'+dep.ID+'">'+dep.Name+'</option>'); }); $("#departmentSelect").removeAttr("disabled"); }, "json"); diff --git a/~dev_rating/media/js/admin/teachers/index.js b/~dev_rating/media/js/admin/teachers/index.js index 5f90701def44f962e907b23d3c07dfddad195f97..c66b92b5d081aae9089de82c9509c8562d3debd9 100644 --- a/~dev_rating/media/js/admin/teachers/index.js +++ b/~dev_rating/media/js/admin/teachers/index.js @@ -24,7 +24,9 @@ $(function() }); $.post(URLdir + 'handler/admTeachers/getDepartmentsList', {'facultyID': $('#facultySelect option:selected').val()}, function(data){ $.each(data, function(i){ - $("#departmentSelect").append('<option value="'+data[i].ID+'">'+data[i].Name+'</option>'); + var dep = data[i]; + if (!dep.Name) dep.Name = 'Служебная кафедра'; + $("#departmentSelect").append('<option value="'+dep.ID+'">'+dep.Name+'</option>'); }); $("#departmentSelect").removeAttr("disabled"); }, "json"); diff --git a/~dev_rating/media/js/discipline/EditTeachers.js b/~dev_rating/media/js/discipline/EditTeachers.js index d0e1c851f94ab6b758272ad8cf139827ed5c2235..8aa3209de438edaac25050fe09b0e08a341aa2d4 100644 --- a/~dev_rating/media/js/discipline/EditTeachers.js +++ b/~dev_rating/media/js/discipline/EditTeachers.js @@ -80,7 +80,9 @@ $(function() { jDepartmentSelect.html("<option value='0'>Выберите кафедру (РЅРµ обязательно)</option>"); for (i in Dep) { - jDepartmentSelect.append("<option value='"+ Dep[i].ID +"'>"+ Dep[i].Name +"</option>"); + var dep = Dep[i]; + if (!dep.Name) dep.Name = 'Служебная кафедра'; + jDepartmentSelect.append("<option value='"+ dep.ID +"'>"+ dep.Name +"</option>"); } if (i <= 0) jDepartmentSelect.html("<option value='0'>Нет кафедр</option>"); diff --git a/~dev_rating/media/js/profileSettings.js b/~dev_rating/media/js/profileSettings.js index 7e0c58926a7ffb4e61e3dde8d73b2261ee7f9484..54f878d104d197d27ae9af71a6d3e834ddfc1d22 100644 --- a/~dev_rating/media/js/profileSettings.js +++ b/~dev_rating/media/js/profileSettings.js @@ -10,8 +10,10 @@ $(function() $.post( URLdir + 'handler/settings/getDepartmentsList', {'facultyID': $('#facultySelect option:selected').val()}, function(data){ - $.each(data, function(i){ - $("#departmentSelect").append('<option value="'+data[i].ID+'">'+data[i].Name+'</option>'); + $.each(data, function(i) { + var dep = data[i]; + if (!dep.Name) dep.Name = 'Служебная кафедра'; + $("#departmentSelect").append('<option value="' + dep.ID + '">' + dep.Name + '</option>'); }); $("#departmentSelect").removeAttr("disabled"); },