<?php
defined('_WPBOOKINGPRO_EXEC') or die;
use WooBooking\CMS\Form\Form;
if(!class_exists("WpBookingPro_toolView")) {
    /**
     * Class WpBookingPro_toolView
     */
    class WpBookingPro_toolView extends WooBookingView
    {
        /**
         * @var
         */
        public $item;
        /**
         * @var
         */
        public $sample_data_form_order;

        /**
         * @param null $tpl
         * @return false|string
         * @throws Exception
         */
        public function display($tpl = null)
        {
            switch ($tpl) {
                case "list":
                    $tpl = 'form';
                    $modelConfig = WoobookingModel::getInstance('config');
                    $input = Factory::getInput();
                    $id = $input->getInt('id');
                    $this->item = $modelConfig->getItem(1);
                    $this->form = $modelConfig->getForm();
                    break;
                case "create_view":
                    $modelConfig = WoobookingModel::getInstance('config');
                    $this->form = $modelConfig->getFormCreateView();
                    break;
                case "list_page_front_end":
                    break;

                case "create_sample_data":
                    break;
                case "create_sample_data_order":
                    $this->sample_data_form_order = $this->getFromOrder();
                    break;
                case "setup_view":
                    $modelConfig = WoobookingModel::getInstance('config');
                    $this->form = $modelConfig->getFormCreateView();
                    break;
            }
            return parent::display($tpl);
        }

        /**
         * @return Form
         */
        private function getFromOrder()
        {
            $paths = Form::addFormPath(WPBOOKINGPRO_PATH_COMPONENT . "/views/tool/forms");
            $form = Form::getInstance("create_order");
            return $form;
        }
    }
}
