<?php

namespace TourOperatorProAdmin\app\views\currencies;

use TourOperatorPro\Html\ToolBar;
use TourOperatorPro\Mvc\Model\Model;
use TourOperatorPro\Mvc\View\View;
use TourOperatorPro\Factory as FactoryAlias;
use TourOperatorProAdmin\app\helpers\CurrencyHelper;

class CurrenciesView extends View
{
    public function display($tpl)
    {
        $modelCurrency = Model::getInstance("currency");
        $input = FactoryAlias::getInput();
        switch ($tpl) {
            case "list":
                ToolBar::add("currency.add");
                ToolBar::delete("currency.delete_list");
                ToolBar::_clone("currency.clone_list");
                $model = Model::getInstance("currencies");
                $this->list = $model->getList();
                $this->list_currencies_api = CurrencyHelper::getRatesCurrenciesbyAPI();
                break;
            case "form":
                ToolBar::setTitle('Edit Currency');
                ToolBar::apply("currency.apply");
                ToolBar::save("currency.save");
                ToolBar::cancel("currency.cancel");
                ToolBar::back_to_list("currency.back_to_list");
                $id = $input->getInt('id', 0);
                $this->item = $modelCurrency->getItem($id);
                $this->form = $modelCurrency->getForm();

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