<?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)
        {
            $modelEvent = $this->getModel('finance');
            $input = Factory::getInput();
            switch ($tpl) {
                case "item":
                    $id = 2;
                    $this->item = $modelEvent->getItem($id);
                    $this->form = $modelEvent->getForm();
                    break;
                case "form":
                    $id = $input->getInt('id', 0);
                    $this->item = $modelEvent->getItem($id);
                    $this->form = $modelEvent->getForm();
                    break;
                case "list":
                default:
                    $modelEvents = $this->getModel('finances');
                    $this->list = $modelEvent->getList();
                    $this->filterForm = $modelEvents->getFilterForm();
                    break;
            }
            return parent::display($tpl);
        }
    }
}