<?php

namespace TourOperatorProAdmin\app\views\discount;

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

class DiscountView extends View
{
    public function display($tpl)
    {

        $modelDiscount = Model::getInstance("discount");
        $input = FactoryAlias::getInput();
        switch ($tpl) {
            case "list":
                ToolBar::add("discount.add");
                ToolBar::delete("discount.delete_list");
                ToolBar::_clone("discount.clone_list");
                $model = Model::getInstance("discounts");
                $this->list = $model->getList();
                break;
            case "form":
                ToolBar::setTitle('Edit discount');
                ToolBar::apply("discount.apply");
                ToolBar::save("discount.save");
                ToolBar::cancel("discount.cancel");
                ToolBar::back_to_list("discount.back_to_list");
                $id = $input->getInt('id', 0);
                $this->item = $modelDiscount->getItem($id);
                $this->form = $modelDiscount->getForm();

                break;
        }
        return parent::display($tpl);
    }
}