<?php

namespace WpBookingHotelAdmin\app\views\tool;
defined('_WPBOOKINGHOTEL_EXEC') or die;

use WpBookingHotel\Factory;
use WpBookingHotel\Html\ToolBar;
use WpBookingHotel\Mvc\Model\Model;
use WpBookingHotel\Mvc\View\View;
use WpBookingHotel\Form\Form;

class ToolView extends View
{
    /**
     * @var
     */
    public $item;
    /**
     * @var
     */
    public $sample_data_form_order;

    /**
     * @param null $tpl
     * @return false|string
     * @throws Exception
     */
    public function display($tpl = null)
    {
        if ($tpl == "list") {
            $tpl = "default";
        }
        switch ($tpl) {
            case "default":
                $tpl = 'form';
                $modelConfig = Model::getInstance('config');
                $input = Factory::getInput();
                $id = $input->getInt('id');
                $this->item = $modelConfig->getItem(1);
                $this->form = $modelConfig->getForm();
                break;
            case "create_view":
                $modelConfig = Model::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 = Model::getInstance('config');
                $this->form = $modelConfig->getFormCreateView();
                break;
        }
        return parent::display($tpl);
    }

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

