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

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