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

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