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

        /**
         * @param null $tpl
         * @return false|string
         * @throws Exception
         */
        public function display($tpl = null)
        {
            $modelAppointment = $this->getModel('appointment');
            $input = Factory::getInput();
            switch ($tpl) {
                case "item":
                    break;
                case "form":
                    $id = $input->getInt('id');
                    $this->item = $modelAppointment->getItem(1);
                    $this->form = $modelAppointment->getForm();
                    break;
                case "order_detail":
                    $id = $input->getInt('id');
                    $modelOderDetail = WoobookingModel::getInstance('OrderDetail');
                    $this->item = $modelOderDetail->getItem($id);
                    $this->form = $modelOderDetail->getForm();
                    break;
                case "list":
                default:
                    $tpl = "list";
                    $modelOrderStatus = $this->getModel('orderStatus');
                    $this->list_order_status = $modelOrderStatus->getList();
                    $this->list = $modelAppointment->getList();
                    break;
            }
            return parent::display($tpl);
        }
    }
}