From 212217822fb90f637ab555b0d4088fa84cff7166 Mon Sep 17 00:00:00 2001
From: PavelBegunkov <asml.silence@gmail.com>
Date: Fri, 4 Sep 2015 12:30:29 +0300
Subject: [PATCH] Students upload fix

---
 .../classes/Controller/Office/Students.php            |  4 +++-
 .../application/views/office/students/upload.twig     | 11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/~dev_rating/application/classes/Controller/Office/Students.php b/~dev_rating/application/classes/Controller/Office/Students.php
index 2c1c45c34..9b14c4b1a 100644
--- a/~dev_rating/application/classes/Controller/Office/Students.php
+++ b/~dev_rating/application/classes/Controller/Office/Students.php
@@ -33,7 +33,9 @@ class Controller_Office_Students extends Controller_Environment_Office
         $errors = [];
 
         if (!empty($_FILES['students']) && $this->request->method() == 'POST') {
-            $facultyID = User::instance()->Faculty->ID;
+            $facultyID = ($this->user->isAdmin()) ?
+                $_POST['facultyID'] :
+                $this->user->Faculty->ID;
             $file = $_FILES['students']['tmp_name'];
             $errors = FileParser::uploadStudents($file, $facultyID);
         }
diff --git a/~dev_rating/application/views/office/students/upload.twig b/~dev_rating/application/views/office/students/upload.twig
index 7e42c3f7b..83b12c468 100644
--- a/~dev_rating/application/views/office/students/upload.twig
+++ b/~dev_rating/application/views/office/students/upload.twig
@@ -19,6 +19,17 @@
     <p><pre>ФИО;Курс;Группа;Уровень подготовки;Специальность</pre></p>
     <p>Уровень подготовки - одно из следующих значений: Бакалавр, Специалист, Магистр</p>
     <form enctype="multipart/form-data" action="" method="POST">
+        {% if User.isAdmin %}
+            <div class="goodClearFix defaultForm marginBetween">
+                <select id="facultySelect" name="facultyID" class="defaultForm">
+                    <option value="0" selected="selected">— Выберите подразделение ЮФУ —</option>
+                    {% for row in Faculties %}
+                        <option value="{{ row.ID }}">{{ row.Name }} ({{ row.Abbr }})</option>
+                    {% endfor %}
+                </select>
+            </div>
+        {% endif %}
+
         <div class="goodClearFix">
             <div class="defaultForm FLeft"><input name="students" class="defaultForm FullWidth" type="file"></div>
             <div class="defaultForm FRight"><input type="submit" class="defaultForm GreenButton P2Width noMargin" value="Загрузить"></div>
-- 
GitLab