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

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