<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_LocationController")) {
    /**
     * Class WpBookingPro_LocationController
     */
    class WpBookingPro_LocationController extends woobooking_controller
    {
        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_get_item()
        {
            return self::view("location.form");
        }
        public function ajax_save($data_post = null)
        {
            $input = Factory::getInput();
            $locationModel = WoobookingModel::getInstance('location');
            if (!$data_post) {
                $data_post = $input->getData()['data'];
            }
            $location = $locationModel->save($data_post); // TODO: Change the autogenerated stub
            return $location;
        }

        /**
         * @return bool
         * @throws Exception
         */
        public function ajax_delete()
        {
            $locationModel = WoobookingModel::getInstance('location');
            $input = Factory::getInput();
            $list_delete_location_id = $input->get('list_delete_location_id', array(), 'array');
            foreach ($list_delete_location_id as $location_id) {
                $locationModel->delete($location_id);
            }
            return true;
        }
    }
}
?>