<?php

namespace WpBookingEventAdmin\app\views\employee;

use WpBookingEvent\Html\ToolBar;
use WpBookingEvent\Mvc\Model\Model;
use WpBookingEvent\Mvc\View\View;
use WpBookingEvent\Factory as FactoryAlias;

class EmployeeView extends View
{
    public function display($tpl)
    {
        $modelEmployee = Model::getInstance("employee");
        $input = FactoryAlias::getInput();
        switch ($tpl) {
            case "list":
                ToolBar::add("employee.add");
                ToolBar::delete("employee.delete_list");
                ToolBar::_clone("employee.clone_list");
                $model = Model::getInstance("employees");
                $this->list = $model->getList();
                break;
            case "form":
                ToolBar::setTitle('Edit employee');
                ToolBar::apply("employee.apply");
                ToolBar::save("employee.save");
                ToolBar::cancel("employee.cancel");
                ToolBar::back_to_list("employee.back_to_list");
                $id = $input->getInt('id', 0);
                $this->item = $modelEmployee->getItem($id);
                $this->form = $modelEmployee->getForm();
                break;
        }
        return parent::display($tpl);
    }
}