Fixed: Missing Hotel API support for nationality, room selling, and property type
Co-authored-by: Name <azharbhat.qlo098@webkul.in>
This commit is contained in:
@@ -147,6 +147,7 @@ class CustomerCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'id_default_group' => array('xlink_resource' => 'groups'),
|
||||
'id_lang' => array('xlink_resource' => 'languages'),
|
||||
'id_country' => array('xlink_resource' => 'countries'),
|
||||
'newsletter_date_add' => array(),
|
||||
'ip_registration_newsletter' => array(),
|
||||
'last_passwd_gen' => array('setter' => null),
|
||||
|
||||
@@ -37,11 +37,65 @@ class RoomTypeSellingObjectCore extends ObjectModel
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true),
|
||||
'plural_name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
|
||||
'plural_name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
|
||||
),
|
||||
);
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'room_type_selling_objects',
|
||||
'objectNodeName' => 'room_type_selling_object',
|
||||
'objectMethods' => array('update' => 'updateWs', 'delete' => 'deleteWs'),
|
||||
'fields' => array(
|
||||
'name' => array('required' => true),
|
||||
'plural_name' => array('required' => true),
|
||||
'active' => array('required' => false),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Webservice: update, refusing to disable a selling object that is in use.
|
||||
*
|
||||
* @param bool $nullValues
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws WebserviceException
|
||||
*/
|
||||
public function updateWs($nullValues = false)
|
||||
{
|
||||
if (!$this->active && $this->id) {
|
||||
$objOld = new RoomTypeSellingObject((int) $this->id);
|
||||
if (Validate::isLoadedObject($objOld) && $objOld->active && $objOld->isUsed()) {
|
||||
throw new WebserviceException(
|
||||
Tools::displayError('You cannot disable this selling object because it is currently assigned.'),
|
||||
array(400, 400)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->update($nullValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Webservice: delete, refusing to delete a selling object that is in use.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws WebserviceException
|
||||
*/
|
||||
public function deleteWs()
|
||||
{
|
||||
if ($this->isUsed()) {
|
||||
throw new WebserviceException(
|
||||
Tools::displayError('You cannot delete this selling object because it is currently assigned.'),
|
||||
array(400, 400)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->delete();
|
||||
}
|
||||
|
||||
public function isUsed()
|
||||
{
|
||||
return (bool) Db::getInstance()->getValue(
|
||||
|
||||
@@ -267,6 +267,7 @@ class WebserviceRequestCore
|
||||
'contacts' => array('description' => 'Shop contacts','class' => 'Contact'),
|
||||
'countries' => array('description' => 'The countries','class' => 'Country'),
|
||||
'currencies' => array('description' => 'The currencies', 'class' => 'Currency'),
|
||||
'room_type_selling_objects' => array('description' => 'The room type selling objects', 'class' => 'RoomTypeSellingObject'),
|
||||
'customers' => array('description' => 'The e-shop\'s customers','class' => 'Customer'),
|
||||
'customer_threads' => array('description' => 'Customer services threads','class' => 'CustomerThread'),
|
||||
'customer_messages' => array('description' => 'Customer services messages','class' => 'CustomerMessage'),
|
||||
|
||||
@@ -106,6 +106,10 @@ class HotelBranchInformation extends ObjectModel
|
||||
'required' => true,
|
||||
'xlink_resource'=> 'countries',
|
||||
),
|
||||
'id_property_type' => array(
|
||||
'required' => true,
|
||||
'xlink_resource'=> 'hotel_property_types',
|
||||
),
|
||||
'id_state' => array(
|
||||
'xlink_resource'=> 'states',
|
||||
),
|
||||
|
||||
@@ -36,10 +36,63 @@ class HotelPropertyType extends ObjectModel
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
|
||||
),
|
||||
);
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'property_types',
|
||||
'objectNodeName' => 'property_type',
|
||||
'objectMethods' => array('update' => 'updateWs', 'delete' => 'deleteWs'),
|
||||
'fields' => array(
|
||||
'name' => array('required' => true),
|
||||
'active' => array('required' => false),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Webservice: update, refusing to disable a property type that is in use.
|
||||
*
|
||||
* @param bool $nullValues
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws WebserviceException
|
||||
*/
|
||||
public function updateWs($nullValues = false)
|
||||
{
|
||||
if (!$this->active && $this->id) {
|
||||
$objOld = new HotelPropertyType((int) $this->id);
|
||||
if (Validate::isLoadedObject($objOld) && $objOld->active && $objOld->isUsed()) {
|
||||
throw new WebserviceException(
|
||||
Tools::displayError('You cannot disable this property type because it is currently assigned.'),
|
||||
array(400, 400)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->update($nullValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Webservice: delete, refusing to delete a property type that is in use.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws WebserviceException
|
||||
*/
|
||||
public function deleteWs()
|
||||
{
|
||||
if ($this->isUsed()) {
|
||||
throw new WebserviceException(
|
||||
Tools::displayError('You cannot delete this property type because it is currently assigned.'),
|
||||
array(400, 400)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this property type is currently assigned to any property.
|
||||
*
|
||||
|
||||
@@ -72,6 +72,11 @@ class HotelRoomType extends ObjectModel
|
||||
'resourceName' => 'hotels',
|
||||
)
|
||||
),
|
||||
'id_selling_object' => array(
|
||||
'xlink_resource' => array(
|
||||
'resourceName' => 'room_type_selling_objects',
|
||||
)
|
||||
),
|
||||
),
|
||||
'associations' => array(
|
||||
'hotel_rooms' => array(
|
||||
|
||||
@@ -48,6 +48,7 @@ class HotelReservationSystem extends Module
|
||||
$resources = array(
|
||||
'hotels' => array('description' => 'Hotel Branch Information','class' => 'HotelBranchInformation'),
|
||||
'hotel_room_types' => array('description' => 'Hotel room types','class' => 'HotelRoomType'),
|
||||
'property_types' => array('description' => 'Hotel property types', 'class' => 'HotelPropertyType'),
|
||||
'hotel_amenities' => array('description' => 'The hotel amenities', 'class' => 'HotelAmenities'),
|
||||
'hotel_refund_rules' => array('description' => 'The hotel refund rules','class' => 'HotelOrderRefundRules'),
|
||||
'hotel_rooms' => array('description' => 'The hotel rooms','class' => 'HotelRoomInformation'),
|
||||
|
||||
Reference in New Issue
Block a user