<?php

namespace WpBookingEventAdmin\app\views\review;

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

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