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

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