Skip to content
Snippets Groups Projects
Commit 555a4582 authored by Andrew Rudenets's avatar Andrew Rudenets
Browse files

Now displays all search results

parent 7f145cea
Branches
Tags
No related merge requests found
......@@ -3,6 +3,7 @@ function cSearch() {
this._jSearchResultContainer = $('.SearchResult');
this._jTemplateContainer = $("#resultPrototype");
this._jSearchButton = $(".searchBtn");
this._jNotFound = $(".SearchNotFound");
this._Template = this._jTemplateContainer.html();
this.Handler = "";
......@@ -14,10 +15,17 @@ function cSearch() {
// Get data from server
this.Load = function (Handler, Data) {
self._jNotFound.css("display", "none");
self._jSearchResultContainer.css("display", "none");
$.post(Handler, Data, function (response) {
self._jSearchResultContainer.html("");
$.each(response, function(i) {
if(i > 10) return;
if(response.length == 0)
{
self._jNotFound.css("display", "block");
return;
}
self._jSearchResultContainer.css("display", "block");
$.each(response, function (i) {
self._jSearchResultContainer.append(
Mustache.render(self._Template, response[i])
);
......@@ -32,16 +40,17 @@ function cSearch() {
self.Handler = Handler;
};
this._EventsLinker = function()
{
this._EventsLinker = function () {
// Привязываем кнопку поиска
self._jSearchButton.click(self.Search());
self.EventsLinker();
};
// Should be implemented by child classes
this.Search = function () {};
this.EventsLinker = function () {};
this.Search = function () {
};
this.EventsLinker = function () {
};
}
function SearchStudent(jName, jFacultySelect, jGradeSelect, jGroupSelect) {
......@@ -60,11 +69,31 @@ function SearchStudent(jName, jFacultySelect, jGradeSelect, jGroupSelect) {
self.Load(self.Handler, Request);
};
this.EventsLinker = function() {
jName.change(this.Search);
jFacultySelect.change(this.Search);
jGradeSelect.change(this.Search);
jGroupSelect.change(this.Search);
this.EventsLinker = function () {
jName.change(self.Search);
jFacultySelect.change(function (){
jGradeSelect.find('option[value=0]').attr("selected", "selected");
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>');
self.Search();
});
jGradeSelect.change(function () {
self.Search();
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>');
$.post(URLdir + 'handler/map/getGroups',
{
FacultyID: jFacultySelect.find('option:selected').val(),
GradeID: jGradeSelect.find('option:selected').val()
},
function (response) {
jGroupSelect.removeAttr("disabled");
$.each(response, function (i) {
var option = Mustache.render("<option value='{{ ID }}'>{{ GroupNum }} группа ({{ SpecName }})</option>", response[i]);
jGroupSelect.append(option);
});
},
"json");
});
jGroupSelect.change(self.Search);
}
}
......@@ -83,9 +112,25 @@ function SearchTeacher(jName, jFacultySelect, jDepartmentSelect) {
self.Load(self.Handler, Request);
};
this.EventsLinker = function() {
this.EventsLinker = function () {
jName.change(this.Search);
jFacultySelect.change(this.Search);
jFacultySelect.change(function () {
self.Search();
jDepartmentSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по кафедре --</option>');
$.post(URLdir + 'handler/map/getDepartments',
{
FacultyID: jFacultySelect.find('option:selected').val()
},
function (response) {
jDepartmentSelect.removeAttr("disabled");
$.each(response, function (i) {
var option = Mustache.render("<option value='{{ ID }}'>{{ Name }}</option>", response[i]);
console.log(option);
jDepartmentSelect.append(option);
});
},
"json");
});
jDepartmentSelect.change(this.Search);
}
}
......@@ -2,6 +2,13 @@
display: block;
}
.SearchResult {
height: 600px;
padding-right: 10px;
overflow-y: scroll;
overflow-x: hidden;
}
.SearchSettings {
background: #f4f4f4;
margin: 10px 0;
......@@ -47,3 +54,12 @@
padding: 7px 10px;
box-shadow: 2px 2px 2px #DDE8F0;
}
.SearchNotFound
{
text-align: center;
padding: 10px;
font-size: 1.3em;
font-weight: bold;
display: none;
}
\ No newline at end of file
......@@ -6,27 +6,27 @@ class Controller_Handler_Search extends Controller_Handler
parent::before();
}
public function action_getTeachersByName() {
$facultyID = (int) $this->post['FacultyID'];
$facultyID = (int) ($this->post['FacultyID'] ? $this->post['FacultyID'] : $this->user->FacultyID);
$departmentID = (int) $this->post['DepartmentID'];
$name = $this->post['Name'];
$arr = [];
if (strlen($name) >= 3) {
$arr = Model_Teachers::search($name, $facultyID, $departmentID, 0);
}
// if (strlen($name) >= 3) {
$arr = Model_Teachers::search($facultyID, $departmentID, $name, 0);
// }
$this->response->body(json_encode($arr));
}
public function action_getStudentsByName() {
$facultyID = (int) $this->post['FacultyID'];
$facultyID = (int) ($this->post['FacultyID'] ? $this->post['FacultyID'] : $this->user->FacultyID);
$gradeID = (int) $this->post['GradeID'];
$groupID = (int) $this->post['GroupID'];
$name = $this->post['Name'];
$arr = [];
if (strlen($name) >= 3) {
// if (strlen($name) >= 3) {
$arr = Model_Students::searchStudentsByName($name, $facultyID, $gradeID, $groupID);
}
// }
$this->response->body(json_encode($arr));
}
}
......@@ -66,5 +66,8 @@
</div>
</div>
</div>
<div class="SearchNotFound">
Нет результатов
</div>
</div>
{% endmacro %}
......@@ -53,5 +53,8 @@
</div>
</div>
</div>
<div class="SearchNotFound">
Нет результатов
</div>
</div>
{% endmacro %}
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