<?php

namespace WpBookingProAdmin\app\views\tool;
defined('_WPBOOKINGPRO_EXEC') or die;

use WpBookingPro\Factory;
use WpBookingPro\Html\ToolBar;
use WpBookingPro\Mvc\Model\Model;
use WpBookingPro\Mvc\View\View;
use WpBookingPro\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(WPBOOKINGPRO_PLUGIN_DIR_URL . "/views/tool/forms");
        $form = Form::getInstance("create_order");
        return $form;
    }
}

