Skip to content

Commit 9f35080

Browse files
authored
Merge pull request #289 from sumitwebkul/gli-625
Validations added to the fields of "bookings" API for POST / PUT API requests
2 parents 25be94a + b12eaf0 commit 9f35080

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

modules/hotelreservationsystem/classes/HotelBookingDetail.php

+25-25
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,40 @@ class HotelBookingDetail extends ObjectModel
7272
'table' => 'htl_booking_detail',
7373
'primary' => 'id',
7474
'fields' => array(
75-
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
76-
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
77-
'id_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
78-
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
79-
'id_room' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
80-
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
81-
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
82-
'booking_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
83-
'id_status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
75+
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
76+
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
77+
'id_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
78+
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
79+
'id_room' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
80+
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
81+
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
82+
'booking_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
83+
'id_status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
8484
'comment' => array('type' => self::TYPE_STRING),
8585
'check_in' => array('type' => self::TYPE_DATE),
8686
'check_out' => array('type' => self::TYPE_DATE),
87-
'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
88-
'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
89-
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
90-
'total_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
91-
'total_paid_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'default' => 0),
87+
'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
88+
'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
89+
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
90+
'total_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
91+
'total_paid_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'default' => 0, 'required' => true),
9292
'is_refunded' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
9393
// 'available_for_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
9494
'is_back_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
9595

9696
// hotel information/location/contact
97-
'room_num' => array('type' => self::TYPE_STRING),
98-
'room_type_name' => array('type' => self::TYPE_STRING),
99-
'hotel_name' => array('type' => self::TYPE_STRING),
100-
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'size' => 64),
97+
'room_num' => array('type' => self::TYPE_STRING, 'required' => true),
98+
'room_type_name' => array('type' => self::TYPE_STRING, 'required' => true),
99+
'hotel_name' => array('type' => self::TYPE_STRING, 'required' => true),
100+
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'size' => 64, 'required' => true),
101101
'state' => array('type' => self::TYPE_STRING),
102-
'country' => array('type' => self::TYPE_STRING),
102+
'country' => array('type' => self::TYPE_STRING, 'required' => true),
103103
'zipcode' => array('type' => self::TYPE_STRING),
104-
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
105-
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 255),
106-
'check_in_time' => array('type' => self::TYPE_STRING),
107-
'check_out_time' => array('type' => self::TYPE_STRING),
108-
'adult' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
104+
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32, 'required' => true),
105+
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 255, 'required' => true),
106+
'check_in_time' => array('type' => self::TYPE_STRING, 'required' => true),
107+
'check_out_time' => array('type' => self::TYPE_STRING, 'required' => true),
108+
'adult' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
109109
'children' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
110110

111111
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
@@ -995,7 +995,7 @@ public function getAvailableRoomsForSwapping($date_from, $date_to, $room_type, $
995995
$sql = 'SELECT `id` AS `id_room`, `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment`
996996
FROM `'._DB_PREFIX_.'htl_room_information`
997997
WHERE `id_hotel`='.(int)$hotel_id.' AND `id_product`='.(int)$room_type.'
998-
AND (id_status = '. HotelRoomInformation::STATUS_ACTIVE .' or id_status = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .')
998+
AND (id_status = '. HotelRoomInformation::STATUS_ACTIVE .' or id_status = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .')
999999
AND `id` IN (
10001000
SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail`
10011001
WHERE `date_from` = \''.pSQL($date_from).'\' AND `date_to` = \''.pSQL($date_to).'\'

0 commit comments

Comments
 (0)