Skip to content
Snippets Groups Projects
Commit afdff818 authored by xamgore's avatar xamgore
Browse files

Status code after uploading files

parent e363594e
Branches
Tags
No related merge requests found
......@@ -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');
}
......
......@@ -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 %}
......
......@@ -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>
......
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