Skip to content
Snippets Groups Projects
Commit 00953df4 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

Third Circle (Gluttony)

parent 814bf8fc
Branches
Tags
No related merge requests found
......@@ -462,7 +462,7 @@ class Controller_Handler_Map extends Controller_Handler {
// Поиск студентов
public function action_SearchStudents() {
$this->post -> rule('GradeID', 'digit')
-> rule('GroupN', 'digit')
-> rule('GroupID', 'digit')
-> rule('FacultyID', 'digit')
-> rule('DisciplineID', 'not_empty')
-> rule('DisciplineID', 'digit');
......@@ -470,11 +470,9 @@ class Controller_Handler_Map extends Controller_Handler {
$SearchResult = DataArray::factory('Students')
->NotAttendingDiscipline(
$this->post->offsetGet('GradeID'),
$this->post->offsetGet('GroupN'),
$this->post->offsetGet('GroupID'),
$this->post->offsetGet('FacultyID'),
$this->post->offsetGet('Last'),
$this->post->offsetGet('First'),
$this->post->offsetGet('Second'),
$this->post->offsetGet('Name'),
$this->post->offsetGet('DisciplineID')
)->asJSON();
}
......
......@@ -57,11 +57,11 @@ class DataArr_Students {
foreach($students as $row)
{
$i++;
$studentsHandled[$i]['ID'] = $row['StudentID'];
$studentsHandled[$i]['AccountID'] = $row['StudentAccID'];
$studentsHandled[$i]['LastName'] = $row['LastName'];
$studentsHandled[$i]['FirstName'] = $row['FirstName'];
$studentsHandled[$i]['SecondName'] = $row['SecondName'];
$studentsHandled[$i]['ID'] = $row['ID'];
$studentsHandled[$i]['AccountID'] = $row['ID'];
$studentsHandled[$i]['LastName'] = $row['Last'];
$studentsHandled[$i]['FirstName'] = $row['First'];
$studentsHandled[$i]['SecondName'] = $row['Second'];
$studentsHandled[$i]['GroupID'] = $row['GroupID'];
$studentsHandled[$i]['GroupNum'] = $row['GroupNum'];
$studentsHandled[$i]['GradeID'] = $row['GradeID']; // ID курса
......@@ -72,9 +72,9 @@ class DataArr_Students {
return $studentsHandled;
}
public function NotAttendingDiscipline($GradeID, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID)
public function NotAttendingDiscipline($GradeID, $GroupID, $FacultyID, $Name, $DisciplineID)
{
$students = $this->model->getStudentsNotAttendingDiscipline($GradeID, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID);
$students = $this->model->SearchStudents($GradeID, $GroupID, $FacultyID, $Name, $DisciplineID);
return new DataArray_Result($this->generateArray($students));
}
}
......@@ -27,21 +27,21 @@ class Model_DataArr_Students extends Model
}
public function searchStudents($Grade, $GroupN, $FacultyID, $Last, $First, $Second)
{
$sql = "CALL `SearchStudents`('$Grade', '$GroupN', '$FacultyID', '$Last', '$First', '$Second'); ";
return DB::query(Database::SELECT, $sql)->execute();
}
// public function searchStudents($Grade, $GroupN, $FacultyID, $Last, $First, $Second)
// {
// $sql = "CALL `SearchStudents`('$Grade', '$GroupN', '$FacultyID', '$Last', '$First', '$Second'); ";
// return DB::query(Database::SELECT, $sql)->execute();
// }
public function searchStudentsNew($Grade, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID)
{
$sql = "CALL `SearchStudentsNew`('$Grade', '$GroupN', '$FacultyID', '$Last', '$First', '$Second', '$DisciplineID'); ";
return DB::query(Database::SELECT, $sql)->execute();
}
// public function searchStudentsNew($Grade, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID)
// {
// $sql = "CALL `SearchStudentsNew`('$Grade', '$GroupN', '$FacultyID', '$Last', '$First', '$Second', '$DisciplineID'); ";
// return DB::query(Database::SELECT, $sql)->execute();
// }
public function getStudentsNotAttendingDiscipline($Grade, $Group, $FacultyID, $Last, $First, $Second, $DisciplineID)
public function SearchStudents($GradeID, $GroupID, $FacultyID, $Name, $DisciplineID)
{
$sql = "CALL `getStudentsNotAttendingDiscipline`('$Grade', '$Group', '$FacultyID', '$Last', '$First', '$Second', '$DisciplineID'); ";
$sql = "CALL `SearchStudents`('$GradeID', '$GroupID', '$FacultyID', '$Name', '$DisciplineID'); ";
return DB::query(Database::SELECT, $sql)->execute();
}
}
......@@ -49,11 +49,11 @@
<div class="AttachedStudentsList">
<h2 class="BlueTitle">Еще студенты</h2>
{% for group in GroupsAttached %}
<div class="GroupContainerAttached">
<div class="GroupContainerAttached" id="{{ group.GroupID }}">
<div class="groupInfo">к. {{ group.GradeNum }}<br>г. {{ group.GroupNum }}</div>
{% for student in group.students %}
{{ idx.outputStudent(student) }}
{% endfor %}
{% endfor %}
</div>
{% endfor %}
</div>
......
......@@ -10,6 +10,7 @@ $(function() {
var jGradeSelect = $(".SelectGrade").first();
var jSGSelect = $(".SelectStudyGroup").first();
var jSearchResult = $(".SearchResult").first();
var jStList = $("div.AttachedStudentsList");
var jStudentPrototype = $($.parseHTML( "<div id='0' class='Student'>\
<span class='Name'></span> \
......@@ -17,12 +18,21 @@ $(function() {
<button class='action'></button> \
</div>"));
var jStudentEmptyPrototype = $($.parseHTML(
"<p class='notification'>Нет результатов... Возможно, студенты, соответствующие критериям поиска, уже прикреплены.</p>"));
var jGroupWrapPrototype = $($.parseHTML( "<select class='SelectStudyGroup default_select'>\
<option value='0'>Выберите группу:</option>"));
var jGroupPrototype = $($.parseHTML("<option value='0'></option>"));
var jGroupContainerPrototype = $($.parseHTML( "<div class='GroupContainerAttached' id='0'>\
<div class='groupInfo'></div>\
</div>"));
function ConstructGroup(groupID, groupNum, specName) {
var jClone = jGroupPrototype.clone();
......@@ -35,7 +45,7 @@ $(function() {
return jClone;
}
function ConstructStudent(ID, name, from, groupID, bind) {
function ConstructStudent(ID, name, bind) {
var jStudent = jStudentPrototype.clone();
var jStudentSib = jStudent.children();
......@@ -50,33 +60,35 @@ $(function() {
}
jStudent.attr("id", ID);
jStudent.addClass(status+" "+groupID);
jStudent.addClass(status);
jStudentSib.filter("span.Name").html(name);
jStudentSib.filter("span.From").attr("id",groupID).html(from);
jStudentSib.filter("button.action").addClass(action).html(actionDesc);
return jStudent;
}
function ConstructGroupContainer(GroupID, Group, Grade) {
var jClone = jGroupContainerPrototype.clone();
var text = "к. "+Grade+"<br>г. "+Group;
jClone.attr("id", GroupID);
jClone.children().html(text);
return jClone;
}
function SearchStudents()
{
var name = [];
var temp = $(".InputStudentName").val();
if ( temp.length > 0)
name = temp.split(" ");
$.post(
g_URLdir + "handler/map/SearchStudents",
{
"GradeID": jGradeSelect.val(),
"GroupN": jSGSelect.val(),
"GroupID": jSGSelect.val(),
"FacultyID": g_facultyID,
"Last": name[0],
"First": name[1],
"Second": name[2],
"Name": temp,
"DisciplineID": g_disciplineID
},
function(searchResult){
......@@ -84,17 +96,26 @@ $(function() {
var i = 0;
jSearchResult.html("");
var jClone = jSearchResult.clone();
for(i in searchResult) {
var ID = searchResult[i].ID;
var name = searchResult[i].LastName +" "+ searchResult[i].FirstName +" "+ searchResult[i].SecondName;
var from = "курс " + searchResult[i].GradeNum + ", группа " + searchResult[i].GroupNum;
var groupID = searchResult[i].GroupID;
jClone.append(ConstructStudent(ID, name, from, groupID, false));
var curGroupID = 0;
for (i in searchResult) {
var student = searchResult[i];
if (student.GroupID != curGroupID) {
var groupID = student.GroupID;
var groupNum = student.GroupNum;
var gradeNum = student.GradeNum;
var jCurGroup = ConstructGroupContainer(groupID, groupNum, gradeNum);
curGroupID = groupID;
jClone.append(jCurGroup);
}
var ID = student.ID;
var name = student.LastName +" "+ student.FirstName +" "+ student.SecondName;
var jTempStudent = ConstructStudent(ID, name, false);
jCurGroup.append(jTempStudent);
}
if (i <= 0) {
jSearchResult.html("<p class='notification'>Нет результатов... Возможно, студенты, соответствующие критериям поиска, уже прикреплены.</p>");
jSearchResult.append(jStudentEmptyPrototype.clone());
} else {
jSearchResult.replaceWith(jClone);
jSearchResult = jClone;
......@@ -157,21 +178,53 @@ $(function() {
// Если студент из поиска
function BindStudentFromSearch(jThis)
{
var reg = /GroupID_\d+/;
var GroupID = ""+reg.exec(jThis.parent().attr("class"));
var ID = jThis.parent().attr("id");
var Name = jThis.siblings(".Name").text();
var From = jThis.siblings(".From").text();
if ($("div").is(".GroupContainer."+GroupID) === false) {
$(".AttachedStudentsList").append("\
<div class='GradeAndGroupTitle ActionShowHideGroupContainer'>\
<span class='info'>"+From+"</span>\
<span class='Action'>Открыть список ▼</span>\
</div>");
$(".AttachedStudentsList").append("<div class='GroupContainer "+GroupID+"' style='display: block'> </div>");
var jThis = jThis.parent();
var jParent = jThis.parent();
var groupID = jParent.attr("id");
var jGroup = jStList.children("#"+groupID);
if (jGroup.length <= 0) {
jGroup = jGroupContainerPrototype.clone();
jGroup.attr("id", groupID);
var text = jParent.children().first().html();
jGroup.children().html(text);
jStList.append(jGroup);
}
console.log(jGroup.html());
var len = jParent.children().length;
if (len <= 1) {
jParent.remove();
} else {
jParent.css("height", jParent.height() - 40);
}
$(".GroupContainer."+GroupID).append(ConstructStudent(ID, Name, From, GroupID, true));
jThis.parent().remove();
jThis.removeClass()
.addClass("Student StatusBind");
var but = jThis.children("button.action");
but.removeClass()
.addClass("action Action_UnbindStudent")
.html("Отсоединить студента");
jGroup.append(jThis);
jGroup.css("height", jGroup.height()+40);
// var reg = /GroupID_\d+/;
// var GroupID = ""+reg.exec(jThis.parent().attr("class"));
// var ID = jThis.parent().attr("id");
// var Name = jThis.siblings(".Name").text();
// var From = jThis.siblings(".From").text();
// if ($("div").is(".GroupContainer."+GroupID) === false) {
// $(".AttachedStudentsList").append("\
// <div class='GradeAndGroupTitle ActionShowHideGroupContainer'>\
// <span class='info'>"+From+"</span>\
// <span class='Action'>Открыть список ▼</span>\
// </div>");
// $(".AttachedStudentsList").append("<div class='GroupContainer "+GroupID+"' style='display: block'> </div>");
// }
// $(".GroupContainer."+GroupID).append(ConstructStudent(ID, Name, From, GroupID, true));
// jThis.parent().remove();
}
// Если студент из основного потока
......@@ -191,7 +244,7 @@ $(function() {
// Прикрепить студента
$(".StudentsList").on("click", "button.Action_BindStudent", function(){
$(".GeneralStudentsList").on("click", "button.Action_BindStudent", function(){
var jThis = $(this);
$(this).attr("disabled", true);
var ID = $(this).parent().attr("id");
......@@ -213,7 +266,7 @@ $(function() {
});
// Прикрепить студента из поиска
$(".StudentsList").on("click", "button.Action_BindStudentFromSearch", function(){
$(".StudentsList").on("click", "button.Action_BindStudent", function(){
var jThis = $(this);
$(this).attr("disabled", true);
var ID = $(this).parent().attr("id");
......@@ -236,7 +289,7 @@ $(function() {
});
// Отсоединить студента
$(".StudentsList").on("click", "button.Action_UnbindStudent", function(){
$(".GeneralStudentsList").on("click", "button.Action_UnbindStudent", function(){
var jThis = $(this);
$(this).attr("disabled", true);
var ID = $(this).parent().attr("id");
......@@ -265,6 +318,37 @@ $(function() {
);
});
$(".AttachedStudentsList").on("click", "button.Action_UnbindStudent", function(){
var jThis = $(this);
$(this).attr("disabled", true);
var ID = $(this).parent().attr("id");
$.post(
URLdir + "handler/map/UnbindStudent",
{
"StudentID": ID,
"DisciplineID": g_disciplineID
},
function(data){
data = $.parseJSON(data);
if(data.success === true) {
var jParent = jThis.parent().parent();
jThis.parent().remove();
var len = jParent.children().length;
if (len <= 1) {
jParent.remove();
} else {
jParent.css("height", jParent.height() - 40);
}
EventInspector_ShowMsg("Студент отсоединен", "success");
}
else EventInspector_ShowMsg("Ошибка при отсоединение студента", "error");
jThis.removeAttr("disabled");
}
);
});
// Показать/скрыть список студентов
$(".StudentsList").on("click", ".ActionShowHideGroupContainer", function(){
var GroupContainer = $(this).next(".GroupContainer");
......
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