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

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