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

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