<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_CountryView")) {
    /**
     * Class WpBookingPro_CountryView
     */
    class WpBookingPro_CountryView extends WooBookingView
    {
        /**
         * @var
         */
        public $item;
        /**
         * @var
         */
        public $state;

        /**
         * @param null $tpl
         * @return false|string
         * @throws Exception
         */
        public function display($tpl = null)
        {
            $modelCountry = $this->getModel('country');
            $input = Factory::getInput();
            switch ($tpl) {
                case "item":
                    $id = 2;
                    $this->item = $modelCountry->getItem($id);
                    $this->form = $modelCountry->getForm();
                    break;
                case "form":
                    $id = $input->getInt('id', 0);
                    $this->item = $modelCountry->getItem($id);
                    $this->form = $modelCountry->getForm();
                    break;
                case "list":
                default:
                    $modelCountries = $this->getModel('countries');
                    $this->filterForm = $modelCountries->getFilterForm();
                    $this->list = $modelCountries->getList();
                    $this->state = $modelCountries->getState();
                    break;
            }
            return parent::display($tpl);
        }
    }
}