From fee42041a1a2c3f30dda7f99d037e09dcefb9359 Mon Sep 17 00:00:00 2001
From: Shalimov Anton <solidovic@yandex.ru>
Date: Thu, 28 Aug 2014 02:49:24 +0400
Subject: [PATCH] =?UTF-8?q?1.=20=D0=9F=D0=BE=D0=B8=D1=81=D0=BA=20=D1=81?=
 =?UTF-8?q?=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D1=82=D0=BE?=
 =?UTF-8?q?=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF=D0=BE=20=D0=A4=D0=98=D0=9E;?=
 =?UTF-8?q?=202.=20fix?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../classes/Controller/Handler/Map.php        | 17 +++++--
 .../application/classes/Model/Teacher/Map.php |  2 +-
 .../views/teacher/map/EditStudents.twig       | 20 +++++---
 .../views/teacher/map/EditTeachers.twig       |  5 +-
 ~dev_rating/media/css/base.css                |  5 ++
 ~dev_rating/media/css/construct.css           | 13 ++---
 ~dev_rating/media/js/construct/edit.js        | 48 +++++++++++++------
 7 files changed, 73 insertions(+), 37 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php
index d7b7387a5..308c6ab44 100644
--- a/~dev_rating/application/classes/Controller/Handler/Map.php
+++ b/~dev_rating/application/classes/Controller/Handler/Map.php
@@ -366,7 +366,6 @@ class Controller_Handler_Map extends Controller_Handler {
 		
 		
 		public function action_SearchStudents() {
-			$data['result'] = false;
 			$this->post -> rule('Grade', 'digit')
 						-> rule('GroupN', 'digit')
 						-> rule('FacultyID', 'digit');
@@ -379,10 +378,20 @@ class Controller_Handler_Map extends Controller_Handler {
 					$this->post->offsetGet('First'),
 					$this->post->offsetGet('Second')
 				); 
-					
-				var_dump($this->post->offsetGet($SeResult));
+				$SearchResult = array();
+				$i = 0;
+				foreach($SeResult as $row){
+					$i++;
+					$SearchResult[$i]['StudentID'] = $row['StudentID'];
+					$SearchResult[$i]['StudentLast'] = $row['StudentLast'];
+					$SearchResult[$i]['StudentFirst'] = $row['StudentFirst'];
+					$SearchResult[$i]['StudentSecond'] = $row['StudentSecond'];
+					$SearchResult[$i]['GroupGrade'] = $row['GroupGrade'];
+					$SearchResult[$i]['GroupNum'] = $row['GroupNum'];
+				}
+				$SearchResult['Count'] = $i;
 			}
-			$this->response->body(json_encode($data));
+			$this->response->body(json_encode($SearchResult));
 		}
 		
 		
diff --git a/~dev_rating/application/classes/Model/Teacher/Map.php b/~dev_rating/application/classes/Model/Teacher/Map.php
index 5d06e178b..1ae782c7d 100644
--- a/~dev_rating/application/classes/Model/Teacher/Map.php
+++ b/~dev_rating/application/classes/Model/Teacher/Map.php
@@ -206,7 +206,7 @@ class Model_Teacher_Map extends Model
         return DB::query(Database::SELECT, $sql)->execute();
     }
 	
-	public function SearchStudents($Grade, $GroupN, $FacultyID, $Last, $First, $Second = 'NULL')
+	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();
diff --git a/~dev_rating/application/views/teacher/map/EditStudents.twig b/~dev_rating/application/views/teacher/map/EditStudents.twig
index f5d635e60..4f4f8d96f 100644
--- a/~dev_rating/application/views/teacher/map/EditStudents.twig
+++ b/~dev_rating/application/views/teacher/map/EditStudents.twig
@@ -3,24 +3,32 @@
 {% block title %}Конструктор УКД{% endblock %} {# head -> title #}
 
 {% block map_content %}
-	<p class="top_center_info" style="display: none">Учебная карта дисциплины на 1 семестр 2014 года</p>
+<div class="StudentsList">
 	<input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}">
 	<div class="AttachedStudentsList">
-		<button class="SearchStudentsButton">РџРѕРёСЃРє</button>
+		<h2 class="BlueTitle">Прикрепленные студенты</h2>
 		{% set NowGroupNum = 0 %}
 		{% for Student in Students %}
 			{% if NowGroupNum != Student.GroupNum %}
 				<div>Курс {{ Student.Grade }}, Группа {{ Student.GroupNum }}</div>
 				{% set NowGroupNum = Student.GroupNum %}
 			{% endif %}
-			<div id="{{ Student.StudentID }}" class="Student {% if Student.Type == detach %}StatusBind{% else %}StatusUnbind{% endif %}">
+			<div id="{{ Student.StudentID }}" class="Student {% if Student.Type == 'detach' %}StatusUnbind{% else %}StatusBind{% endif %}">
 				<span class="Name">{{ Student.LastName }} {{ Student.FirstName }} {{ Student.SecondName }}</span>
-				{% if Student.Type == detach%}
-					<span class="action Action_UnbindStudent">Отсоединить студента</span>
-				{% else %}
+				{% if Student.Type == 'detach' %}
 					<span class="action Action_BindStudent">Прикрепить студента</span>
+				{% else %}
+					<span class="action Action_UnbindStudent">Отсоединить студента</span>
 				{% endif %}
 			</div>
 		{% endfor %}
 	</div>
+	<div class="SearchStudents">
+		<h2 class="BlueTitle">Поиск студентов</h2>
+		<div class="SearchSettings">
+			<input tupe="text" class="InputStudentName default_input_text" placeholder="Фамилия Имя Отчество" value="">
+		</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 7a72437d2..dfd9fd883 100644
--- a/~dev_rating/application/views/teacher/map/EditTeachers.twig
+++ b/~dev_rating/application/views/teacher/map/EditTeachers.twig
@@ -5,7 +5,7 @@
 {% block map_content %}
 	<div class="TeachersList">
 		<div class="BindTeachersList">
-		<h2>Прикрепленные преподаватели</h2>
+		<h2 class="BlueTitle">Прикрепленные преподаватели</h2>
 		{% for Teacher in BindTeachersList %}
 			<div class="Teacher" id="{{ Teacher.TeacherID }}">
 				<div class="Name">{{ Teacher.TeacherLast }} {{ Teacher.TeacherFirst }} {{ Teacher.TeacherSecond }}</div>
@@ -13,9 +13,8 @@
 			</div>
 		{% endfor %}
 		</div>
-		<div style="width: 2%;"></div>
 		<div class="SearchTeachers">
-			<h2>Поиск преподавателей</h2>
+			<h2 class="BlueTitle">Поиск преподавателей</h2>
 			<div class="SearchSettings">
 				<input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}">
 				<select class="SelectDepartment default_select">
diff --git a/~dev_rating/media/css/base.css b/~dev_rating/media/css/base.css
index b4552a8fb..d6cd2142d 100644
--- a/~dev_rating/media/css/base.css
+++ b/~dev_rating/media/css/base.css
@@ -199,6 +199,11 @@ p.notification{
 	text-align: center;
 	font-size: 16px;
 }
+h2.BlueTitle{
+	font-size: 18px;
+	font-weight: normal;
+	color: #3399CC;
+}
 
 
 
diff --git a/~dev_rating/media/css/construct.css b/~dev_rating/media/css/construct.css
index cbd57ed4f..710f3392d 100644
--- a/~dev_rating/media/css/construct.css
+++ b/~dev_rating/media/css/construct.css
@@ -214,17 +214,17 @@
 				color: #FF0000;
 			}
 /* Прикрипление студентов */
-.AttachedStudentsList {}
-	.AttachedStudentsList .Student {
+.StudentsList {}
+	.StudentsList .Student {
 		margin: 10px 0;
 		padding: 10px;
 	}
-		.AttachedStudentsList .Student .Name {
+		.StudentsList .Student .Name {
 			float: left;
 			font-size: 14px;
 			color: #363636;
 		}
-		.AttachedStudentsList .Student .action {
+		.StudentsList .Student .action {
 			float: right;
 			font-size: 14px;
 			cursor: pointer
@@ -238,11 +238,6 @@
 /* Прикрипление преподавателей */
 .TeachersList {
 	width: auto
-}
-.TeachersList h2{
-	font-size: 18px;
-	font-weight: normal;
-	color: #3399CC;
 }
 	.TeachersList .Teacher {
 		background: #EDF1F5;
diff --git a/~dev_rating/media/js/construct/edit.js b/~dev_rating/media/js/construct/edit.js
index b6ad9f6e3..946e4d5c8 100644
--- a/~dev_rating/media/js/construct/edit.js
+++ b/~dev_rating/media/js/construct/edit.js
@@ -454,10 +454,10 @@ $(function() {
 var FacultyID = $('.HiddenInputFacultyID').val(); // Факультет, к которой привязана дисциплина
 $('.HiddenInputFacultyID').remove(); // Тут даже Шерлок Холмс бессилен
 
-function BindGroup(id){
+function BindGroup(id, StudyGroupName){
 	return '\
 	<div class="AttachedGroup" id="'+ id +'">\
-		Курс - , Группа - \
+		<div class="StudyGroupInfo">'+ StudyGroupName +'</div>\
 		<div class="UnbindGroup">Отсоединить группу</div>\
 	</div>';
 }
@@ -465,6 +465,7 @@ function BindGroup(id){
 // Прикрепить группу
 $('.AttachGroupButton').click(function(){
 	var StudyGroupID = $('.SelectStudyGroup').val();
+	var StudyGroupName = $(".SelectStudyGroup option:selected").text();
 	$.post(
 		'/~dev_rating/handler/map/BindGroup',
 		{
@@ -478,7 +479,7 @@ $('.AttachGroupButton').click(function(){
 			else EventInspector_ShowMsg('Error, BindGroup', 'error');
 		}
 	);
-	$('.AttachedGroupsList').append(BindGroup(StudyGroupID));
+	$('.AttachedGroupsList').append(BindGroup(StudyGroupID, StudyGroupName));
 });
 
 // Отсоединить группу
@@ -503,25 +504,44 @@ $('.AttachedGroupsList').on('click', '.UnbindGroup', function(){
 });
 
 // Поиск студентов
-$('.SearchStudentsButton').click(function(){
+function AddStudent(ID, Name, From){
+return '\
+	<div id="'+ ID +'" class="Student StatusUnbind">\
+		<span class="Name">'+ Name +', '+ From +'</span>\
+		<span class="action Action_BindStudent">Прикрепить студента</span>\
+	</div>';
+}
+$('.InputStudentName').focusout(function(){
+	var Name = [];
+	Name = ($('.InputStudentName ').val()).split(' ');
 	$.post(
 		'/~dev_rating/handler/map/SearchStudents',
 		{
-			'Grade': '',
-			'GroupN': '',
-			'FacultyID': '',
-			'Last': 'Иванов',
-			'First': 'Ив',
-			'Second': 'h'
+			'Grade': 0, //$('.SelectDepartment').val(),
+			'GroupN': 0,
+			'FacultyID': FacultyID,
+			'Last': Name[0],
+			'First': Name[1],
+			'Second': Name[2]
 		},
-		function(date){
-			
+		function(data){
+			SearchResult = $.parseJSON(data);
+			$('.SearchResult').html('');
+			if (parseInt(SearchResult.Count) > 0)
+				for(var i = 1; i <= parseInt(SearchResult.Count); i++) {
+					var ID = SearchResult[i].StudentID;
+					var Name = SearchResult[i].StudentLast +' '+  SearchResult[i].StudentFirst +' '+ SearchResult[i].StudentSecond;
+					var From = 'Курс ' + SearchResult[i].GroupGrade + ', Группа ' + SearchResult[i].GroupNum;
+					$('.SearchResult').append(AddStudent(ID, Name, From));
+				}
+			else
+				$('.SearchResult').html('Нет результатов');
 		}
 	);
 });
 
 // Прикрепить студента 
-$('.AttachedStudentsList').on('click', '.Action_BindStudent', function(){
+$('.StudentsList').on('click', '.Action_BindStudent', function(){
 	$(this)
 		.removeClass('Action_BindStudent')
 		.addClass('Action_UnbindStudent')
@@ -547,7 +567,7 @@ $('.AttachedStudentsList').on('click', '.Action_BindStudent', function(){
 });
 
 // Отсоединить студента 
-$('.AttachedStudentsList').on('click', '.Action_UnbindStudent', function(){
+$('.StudentsList').on('click', '.Action_UnbindStudent', function(){
 	$(this)
 		.removeClass('Action_UnbindStudent')
 		.addClass('Action_BindStudent')
-- 
GitLab