From afdff818b79335f30482161020889fb342c24d4e Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Fri, 4 Sep 2015 18:01:27 +0300
Subject: [PATCH] Status code after uploading files

---
 .../classes/Controller/Office/Students.php            |  5 ++---
 .../application/views/office/students/upload.twig     | 11 ++++++++---
 .../application/views/office/subjects/upload.twig     |  9 ++++++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Office/Students.php b/~dev_rating/application/classes/Controller/Office/Students.php
index 1d908964f..5d42b458a 100644
--- a/~dev_rating/application/classes/Controller/Office/Students.php
+++ b/~dev_rating/application/classes/Controller/Office/Students.php
@@ -33,15 +33,14 @@ class Controller_Office_Students extends Controller_Environment_Office
         $errors = [];
 
         if (!empty($_FILES['students']) && $this->request->method() == 'POST') {
-            $facultyID = ($this->user->isAdmin()) ?
-                $_POST['facultyID'] :
-                $this->user->Faculty->ID;
+            $facultyID = $this->user->isAdmin() ? $_POST['facultyID'] : $this->user->Faculty->ID;
             $file = $_FILES['students']['tmp_name'];
             $errors = FileParser::uploadStudents($file, $facultyID);
         }
 
         $this->twig->set([
             'Errors'    => $errors,
+            'Uploaded'  => isset($file) && empty($errors),
             'Faculties' => $this->user->isAdmin() ? Model_Faculties::load() : [],
         ])->set_filename(static::OFFICE . 'students/upload');
     }
diff --git a/~dev_rating/application/views/office/students/upload.twig b/~dev_rating/application/views/office/students/upload.twig
index 6cf531f1a..ab6a57a89 100644
--- a/~dev_rating/application/views/office/students/upload.twig
+++ b/~dev_rating/application/views/office/students/upload.twig
@@ -28,10 +28,15 @@
         </div>
     </form>
     
-    {% if Errors is not empty %}
-        <script>
-            EventInspector.error('Загружено с ошибками!');
+    {% if Uploaded %}
+        <script>$(function() { 
+            EventInspector.success('Успешно загружено!');
+        });
         </script>
+    {% endif %}
+    
+    {% if Errors is not empty %}
+        <script>$(function() { EventInspector.error('Загружено с ошибками!'); });</script>
         
         {% set res %}
             {% for item in Errors %}
diff --git a/~dev_rating/application/views/office/subjects/upload.twig b/~dev_rating/application/views/office/subjects/upload.twig
index 13360d6ce..e1c36076a 100644
--- a/~dev_rating/application/views/office/subjects/upload.twig
+++ b/~dev_rating/application/views/office/subjects/upload.twig
@@ -59,9 +59,12 @@
     </form>
    
     {% if UploadingResult is not empty %}
-        <script>({{ UploadingResult.ErrorsCount }})
-            ? EventInspector.error('Загружено с ошибками!')
-            : EventInspector.success('Загружено успешно!');
+        <script>
+            $(function() {
+                 ({{ UploadingResult.ErrorsCount }})
+                    ? EventInspector.error('Загружено с ошибками!')
+                    : EventInspector.success('Загружено успешно!');
+            });
         </script>
         
         <p>
-- 
GitLab