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

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