Booking Helper Functions
The helper you can use to create, delete, get and update booking.
Filter name: before_get_booking
Description: This filter would be executed before retrieving booking from database in get_booking helper.
Usage:
add_filter('before_get_booking', 'before_get_booking_callback_fn', 10, 1);
function before_get_booking_callback_fn ($booking_id) {
// This filter would be executed before retrieving booking from database in get_booking helper.
}
Filter name: should_get_booking
Description: This filter would be executed before retrieving booking from database in get_booking helper.
Usage:
add_filter('should_get_booking', 'should_get_booking_callback_fn', 10, 1);
function should_get_booking_callback_fn ($booking_id) {
// This filter would be executed before retrieving booking from database in get_booking helper.
}
Hook name : pre.get.booking
Description: This hook would be executed before retrieving booking from database in get_booking helper.
Usage:
add_filter('pre.get.booking', 'pre_get_booking_callback_fn', 10, 1);
function pre_get_booking_callback_fn ($booking_id) {
// This filter would be executed before retrieving booking from database in get_booking helper.
}
Hook name : post.get.booking
Description: This hook would be executed after retrieving booking from database in get_booking helper.
Usage:
add_filter('post.get.booking', ' post_get_booking_callback_fn', 10, 1);
function post_get_booking_callback_fn ($booking_id) {
// This filter would be executed before retrieving booking from database in get_booking helper.
}
Usage
// for use booking helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/booking');
// Retrieves booking data based on a booking_id.
$booking_data = get_booking($booking_id);
Request Parameters
Param | Type | Required | Default | Description |
---|---|---|---|---|
$booking_id | Integer | Yes | Null | Booking ID is the primary key for the booking table. |
Response
// $response array includes following attributes:
// $response['rate'] : the rate (integer) of specific booking.
// $response['adult_count'] : the adult_count (integer) for specific booking (must required).
// $response['children_count'] : the children_count (integer) for specific booking.
// $response['company_id'] : the company_id (integer) for specific booking.
// $response['state'] : the state (integer) for specific booking (must required).
// $response['booking_notes'] : the booking_notes for specific booking.
// $response['booking_customer_id'] : the booking_customer_id (integer) for specific booking.
// $response['booked_by'] : the booked_by for specific booking.
// $response['balance'] : the balance (integer) for specific booking.
// $response['use_rate_plan'] : the use_rate_plan (integer) for specific booking (must required).
// $response['rate_plan_id'] : the rate_plan_id (integer) for specific booking.
// $response['charge_type_id'] : the charge_type_id (integer) for specific booking.
// $response['source'] : the source for specific booking.
// $response['is_ota_booking'] : the is_ota_booking (integer) for specific booking.
// $response['pay_period'] : the pay_period (integer) for specific booking.
// $response['room_type_id'] : the room_type_id (integer) for specific booking block.
// and many more attributes from table booking and join with booking block and customer table.
// Successfully response giving you array of booking data.
Array
(
[booking_id] => 26
[rate] => 40
[adult_count] => 2
[children_count] => 1
[state] => 0
[booking_notes] => 0
[company_id] => 1
[booking_customer_id] =>
[booked_by] => 0
[balance] => 10
[balance_without_forecast] => 0
[invoice_hash] => xxxxxxxxxxxxxxxxxxxxxx
[use_rate_plan] => 1
[rate_plan_id] => 1
[color] => transparent
[housekeeping_notes] =>
[charge_type_id] => 0
[guest_review] =>
[is_deleted] => 0
[source] => 0
[is_ota_booking] => 0
[pay_period] => 0
[revenue] => 0
[add_daily_charge] => 0
[residual_rate] =>
[is_invoice_auto_sent] => 0
[name] => comapny 1
[address] =>
[phone] =>
[city] =>
[region] =>
[country] => India
[website] =>
[email] => test@minical.io
[fax] =>
[selling_date] => 2022-01-27
[nightly_audit_charge_id] =>
[time_zone] => Pacific/Midway
)
// If there is no booking data for any booking id provided in input or any error will return null.
Filter name: before_add_booking
Description: This filter would be executed before add booking into database in get_booking helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_add_booking’, ‘before_add_booking_callback_fun’, 10, 1 );
function before_add_booking_callback_fun($booking) {
// code
}
Filter name: should_add_booking
Description: This filter would be executed before add booking into database in get_booking helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_add_booking’, ‘example_callback_fun’, 10, 1 );
function example_callback_fun($booking) {
// code
}
hook name: pre.add.booking
Description: This hook would be executed before add booking into the database in get_booking helper.
Usage:
// The filter callback function is based on the filter.
add_action('pre.add.booking', 'pre_add_booking_callback_fun', 10, 1);
function pre_add_booking_callback_fun($booking) {
// code
}
hook name: post.add.booking
Description: This hook would be executed after add booking into the database in get_booking helper.
Usage:
// The filter callback function is based on the filter.
add_action('post.add.booking', 'post_add_boking_callback_fun', 10, 1);
function post_add_boking_callback_fun($booking) {
// code
}
Usage
// Create a new booking that will also add booking details in booking, booking block and create a new invoice for booking.
$booking_id = add_booking($booking);
Request Parameters
Parameters in array format includes following attributes:
Param | Type | Required | Default | Description |
---|---|---|---|---|
room_id | Integer | Yes | Null | The room_id for specific booking block. |
check_in_date | Date_time | Yes | date | The check_in_date for specific booking block.(must required date in gmdate() format) |
check_out_date | Date_time | Yes | date | the check_out_date for specific booking block(must required date in gmdate() format) |
room_type_id | Integer | Yes | Null | The room_type_id for specific booking block. |
rate | Integer | | | The rate of specific booking. |
adult_count | Integer | Yes | Null | The adult_count for specific booking (must require). |
children_count | Integer | | Null | The children_count for specific booking. |
company_id | Integer | Yes | Null | The company for specific booking(must require). |
state | Integer | Yes | 0 | The state for specific booking. |
booking_notes | Text | | Null | The booking_notes for specific booking. |
booking_customer_id | Integer | Yes | Null | The booking_customer_id it's the customer id from the customer table for a specific booking. |
balance | Integer | | 0.00 | The balance for the specific booking. |
use_rate_plan | Integer | Yes | 0 | The use_rate_plan for specific booking (must require). |
rate_plan_id | Integer | Yes | 0 | The rate_plan_id it's id from the rate plan table for specific booking. |
charge_type_id | Integer | | 0 | The charge_type_id for specific booking. |
source | Integer | | 0 | The source of booking for specific booking. |
is_ota_booking | Integer | | 0 | The is_ota_booking conforms for specific booking. |
pay_period | Integer | | 0 | The pay_period for specific booking. |
room_type_id | Integer | Yes | 0 | The room_type_id for specific booking block. |
booking_type | Integer | | 0 | The booking_type for hook function. |
booking_from | Integer | | 0 | The booking_from for hook function. |
housekeeping_notes | Text | | Null | The housekeeping_notes for specific booking. |
revenue | Integer | | 0 | The revenue for specific booking. |
add_daily_charge | Integer | | 0 | The add_daily_charge for specific booking. |
residual_rate | Integer | | 0 | The residual_rate for specific booking. |
is_invoice_auto_sent | Integer | | 0 | The is_invoice_auto_sent for specific booking. |
Response
Response includes the following attributes:
if data have been added successfully it would return the key of specific booking id.
return $booking_id;
if data does not add it will return null.
Supported hooks
Filter name: before_get_bookings
Description: This filter would be executed before retrieving booking details from database in get_bookings helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_bookings’, ‘before_get_bookings_callback_fun’, 10, 1 );
function before_get_bookings_callback_fun($filter) {
// code
}
Filter name: should_get_bookings
Description: This filter would be executed before retrieving booking details from database in get_bookings helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_bookings’, ‘should_get_bookings_callback_fun’, 10, 1 );
function should_get_bookings_callback_fun($filter) {
// code
}
hook name: pre.get.bookings
Description: This hook would be executed before retrieving booking details from database in get_bookings helper.
Usage:
// The filter callback function is based on the filter.
add_action('pre.get.bookings', 'pre_get_bookings_callback_fun', 10, 1);
function pre_get_bookings_callback_fun($filter) {
// code
}
hook name: post.get.bookings
Description: This hook would be executed after retrieving payment details from database in get_payments helper.
Usage:
// The filter callback function is based on the filter.
add_action('post.get.bookings', 'post_get_bookings_callback_fun', 10, 1);
function post_get_bookings_callback_fun($filter) {
// code
}
Usage
// Retrieves booking data based on a filter array.
$booking_data = get_bookings($filter);
Request Parameters
parameter array filter required for booking details.
Param | Type | Required | Default | Description |
---|---|---|---|---|
company_id | Integer | Yes | Null | The company id for a specific booking. |
booking_id | Integer | Yes | Null | The primary key id of the booking table for a specific booking. |
customer_id | Integer | Yes | Null | The customer_id for a specific booking. |
room_id | Integer | Yes | Null | The room_id for a specific booking. |
Response
// Successfully response giving you array of payment data.
Array
(
[0] => Array
(
[booking_id] => 1
[rate] => 10
[adult_count] => 1
[children_count] => 0
[state] => 5
[booking_notes] =>
[company_id] => 1
[booking_customer_id] => 1
[booked_by] =>
[balance] => 140
[balance_without_forecast] => 140
[invoice_hash] => xxxxxxxxxxxxxxxxxxxxxxxxxx
[use_rate_plan] => 0
[rate_plan_id] =>
[color] =>
[housekeeping_notes] =>
[charge_type_id] => 1
[guest_review] =>
[is_deleted] => 0
[source] => 0
[is_ota_booking] => 0
[pay_period] => 0
[revenue] => 0
[add_daily_charge] => 1
[residual_rate] => 0
[is_invoice_auto_sent] => 0
[room_id] => 11
[room_type_id] => 2
[check_in_date] => 2021-12-10 00:00:00
[check_out_date] => 2021-12-11 00:00:00
[booking_room_history_id] => 1
[customer_id] => 1
[customer_name] => test user
[address] =>
[city] =>
[region] =>
[country] =>
[postal_code] =>
[phone] =>
[fax] =>
[email] => test1@gmail.com
[customer_notes] =>
[customer_type] => PERSON
[cc_number] =>
[cc_expiry_month] =>
[cc_expiry_year] =>
[stripe_customer_id] =>
[customer_type_id] => 1
[address2] =>
[phone2] =>
[cc_tokenex_token] =>
[cc_cvc_encrypted] =>
)
[1] => Array
(
[booking_id] => 2
[rate] => 20
[adult_count] => 1
[children_count] => 0
[state] => 5
[booking_notes] =>
[company_id] => 1
[booking_customer_id] => 2
[booked_by] =>
[balance] => 0
[balance_without_forecast] => 0
[invoice_hash] => xxxxxxxxxxxxxxxxxxxxxx
[use_rate_plan] => 1
[rate_plan_id] => 6
[color] =>
[housekeeping_notes] =>
[charge_type_id] =>
[guest_review] =>
[is_deleted] => 0
[source] => 0
[is_ota_booking] => 0
[pay_period] => 0
[revenue] => 0
[add_daily_charge] => 1
[residual_rate] => 0
[is_invoice_auto_sent] => 0
[room_id] => 14
[room_type_id] => 2
[check_in_date] => 2021-12-17 00:00:00
[check_out_date] => 2021-12-18 00:00:00
[booking_room_history_id] => 2
[customer_id] => 2
[customer_name] => honey
[address] =>
[city] =>
[region] =>
[country] =>
[postal_code] =>
[phone] =>
[fax] =>
[email] => honey@gmail.com
[customer_notes] =>
[customer_type] => PERSON
[cc_number] =>
[cc_expiry_month] =>
[cc_expiry_year] =>
[stripe_customer_id] =>
[customer_type_id] => 1
[address2] =>
[phone2] =>
[cc_tokenex_token] =>
[cc_cvc_encrypted] =>
)
)
// if there is no booking data for filter provided in input or any error will return null.
Usage
// delete a booking data from booking table. it's a soft delete process only status will change data still existing in back end database.
delete_booking($booking_id);
Request Parameters
Param | Type | Required | Description |
---|---|---|---|
$booking_id | integer | yes | The id of the booking corresponds to the booking table. |
Response
Response return mixed Either true or null if booking data is deleted then true
else null.
Last modified 1yr ago