diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index f13608f28b96f4bfba7a0242dca3e6d8be7f93f9..6ea0e44257fca3c8e85f81010a8941702d303817 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -364,8 +364,36 @@ class Controller_Handler_Map extends Controller_Handler { $this->response->body(json_encode($data)); } + // Получаем СЃРїРёСЃРѕРє РіСЂСѓРїРї (позже нужно будет перенести РІ РґСЂСѓРіРѕР№ контроллер)(для РїРѕРёСЃРєР°) + public function action_GetStudyGroups() { + $GroupList['success'] = false; + $this->post -> rule('Grade', 'digit') + -> rule('FacultyID', 'digit'); + if($this->post->check()) { + + $Groups = $this->model->GetStudyGroupsOrdByGroups($this->post->offsetGet('Grade'), $this->post->offsetGet('FacultyID')); + $GroupList = array(); + $i = 0; + + foreach($Groups as $row) { + $i++; + $GroupList[$i]['GroupID'] = $row['GroupID']; + $GroupList[$i]['GroupNum'] = $row['GroupNum']; + $GroupList[$i]['SpecID'] = $row['SpecID']; + $GroupList[$i]['SpecName'] = $row['SpecName']; + $GroupList[$i]['SpecAbbr'] = $row['SpecAbbr']; + } + + $GroupList['count'] = $i; + + if ($i > 0 ) + $GroupList['success'] = true; + } + $this->response->body(json_encode($GroupList)); + } - public function action_SearchStudents() { + // РџРѕРёСЃРє студентов + public function action_SearchStudents() { $this->post -> rule('Grade', 'digit') -> rule('GroupN', 'digit') -> rule('FacultyID', 'digit'); @@ -424,12 +452,36 @@ class Controller_Handler_Map extends Controller_Handler { } $this->response->body(json_encode($data)); } + + // Получаем СЃРїРёСЃРѕРє кафедр (позже нужно будет перенести РІ РґСЂСѓРіРѕР№ контроллер)(для РїРѕРёСЃРєР°) + public function action_GetDepartments() { + $DepList['success'] = false; + $this->post -> rule('FacultyID', 'not_empty') + -> rule('FacultyID', 'digit'); + if($this->post->check()) { + $list = $this->model->GetDepartments($this->post->offsetGet('FacultyID')); + $DepList = array(); $i = 0; + + foreach ($list as $row) { + $i++; + $DepList[$i]['DepID'] = $row['DepID']; + $DepList[$i]['DepName'] = $row['DepName']; + } + + $DepList['count'] = $i; + + if ($i > 0 ) + $DepList['success'] = true; + } + $this->response->body(json_encode($DepList)); + } + // РџРѕРёСЃРє преподавателей public function action_SearchTeachers() { $this->post -> rule('DepartmentID', 'digit'); if($this->post->check()) { $SeResult = $this->model->SearchTeachers( - $this->FacultyID, + $this->post->offsetGet('FacultyID'), $this->post->offsetGet('DepartmentID'), $this->post->offsetGet('Last'), $this->post->offsetGet('First'), @@ -447,6 +499,7 @@ class Controller_Handler_Map extends Controller_Handler { $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 a13c177ba603e33209dfa6815f382e30bdf35200..49dc2458cf0b3c08c1eaab697142b216995cb096 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Map.php +++ b/~dev_rating/application/classes/Controller/Teacher/Map.php @@ -1,8 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); class Controller_Teacher_Map extends Controller_UserEnvi { - - private $GradeID; private $GradesList = array( 1 => array( @@ -58,8 +56,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->SubjectsList = $this->GetSubjectsList($db); $twig->GradesList = $this->GradesList; - - //echo Debug::vars($twig->User); $this->response->body($twig); } @@ -86,7 +82,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->GroupsForDiscipline = $this->GetGroupsForDiscipline($db, $id); - $twig->StudyGroups = $this->GetStudyGroupsOrdByGroups($db, $this->GradeID, $twig->Discipline['FacultyID']); + $twig->StudyGroups = $this->GetStudyGroupsOrdByGroups($db, $twig->Discipline['GradeID'], $twig->Discipline['FacultyID']); $this->response->body($twig); } @@ -100,6 +96,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Students = $this->GetStudentsList($db, $id); + $twig->GradesList = $this->GradesList; + $twig->StudyGroups = $this->GetStudyGroupsOrdByGroups($db, $twig->Discipline['GradeID'], $twig->Discipline['FacultyID']); $this->response->body($twig); } @@ -113,7 +111,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->BindTeachersList = $this->GetTeachersForDiscipline($db, $id); - $twig->Departments = $this->GetDepartments($db, $twig->Discipline['FacultyID']); + $twig->FacultiesList = $this->GetFaculties($db); + $twig->Departments = $this->GetDepartments($db, $twig->Discipline['FacultyID']); $twig->TeachersList = $this->GetTeachersByDepartment($db, $twig->Discipline['DepID']); $this->response->body($twig); @@ -180,7 +179,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $subject['LectureHours'] = $info['LectionCount']; $subject['PracticeHours'] = $info['PracticeCount']; $subject['GradeID'] = $info['DisciplineGrade']; - $this->GradeID = $subject['GradeID']; $teachersHandled = array(); $i = 0; diff --git a/~dev_rating/application/views/teacher/map/EditStudents.twig b/~dev_rating/application/views/teacher/map/EditStudents.twig index 4f4f8d96f12773cfdd7bb86b3e1ef88f5301f952..1f03d87d7631859e2e74d8e646a85d56e08d72df 100644 --- a/~dev_rating/application/views/teacher/map/EditStudents.twig +++ b/~dev_rating/application/views/teacher/map/EditStudents.twig @@ -26,9 +26,23 @@ <div class="SearchStudents"> <h2 class="BlueTitle">РџРѕРёСЃРє студентов</h2> <div class="SearchSettings"> + <select class="SelectGrade default_select"> + <option value="0">Выберите РєСѓСЂСЃ:</option> + {% for Grade in GradesList %} + <option value="{{ Grade.ID }}" {% if Grade.ID == Discipline.GradeID %}selected{% endif %}>{{ Grade.Title }}</option> + {% endfor %} + </select> + <select class="SelectStudyGroup default_select"> + <option value="0">Выберите РіСЂСѓРїРїСѓ:</option> + {% for Group in StudyGroups %} + <option value="{{ Group.GroupID }}">Группа {{ Group.GroupNum }} - {{ Group.SpecName }}</option> + {% endfor %} + </select> <input tupe="text" class="InputStudentName default_input_text" placeholder="Фамилия РРјСЏ Отчество" value=""> </div> - <div class="SearchResult"></div> + <div class="SearchResult"> + + </div> </div> </div> {% endblock %} diff --git a/~dev_rating/application/views/teacher/map/EditTeachers.twig b/~dev_rating/application/views/teacher/map/EditTeachers.twig index 2366e69cefd0749b40ba9e4d2e246255344e091c..e3e9262372a8654a03c2250bb3c517c3239640d4 100644 --- a/~dev_rating/application/views/teacher/map/EditTeachers.twig +++ b/~dev_rating/application/views/teacher/map/EditTeachers.twig @@ -17,13 +17,17 @@ <h2 class="BlueTitle">РџРѕРёСЃРє преподавателей</h2> <div class="SearchSettings"> <input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}"> - <input tupe="text" class="InputTeacherName default_input_text" placeholder="Фамилия РРјСЏ Отчество" value=""> + <select class="SelectFaculty default_select"> + {% for Faculty in FacultiesList %} + <option value="{{ Faculty.FacultyID }}" {% if Discipline.FacultyID == Faculty.FacultyID %}selected{% endif %}>{{ Faculty.FacultyName }}</option> + {% endfor %} + </select> <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> + <option value="{{ Dep.DepID }}" {% if Discipline.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 %} diff --git a/~dev_rating/media/css/construct.css b/~dev_rating/media/css/construct.css index 30c1ddf035514bdbbe1a57282bc60b6d0e05a21b..6b37a7b8f3f55725035a9723acafa0e32739b1d9 100644 --- a/~dev_rating/media/css/construct.css +++ b/~dev_rating/media/css/construct.css @@ -265,6 +265,32 @@ cursor: pointer; border-bottom: 1px solid #009933; } +.SearchStudents { + display: block; + margin-top: 20px; +} + .SearchStudents .SearchSettings { + background: #f4f4f4; + margin: 10px 0; + padding: 10px 0; + } + .SearchStudents .SearchSettings .SelectGrade { + float: left; + width: 48%; + margin-left: 1%; + } + .SearchStudents .SearchSettings .SelectStudyGroup { + float: right; + width: 48%; + margin-right: 1%; + } + .SearchStudents .SearchSettings .InputStudentName { + clear: both; + margin: 0 1%; + margin-top: 10px; + width: 98%; + } + /* Прикрипление преподавателей */ .TeachersList { width: auto @@ -309,13 +335,23 @@ margin-top: 20px; } .SearchTeachers .SearchSettings { + background: #f4f4f4; margin: 10px 0; + padding: 10px 0; } - .SearchTeachers .SearchSettings .InputTeacherName { - float: right; - width: 49%; + .SearchTeachers .SearchSettings .SelectFaculty { + float: left; + width: 48%; + margin-left: 1%; } .SearchTeachers .SearchSettings .SelectDepartment { - float: left; - width: 49%; + float: right; + width: 48%; + margin-right: 1%; + } + .SearchTeachers .SearchSettings .InputTeacherName { + clear: both; + margin: 0 1%; + margin-top: 10px; + width: 98%; } \ 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 018b1132d458e06bf572a5272fe4969cd9e35ab8..34c0d61555a42d8722e4dbda3e4308da81870037 100644 --- a/~dev_rating/media/js/construct/edit.js +++ b/~dev_rating/media/js/construct/edit.js @@ -511,14 +511,16 @@ return '\ <span class="action Action_BindStudent">Прикрепить студента</span>\ </div>'; } -$('.InputStudentName').focusout(function(){ + +// РџРѕРёСЃРє студентов +function CallSearchStudents() { var Name = []; Name = ($('.InputStudentName ').val()).split(' '); $.post( '/~dev_rating/handler/map/SearchStudents', { - 'Grade': 0, //$('.SelectDepartment').val(), - 'GroupN': 0, + 'Grade': $('.SelectGrade').val(), + 'GroupN': $('.SelectStudyGroup').val(), 'FacultyID': FacultyID, 'Last': Name[0], 'First': Name[1], @@ -535,10 +537,39 @@ $('.InputStudentName').focusout(function(){ $('.SearchResult').append(AddStudent(ID, Name, From)); } else - $('.SearchResult').html('Нет результатов'); + $('.SearchResult').html('<p class="notification">Нет результатов</p>'); + } + ); +} + +$('.SelectGrade').change(function(){ + $.post( + '/~dev_rating/handler/map/GetStudyGroups', + { + 'FacultyID': FacultyID, + 'Garde': $('.SelectGrade').val() + }, + function(data){ + data = $.parseJSON(data); + if (data != null && data != undefined) { + $('.SelectStudyGroup').html(''); + for (i = 1; i <= data.count; i++) { + $('.SelectStudyGroup').append('<option value="'+ data[i].GroupID +'">'+ data[i].GroupNum +'</option>'); + } + + if (data.count <= 0) + $('.SelectStudyGroup').append('<option value="0">Нет РіСЂСѓРїРї</option>'); + } + CallSearchStudents(); } ); }); +$('.SelectStudyGroup').change(function(){ + CallSearchStudents(); +}); +$('.InputStudentName').focusout(function(){ + CallSearchStudents(); +}); // Прикрепить студента $('.StudentsList').on('click', '.Action_BindStudent', function(){ @@ -592,6 +623,7 @@ $('.StudentsList').on('click', '.Action_UnbindStudent', function(){ ); }); +// Добавить преподавателя function AddTeacher(ID, Name, Action){ $r = '\ <div class="Teacher" id="'+ ID +'">\ @@ -613,7 +645,7 @@ function CallSearchTeachers(){ $.post( '/~dev_rating/handler/map/SearchTeachers', { - 'FacultyID': FacultyID, + 'FacultyID': $('.SelectFaculty').val(), 'DepartmentID': $('.SelectDepartment').val(), 'Last': Name[0], 'First': Name[1], @@ -621,17 +653,43 @@ function CallSearchTeachers(){ }, 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('Нет результатов'); + if (SearchResult != null && SearchResult != undefined) { + $('.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('<p class="notification">Нет результатов</p>'); + } } ); } + +// Выборка кафедр +$('.SelectFaculty').change(function(){ + $.post( + '/~dev_rating/handler/map/GetDepartments', + { + 'FacultyID': $('.SelectFaculty').val() + }, + function(data){ + data = $.parseJSON(data); + if (data != null && data != undefined) { + $('.SelectDepartment').html(''); + for (i = 1; i <= data.count; i++) { + $('.SelectDepartment').append('<option value="'+ data[i].DepID +'">'+ data[i].DepName +'</option>'); + } + + if (data.count <= 0) + $('.SelectDepartment').append('<option value="0">Нет кафедр</option>'); + } + CallSearchTeachers(); + } + ); +}); + $('.SelectDepartment ').change(function(){ CallSearchTeachers(); }); diff --git a/~dev_rating/media/js/functions.js b/~dev_rating/media/js/functions.js index 45680cc3071cd801edcadabca370f15c6a3622aa..13d27b89c287dee0eaa12cf9ea5037dfdd098896 100644 --- a/~dev_rating/media/js/functions.js +++ b/~dev_rating/media/js/functions.js @@ -3,6 +3,10 @@ function isNum(v) { return typeof v === 'number' && isFinite(v); } +function is_object(obj){ + return (typeof obj == "object"); +} + // Разрешаем вводить только цифры function KeyDownOnlyNumber(event) { // Разрешаем: backspace, delete, tab Рё escape