<?php

namespace WpBookingEventAdmin\app\views\eventtype;

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

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