diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index e797b65689234dae443a549638972cc73f8af3fd..c91471871ad8d1d54835128086b1e8f16d6b9cdb 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -364,6 +364,28 @@ class Controller_Handler_Map extends Controller_Handler { $this->response->body(json_encode($data)); } + /* + public function action_SearchStudents() { + $data['result'] = false; + $this->post -> rule('Grade', 'digit') + -> rule('GroupN', 'digit') + -> rule('FacultyID', 'digit'); + if($this->post->check()) { + $SeResult = $this->model->SearchStudents( + $this->post->offsetGet('Grade', 'null'), + $this->post->offsetGet('GroupN', 'null'), + $this->post->offsetGet('FacultyID', 'null'), + $this->post->offsetGet('Last', 'null'), + $this->post->offsetGet('First', 'null'), + $this->post->offsetGet('Second', 'null') + ); + + var_dump($this->post->offsetGet($SeResult)); + } + $this->response->body(json_encode($data)); + } + */ + // Прикрепить преподавателя public function action_BindTeacher() { $data['success'] = false; @@ -393,4 +415,30 @@ class Controller_Handler_Map extends Controller_Handler { } $this->response->body(json_encode($data)); } + + public function action_SearchTeachers() { + $this->post -> rule('DepartmentID', 'digit'); + if($this->post->check()) { + $SeResult = $this->model->SearchTeachers( + $this->FacultyID, + $this->post->offsetGet('DepartmentID'), + $this->post->offsetGet('Last'), + $this->post->offsetGet('First'), + $this->post->offsetGet('Second') + ); + $SearchResult = array(); + $i = 0; + foreach($SeResult as $row){ + $i++; + $SearchResult[$i]['TeacherID'] = $row['TeacherID']; + $SearchResult[$i]['TeacherLast'] = $row['TeacherLast']; + $SearchResult[$i]['TeacherFirst'] = $row['TeacherFirst']; + $SearchResult[$i]['TeacherSecond'] = $row['TeacherSecond']; + $SearchResult[$i]['JobPositionName'] = $row['JobPositionName']; + $SearchResult[$i]['DepID'] = $row['DepID']; + } + $SearchResult['Count'] = $i; + } + $this->response->body(json_encode($SearchResult)); + } } diff --git a/~dev_rating/application/classes/Controller/Teacher/Map.php b/~dev_rating/application/classes/Controller/Teacher/Map.php index 87949031d33ac1befb59dea08b29c593968921cc..c4970febe61dee41e71cfe021b5c9041f82ddf6e 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Map.php +++ b/~dev_rating/application/classes/Controller/Teacher/Map.php @@ -47,7 +47,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Map = $this->getMapInfo($map); - $twig->Subject = $this->getSubjectInfo($db, $id); + $twig->Subject = $this->getDisciplineInfo($db, $id); $this->response->body($twig); } @@ -68,7 +68,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig = Twig::factory('teacher/map/EditDiscipline'); $twig->User = $this->UserInfo; - $twig->Discipline = $this->getSubjectInfo($db, $id); + $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->SubjectsList = $this->GetSubjectsList($db); $twig->GradesList = $this->GradesList; @@ -82,7 +82,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig = Twig::factory('teacher/map/EditStructure'); $twig->User = $this->UserInfo; - $twig->Discipline = $this->getSubjectInfo($db, $id); + $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Map = $this->getMapInfo($db->getMapForDiscipline($this->UserInfo['TeacherID'], $id)); $this->response->body($twig); @@ -95,7 +95,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig = Twig::factory('teacher/map/EditGroups'); $twig->User = $this->UserInfo; - $twig->Discipline = $this->getSubjectInfo($db, $id); + $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->GroupsForDiscipline = $this->GetGroupsForDiscipline($db, $id); $twig->StudyGroups = $this->GetStudyGroups($db, $this->GradeID, $this->UserInfo['FacultyID']); @@ -109,7 +109,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig = Twig::factory('teacher/map/EditStudents'); $twig->User = $this->UserInfo; - $twig->Discipline = $this->getSubjectInfo($db, $id); + $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Students = $this->GetStudentsList($db, $id); $this->response->body($twig); @@ -122,9 +122,11 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig = Twig::factory('teacher/map/EditTeachers'); $twig->User = $this->UserInfo; - $twig->Discipline = $this->getSubjectInfo($db, $id); - $twig->TeachersList = $this->GetTeachersForDiscipline($db, $id); - + $twig->Discipline = $this->getDisciplineInfo($db, $id); + $twig->BindTeachersList = $this->GetTeachersForDiscipline($db, $id); + $twig->Departments = $this->GetDepartments($db, $twig->Discipline['FacultyID']); + $twig->TeachersList = $this->GetTeachersByDepartment($db, $twig->Discipline['DepID']); + $this->response->body($twig); } @@ -167,16 +169,18 @@ class Controller_Teacher_Map extends Controller_UserEnvi { return $mapHandled; } - public function getSubjectInfo($db, $id) + public function getDisciplineInfo($db, $id) { $info = $db->getDisciplineInfoByID($id); - + if($info->count() == 0) throw HTTP_Exception::factory(404, "Учебная карта дисциплины СЃ ID $id РЅРµ найдена!"); else $info = $info->offsetGet(0); $subject['DisciplineID'] = $id; + $subject['DepID'] = $info['DepID']; + $subject['FacultyID'] = $info['FacultyID']; $teachers = $db->getTeachersForDiscipline($id); @@ -220,6 +224,35 @@ class Controller_Teacher_Map extends Controller_UserEnvi { return $SubjectsList; } + private function GetFaculties($db) { + $list = $db->GetFaculties(); + + $FacList = array(); $i = 0; + + foreach ($list as $row) { + $i++; + $FacList[$i]['FacultyID'] = $row['FacultyID']; + $FacList[$i]['FacultyName'] = $row['FacultyName']; + $FacList[$i]['FacultyAbbr'] = $row['FacultyAbbr']; + } + + return $FacList; + } + + private function GetDepartments($db, $FacultyID) { + $list = $db->GetDepartments($FacultyID); + + $DepList = array(); $i = 0; + + foreach ($list as $row) { + $i++; + $DepList[$i]['DepID'] = $row['DepID']; + $DepList[$i]['DepName'] = $row['DepName']; + } + + return $DepList; + } + private function GetStudentsList($db, $DisciplineID) { $students = $db->GetStudentsForDiscipline($this->UserInfo['TeacherID'], $DisciplineID); @@ -313,8 +346,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $TeachersHandled[$i]['FacultyName'] = $row['FacultyName']; $TeachersHandled[$i]['FacultyAbbreviation'] = $row['FacultyAbbreviation']; } - - // echo Debug::vars($TeachersHandled); + return $TeachersHandled; } diff --git a/~dev_rating/application/classes/Model/Teacher/Map.php b/~dev_rating/application/classes/Model/Teacher/Map.php index cc183b026f7ec97f115b4fe598af510a699371e3..db47747a607af2ab8a4e54a70c7610b09f4fc29c 100644 --- a/~dev_rating/application/classes/Model/Teacher/Map.php +++ b/~dev_rating/application/classes/Model/Teacher/Map.php @@ -116,6 +116,18 @@ class Model_Teacher_Map extends Model return DB::query(Database::SELECT, $sql)->execute(); } + public function GetFaculties() + { + $sql = "CALL `GetFaculties`(); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function GetDepartments($FacultyID) + { + $sql = "CALL `GetDepartments`('$FacultyID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + public function GetStudyGroups($Grade, $FacultyID) { $sql = "CALL `GetStudyGroups`('$Grade', '$FacultyID'); "; @@ -188,4 +200,14 @@ class Model_Teacher_Map extends Model return DB::query(Database::SELECT, $sql)->execute(); } + public function SearchStudents($Grade, $GroupN, $FacultyID, $Last, $First, $Second = 'NULL') + { + $sql = "CALL `SearchStudents`('$Grade', '$GroupN', '$FacultyID', '$Last', '$First', '$Second'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function SearchTeachers($FacultyID, $DepartmentID, $Last, $First, $Second) { + $sql = "CALL `SearchTeachers`('$FacultyID', '$DepartmentID', '$Last', '$First', '$Second'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } } diff --git a/~dev_rating/application/views/teacher/map/EditGroups.twig b/~dev_rating/application/views/teacher/map/EditGroups.twig index 9fa7b9717c659bac01da451dc465c2ed465e4613..ea9b22ebc0f1dd90d5ee95edca5d33959a18b294 100644 --- a/~dev_rating/application/views/teacher/map/EditGroups.twig +++ b/~dev_rating/application/views/teacher/map/EditGroups.twig @@ -3,7 +3,7 @@ {% block title %}Конструктор РЈРљР”{% endblock %} {# head -> title #} {% block map_content %} - <p class="top_center_info" style="display: none">Учебная карта дисциплины РЅР° 1 семестр 2014 РіРѕРґР°</p> + <p class="notification">Обратите внимание, если вам нужно прикрепить 1-РѕРіРѕ или максимум 4-С… студентов РёР· РіСЂСѓРїРїС‹, то удобней это сделать РЅР° странице 'Прикрепление студентов'</p> <div class="ChangeStudyGroupDIV"> <select class="SelectStudyGroup default_select"> <option value="0">Выберите РіСЂСѓРїРїСѓ:</option> diff --git a/~dev_rating/application/views/teacher/map/EditStudents.twig b/~dev_rating/application/views/teacher/map/EditStudents.twig index 1a435e4704bd719f65c8d0d98d2b91fb1eacca04..f5d635e603f58870eb620aebab0a6b2ffe75f082 100644 --- a/~dev_rating/application/views/teacher/map/EditStudents.twig +++ b/~dev_rating/application/views/teacher/map/EditStudents.twig @@ -4,7 +4,9 @@ {% block map_content %} <p class="top_center_info" style="display: none">Учебная карта дисциплины РЅР° 1 семестр 2014 РіРѕРґР°</p> + <input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}"> <div class="AttachedStudentsList"> + <button class="SearchStudentsButton">РџРѕРёСЃРє</button> {% set NowGroupNum = 0 %} {% for Student in Students %} {% if NowGroupNum != Student.GroupNum %} diff --git a/~dev_rating/application/views/teacher/map/EditTeachers.twig b/~dev_rating/application/views/teacher/map/EditTeachers.twig index 334e9340f0cc6e763a0b295359040a2a3c9239f3..7a72437d23698b413ad582fba49b0283fe538633 100644 --- a/~dev_rating/application/views/teacher/map/EditTeachers.twig +++ b/~dev_rating/application/views/teacher/map/EditTeachers.twig @@ -3,14 +3,37 @@ {% block title %}Конструктор РЈРљР”{% endblock %} {# head -> title #} {% block map_content %} - <p class="top_center_info" style="display: none">Учебная карта дисциплины РЅР° 1 семестр 2014 РіРѕРґР°</p> - <h2>Прикрепленные преподаватели</h2> - <div class="AttachedTeachersList"> - {% for Teacher in TeachersList %} - <div class="Teacher" id="{{ Teacher.TeacherID }}" style="background: #f1f1f1; margin: 10px 0;"> - <div class="Name">{{ Teacher.TeacherLast }} {{ Teacher.TeacherFirst }} {{ Teacher.TeacherSecond }}</div> - <div class="Action_UnbindTeacher">Отсоединить</div> + <div class="TeachersList"> + <div class="BindTeachersList"> + <h2>Прикрепленные преподаватели</h2> + {% for Teacher in BindTeachersList %} + <div class="Teacher" id="{{ Teacher.TeacherID }}"> + <div class="Name">{{ Teacher.TeacherLast }} {{ Teacher.TeacherFirst }} {{ Teacher.TeacherSecond }}</div> + <div class="Action_UnbindTeacher Action">Отсоединить</div> + </div> + {% endfor %} + </div> + <div style="width: 2%;"></div> + <div class="SearchTeachers"> + <h2>РџРѕРёСЃРє преподавателей</h2> + <div class="SearchSettings"> + <input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}"> + <select class="SelectDepartment default_select"> + <option value="0">-- Выберите кафедру --</option> + {% for Dep in Departments %} + <option value="{{ Dep.DepID }}" {% if User.DepID == Dep.DepID %}selected{% endif %}>{{ Dep.DepName }}</option> + {% endfor %} + </select> + <input tupe="text" class="InputTeacherName default_input_text" placeholder="Фамилия РРјСЏ Отчество" value=""> + </div> + <div class="SearchResult"> + {% for Teacher in TeachersList %} + <div class="Teacher" id="{{ Teacher.TeacherID }}"> + <div class="Name">{{ Teacher.TeacherLast }} {{ Teacher.TeacherFirst }} {{ Teacher.TeacherSecond }}</div> + <div class="Action_BindTeacher Action">Присоединить</div> + </div> + {% endfor %} + </div> </div> - {% endfor %} </div> {% endblock %} diff --git a/~dev_rating/media/css/base.css b/~dev_rating/media/css/base.css index 6f0d858e7c697c69037184e7ec4851f8fb9b7a2a..b4552a8fb0fc01523ba1659781134db61a05b49c 100644 --- a/~dev_rating/media/css/base.css +++ b/~dev_rating/media/css/base.css @@ -196,7 +196,8 @@ html>body #wrap /* Оповещение */ p.notification{ margin: 10px 0; - text-align: center; font-size: 16px; + text-align: center; + font-size: 16px; } diff --git a/~dev_rating/media/css/construct.css b/~dev_rating/media/css/construct.css index 18fb68fabfe51c86a39b451b1ed5e21bef9247e3..cbd57ed4fdccdfce733f3e487f07e91492fda0b2 100644 --- a/~dev_rating/media/css/construct.css +++ b/~dev_rating/media/css/construct.css @@ -19,7 +19,7 @@ /* -- Вкладки РЅР° странице -------------------- */ .tabs { - margin: 10px 25px; + margin: 10px 25px 20px 25px; } .tabs .tab { display: inline; @@ -235,3 +235,65 @@ .StatusUnbind { background: #F3C0C0; } +/* Прикрипление преподавателей */ +.TeachersList { + width: auto +} +.TeachersList h2{ + font-size: 18px; + font-weight: normal; + color: #3399CC; +} + .TeachersList .Teacher { + background: #EDF1F5; + margin: 10px 0; + padding: 5px 10px; + } + .TeachersList .Teacher .Name { + float: left; + font-size: 15px; + } + .TeachersList .Teacher .Action{ + float: right; + font-weight: bold; + font-size: 13px; + } + .TeachersList .Teacher .Action_UnbindTeacher { + color: #FF0000; + border-bottom: 1px solid transparent; + } + .TeachersList .Teacher .Action_UnbindTeacher:hover { + cursor: pointer; + border-bottom: 1px solid #FF0000; + } + .TeachersList .Teacher .Action_BindTeacher { + color: #009933; + border-bottom: 1px solid transparent; + } + .TeachersList .Teacher .Action_BindTeacher:hover { + cursor: pointer; + border-bottom: 1px solid #009933; + } +/* ==> */ +.BindTeachersList { + display: block; +} +.SearchTeachers { + display: block; + margin-top: 20px; +} + .SearchTeachers .SearchSettings { + margin: 10px 0; + } + .SearchTeachers .SearchSettings .SelectFaculty { + float: left; + width: 49%; + } + .SearchTeachers .SearchSettings .SelectDepartment { + float: right; + width: 49%; + } + .SearchTeachers .SearchSettings .InputTeacherName { + margin-top: 10px; + width: 100%; + } \ No newline at end of file diff --git a/~dev_rating/media/js/construct/edit.js b/~dev_rating/media/js/construct/edit.js index 9ba2a1995592cb6295ca6d28a2ab76fb6df3df9e..b6ad9f6e3a484341663c1ed329e632430f1e0b7a 100644 --- a/~dev_rating/media/js/construct/edit.js +++ b/~dev_rating/media/js/construct/edit.js @@ -451,6 +451,9 @@ $(function() { // ------ Прикрипление студентов/РіСЂСѓРїРї/преподавателей -- +var FacultyID = $('.HiddenInputFacultyID').val(); // Факультет, Рє которой привязана дисциплина +$('.HiddenInputFacultyID').remove(); // РўСѓС‚ даже Шерлок Холмс бессилен + function BindGroup(id){ return '\ <div class="AttachedGroup" id="'+ id +'">\ @@ -499,6 +502,24 @@ $('.AttachedGroupsList').on('click', '.UnbindGroup', function(){ ); }); +// РџРѕРёСЃРє студентов +$('.SearchStudentsButton').click(function(){ + $.post( + '/~dev_rating/handler/map/SearchStudents', + { + 'Grade': '', + 'GroupN': '', + 'FacultyID': '', + 'Last': 'Рванов', + 'First': 'РРІ', + 'Second': 'h' + }, + function(date){ + + } + ); +}); + // Прикрепить студента $('.AttachedStudentsList').on('click', '.Action_BindStudent', function(){ $(this) @@ -551,7 +572,56 @@ $('.AttachedStudentsList').on('click', '.Action_UnbindStudent', function(){ ); }); -$('.AttachedTeachersList').on('click', '.Action_UnbindTeacher', function(){ +function AddTeacher(ID, Name, Action){ + $r = '\ + <div class="Teacher" id="'+ ID +'">\ + <div class="Name">'+ Name +'</div>'; + if (Action == 'Unbind') + $r += '<div class="Action_UnbindTeacher Action">Отсоединить</div>'; + if (Action == 'Bind') + $r += '<div class="Action_BindTeacher Action">Присоединить</div>'; + $r += '\ + </div>'; + return $r; +} + + +// РџРѕРёСЃРє преподавателей +function CallSearchTeachers(){ + var Name = []; + Name = ($('.InputTeacherName ').val()).split(' '); + $.post( + '/~dev_rating/handler/map/SearchTeachers', + { + 'FacultyID': FacultyID, + 'DepartmentID': $('.SelectDepartment').val(), + 'Last': Name[0], + 'First': Name[1], + 'Second': Name[2] + }, + function(data){ + SearchResult = $.parseJSON(data); + $('.SearchResult').html(''); + if (parseInt(SearchResult.Count) > 0) + for(var i = 1; i <= parseInt(SearchResult.Count); i++) { + var Name = SearchResult[i].TeacherLast + ' ' + SearchResult[i].TeacherFirst + ' ' + SearchResult[i].TeacherSecond; + $('.SearchResult').append(AddTeacher(SearchResult[i].TeacherID, Name, 'Bind')); + } + else + $('.SearchResult').html('Нет результатов'); + } + ); +} +$('.SelectDepartment ').change(function(){ + CallSearchTeachers(); +}); +$('.InputTeacherName').focusout(function(){ + CallSearchTeachers(); +}); +// Конец РїРѕРёСЃРєР° преподавателей + +// Отсоединить преподавателя +$('.TeachersList').on('click', '.Action_UnbindTeacher', function(){ $(this) .parent() .remove(); @@ -571,4 +641,28 @@ $('.AttachedTeachersList').on('click', '.Action_UnbindTeacher', function(){ ); }); +// Присоединить преподавателя +$('.TeachersList').on('click', '.Action_BindTeacher', function(){ + $(this) + .parent() + .remove(); + var ID = $(this).parent().attr('id'); + var Name = $(this).siblings('.Name').text(); + $.post( + '/~dev_rating/handler/map/BindTeacher', + { + 'BindingTeacher': ID, + 'DisciplineID': DisciplineID + }, + function(data){ + data = $.parseJSON(data); + if(data.success === true) { + EventInspector_ShowMsg('РћРє, BindTeacher', 'success'); + $('.BindTeachersList').append(AddTeacher(ID, Name, 'Unbind')); + } + else EventInspector_ShowMsg('Error, BindTeacher', 'error'); + } + ); +}); + });