<?php

namespace WpBookingEventAdmin\app\views\category;

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

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