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

        /**
         * @param null $tpl
         * @return false|string
         * @throws Exception
         */
        public function display($tpl = null)
        {
            $modelEvent = $this->getModel('booking');
            $input = Factory::getInput();
            switch ($tpl) {
                case "training":
                    $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 = $this->getModel('events');
                    $this->filterForm = $modelEvents->getFilterForm();
                    $this->list = $modelEvent->getList();
                    break;
            }
            return parent::display($tpl);
        }
    }
}