<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_RateController")) {
    /**
     * Class WpBookingPro_RateController
     */
    class WpBookingPro_RateController extends woobooking_controller
    {
        /**
         * @var string
         */
        public $view = "rate";

        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_add_new_event()
        {
            //TODO check permission add new
            return self::view("event.form");
        }

        /**
         * @param null $data_post
         * @return array|bool|mixed
         */
        public function ajax_save($data_post = null)
        {
            $input = Factory::getInput();
            if (!$data_post) {
                $data_post = $input->getData();
            }
            $rate = parent::save($data_post);
            return $rate;
        }

        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_get_rang_time_avail()
        {
            $data = json_decode(file_get_contents('php://input'));
            $date = $data->date;
            $event_id = $data->event_id;
            $event_model = $this->getModel('event');
            $list_date = $event_model->get_rang_time_avail($event_id, $date);
            return $list_date;
        }
    }
}
?>