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

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