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

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