<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_wbcustomerController")) {
    /**
     * Class WpBookingPro_wbcustomerController
     */
    class WpBookingPro_wbcustomerController extends woobooking_controller
    {
        /**
         * @return mixed
         * @throws Exception
         */
        public function get_wbcustomer_by_id()
        {
            return self::view("wbcustomer.form");
        }

        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_get_item()
        {
            return self::view("wbcustomer.form");
        }

        /**
         * @param string $data_post
         * @return array|bool|mixed|stdClass
         */
        public function ajax_save($data_post = "")
        {
            $input = Factory::getInput();
            if (!$data_post) {
                $data_post = $input->getData()['data'];
            }
            $data_post['id'] = 1;
            $data_post = parent::save($data_post); // TODO: Change the autogenerated stub
            $response = new stdClass();
            $response->data = $data_post;
            return $response;
        }

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