<?php

namespace WpBookingEventAdmin\app\views\states;

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

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