<?php

namespace WpBookingProAdmin\app\views\review;

use WpBookingPro\Html\ToolBar;
use WpBookingPro\Mvc\Model\Model;
use WpBookingPro\Mvc\View\View;
use WpBookingPro\Factory as FactoryAlias;
use WpBookingProAdmin\app\helpers\AdminHelper;

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();
                $modelVendors = Model::getInstance('vendors');
                $this->list_vendor = $modelVendors->getListVendor();
                $this->permission = AdminHelper::setPermission();
                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);
    }
}