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

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