Skip to content
Snippets Groups Projects
Forked from it-lab / grade
Source project has a limited visibility.
Students.php 1.59 KiB
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Admin_Students extends Controller_UserEnvi {

    public function action_index()
    {
        // VIEW
        $twig = Twig::factory('admin/students/index');
        $twig->Faculties = Model_Faculties::factory()->common()->asArray();
        $twig->Grades = Model_Grades::factory()->structured()->asArray();
        $twig->User = $this->UserInfo;
        $this->response->body($twig);        
    }
    
    public function action_add()
    {
        $twig = Twig::factory('admin/students/add');
        $twig->Faculties = Model_Faculties::factory()->common()->asArray();
        $twig->Grades = Model_Grades::factory()->structured()->asArray();
        $twig->User = $this->UserInfo;
        $this->response->body($twig);
    }
    
    public function action_upload()
    {
        if(!empty($_FILES['students']) AND $this->request->method() == 'POST')
        {
            $result = $this->parseFile($_FILES["students"]["tmp_name"]);
        }
        // VIEW
        $twig = Twig::factory('admin/students/upload');
        $twig->Faculties = Model_Faculties::factory()->common()->asArray();
        $twig->UploadingResult = $result;
        $twig->User = $this->UserInfo;
        $this->response->body($twig);
    }

    public function action_edit()
    {
        $twig = Twig::factory('admin/students/edit');    
        $twig->User = $this->UserInfo;
        $this->response->body($twig);
    }
    
    protected function parseFile($filename)
    {
        return FileParser::StudentsList($filename, $_POST['facultyID']);
    }
}