Staff.php 1.48 KB
Newer Older
1
2
<?php
/**
3
 * gredu_labs.
4
5
 *
 * @link https://github.com/eellak/gredu_labs for the canonical source repository
6
 *
7
8
9
10
 * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
 * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
 */

11
namespace GrEduLabs\Schools\Action;
12
13
14
15
16
17
18
19
20

use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;

class Staff
{
    protected $view;

21
    public function __construct(Twig $view, $staffservice)
22
    {
kanellov's avatar
kanellov committed
23
        $this->view         = $view;
24
        $this->staffservice = $staffservice;
25
26
27
28
    }

    public function __invoke(Request $req, Response $res, array $args = [])
    {
29
        $staff = $this->staffservice->getTeachersBySchoolId(1);
kanellov's avatar
kanellov committed
30

31
        return $this->view->render($res, 'schools/staff.twig', [
kanellov's avatar
kanellov committed
32
33
34
35
36
            'staff'     => array_map(function ($employee) {
                return array_merge($employee->export(), [
                    'branch' => $employee->branch->name,
                ]);
            }, $staff),
37
38
39
40
41
            'positions' => [
                ['value' => 1, 'label' => 'Εκπαδευτικός'],
                ['value' => 2, 'label' => 'Διευθυντής σχολείου'],
                ['value' => 3, 'label' => 'Υπεύθυνος εργαστηρίου'],
            ],
kanellov's avatar
kanellov committed
42
43
44
            'branches' => array_map(function ($branch) {
                return ['value' => $branch['id'], 'label' => $branch['name']];
            }, $this->staffservice->getBranches()),
45
46
47
        ]);
    }
}