<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_EventView")) {
    /**
     * Class WpBookingPro_EventView
     */
    class WpBookingPro_EventView extends WooBookingView
    {
        /**
         * @var
         */
        public $list;
        /**
         * @var
         */
        public $filterForm;
        /**
         * @var
         */
        public $pagination;

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