Skip to content
Snippets Groups Projects
Commit 0b4093e3 authored by PavelBegunkov's avatar PavelBegunkov
Browse files
parents 09939733 c88ad9f5
Branches
Tags
No related merge requests found
...@@ -364,8 +364,36 @@ class Controller_Handler_Map extends Controller_Handler { ...@@ -364,8 +364,36 @@ class Controller_Handler_Map extends Controller_Handler {
$this->response->body(json_encode($data)); $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') $this->post -> rule('Grade', 'digit')
-> rule('GroupN', 'digit') -> rule('GroupN', 'digit')
-> rule('FacultyID', 'digit'); -> rule('FacultyID', 'digit');
...@@ -424,12 +452,36 @@ class Controller_Handler_Map extends Controller_Handler { ...@@ -424,12 +452,36 @@ class Controller_Handler_Map extends Controller_Handler {
} }
$this->response->body(json_encode($data)); $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() { public function action_SearchTeachers() {
$this->post -> rule('DepartmentID', 'digit'); $this->post -> rule('DepartmentID', 'digit');
if($this->post->check()) { if($this->post->check()) {
$SeResult = $this->model->SearchTeachers( $SeResult = $this->model->SearchTeachers(
$this->FacultyID, $this->post->offsetGet('FacultyID'),
$this->post->offsetGet('DepartmentID'), $this->post->offsetGet('DepartmentID'),
$this->post->offsetGet('Last'), $this->post->offsetGet('Last'),
$this->post->offsetGet('First'), $this->post->offsetGet('First'),
...@@ -447,6 +499,7 @@ class Controller_Handler_Map extends Controller_Handler { ...@@ -447,6 +499,7 @@ class Controller_Handler_Map extends Controller_Handler {
$SearchResult[$i]['DepID'] = $row['DepID']; $SearchResult[$i]['DepID'] = $row['DepID'];
} }
$SearchResult['Count'] = $i; $SearchResult['Count'] = $i;
} }
$this->response->body(json_encode($SearchResult)); $this->response->body(json_encode($SearchResult));
} }
......
<?php defined('SYSPATH') or die('No direct script access.'); <?php defined('SYSPATH') or die('No direct script access.');
class Controller_Teacher_Map extends Controller_UserEnvi { class Controller_Teacher_Map extends Controller_UserEnvi {
private $GradeID;
private $GradesList = array( private $GradesList = array(
1 => array( 1 => array(
...@@ -58,8 +56,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi { ...@@ -58,8 +56,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
$twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Discipline = $this->getDisciplineInfo($db, $id);
$twig->SubjectsList = $this->GetSubjectsList($db); $twig->SubjectsList = $this->GetSubjectsList($db);
$twig->GradesList = $this->GradesList; $twig->GradesList = $this->GradesList;
//echo Debug::vars($twig->User);
$this->response->body($twig); $this->response->body($twig);
} }
...@@ -86,7 +82,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi { ...@@ -86,7 +82,7 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
$twig->User = $this->UserInfo; $twig->User = $this->UserInfo;
$twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Discipline = $this->getDisciplineInfo($db, $id);
$twig->GroupsForDiscipline = $this->GetGroupsForDiscipline($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); $this->response->body($twig);
} }
...@@ -100,6 +96,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi { ...@@ -100,6 +96,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
$twig->User = $this->UserInfo; $twig->User = $this->UserInfo;
$twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Discipline = $this->getDisciplineInfo($db, $id);
$twig->Students = $this->GetStudentsList($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); $this->response->body($twig);
} }
...@@ -113,7 +111,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi { ...@@ -113,7 +111,8 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
$twig->User = $this->UserInfo; $twig->User = $this->UserInfo;
$twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->Discipline = $this->getDisciplineInfo($db, $id);
$twig->BindTeachersList = $this->GetTeachersForDiscipline($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']); $twig->TeachersList = $this->GetTeachersByDepartment($db, $twig->Discipline['DepID']);
$this->response->body($twig); $this->response->body($twig);
...@@ -180,7 +179,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi { ...@@ -180,7 +179,6 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
$subject['LectureHours'] = $info['LectionCount']; $subject['LectureHours'] = $info['LectionCount'];
$subject['PracticeHours'] = $info['PracticeCount']; $subject['PracticeHours'] = $info['PracticeCount'];
$subject['GradeID'] = $info['DisciplineGrade']; $subject['GradeID'] = $info['DisciplineGrade'];
$this->GradeID = $subject['GradeID'];
$teachersHandled = array(); $i = 0; $teachersHandled = array(); $i = 0;
......
...@@ -26,9 +26,23 @@ ...@@ -26,9 +26,23 @@
<div class="SearchStudents"> <div class="SearchStudents">
<h2 class="BlueTitle">Поиск студентов</h2> <h2 class="BlueTitle">Поиск студентов</h2>
<div class="SearchSettings"> <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=""> <input tupe="text" class="InputStudentName default_input_text" placeholder="Фамилия Имя Отчество" value="">
</div> </div>
<div class="SearchResult"></div> <div class="SearchResult">
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
...@@ -17,13 +17,17 @@ ...@@ -17,13 +17,17 @@
<h2 class="BlueTitle">Поиск преподавателей</h2> <h2 class="BlueTitle">Поиск преподавателей</h2>
<div class="SearchSettings"> <div class="SearchSettings">
<input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}"> <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"> <select class="SelectDepartment default_select">
<option value="0">-- Выберите кафедру --</option>
{% for Dep in Departments %} {% 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 %} {% endfor %}
</select> </select>
<input tupe="text" class="InputTeacherName default_input_text" placeholder="Фамилия Имя Отчество" value="">
</div> </div>
<div class="SearchResult"> <div class="SearchResult">
{% for Teacher in TeachersList %} {% for Teacher in TeachersList %}
......
...@@ -265,6 +265,32 @@ ...@@ -265,6 +265,32 @@
cursor: pointer; cursor: pointer;
border-bottom: 1px solid #009933; 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 { .TeachersList {
width: auto width: auto
...@@ -309,13 +335,23 @@ ...@@ -309,13 +335,23 @@
margin-top: 20px; margin-top: 20px;
} }
.SearchTeachers .SearchSettings { .SearchTeachers .SearchSettings {
background: #f4f4f4;
margin: 10px 0; margin: 10px 0;
padding: 10px 0;
} }
.SearchTeachers .SearchSettings .InputTeacherName { .SearchTeachers .SearchSettings .SelectFaculty {
float: right; float: left;
width: 49%; width: 48%;
margin-left: 1%;
} }
.SearchTeachers .SearchSettings .SelectDepartment { .SearchTeachers .SearchSettings .SelectDepartment {
float: left; float: right;
width: 49%; width: 48%;
margin-right: 1%;
}
.SearchTeachers .SearchSettings .InputTeacherName {
clear: both;
margin: 0 1%;
margin-top: 10px;
width: 98%;
} }
\ No newline at end of file
...@@ -511,14 +511,16 @@ return '\ ...@@ -511,14 +511,16 @@ return '\
<span class="action Action_BindStudent">Прикрепить студента</span>\ <span class="action Action_BindStudent">Прикрепить студента</span>\
</div>'; </div>';
} }
$('.InputStudentName').focusout(function(){
// Поиск студентов
function CallSearchStudents() {
var Name = []; var Name = [];
Name = ($('.InputStudentName ').val()).split(' '); Name = ($('.InputStudentName ').val()).split(' ');
$.post( $.post(
'/~dev_rating/handler/map/SearchStudents', '/~dev_rating/handler/map/SearchStudents',
{ {
'Grade': 0, //$('.SelectDepartment').val(), 'Grade': $('.SelectGrade').val(),
'GroupN': 0, 'GroupN': $('.SelectStudyGroup').val(),
'FacultyID': FacultyID, 'FacultyID': FacultyID,
'Last': Name[0], 'Last': Name[0],
'First': Name[1], 'First': Name[1],
...@@ -535,10 +537,39 @@ $('.InputStudentName').focusout(function(){ ...@@ -535,10 +537,39 @@ $('.InputStudentName').focusout(function(){
$('.SearchResult').append(AddStudent(ID, Name, From)); $('.SearchResult').append(AddStudent(ID, Name, From));
} }
else 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(){ $('.StudentsList').on('click', '.Action_BindStudent', function(){
...@@ -592,6 +623,7 @@ $('.StudentsList').on('click', '.Action_UnbindStudent', function(){ ...@@ -592,6 +623,7 @@ $('.StudentsList').on('click', '.Action_UnbindStudent', function(){
); );
}); });
// Добавить преподавателя
function AddTeacher(ID, Name, Action){ function AddTeacher(ID, Name, Action){
$r = '\ $r = '\
<div class="Teacher" id="'+ ID +'">\ <div class="Teacher" id="'+ ID +'">\
...@@ -613,7 +645,7 @@ function CallSearchTeachers(){ ...@@ -613,7 +645,7 @@ function CallSearchTeachers(){
$.post( $.post(
'/~dev_rating/handler/map/SearchTeachers', '/~dev_rating/handler/map/SearchTeachers',
{ {
'FacultyID': FacultyID, 'FacultyID': $('.SelectFaculty').val(),
'DepartmentID': $('.SelectDepartment').val(), 'DepartmentID': $('.SelectDepartment').val(),
'Last': Name[0], 'Last': Name[0],
'First': Name[1], 'First': Name[1],
...@@ -621,17 +653,43 @@ function CallSearchTeachers(){ ...@@ -621,17 +653,43 @@ function CallSearchTeachers(){
}, },
function(data){ function(data){
SearchResult = $.parseJSON(data); SearchResult = $.parseJSON(data);
$('.SearchResult').html(''); if (SearchResult != null && SearchResult != undefined) {
if (parseInt(SearchResult.Count) > 0) $('.SearchResult').html('');
for(var i = 1; i <= parseInt(SearchResult.Count); i++) { if (parseInt(SearchResult.Count) > 0)
var Name = SearchResult[i].TeacherLast + ' ' + SearchResult[i].TeacherFirst + ' ' + SearchResult[i].TeacherSecond; for(var i = 1; i <= parseInt(SearchResult.Count); i++) {
$('.SearchResult').append(AddTeacher(SearchResult[i].TeacherID, Name, 'Bind')); var Name = SearchResult[i].TeacherLast + ' ' + SearchResult[i].TeacherFirst + ' ' + SearchResult[i].TeacherSecond;
} $('.SearchResult').append(AddTeacher(SearchResult[i].TeacherID, Name, 'Bind'));
else }
$('.SearchResult').html('Нет результатов'); 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(){ $('.SelectDepartment ').change(function(){
CallSearchTeachers(); CallSearchTeachers();
}); });
......
...@@ -3,6 +3,10 @@ function isNum(v) { ...@@ -3,6 +3,10 @@ function isNum(v) {
return typeof v === 'number' && isFinite(v); return typeof v === 'number' && isFinite(v);
} }
function is_object(obj){
return (typeof obj == "object");
}
// Разрешаем вводить только цифры // Разрешаем вводить только цифры
function KeyDownOnlyNumber(event) { function KeyDownOnlyNumber(event) {
// Разрешаем: backspace, delete, tab и escape // Разрешаем: backspace, delete, tab и escape
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment