Merge branch 'develop' into gli-3071

This commit is contained in:
varun kewlani
2026-08-18 15:57:08 +05:30
250 changed files with 4346 additions and 11607 deletions

View File

@@ -0,0 +1,291 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3.0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
*/
class HotelAmenities extends ObjectModel
{
public $name;
public $id_parent;
public $position;
public $active;
public $logo_type;
public $logo;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_amenity',
'primary' => 'id_amenity',
'multilang' => true,
'fields' => array(
'id_parent' => array('type' => self::TYPE_INT, 'required' => true),
'position' => array('type' => self::TYPE_INT),
'active' => array('type' => self::TYPE_INT, 'required' => true),
'logo_type' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'logo' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
// lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'required' => true),
),
);
protected $webserviceParameters = array(
'objectsNodeName' => 'hotel_amenities',
'objectNodeName' => 'hotel_amenity',
'fields' => array(),
);
public function delete()
{
if ($id = $this->id) {
$imgFile = dirname(__FILE__).'/../views/img/hotel_amenities/'.(int)$id.'.jpg';
if (file_exists($imgFile)) {
unlink($imgFile);
}
return parent::delete();
}
return false;
}
/**
* Return all categories (id_parent = 0) with their child amenities.
*
* @param int $idLang
* @return array|false
*/
public function getAmenitiesTree($idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$rows = Db::getInstance()->executeS(
'SELECT ha.`id_amenity`, ha.`id_parent`, ha.`position`, ha.`active`, ha.`logo_type`, ha.`logo`, hal.`name`
FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = ha.`id_amenity` AND hal.`id_lang` = '.(int)$idLang.')
ORDER BY ha.`id_parent` ASC, ha.`position` ASC'
);
if (!$rows) {
return false;
}
$result = array();
$amenitiesByCategory = array();
foreach ($rows as $row) {
if ($row['id_parent'] == 0) {
$result[$row['id_amenity']] = array(
'id' => $row['id_amenity'],
'name' => $row['name'],
'position' => $row['position'],
'children' => array(),
);
} else {
$row['id'] = $row['id_amenity'];
$amenitiesByCategory[$row['id_parent']][] = $row;
}
}
foreach ($amenitiesByCategory as $categoryId => $amenities) {
if (isset($result[$categoryId])) {
$result[$categoryId]['children'] = $amenities;
}
}
return $result ?: false;
}
/**
* Returns all amenity categories with children, marking which are selected for a hotel/room type.
*
* @param array $selectedIds flat array of selected amenity IDs
* @param int $idLang
* @return array|false
*/
public function hotelBranchSelectedAmenities($selectedIds, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$rows = Db::getInstance()->executeS(
'SELECT ha.`id_amenity`, ha.`id_parent`, hal.`name`
FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = ha.`id_amenity` AND hal.`id_lang` = '.(int)$idLang.')
ORDER BY ha.`id_parent` ASC'
);
if (!$rows) {
return array();
}
$result = array();
foreach ($rows as $row) {
if ($row['id_parent'] == 0) {
$result[$row['id_amenity']]['name'] = $row['name'];
} else {
$result[$row['id_parent']]['children'][] = array(
'id_amenity' => $row['id_amenity'],
'id' => $row['id_amenity'],
'name' => $row['name'],
'selected' => in_array($row['id_amenity'], $selectedIds) ? 1 : 0,
);
}
}
return $result ?: false;
}
/**
* @param int $id
* @param int $idLang
* @return array|false
*/
public function getAmenityInfoById($id, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->getRow(
'SELECT ha.`id_amenity`, hal.`name`
FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = ha.`id_amenity` AND hal.`id_lang` = '.(int)$idLang.')
WHERE ha.`id_amenity` = '.(int)$id
);
}
/**
* @param int $parentId
* @return array|false
*/
public function getChildAmenitiesByParentAmenityId($parentId)
{
return Db::getInstance()->executeS(
'SELECT `id_amenity` FROM `'._DB_PREFIX_.'htl_amenity` WHERE `id_parent` = '.(int)$parentId
);
}
/**
* Delete a category and all its child amenities.
*
* @param int $deleteId
* @return bool
*/
public function deleteCategory($idCategory)
{
$rows = Db::getInstance()->executeS(
'SELECT `id_amenity` FROM `'._DB_PREFIX_.'htl_amenity`
WHERE `id_parent` = '.(int)$idCategory.' OR `id_amenity` = '.(int)$idCategory
);
if ($rows) {
foreach ($rows as $row) {
$objHotelAmenities = new HotelAmenities((int)$row['id_amenity']);
$objHotelAmenities->delete();
}
}
return true;
}
/**
* @param string $query
* @param int $idLang
* @return array|false
*/
public function searchByName($query, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->executeS(
'SELECT ha.*, hal.* FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal ON hal.`id_amenity` = ha.`id_amenity`
WHERE hal.`name` LIKE \'%'.pSQL($query).'%\'
AND hal.`id_lang` = '.(int)$idLang
);
}
/**
* Return all amenity categories (id_parent = 0), ordered by position.
*
* @param int $idLang
* @return array
*/
public static function getCategories($idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->executeS(
'SELECT ha.`id_amenity`, hal.`name`
FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = ha.`id_amenity` AND hal.`id_lang` = '.(int)$idLang.')
WHERE ha.`id_parent` = 0
ORDER BY ha.`position` ASC'
) ?: array();
}
/**
* Return all active child amenities (id_parent > 0).
*
* @param int $idLang
* @return array
*/
public static function getAmenities($idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->executeS(
'SELECT ha.`id_amenity`, hal.`name`
FROM `'._DB_PREFIX_.'htl_amenity` ha
LEFT JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = ha.`id_amenity` AND hal.`id_lang` = '.(int)$idLang.')
WHERE ha.`id_parent` > 0
AND ha.`active` = 1
ORDER BY hal.`name` ASC'
) ?: array();
}
/**
* Return image path for amenity logo stored in views/img/hotel_amenities/.
*
* @param int $id
* @return string
*/
public static function getAmenityImagePath($id)
{
return _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/'.(int)$id.'.jpg';
}
}

View File

@@ -1,62 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class HotelBedType extends ObjectModel
{
public $length;
public $width;
public $name;
public static $definition =array(
'table' => 'htl_bed_type',
'primary' => 'id_bed_type',
'multilang' => true,
'fields' => array(
'length' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'width' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
// lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
),
);
public function getAllBedTypes($idLang)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$sql = 'SELECT hbt.*, hbtl.`name` FROM `'._DB_PREFIX_.$this->table.'` hbt
LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` hbtl ON hbt.`id_bed_type` = hbtl.`id_bed_type`
WHERE 1 AND hbtl.`id_lang` ='.(int) $idLang;
return Db::getInstance()->executeS($sql);
}
public function delete()
{
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$objHotelRoomTypeBedType->deleteRoomTypeBedTypes($this->id);
return parent::delete();
}
}

View File

@@ -23,6 +23,85 @@
class HotelBookingDetail extends ObjectModel
{
// Guest Registration Card — Section IDs
const GRC_SECTION_GUEST_INFO = 1;
const GRC_SECTION_TRAVEL_INFO = 2;
const GRC_SECTION_BOOKING_INFO = 3;
const GRC_SECTION_IDENTIFICATION = 4;
const GRC_SECTION_ADDITIONAL_GUESTS = 5;
const GRC_SECTION_BILLING_CORPORATE = 6;
const GRC_SECTION_PAYMENT_DEPOSIT = 7;
const GRC_SECTION_GUEST_SIGNATURE = 8;
const GRC_SECTION_PROPERTY_REGS = 9;
const GRC_SECTION_OFFICE_USE_ONLY = 10;
// Guest Registration Card — Guest Information fields (section 1)
const GRC_GUEST_TITLE = 1;
const GRC_GUEST_FULL_NAME = 2;
const GRC_GUEST_PHONE = 3;
const GRC_GUEST_EMAIL = 4;
const GRC_GUEST_DOB = 5;
const GRC_GUEST_NATIONALITY = 6;
const GRC_GUEST_CITY_COUNTRY = 7;
const GRC_GUEST_POSTAL_CODE = 8;
const GRC_GUEST_ADDRESS = 9;
// Guest Registration Card — Travel Information fields (section 2)
const GRC_TRAVEL_ARRIVED_FROM = 1;
const GRC_TRAVEL_NEXT_DESTINATION = 2;
const GRC_TRAVEL_FLIGHT_TRAIN = 3;
const GRC_TRAVEL_VEHICLE_REG = 4;
const GRC_TRAVEL_PURPOSE_OF_VISIT = 5;
// Guest Registration Card — Booking Information fields (section 3)
const GRC_BOOKING_REFERENCE = 1;
const GRC_BOOKING_RATE_PER_NIGHT = 2;
const GRC_BOOKING_ARRIVAL = 3;
const GRC_BOOKING_DEPARTURE = 4;
const GRC_BOOKING_ROOM_TYPE = 5;
const GRC_BOOKING_ROOM_NUMBER = 6;
const GRC_BOOKING_NUM_GUESTS = 7;
// Guest Registration Card — Identification Document fields (section 4)
const GRC_ID_IDENTITY_PROOF = 1;
const GRC_ID_NUMBER = 2;
const GRC_ID_PASSPORT_NO = 3;
const GRC_ID_PLACE_OF_ISSUE = 4;
const GRC_ID_DATE_OF_ISSUE = 5;
const GRC_ID_DATE_OF_EXPIRY = 6;
const GRC_ID_VISA_NUMBER = 7;
const GRC_ID_VALID_UNTIL = 8;
const GRC_ID_ARRIVAL_DATE_IN_COUNTRY = 9;
// Guest Registration Card — Additional Guests fields (section 5)
const GRC_ADD_GUEST_NAME = 1;
const GRC_ADD_GUEST_ID_TYPE = 2;
const GRC_ADD_GUEST_ID_NUMBER = 3;
const GRC_ADD_GUEST_NATIONALITY = 4;
// Guest Registration Card — Billing & Corporate Details fields (section 6)
const GRC_BILLING_COMPANY = 1;
const GRC_BILLING_TAX_ID = 2;
// Guest Registration Card — Payment & Deposit fields (section 7)
const GRC_PAYMENT_METHOD = 1;
const GRC_PAYMENT_CARD_NUMBER = 2;
const GRC_PAYMENT_SECURITY_DEPOSIT = 3;
// Guest Registration Card — Guest Signature fields (section 8)
const GRC_SIG_SIGNATURE = 1;
const GRC_SIG_DATE = 2;
// Guest Registration Card — Property Regulations fields (section 9)
const GRC_PROP_CHECKIN_CHECKOUT_TIME = 1;
const GRC_PROP_HOTEL_POLICIES = 2;
// Guest Registration Card — For Office Use Only fields (section 10)
const GRC_OFFICE_STAFF_NAME = 1;
const GRC_OFFICE_CHECKIN_TIME = 2;
const GRC_OFFICE_ID_VERIFIED = 3;
const GRC_OFFICE_REG_NO = 4;
private $allReqDates;
private $dltDates;
private $partAvaiDates; // used to remove cart rooms from partial available rooms
@@ -1700,19 +1779,15 @@ class HotelBookingDetail extends ObjectModel
if (!$only_search_data) {
if (!empty($bookingData)) {
foreach ($bookingData['rm_data'] as $key => $value) {
$product_feature = Product::getFrontFeaturesStatic($context->language->id, $value['id_product']);
$prod_amen = array();
// featured amenities for display in room type list
$product_feature = HotelRoomTypeAmenities::getAmenities(
$value['id_product'],
$context->language->id,
true
);
if (!empty($amenities) && $amenities) {
$prod_amen = $amenities;
foreach ($product_feature as $a_key => $a_val) {
if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) {
unset($prod_amen[$pa_key]);
if (empty($prod_amen)) {
break;
}
}
}
if (!empty($prod_amen)) {
$roomAmenityIds = array_column(HotelRoomTypeAmenities::getAmenities($value['id_product']), 'id');
if (array_diff($amenities, $roomAmenityIds)) {
unset($bookingData['rm_data'][$key]);
continue;
}
@@ -4802,4 +4877,118 @@ class HotelBookingDetail extends ObjectModel
}
return $result;
}
/**
* Returns all Guest Registration Card sections and their fields.
* Modules may add, remove, or reorder sections/fields via the hook.
*
* @return array sectionId => ['name' => string, 'fields' => [fieldId => string, ...]]
*/
public function getRegistrationCardInfo()
{
$guestRegCardInfo = array(
self::GRC_SECTION_GUEST_INFO => array(
'name' => $this->moduleInstance->l('Guest Information', 'hotelreservationsystem'),
'fields' => array(
self::GRC_GUEST_TITLE => $this->moduleInstance->l('Title', 'hotelreservationsystem'),
self::GRC_GUEST_FULL_NAME => $this->moduleInstance->l('Full Name (As per ID)', 'hotelreservationsystem'),
self::GRC_GUEST_PHONE => $this->moduleInstance->l('Phone / Mobile', 'hotelreservationsystem'),
self::GRC_GUEST_EMAIL => $this->moduleInstance->l('Email', 'hotelreservationsystem'),
self::GRC_GUEST_DOB => $this->moduleInstance->l('Date of Birth', 'hotelreservationsystem'),
self::GRC_GUEST_NATIONALITY => $this->moduleInstance->l('Nationality', 'hotelreservationsystem'),
self::GRC_GUEST_CITY_COUNTRY => $this->moduleInstance->l('City / Country', 'hotelreservationsystem'),
self::GRC_GUEST_POSTAL_CODE => $this->moduleInstance->l('Postal Code', 'hotelreservationsystem'),
self::GRC_GUEST_ADDRESS => $this->moduleInstance->l('Address', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_TRAVEL_INFO => array(
'name' => $this->moduleInstance->l('Travel Information', 'hotelreservationsystem'),
'fields' => array(
self::GRC_TRAVEL_ARRIVED_FROM => $this->moduleInstance->l('Arrived From', 'hotelreservationsystem'),
self::GRC_TRAVEL_NEXT_DESTINATION => $this->moduleInstance->l('Next Destination', 'hotelreservationsystem'),
self::GRC_TRAVEL_FLIGHT_TRAIN => $this->moduleInstance->l('Flight / Train Number', 'hotelreservationsystem'),
self::GRC_TRAVEL_VEHICLE_REG => $this->moduleInstance->l('Vehicle Reg. No.', 'hotelreservationsystem'),
self::GRC_TRAVEL_PURPOSE_OF_VISIT => $this->moduleInstance->l('Purpose of Visit', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_BOOKING_INFO => array(
'name' => $this->moduleInstance->l('Booking Information', 'hotelreservationsystem'),
'fields' => array(
self::GRC_BOOKING_REFERENCE => $this->moduleInstance->l('Booking Reference No.', 'hotelreservationsystem'),
self::GRC_BOOKING_RATE_PER_NIGHT => $this->moduleInstance->l('Rate per Night', 'hotelreservationsystem'),
self::GRC_BOOKING_ARRIVAL => $this->moduleInstance->l('Arrival Date & Time', 'hotelreservationsystem'),
self::GRC_BOOKING_DEPARTURE => $this->moduleInstance->l('Departure Date & Time', 'hotelreservationsystem'),
self::GRC_BOOKING_ROOM_TYPE => $this->moduleInstance->l('Room Type', 'hotelreservationsystem'),
self::GRC_BOOKING_ROOM_NUMBER => $this->moduleInstance->l('Room Number', 'hotelreservationsystem'),
self::GRC_BOOKING_NUM_GUESTS => $this->moduleInstance->l('Number of Guests', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_IDENTIFICATION => array(
'name' => $this->moduleInstance->l('Identification Document', 'hotelreservationsystem'),
'fields' => array(
self::GRC_ID_IDENTITY_PROOF => $this->moduleInstance->l('Identity Proof', 'hotelreservationsystem'),
self::GRC_ID_NUMBER => $this->moduleInstance->l('ID Number', 'hotelreservationsystem'),
self::GRC_ID_PASSPORT_NO => $this->moduleInstance->l('Passport No.', 'hotelreservationsystem'),
self::GRC_ID_PLACE_OF_ISSUE => $this->moduleInstance->l('Place of Issue', 'hotelreservationsystem'),
self::GRC_ID_DATE_OF_ISSUE => $this->moduleInstance->l('Date of Issue', 'hotelreservationsystem'),
self::GRC_ID_DATE_OF_EXPIRY => $this->moduleInstance->l('Date of Expiry', 'hotelreservationsystem'),
self::GRC_ID_VISA_NUMBER => $this->moduleInstance->l('Visa Number', 'hotelreservationsystem'),
self::GRC_ID_VALID_UNTIL => $this->moduleInstance->l('Valid Until', 'hotelreservationsystem'),
self::GRC_ID_ARRIVAL_DATE_IN_COUNTRY => $this->moduleInstance->l('Arrival Date in Country', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_ADDITIONAL_GUESTS => array(
'name' => $this->moduleInstance->l('Additional Guests', 'hotelreservationsystem'),
'fields' => array(
self::GRC_ADD_GUEST_NAME => $this->moduleInstance->l('Guest Name', 'hotelreservationsystem'),
self::GRC_ADD_GUEST_ID_TYPE => $this->moduleInstance->l('ID Type', 'hotelreservationsystem'),
self::GRC_ADD_GUEST_ID_NUMBER => $this->moduleInstance->l('ID Number', 'hotelreservationsystem'),
self::GRC_ADD_GUEST_NATIONALITY => $this->moduleInstance->l('Nationality', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_BILLING_CORPORATE => array(
'name' => $this->moduleInstance->l('Billing & Corporate Details', 'hotelreservationsystem'),
'fields' => array(
self::GRC_BILLING_COMPANY => $this->moduleInstance->l('Company / Agent', 'hotelreservationsystem'),
self::GRC_BILLING_TAX_ID => $this->moduleInstance->l('Tax ID / VAT No.', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_PAYMENT_DEPOSIT => array(
'name' => $this->moduleInstance->l('Payment & Deposit', 'hotelreservationsystem'),
'fields' => array(
self::GRC_PAYMENT_METHOD => $this->moduleInstance->l('Payment Method', 'hotelreservationsystem'),
self::GRC_PAYMENT_CARD_NUMBER => $this->moduleInstance->l('Credit Card Number', 'hotelreservationsystem'),
self::GRC_PAYMENT_SECURITY_DEPOSIT => $this->moduleInstance->l('Security Deposit', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_GUEST_SIGNATURE => array(
'name' => $this->moduleInstance->l('Guest Signature', 'hotelreservationsystem'),
'fields' => array(
self::GRC_SIG_SIGNATURE => $this->moduleInstance->l('Signature', 'hotelreservationsystem'),
self::GRC_SIG_DATE => $this->moduleInstance->l('Date', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_PROPERTY_REGS => array(
'name' => $this->moduleInstance->l('Property Regulations', 'hotelreservationsystem'),
'fields' => array(
self::GRC_PROP_CHECKIN_CHECKOUT_TIME => $this->moduleInstance->l('Check-in / Check-out Time', 'hotelreservationsystem'),
self::GRC_PROP_HOTEL_POLICIES => $this->moduleInstance->l('Hotel Policies', 'hotelreservationsystem'),
),
),
self::GRC_SECTION_OFFICE_USE_ONLY => array(
'name' => $this->moduleInstance->l('For Office Use Only', 'hotelreservationsystem'),
'fields' => array(
self::GRC_OFFICE_STAFF_NAME => $this->moduleInstance->l('Staff Name', 'hotelreservationsystem'),
self::GRC_OFFICE_CHECKIN_TIME => $this->moduleInstance->l('Check-in Time', 'hotelreservationsystem'),
self::GRC_OFFICE_ID_VERIFIED => $this->moduleInstance->l('ID Verified', 'hotelreservationsystem'),
self::GRC_OFFICE_REG_NO => $this->moduleInstance->l('Registration No.', 'hotelreservationsystem'),
),
),
);
Hook::exec('actionGuestRegCardInfoModifier', array(
'guest_registration_info' => &$guestRegCardInfo,
));
return $guestRegCardInfo;
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3.0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
*/
class HotelBranchAmenities extends ObjectModel
{
public $id_hotel;
public $amenity_id;
public $is_featured;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_branch_amenity',
'primary' => 'id_branch_amenity',
'fields' => array(
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'amenity_id' => array('type' => self::TYPE_INT),
'is_featured' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
);
/**
* @param int $idHotel
* @param int $idLang defaults to current context language
* @param bool $featuredOnly true = is_featured=1 only; false = all active child amenities
* @return array
*/
public static function getAmenities($idHotel, $idLang = 0, $featuredOnly = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$filter = $featuredOnly ? 'AND hba.`is_featured` = 1' : '';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT ha.`id_amenity` AS `id`, ha.`logo_type`, ha.`logo`, hal.`name`
FROM `'._DB_PREFIX_.'htl_branch_amenity` hba
INNER JOIN `'._DB_PREFIX_.'htl_amenity` ha
ON (ha.`id_amenity` = hba.`amenity_id`)
INNER JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = hba.`amenity_id` AND hal.`id_lang` = '.(int)$idLang.')
WHERE hba.`id_hotel` = '.(int)$idHotel.'
AND ha.`active` = 1
AND ha.`id_parent` > 0
'.$filter.'
ORDER BY ha.`position` ASC, hal.`name` ASC'
) ?: array();
}
/**
* Prepare amenities tree data for a hotel form, with selection state.
*
* @param int $idHotel
* @param int $idLang defaults to current context language
* @return array
*/
public static function getBranchAmenitiesTreeData($idHotel, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$objHotelAmenities = new HotelAmenities();
$amenities = $objHotelAmenities->hotelBranchSelectedAmenities(
array_column(self::getAmenities($idHotel), 'id'),
$idLang
);
if (!$amenities) {
return array();
}
foreach ($amenities as $idAmenity => &$amenity) {
$amenity['value'] = $idAmenity;
$amenity['input_name'] = 'id_amenity_parents';
$selectedChildAmenities = 0;
if (!empty($amenity['children'])) {
foreach ($amenity['children'] as &$childAmenity) {
$childAmenity['value'] = $childAmenity['id'];
$childAmenity['input_name'] = 'id_amenities';
if (!empty($childAmenity['selected'])) {
$selectedChildAmenities++;
}
}
if ($selectedChildAmenities === count($amenity['children'])) {
$amenity['selected'] = true;
}
}
}
return $amenities;
}
/**
* Delete existing assignments then save new ones for a hotel.
*
* @param int $idHotel
* @param array $amenityIds
* @param array $featuredIds amenity IDs that should be marked is_featured=1
* @return bool
*/
public function saveBranchAmenities($idHotel, array $amenityIds, array $featuredIds = array())
{
Db::getInstance()->delete('htl_branch_amenity', '`id_hotel` = '.(int)$idHotel);
$featuredSet = array_flip(array_map('intval', $featuredIds));
foreach ($amenityIds as $amenityId) {
$objHotelBranchAmenities = new self();
$objHotelBranchAmenities->id_hotel = (int)$idHotel;
$objHotelBranchAmenities->amenity_id = (int)$amenityId;
$objHotelBranchAmenities->is_featured = isset($featuredSet[$amenityId]) ? 1 : 0;
if (!$objHotelBranchAmenities->save()) {
return false;
}
}
return true;
}
}

View File

@@ -1,69 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class HotelBranchFeatures extends ObjectModel
{
public $id;
public $id_hotel;
public $feature_id;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_branch_features',
'primary' => 'id',
'fields' => array(
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'feature_id' => array('type' => self::TYPE_STRING),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
));
/**
* [deleteBranchFeaturesByHotelId : For deleting features of a hotel by hotel id]
* @param [int] $idHotel [Hotel's id , which hotel's features to be deleted]
* @return [Boolean] [true if deleted or false if no deleted]
*/
public function deleteBranchFeaturesByHotelId($idHotel)
{
return Db::getInstance()->delete('htl_branch_features', '`id_hotel` = '.(int) $idHotel);
}
/**
* [assignFeaturesToHotel : For assigning Hotel features to a hotel]
* @param [int] $idHotel [Hotel's id , To which features to be assigned]
* @param [Array] $features [array of features to be assigned to the hotel]
* @return [Boolean] [true]
*/
public function assignFeaturesToHotel($idHotel, $features)
{
if ($features) {
foreach ($features as $feature) {
$obj_htl_features = new HotelBranchFeatures();
$obj_htl_features->id_hotel = $idHotel;
$obj_htl_features->feature_id = $feature;
$obj_htl_features->save();
}
}
return true;
}
}

View File

@@ -128,8 +128,8 @@ class HotelBranchInformation extends ObjectModel
'resource' => 'image',
'fields' => array('id' => array())
),
'hotel_features' => array(
'resource' => 'hotel_feature',
'hotel_amenities' => array(
'resource' => 'hotel_amenity',
'fields' => array('id' => array('required' => true))
),
'hotel_refund_rules' => array(
@@ -506,31 +506,25 @@ class HotelBranchInformation extends ObjectModel
$sql = 'SELECT hbi.`id`, hbl.`hotel_name` FROM `'._DB_PREFIX_.'htl_branch_info` hbi
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)$idLang.')
WHERE hbi.`id` NOT IN (SELECT DISTINCT id_hotel FROM `'._DB_PREFIX_.'htl_branch_features`)';
WHERE hbi.`id` NOT IN (SELECT DISTINCT id_hotel FROM `'._DB_PREFIX_.'htl_branch_amenity`)';
return Db::getInstance()->executeS($sql);
}
/**
* [getFeaturesOfHotelByHotelId : To get assigned Features of a hotel by its id].
*
* @param [type] $id_hotel [id of the hotel]
*
* @return [array | false] [If no feature found then returns false otherwise returns array of all features assigned to the hotel]
* @param int $id_hotel
* @return array|false
*/
public function getFeaturesOfHotelByHotelId($id_hotel)
public function getAmenitiesOfHotelByHotelId($id_hotel)
{
return Db::getInstance()->executeS(
'SELECT feature_id FROM `'._DB_PREFIX_.'htl_branch_features` WHERE id_hotel='.(int)$id_hotel
'SELECT amenity_id FROM `'._DB_PREFIX_.'htl_branch_amenity` WHERE id_hotel='.(int)$id_hotel
);
}
/**
* [getFeaturesOfHotelByHotelId : To get Hotel's id by its category id].
*
* @param [int] $id_category [id_category of the hotel]
*
* @return [array | int] [If no hotel found then returns false otherwise returns id of the hotel]
* @param int $id_category
* @return int|false
*/
public static function getHotelIdByIdCategory($id_category)
{
@@ -548,11 +542,8 @@ class HotelBranchInformation extends ObjectModel
}
/**
* [getFeaturesOfHotelByHotelId : To get Category Information by its id_category].
*
* @param [int] $id_category [id of the category , Which innformation is wanted]
*
* @return [array | false] [If no Category found then returns false otherwise returns array of information of that category]
* @param int $id_category
* @return array|false
*/
public function getCategoryDataByIdCategory($id_category)
{
@@ -802,11 +793,11 @@ class HotelBranchInformation extends ObjectModel
}
}
}
$objHotelfeatures = new HotelBranchFeatures();
$objHotelAmenities = new HotelBranchAmenities();
$objHotelImage = new HotelImage();
if (!$objHotelfeatures->deleteBranchFeaturesByHotelId($idHotel)) {
if (!$objHotelAmenities->saveBranchAmenities($idHotel, array())) {
$contextController->errors[] = $this->moduleInstance->l(
'Some error has occurred while deleting hotel feature data.',
'Some error has occurred while deleting hotel amenity data.',
'HotelBranchInformation'
);
}
@@ -1003,25 +994,25 @@ class HotelBranchInformation extends ObjectModel
return $ids;
}
// Webservice:: function to prepare id parameter for hotel features in a hotel api
public function getWsHotelFeatures()
// Webservice:: function to prepare id parameter for hotel amenities in a hotel api
public function getWsHotelAmenities()
{
return Db::getInstance()->executeS(
'SELECT `feature_id` as `id` FROM `'._DB_PREFIX_.'htl_branch_features` WHERE `id_hotel` = '.(int)$this->id.
' ORDER BY `feature_id` ASC'
'SELECT `amenity_id` as `id` FROM `'._DB_PREFIX_.'htl_branch_amenity` WHERE `id_hotel` = '.(int)$this->id.
' ORDER BY `amenity_id` ASC'
);
}
// Webservice:: function to prepare id parameter for hotel features in a hotel api
public function setWsHotelFeatures($branchFeatures)
// Webservice:: function to set hotel amenities in a hotel api
public function setWsHotelAmenities($branchAmenities)
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'htl_branch_features`
DELETE FROM `'._DB_PREFIX_.'htl_branch_amenity`
WHERE `id_hotel` = '.(int)$this->id
);
foreach ($branchFeatures as $feature) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_branch_features` (`id_hotel`, `feature_id`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int)$feature['id'].', NOW(), NOW())');
foreach ($branchAmenities as $amenity) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_branch_amenity` (`id_hotel`, `amenity_id`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int)$amenity['id'].', NOW(), NOW())');
}
return true;

View File

@@ -87,7 +87,7 @@ class HotelBranchRefundRules extends ObjectModel
$condition .= ' AND `id_refund_rule` = '.(int)$idRefundRule;
}
if ($notInVals) {
$condition .= ' AND `id_refund_rule` NOT IN ('.implode(',', $notInVals).')';
$condition .= ' AND `id_refund_rule` NOT IN ('.implode(',', array_map('intval', $notInVals)).')';
}
return Db::getInstance()->delete(
'htl_branch_refund_rules',

View File

@@ -1535,7 +1535,7 @@ class HotelCartBookingData extends ObjectModel
$objCartBooking = new self();
$objRoomType = new HotelRoomType();
$objHotelBranch = new HotelBranchInformation();
$objHtlFeatures = new HotelFeatures();
$objHtlFeatures = new HotelAmenities();
$objCartBookingData = new HotelCartBookingData();
$objRoomDemands = new HotelRoomTypeDemand();
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
@@ -1609,17 +1609,16 @@ class HotelCartBookingData extends ObjectModel
$addressInfo['country'].', '.$addressInfo['postcode'];
// append hotel features
if ($hotelFeaureIds = $objHotelBranch->getFeaturesOfHotelByHotelId($roomDetail['id_hotel'])) {
$hotelFeatures = array();
foreach ($hotelFeaureIds as $value) {
$htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id']);
if ($htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id'])) {
$hotelFeatures[] = $htlFeatureInfo['name'];
// append hotel amenities
if ($hotelAmenityIds = $objHotelBranch->getAmenitiesOfHotelByHotelId($roomDetail['id_hotel'])) {
$hotelAmenities = array();
foreach ($hotelAmenityIds as $value) {
if ($htlAmenityInfo = $objHtlFeatures->getAmenityInfoById($value['amenity_id'])) {
$hotelAmenities[] = $htlAmenityInfo['name'];
}
}
if ($hotelFeatures) {
$hotelInfo['htl_features'] = $hotelFeatures;
if ($hotelAmenities) {
$hotelInfo['htl_features'] = $hotelAmenities;
}
}
// append roomtype features

View File

@@ -1,228 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class HotelFeatures extends ObjectModel
{
public $name;
public $parent_feature_id;
public $position;
public $active;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_features',
'primary' => 'id',
'multilang' => true,
'fields' => array(
'parent_feature_id' => array('type' => self::TYPE_INT, 'required' => true),
'position' => array('type' => self::TYPE_INT),
'active' => array('type' => self::TYPE_INT, 'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
//lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'required' => true),
)
);
protected $webserviceParameters = array(
'objectsNodeName' => 'hotel_features',
'objectNodeName' => 'hotel_feature',
'fields' => array(),
);
public function delete()
{
if ($id = $this->id) {
if (Db::getInstance()->delete('htl_branch_features', '`feature_id` = '.(int) $id)) {
return parent::delete();
}
}
return false;
}
/**
* [getFeatureInfoById :: To get feature in formation by its id]
* @param [int] $id [description]
* @return [false | array] [Returns false if no data found otherwise returns array of the information of the
* feature]
*/
public function getFeatureInfoById($id, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->getRow(
'SELECT hf.`id` , hfl.`name`
FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.')
WHERE hf.`id`='.(int) $id
);
}
/**
* [HotelAllCommonFeaturesArray :: To get array of all hotel features information according to parents feature and
* children features under parent feature]
* @return [boolean] [If data found returns array of all common features as parent then children under this parent]
*/
public function HotelAllCommonFeaturesArray($idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$result = array();
if ($parentFeatures = Db::getInstance()->executeS(
'SELECT hf.`id`, hf.`position`, hfl.`name`
FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.')
WHERE hf.`parent_feature_id`=0 order by position'
)) {
foreach ($parentFeatures as $value) {
$result[$value['id']]['name'] = $value['name'];
$result[$value['id']]['id'] = $value['id'];
$result[$value['id']]['position'] = $value['position'];
if ($childFeatures = Db::getInstance()->executeS(
'SELECT hf.`id`, hfl.`name`
FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.')
WHERE hf.`parent_feature_id`='.(int) $value['id']
)) {
foreach ($childFeatures as $value1) {
$result[$value['id']]['children'][] = $value1;
}
}
}
}
if (!$result) {
return false;
}
return $result;
}
/**
* [deleteHotelFeatures :: Deletes the feature which id is $deleteId and also delete all the child features which
* parent id is $deleteId]
* @param [int] $deleteId [id(primary_key) of the htl_features table]
* @return [boolean] [true if deleted otherwise false]
*/
public function deleteHotelFeatures($deleteId, $deleteOnlyChilds = 0)
{
$sql = 'SELECT `id` FROM `'._DB_PREFIX_.'htl_features` WHERE `parent_feature_id`='.(int) $deleteId;
if (!$deleteOnlyChilds) {
$sql .= ' OR `id`='.(int) $deleteId;
}
if ($idsToDetele = Db::getInstance()->executeS($sql)) {
foreach ($idsToDetele as $value) {
$objHotelFeatures = new HotelFeatures($value['id']);
$objHotelFeatures->delete();
}
}
return true;
}
/**
* [HotelBranchSelectedFeaturesArray :: To get array of all hotel features information according to parents and
* children including which child features are selected for a hotel]
* @param [array] $htl_features [array containing information of the features of a hotel]
* @return [boolean] [If data found returns array of all common features as parent then children under this parent
* and also set an index in the array that defines whether the child feature is selected for the hotel or not]
*/
public function HotelBranchSelectedFeaturesArray($htl_features, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$result = array();
if ($parentFeatures = Db::getInstance()->executeS(
'SELECT hf.`id`, hfl.`name`
FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.')
WHERE hf.`parent_feature_id`=0'
)) {
foreach ($parentFeatures as $value) {
$result[$value['id']]['name'] = $value['name'];
if ($childFeatures = Db::getInstance()->executeS(
'SELECT hf.`id`, hfl.`name`
FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.')
WHERE hf.`parent_feature_id`='.(int) $value['id']
)) {
foreach ($childFeatures as $value1) {
$flag =0;
if ($htl_features) {
foreach ($htl_features as $ftr) {
if ($value1['id'] == $ftr['feature_id']) {
$flag = 1;
}
}
}
if ($flag) {
$value1['selected'] = 1;
} else {
$value1['selected'] = 0;
}
$result[$value['id']]['children'][] = $value1;
}
}
}
}
if (!$result) {
return false;
}
return $result;
}
public function getChildFeaturesByParentFeatureId($parent_feature_id)
{
return Db::getInstance()->executeS(
'SELECT `id` FROM `'._DB_PREFIX_.'htl_features` WHERE `parent_feature_id`='.(int)$parent_feature_id
);
}
public function updateHotelFeatureInfoByParentFeatureId($parent_feature_id, $update_params)
{
return Db::getInstance()->update('htl_features', $update_params, 'id='.(int) $parent_feature_id);
}
public function searchByName($query, $idLang = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->executeS(
'SELECT hf.*, hfl.* FROM `'._DB_PREFIX_.'htl_features` hf
LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
ON hfl.`id` = hf.`id`
WHERE hfl.`name` LIKE \'%'.pSQL($query).'%\'
AND hfl.`id_lang`='.(int) $idLang
);
}
}

View File

@@ -43,9 +43,9 @@ class HotelHelper
Media::addJsDef($jsVars);
}
public function insertHotelCommonFeatures()
public function insertHotelCommonAmenities()
{
$parent_features_arr = array(
$parent_amenities_arr = array(
'Business Services' => array(
'name' => array(
'en' => 'Business Services',
@@ -55,7 +55,7 @@ class HotelHelper
'ru' => 'Бизнес-услуги',
'es' => 'Servicios empresariales',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Business Center',
'nl' => 'Businesscentrum',
@@ -123,7 +123,7 @@ class HotelHelper
'ru' => 'Дополнительные услуги',
'es' => 'Servicios complementarios',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Internet Access Free',
'nl' => 'Gratis internettoegang',
@@ -175,7 +175,7 @@ class HotelHelper
'ru' => 'Развлечения',
'es' => 'Entretenimiento',
),
'features' => array(
'amenities' => array(
array(
'en' => 'DiscoTheatre',
'nl' => 'Discotheek/theater',
@@ -243,7 +243,7 @@ class HotelHelper
'ru' => 'Удобства',
'es' => 'Instalaciones',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Laundry Service',
'nl' => 'Wasservice',
@@ -359,7 +359,7 @@ class HotelHelper
'ru' => 'Общие услуги',
'es' => 'Servicios generales',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Room Service',
'nl' => 'Roomservice',
@@ -443,7 +443,7 @@ class HotelHelper
'ru' => 'В помещении',
'es' => 'Interior',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Parking',
'nl' => 'Parkeren',
@@ -479,7 +479,7 @@ class HotelHelper
'ru' => 'Интернет',
'es' => 'Internet',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Internet Access-Surcharge',
'nl' => 'Internettoegang - toeslag',
@@ -507,7 +507,7 @@ class HotelHelper
'ru' => 'На открытом воздухе',
'es' => 'Al aire libre',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Gardens',
'nl' => 'Tuinen',
@@ -591,7 +591,7 @@ class HotelHelper
'ru' => 'Парковка',
'es' => 'Aparcamiento',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Parking (Surcharge)',
'nl' => 'Parkeren (toeslag)',
@@ -627,7 +627,7 @@ class HotelHelper
'ru' => 'Спорт и отдых',
'es' => 'Deportes y recreación',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Health Club / Gym Facility Available',
'nl' => 'Health Club / Sportschool beschikbaar',
@@ -823,7 +823,7 @@ class HotelHelper
'ru' => 'Водные удобства',
'es' => 'Instalaciones acuáticas',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Swimming Pool',
'nl' => 'Zwembad',
@@ -875,7 +875,7 @@ class HotelHelper
'ru' => 'Вино и ужин',
'es' => 'Vino y cena',
),
'features' => array(
'amenities' => array(
array(
'en' => 'Bar / Lounge',
'nl' => 'Bar / Lounge',
@@ -977,34 +977,46 @@ class HotelHelper
);
// lang fields
$languages = Language::getLanguages(false);
$imgDir = dirname(__FILE__).'/../views/img/hotel_amenities/';
$i = 1;
foreach ($parent_features_arr as $key => $value) {
$obj_feature = new HotelFeatures();
$defaultImageIndex = 0;
foreach ($parent_amenities_arr as $key => $value) {
$obj_amenity = new HotelAmenities();
foreach ($languages as $lang) {
if (isset($value['name'][$lang['iso_code']])) {
$obj_feature->name[$lang['id_lang']] = $value['name'][$lang['iso_code']];
$obj_amenity->name[$lang['id_lang']] = $value['name'][$lang['iso_code']];
} else {
$obj_feature->name[$lang['id_lang']] = $value['name']['en'];
$obj_amenity->name[$lang['id_lang']] = $value['name']['en'];
}
}
$obj_feature->active = 1;
$obj_feature->position = $i;
$obj_feature->parent_feature_id = 0;
$obj_feature->save();
$parent_feature_id = $obj_feature->id;
foreach ($value['features'] as $val) {
$obj_feature = new HotelFeatures();
$obj_amenity->active = 1;
$obj_amenity->position = $i;
$obj_amenity->id_parent = 0;
$obj_amenity->save();
$idParent = $obj_amenity->id;
foreach ($value['amenities'] as $val) {
++$defaultImageIndex;
$obj_amenity = new HotelAmenities();
foreach ($languages as $lang) {
if (isset($val[$lang['iso_code']])) {
$obj_feature->name[$lang['id_lang']] = $val[$lang['iso_code']];
$obj_amenity->name[$lang['id_lang']] = $val[$lang['iso_code']];
} else {
$obj_feature->name[$lang['id_lang']] = $val['en'];
$obj_amenity->name[$lang['id_lang']] = $val['en'];
}
}
$obj_amenity->active = 1;
$obj_amenity->id_parent = $idParent;
$obj_amenity->save();
$srcImg = $imgDir.'_default/'.$defaultImageIndex.'.jpg';
if (file_exists($srcImg)) {
if (ImageManager::resize($srcImg, $imgDir.$obj_amenity->id.'.jpg')) {
$obj_amenity->logo_type = 'image';
$obj_amenity->logo = $obj_amenity->id.'.jpg';
$obj_amenity->save();
}
}
$obj_feature->active = 1;
$obj_feature->parent_feature_id = $parent_feature_id;
$obj_feature->save();
}
++$i;
}
@@ -1139,233 +1151,57 @@ class HotelHelper
return true;
}
/**
* Seed default core room features and values used by room types.
*
* @return bool
*/
public function createHotelRoomDefaultFeatures()
{
$htl_room_ftrs = array(
'Wi-Fi' => array(
'en' => 'Wi-Fi',
'nl' => 'Wi-Fi',
'fr' => 'Wi-Fi',
'de' => 'Wi-Fi',
'ru' => 'Wi-Fi',
'es' => 'Wi-Fi'
),
'News Paper' => array(
'en' => 'News Paper',
'nl' => 'Krant',
'fr' => 'Journal',
'de' => 'Zeitung',
'ru' => 'Газета',
'es' => 'Periódico'
),
'Power BackUp' => array(
'en' => 'Power BackUp',
'nl' => 'Stroomvoorziening',
'fr' => 'Alimentation de secours',
'de' => 'Notstromversorgung',
'ru' => 'Резервное электропитание',
'es' => 'Energía de respaldo'
),
'Refrigerator' => array(
'en' => 'Refrigerator',
'nl' => 'Koelkast',
'fr' => 'Réfrigérateur',
'de' => 'Kühlschrank',
'ru' => 'Холодильник',
'es' => 'Refrigerador'
),
'Restaurant' => array(
'en' => 'Restaurant',
'nl' => 'Restaurant',
'fr' => 'Restaurant',
'de' => 'Restaurant',
'ru' => 'Ресторан',
'es' => 'Restaurante'
),
'Room Service' => array(
'en' => 'Room Service',
'nl' => 'Roomservice',
'fr' => 'Service de chambre',
'de' => 'Zimmerservice',
'ru' => 'Обслуживание номеров',
'es' => 'Servicio de habitaciones'
),
'Gym' => array(
'en' => 'Gym',
'nl' => 'Fitnessruimte',
'fr' => 'Salle de sport',
'de' => 'Fitnessraum',
'ru' => 'Фитнес',
'es' => 'Gimnasio'
)
);
$idLang = (int) Configuration::get('PS_LANG_DEFAULT');
$position = 0;
// image value in rf/ folder
$pos = 1;
$languages = Language::getLanguages(true);
foreach ($htl_room_ftrs as $room_ftr_k => $room_ftr_v) {
$obj_feature = new Feature();
foreach ($languages as $lang) {
if (isset($room_ftr_v[$lang['iso_code']])) {
$obj_feature->name[$lang['id_lang']] = $room_ftr_v[$lang['iso_code']];
} else {
$obj_feature->name[$lang['id_lang']] = $room_ftr_v['en'];
}
foreach ($this->getDefaultRoomFeatures() as $featureName => $featureValues) {
$idFeature = (int) Feature::addFeatureImport($featureName, $position);
if (!$idFeature) {
return false;
}
$obj_feature->position = $pos-1;
$obj_feature->save();
if ($obj_feature->id) {
$obj_feature_value = new FeatureValue();
$obj_feature_value->id_feature = $obj_feature->id;
foreach ($languages as $lang) {
$obj_feature_value->value[$lang['id_lang']] = $obj_feature->id.'.jpg';
}
$obj_feature_value->save();
if ($obj_feature_value->id) {
if (file_exists(_PS_IMG_DIR_.'rf/'.$pos.'.jpg')) {
rename(_PS_IMG_DIR_.'rf/'.$pos.'.jpg', _PS_IMG_DIR_.'rf/'.$obj_feature->id.'.jpg');
}
foreach ($featureValues as $featureValue) {
$idFeatureValue = (int) FeatureValue::addFeatureValueImport($idFeature, $featureValue, null, $idLang, false);
if (!$idFeatureValue) {
return false;
}
}
$pos++;
++$position;
}
return true;
}
public function createHotelDefaultBedTypes()
/**
* Return the default room feature/value seed set.
*
* @return array
*/
protected function getDefaultRoomFeatures()
{
$htlBedTypes = array(
array(
'length' => '6.25',
'width' => '3.16',
'name' => array(
'en' => 'Twin Bed',
'nl' => 'Eenpersoonsbed',
'fr' => 'Lit simple',
'de' => 'Einzelbett',
'ru' => 'Односпальная кровать',
'es' => 'Cama individual',
),
),
array(
'length' => '6.66',
'width' => '3.16',
'name' => array(
'en' => 'Twin XL Bed',
'nl' => 'Eenpersoonsbed XL',
'fr' => 'Lit simple XL',
'de' => 'Einzelbett XL',
'ru' => 'Односпальная кровать XL',
'es' => 'Cama individual XL',
),
),
array(
'length' => '6.25',
'width' => '4.5',
'name' => array(
'en' => 'Full Bed',
'nl' => 'Tweepersoonsbed',
'fr' => 'Lit double',
'de' => 'Doppelbett',
'ru' => 'Двуспальная кровать',
'es' => 'Cama doble',
),
),
array(
'length' => '6.66',
'width' => '5',
'name' => array(
'en' => 'Queen Bed',
'nl' => 'Queen size bed',
'fr' => 'Lit Queen',
'de' => 'Queen-Size-Bett',
'ru' => 'Кровать Queen Size',
'es' => 'Cama Queen',
),
),
array(
'length' => '6.66',
'width' => '6.33',
'name' => array(
'en' => 'King Bed',
'nl' => 'King size bed',
'fr' => 'Lit King',
'de' => 'King-Size-Bett',
'ru' => 'Кровать King Size',
'es' => 'Cama King',
),
),
array(
'length' => '7',
'width' => '6',
'name' => array(
'en' => 'California King Bed',
'nl' => 'California King bed',
'fr' => 'Lit California King',
'de' => 'California King-Bett',
'ru' => 'Калифорнийская кровать King Size',
'es' => 'Cama California King',
),
),
array(
'length' => '6.25',
'width' => '3.16',
'name' => array(
'en' => 'Bunk Bed',
'nl' => 'Stapelbed',
'fr' => 'Lit superposé',
'de' => 'Etagenbett',
'ru' => 'Двухъярусная кровать',
'es' => 'Litera',
),
),
array(
'length' => '6.25',
'width' => '4.5',
'name' => array(
'en' => 'Sofa Bed',
'nl' => 'Slaapbank',
'fr' => 'Canapé-lit',
'de' => 'Schlafsofa',
'ru' => 'Диван-кровать',
'es' => 'Sofá cama',
),
),
array(
'length' => '6.66',
'width' => '5',
'name' => array(
'en' => 'Murphy Bed',
'nl' => 'Inklapbed',
'fr' => 'Lit escamotable',
'de' => 'Klappbett',
'ru' => 'Откидная кровать',
'es' => 'Cama abatible',
),
),
return array(
'Bed Type' => array('Single', 'Double', 'Queen', 'King', 'Super King', 'Twin', 'Bunk Bed', 'Sofa Bed', 'Futon', 'Murphy Bed', 'Water Bed'),
'Extra Bed Available' => array('Yes', 'No', 'On Request', 'Chargeable'),
'Crib/Cot Available' => array('Yes', 'No', 'On Request'),
'Room Size' => array('150 sq ft', '200 sq ft', '300 sq ft', '400 sq ft', '500 sq ft', '600 sq ft', '800 sq ft', '1000+ sq ft'),
'View' => array('Sea/Ocean View', 'Garden View', 'City View', 'Pool View', 'Mountain View', 'Lake View', 'River View', 'Park View', 'Courtyard View', 'Desert View', 'No View/Interior'),
'Balcony Type' => array('Private Balcony', 'Shared Terrace', 'Juliet Balcony', 'Rooftop Access', 'Patio', 'Veranda', 'None'),
'Bathroom Type' => array('Private/Ensuite', 'Shared', 'Jack and Jill (shared between 2 rooms)', 'Half Bath'),
'AC Type' => array('Split AC', 'Central AC', 'Window AC', 'No AC', 'Fan Only'),
'Heating Type' => array('Central Heating', 'Room Heater', 'Underfloor Heating', 'Fireplace', 'No Heating'),
'TV Type' => array('No TV', 'LED TV', 'Smart TV', 'OLED TV'),
'Wi-Fi Speed' => array('No Wi-Fi', 'Basic', 'High Speed', 'Premium/Fiber'),
'Smoke Detection' => array('Smoke Detector', 'Sprinkler', 'None'),
'Smoking Policy' => array('Smoking Not Allowed', 'Smoking Allowed'),
);
$languages = Language::getLanguages(true);
foreach ($htlBedTypes as $htlBedType) {
$objBedType = new HotelBedType();
foreach ($languages as $lang) {
if (isset($htlBedType['name'][$lang['iso_code']])) {
$objBedType->name[$lang['id_lang']] = $htlBedType['name'][$lang['iso_code']];
} else {
$objBedType->name[$lang['id_lang']] = $htlBedType['name']['en'];
}
$objBedType->width = $htlBedType['width'];
$objBedType->length = $htlBedType['length'];
$objBedType->save();
}
}
return true;
}
public static function getPsProducts($id_lang, $start = 0, $limit = 0, $booking_product = null)
@@ -1804,14 +1640,14 @@ class HotelHelper
return $htl_id;
}
public function saveDummyHotelFeatures($id_hotel)
public function saveDummyHotelAmenities($id_hotel)
{
$branch_ftr_ids = array(1, 2, 4, 7, 8, 9, 11, 12, 14, 16, 17, 18, 21);
foreach ($branch_ftr_ids as $value_ftr) {
$htl_ftr_obj = new HotelBranchFeatures();
$htl_ftr_obj->id_hotel = $id_hotel;
$htl_ftr_obj->feature_id = $value_ftr;
$htl_ftr_obj->save();
$branch_amenity_ids = array(2, 4, 7, 8, 11, 12, 14, 16, 17, 18, 21);
foreach ($branch_amenity_ids as $amenityId) {
$objHotelAmenities = new HotelBranchAmenities();
$objHotelAmenities->id_hotel = $id_hotel;
$objHotelAmenities->amenity_id = $amenityId;
$objHotelAmenities->save();
}
}
@@ -1820,7 +1656,6 @@ class HotelHelper
$roomTypeDemoDataLang = array(
array(
'price' => 1000,
'id_bed_types' => array(4),
'en' => array(
'name' => 'General Rooms',
'description_short' => 'Our General Rooms offer space and comfort with multiple bedrooms and a cozy living area. Enjoy flat-screen TVs, complimentary Wi-Fi, and a kitchenette for a perfect family getaway.',
@@ -1854,7 +1689,6 @@ class HotelHelper
),
array(
'price' => 1500,
'id_bed_types' => array(4, 5),
'en' => array(
'name' => 'Delux Rooms',
'description_short' => 'Enjoy lake views from our Deluxe Rooms with a king-sized bed, elegant furnishings, and a spacious sitting area. Perfect for guests seeking comfort, luxury, and modern amenities.',
@@ -1888,7 +1722,6 @@ class HotelHelper
),
array(
'price' => 2000,
'id_bed_types' => array(5, 6),
'en' => array(
'name' => 'Executive Rooms',
'description_short' => 'Indulge in our Executive Rooms, featuring separate living and sleeping areas, a luxurious bathroom, and exclusive lounge access. Ideal for business travelers seeking privacy',
@@ -1922,7 +1755,6 @@ class HotelHelper
),
array(
'price' => 2500,
'id_bed_types' => array(6, 8),
'en' => array(
'name' => 'Luxury Rooms',
'description_short' => 'Retreat to tranquility in our Luxury Rooms with expansive views. Featuring a queen-sized bed, workspace, and serene decor, perfect for business and leisure travelers alike.',
@@ -1956,7 +1788,6 @@ class HotelHelper
),
);
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$languages = Language::getLanguages(true);
foreach ($roomTypeDemoDataLang as $key => $roomTypeData) {
// Add Product
@@ -2077,16 +1908,8 @@ class HotelHelper
$htl_rm_type->save();
// Add features to the product
$ftr_arr = array(0 => 1, 1 => 2, 2 => 3, 3 => 4);
$ftr_val_arr = array(0 => 1, 1 => 2, 2 => 3, 3 => 4);
foreach ($ftr_arr as $key_htl_ftr => $val_htl_ftr) {
$product->addFeaturesToDB($val_htl_ftr, $ftr_val_arr[$key_htl_ftr]);
}
// save advance payment information
$this->saveAdvancedPaymentInfo($product_id);
$objHotelRoomTypeBedType->updateRoomTypeBedTypes($roomTypeData['id_bed_types'], $product_id);
}
}
@@ -2474,7 +2297,7 @@ class HotelHelper
{
$htl_id = $this->saveDummyHotelBranchInfo();
$this->saveDummyHotelImages($htl_id);
$this->saveDummyHotelFeatures($htl_id);
$this->saveDummyHotelAmenities($htl_id);
$this->saveDummyProductsAndRelatedInfo($htl_id);
$this->saveDummyServiceProductsAndRelatedInfo();

View File

@@ -91,32 +91,50 @@ class HotelReservationSystemDb
PRIMARY KEY (`id`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_branch_features` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_hotel` int(10) unsigned NOT NULL,
`feature_id` varchar(255) DEFAULT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parent_feature_id` int(10) unsigned NOT NULL,
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenity` (
`id_amenity` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_parent` int(10) unsigned NOT NULL,
`position` int(10) unsigned NOT NULL,
`active` int(2) NOT NULL DEFAULT '0',
`logo_type` varchar(10) NOT NULL DEFAULT 'icon',
`logo` varchar(255) NOT NULL DEFAULT '',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id_amenity`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features_lang` (
`id` int(10) unsigned NOT NULL,
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenity_lang` (
`id_amenity` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`, `id_lang`)
PRIMARY KEY (`id_amenity`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_branch_amenity` (
`id_branch_amenity` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_hotel` int(10) unsigned NOT NULL,
`amenity_id` int(10) unsigned NOT NULL,
`is_featured` tinyint(1) NOT NULL DEFAULT '0',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_branch_amenity`),
CONSTRAINT `fk_htl_branch_amenity_amenity` FOREIGN KEY (`amenity_id`)
REFERENCES `"._DB_PREFIX_."htl_amenity` (`id_amenity`) ON DELETE CASCADE
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_amenity` (
`id_room_type_amenity` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_product` int(10) unsigned NOT NULL,
`amenity_id` int(10) unsigned NOT NULL,
`is_featured` tinyint(1) NOT NULL DEFAULT '0',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_room_type_amenity`),
KEY `id_product` (`id_product`),
CONSTRAINT `fk_htl_room_type_amenity_amenity` FOREIGN KEY (`amenity_id`)
REFERENCES `"._DB_PREFIX_."htl_amenity` (`id_amenity`) ON DELETE CASCADE
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_cart_booking_data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cart` int(11) NOT NULL,
@@ -494,26 +512,7 @@ class HotelReservationSystemDb
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_settings_link`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_bed_type` (
`id_bed_type` INT(11) NOT NULL AUTO_INCREMENT,
`length` DECIMAL(20,6) NOT NULL DEFAULT '0.000000',
`width` DECIMAL(20,6) NOT NULL DEFAULT '0.000000',
PRIMARY KEY (`id_bed_type`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_bed_type_lang`(
`id_bed_type` INT(11) NOT NULL,
`name` VARCHAR(255) DEFAULT NULL,
`id_lang` INT(11) NOT NULL,
PRIMARY KEY (`id_bed_type`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_bed_type` (
`id_room_type_bed_type` INT(11) NOT NULL AUTO_INCREMENT,
`id_product` INT(11) NOT NULL,
`id_bed_type` INT(11) NOT NULL,
PRIMARY KEY (`id_room_type_bed_type`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES
(1, 'icon-cogs', 'index.php?controller=AdminHotelGeneralSettings', 0, 0, 1, 1, NOW(), NOW()),
(2, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()),
(3, 'icon-plus-square', 'index.php?controller=AdminRoomTypeGlobalDemand', 0, 3, 1, 1, NOW(), NOW()),
@@ -528,27 +527,27 @@ class HotelReservationSystemDb
PRIMARY KEY (`id_settings_link`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
SELECT 1, `id_lang`, 'General Settings', 'Configure Your hotel general settings using this option.'
FROM `"._DB_PREFIX_."lang`
ORDER BY `id_lang`;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
SELECT 2, `id_lang`, 'Advanced Price Rules', 'Here set Advanced price rules for specific dates.'
FROM `"._DB_PREFIX_."lang`
ORDER BY `id_lang`;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
SELECT 3, `id_lang`, 'Additional Facilities', 'Here create Additional facilities and their prices for room types.'
FROM `"._DB_PREFIX_."lang`
ORDER BY `id_lang`;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
SELECT 4, `id_lang`, 'Hotel Interior Block', 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.'
FROM `"._DB_PREFIX_."lang`
ORDER BY `id_lang`;",
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
"INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
SELECT 5, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.'
FROM `"._DB_PREFIX_."lang`
ORDER BY `id_lang`;",
@@ -589,9 +588,10 @@ class HotelReservationSystemDb
`'._DB_PREFIX_.'htl_branch_info`,
`'._DB_PREFIX_.'htl_branch_info_lang`,
`'._DB_PREFIX_.'htl_image`,
`'._DB_PREFIX_.'htl_branch_features`,
`'._DB_PREFIX_.'htl_features`,
`'._DB_PREFIX_.'htl_features_lang`,
`'._DB_PREFIX_.'htl_branch_amenity`,
`'._DB_PREFIX_.'htl_room_type_amenity`,
`'._DB_PREFIX_.'htl_amenity`,
`'._DB_PREFIX_.'htl_amenity_lang`,
`'._DB_PREFIX_.'htl_cart_booking_data`,
`'._DB_PREFIX_.'htl_booking_detail`,
`'._DB_PREFIX_.'htl_booking_document`,

View File

@@ -0,0 +1,155 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3.0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
*/
class HotelRoomTypeAmenities extends ObjectModel
{
public $id_product;
public $amenity_id;
public $is_featured;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_room_type_amenity',
'primary' => 'id_room_type_amenity',
'fields' => array(
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'amenity_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'is_featured' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
);
/**
* @param int $idProduct
* @param int $idLang defaults to current context language
* @param bool $featuredOnly true = is_featured=1 only; false = all active child amenities
* @return array
*/
public static function getAmenities($idProduct, $idLang = 0, $featuredOnly = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$filter = $featuredOnly ? 'AND hrta.`is_featured` = 1' : '';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT ha.`id_amenity` AS `id`, ha.`logo_type`, ha.`logo`, hal.`name`, hrta.`is_featured`
FROM `'._DB_PREFIX_.'htl_room_type_amenity` hrta
INNER JOIN `'._DB_PREFIX_.'htl_amenity` ha
ON (ha.`id_amenity` = hrta.`amenity_id`)
INNER JOIN `'._DB_PREFIX_.'htl_amenity_lang` hal
ON (hal.`id_amenity` = hrta.`amenity_id` AND hal.`id_lang` = '.(int)$idLang.')
WHERE hrta.`id_product` = '.(int)$idProduct.'
AND ha.`active` = 1
AND ha.`id_parent` > 0
'.$filter.'
ORDER BY ha.`position` ASC, hal.`name` ASC'
) ?: array();
}
/**
* @param int $idProduct
* @return bool
*/
public static function deleteByProduct($idProduct)
{
return (bool)Db::getInstance()->delete('htl_room_type_amenity', '`id_product` = '.(int)$idProduct);
}
/**
* Prepare amenities tree data for a room type form, with selection state.
*
* @param int $idProduct
* @param int $idLang defaults to current context language
* @return array
*/
public static function getRoomTypeAmenitiesTreeData($idProduct, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$objHotelAmenities = new HotelAmenities();
$amenities = $objHotelAmenities->hotelBranchSelectedAmenities(
array_column(self::getAmenities($idProduct), 'id'),
$idLang
);
if (!$amenities) {
return array();
}
foreach ($amenities as $idAmenityGroup => &$amenityGroup) {
$amenityGroup['value'] = (int) $idAmenityGroup;
$amenityGroup['input_name'] = 'room_type_amenity_parents';
$selectedAmenities = 0;
if (!empty($amenityGroup['children'])) {
foreach ($amenityGroup['children'] as &$amenity) {
$amenity['value'] = (int) $amenity['id'];
$amenity['input_name'] = 'room_type_amenities';
if (!empty($amenity['selected'])) {
++$selectedAmenities;
}
}
if ($selectedAmenities === count($amenityGroup['children'])) {
$amenityGroup['selected'] = true;
}
}
}
return $amenities;
}
/**
* Delete existing assignments then save new ones for a room type.
*
* @param int $idProduct
* @param array $amenityIds
* @param array $featuredIds amenity IDs that should be marked is_featured=1
* @return bool
*/
public function saveRoomTypeAmenities($idProduct, array $amenityIds, array $featuredIds = array())
{
static::deleteByProduct($idProduct);
$featuredSet = array_flip(array_map('intval', $featuredIds));
foreach (array_unique(array_filter(array_map('intval', $amenityIds))) as $amenityId) {
$objHotelRoomTypeAmenities = new self();
$objHotelRoomTypeAmenities->id_product = (int)$idProduct;
$objHotelRoomTypeAmenities->amenity_id = (int)$amenityId;
$objHotelRoomTypeAmenities->is_featured = isset($featuredSet[$amenityId]) ? 1 : 0;
if (!$objHotelRoomTypeAmenities->save()) {
return false;
}
}
return true;
}
}

View File

@@ -1,96 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class HotelRoomTypeBedType extends ObjectModel
{
public $id_product;
public $id_bed_type;
public static $definition =array(
'table' => 'htl_room_type_bed_type',
'primary' => 'id_room_type_bed_type',
'fields' => array(
'id_bed_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
),
);
public function getRoomTypeBedTypes($idProduct)
{
$sql = 'SELECT * FROM `'._DB_PREFIX_.$this->table.'`
WHERE `id_product` ='.(int) $idProduct;
return Db::getInstance()->executeS($sql);
}
public function updateRoomTypeBedTypes($idBedTypes, $idProduct)
{
$res = true;
if ($roomTypeBedTypes = $this->getRoomTypeBedTypes($idProduct)) {
$roomTypeBedTypes = array_column($roomTypeBedTypes, 'id_room_type_bed_type', 'id_bed_type');
}
if ($idBedTypes) {
foreach ($idBedTypes as $idBedType) {
// If room type bed type mapping already exits no need to update it.
if (isset($roomTypeBedTypes[$idBedType])) {
unset($roomTypeBedTypes[$idBedType]);
} else {
$objHotelRoomTypeBedType = new self();
$objHotelRoomTypeBedType->id_product = $idProduct;
$objHotelRoomTypeBedType->id_bed_type = $idBedType;
$res &=$objHotelRoomTypeBedType->save();
}
}
}
// Removing the non selected bed types.
if ($roomTypeBedTypes) {
$res &= $this->deleteRoomTypeBedTypesById($roomTypeBedTypes);
}
return $res;
}
public function deleteRoomTypeBedTypesById($idRoomTypeBedTypes)
{
$res = true;
if ($idRoomTypeBedTypes) {
foreach ($idRoomTypeBedTypes as $idRoomTypeBedType) {
$objHotelRoomTypeBedType = new self($idRoomTypeBedType);
$res &= $objHotelRoomTypeBedType->delete();
}
}
return $res;
}
public function deleteRoomTypeBedTypes($idBedType = false, $idProduct = false)
{
return Db::getInstance()->delete(
$this->table,
' 1 '.($idBedType ? ' AND `id_bed_type`='.(int) $idBedType : '').($idProduct ? ' AND `id_product`='.(int) $idProduct : '')
);
}
}

View File

@@ -149,7 +149,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp
ON (rtfpr.`id_feature_price` = rtfp.`id_feature_price` AND rtfp.`id_product`='.(int) $idRoomType.')
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price` '.($groups ? ' AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')' : ' ' ).')
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price` '.($groups ? ' AND rtfpg.`id_group` IN ('.implode(', ', array_map('intval', $groups)).')' : ' ' ).')
WHERE 1 '.( !is_null($active) ? ' AND rtfp.`active`= '.(int) $active: ' ').' ' .(!is_null($skipFeaturePriceId) ? ' AND rtfpr.`id_feature_price`!='.(int) $skipFeaturePriceId : ' ');
$sqlWhere = '';
if ($restrictions && is_array($restrictions)) {

View File

@@ -113,7 +113,7 @@ class HotelRoomTypeGlobalDemandAdvanceOption extends ObjectModel
$sql = 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option`
WHERE `id_global_demand` = '.(int)$idGlobalDemand;
if (count($skipIds)) {
$sql .= ' AND `id_option` NOT IN ('.pSQL(implode(',', $skipIds)).')' ;
$sql .= ' AND `id_option` NOT IN ('.implode(',', array_map('intval', $skipIds)).')' ;
}
if ($advOptions = Db::getInstance()->executeS($sql)) {
foreach ($advOptions as &$option) {

View File

@@ -176,35 +176,15 @@ class AdminAddHotelController extends ModuleAdminController
}
$smartyVars['order_restrict_date_info'] = HotelOrderRestrictDate::getDataByHotelId($idHotel);
$objHotelFeatures = new HotelFeatures();
$hotelFeatures = $this->object->getFeaturesOfHotelByHotelId($this->object->id);
if ($features = $objHotelFeatures->HotelBranchSelectedFeaturesArray($hotelFeatures)) {
foreach ($features as $idFeature => $feature) {
$features[$idFeature]['value'] = $idFeature;
$features[$idFeature]['input_name'] = 'id_feature_parents';
if (isset($feature['children']) && $feature['children']) {
$selectedChildFeatures = 0;
foreach ($feature['children'] as $childKey => $childFeature) {
$features[$idFeature]['children'][$childKey]['value'] = $childFeature['id'];
$features[$idFeature]['children'][$childKey]['input_name'] = 'id_features';
if (isset($childFeature['selected']) && $childFeature['selected']) {
$selectedChildFeatures++;
}
}
if ($selectedChildFeatures == count($feature['children'])) {
$features[$idFeature]['selected'] = true;
}
}
}
$tree = new HelperTree('hotel-features-tree', $features);
if ($amenities = HotelBranchAmenities::getBranchAmenitiesTreeData((int)$idHotel)) {
$tree = new HelperTree('hotel-amenities-tree', $amenities);
$tree->setShowCollapseExpandButton(true)
->setUseCheckBox(true)
->setAutoSelectChildren(true)
->setUseBulkActions(true);
$treeContent = $tree->render();
$smartyVars['hotel_feature_tree'] = $treeContent;
->setUseBulkActions(true)
->setUseSearch(true);
$smartyVars['hotel_amenity_tree'] = $tree->render();
$smartyVars['hotel_featured_amenity_ids'] = array_column(HotelBranchAmenities::getAmenities((int)$idHotel, 0, true), 'id');
}
$smartyVars['rewrite_url'] = [];
@@ -282,7 +262,8 @@ class AdminAddHotelController extends ModuleAdminController
$longitude = Tools::getValue('loclongitude');
$map_formated_address = Tools::getValue('locformatedAddr');
$map_input_text = Tools::getValue('googleInputField');
$hotelFeatures = Tools::getValue('id_features', array());
$hotelAmenities = Tools::getValue('id_amenities', array());
$hotelFeaturedAmenities = Tools::getValue('hotel_featured_amenities', array());
$shortDescriptionMaxChar = Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : Configuration::PS_SHORT_DESC_LIMIT;
// check if field is atleast in default language. Not available in default prestashop
@@ -496,6 +477,11 @@ class AdminAddHotelController extends ModuleAdminController
}
}
$amenityCategories = HotelAmenities::getCategories();
if ($amenityCategories && !HotelAmenities::getAmenities()) {
$this->errors[] = $this->l('No amenities have been created. Please add amenities to at least one category before assigning them.');
}
if (!count($this->errors)) {
if ($idHotel) {
$objHotelBranch = new HotelBranchInformation($idHotel);
@@ -819,10 +805,9 @@ class AdminAddHotelController extends ModuleAdminController
$objHotelOrderRestrictDate->save();
$objHotelFeatures = new HotelBranchFeatures();
$objHotelFeatures->deleteBranchFeaturesByHotelId($idHotel);
if (!$objHotelFeatures->assignFeaturesToHotel($idHotel, $hotelFeatures)) {
$this->errors[] = $this->l('Some problem occurred while assigning features to the hotel.');
$objHotelAmenities = new HotelBranchAmenities();
if (!$objHotelAmenities->saveBranchAmenities($idHotel, $hotelAmenities, $hotelFeaturedAmenities)) {
$this->errors[] = $this->l('Some problem occurred while assigning amenities to the hotel.');
}
}

View File

@@ -0,0 +1,352 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3.0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
*/
class AdminHotelAmenitiesController extends ModuleAdminController
{
const IMG_DIR = 'views/img/hotel_amenities/';
public function __construct()
{
$this->bootstrap = true;
$this->table = 'htl_amenity';
$this->className = 'HotelAmenities';
$this->identifier = 'id_amenity';
$this->toolbar_title = $this->l('Manage Amenities');
parent::__construct();
$this->display = 'view';
}
public function initToolbar()
{
parent::initToolbar();
if ($this->display == 'view') {
$this->page_header_toolbar_btn['add_category'] = array(
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
'desc' => $this->l('Add new Amenity Category'),
'imgclass' => 'new',
);
}
}
public function initContent()
{
if (Tools::isSubmit('add'.$this->table) || Tools::isSubmit('update'.$this->table)
|| Tools::isSubmit('add'.$this->table.'_item') || Tools::isSubmit('update'.$this->table.'_item')
) {
$this->display = 'edit';
}
$this->initTabModuleList();
$this->initToolbar();
$this->initPageHeaderToolbar();
if ($this->display == 'edit') {
$this->content = $this->renderForm();
} else {
$this->content = $this->renderView();
}
$this->context->smarty->assign(array(
'content' => $this->content,
'url_post' => self::$currentIndex.'&token='.$this->token,
'show_page_header_toolbar' => $this->show_page_header_toolbar,
'page_header_toolbar_title' => $this->page_header_toolbar_title,
'page_header_toolbar_btn' => $this->page_header_toolbar_btn,
));
}
public function renderView()
{
$objHotelAmenities = new HotelAmenities();
$this->context->smarty->assign(array(
'amenities_tree' => $objHotelAmenities->getAmenitiesTree(),
'img_base_url' => $this->module->getPathUri().self::IMG_DIR,
'current_index' => self::$currentIndex,
'token' => $this->token,
'admin_link' => Context::getContext()->link->getAdminLink('AdminHotelAmenities'),
));
return parent::renderView();
}
public function renderForm()
{
$languages = Language::getLanguages(false);
$defaultLang = (int)Configuration::get('PS_LANG_DEFAULT');
$adminLink = Context::getContext()->link->getAdminLink('AdminHotelAmenities');
$this->context->smarty->assign(array(
'languages' => $languages,
'default_lang_id' => $defaultLang,
'current_index' => self::$currentIndex,
'token' => $this->token,
'admin_link' => $adminLink,
));
if (Tools::isSubmit('add'.$this->table.'_item') || Tools::isSubmit('update'.$this->table.'_item')) {
$idAmenity = (int)Tools::getValue('id');
$idCategory = (int)Tools::getValue('id_category');
$amenity = array();
if ($idAmenity) {
$objHotelAmenities = new HotelAmenities($idAmenity);
if (Validate::isLoadedObject($objHotelAmenities)) {
$idCategory = (int)$objHotelAmenities->id_parent;
$amenity = array(
'id' => $objHotelAmenities->id,
'id_parent' => $idCategory,
'active' => (int)$objHotelAmenities->active,
'logo_type' => $objHotelAmenities->logo_type,
'logo' => $objHotelAmenities->logo,
'name' => is_array($objHotelAmenities->name) ? $objHotelAmenities->name : array(),
);
}
}
$imgPath = $this->module->getLocalPath().self::IMG_DIR.$idAmenity.'.jpg';
$this->context->smarty->assign(array(
'amenity' => $amenity,
'id_category' => $idCategory,
'existing_img' => ($idAmenity && file_exists($imgPath))
? $this->module->getPathUri().self::IMG_DIR.$idAmenity.'.jpg'
: false,
));
} else {
$idCategory = (int)Tools::getValue('id');
$category = array();
if ($idCategory) {
$objHotelAmenities = new HotelAmenities($idCategory);
if (Validate::isLoadedObject($objHotelAmenities)) {
$category = array(
'id' => $objHotelAmenities->id,
'position' => $objHotelAmenities->position,
'name' => is_array($objHotelAmenities->name) ? $objHotelAmenities->name : array(),
);
}
}
$this->context->smarty->assign('category', $category);
}
$this->fields_form = array('submit' => array('title' => $this->l('Save')));
return parent::renderForm();
}
public function postProcess()
{
if (Tools::isSubmit('submitHtlCategory') || Tools::isSubmit('submitHtlCategoryAndStay')) {
$idCategory = (int)Tools::getValue('id');
$pos = (int)Tools::getValue('position');
$languages = Language::getLanguages(false);
$defaultLang = (int)Configuration::get('PS_LANG_DEFAULT');
if (!$pos || !Validate::isUnsignedInt($pos)) {
$this->errors[] = $this->l('Position is invalid.');
}
$nameDefault = trim(Tools::getValue('cat_name_'.$defaultLang));
if (!$nameDefault) {
$this->errors[] = $this->l('Category name is required in default language.');
} elseif (!Validate::isGenericName($nameDefault)) {
$this->errors[] = $this->l('Category name is invalid.');
}
if (count($this->errors)) {
$this->display = 'edit';
return;
}
$objHotelAmenities = $idCategory ? new HotelAmenities($idCategory) : new HotelAmenities();
foreach ($languages as $lang) {
$val = trim(Tools::getValue('cat_name_'.$lang['id_lang']));
$objHotelAmenities->name[$lang['id_lang']] = $val ?: $nameDefault;
}
$objHotelAmenities->id_parent = 0;
$objHotelAmenities->position = $pos;
$objHotelAmenities->active = 1;
if (!$objHotelAmenities->save()) {
$this->errors[] = $this->l('Error saving category.');
$this->display = 'edit';
return;
}
$conf = $idCategory ? 4 : 3;
if (Tools::isSubmit('submitHtlCategoryAndStay')) {
Tools::redirectAdmin(self::$currentIndex.'&id='.(int)$objHotelAmenities->id.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
return;
}
if (Tools::isSubmit('submitHtlAmenityItem') || Tools::isSubmit('submitHtlAmenityItemAndStay')) {
$idAmenity = (int)Tools::getValue('id');
$idCategory = (int)Tools::getValue('id_category');
$active = (int)Tools::getValue('active');
$logoType = Tools::getValue('logo_type');
$languages = Language::getLanguages(false);
$defaultLang = (int)Configuration::get('PS_LANG_DEFAULT');
if (!$idCategory) {
$this->errors[] = $this->l('Category is required.');
}
$nameDefault = trim(Tools::getValue('amenity_name_'.$defaultLang));
if (!$nameDefault) {
$this->errors[] = $this->l('Amenity name is required in default language.');
} elseif (!Validate::isGenericName($nameDefault)) {
$this->errors[] = $this->l('Amenity name is invalid.');
}
$logoValue = '';
if ($logoType === 'icon') {
$logoValue = trim(Tools::getValue('logo_icon'));
if (!$logoValue) {
$this->errors[] = $this->l('Icon class is required.');
} elseif (!preg_match('/^icon-/', $logoValue)) {
$this->errors[] = $this->l('Icon class must start with "icon-" (e.g. icon-wifi).');
} elseif (!Validate::isGenericName(str_replace('-', ' ', $logoValue))) {
$this->errors[] = $this->l('Icon name is invalid.');
}
} else {
$hasUpload = isset($_FILES['logo_image']) && !empty($_FILES['logo_image']['tmp_name']);
$hasExisting = $idAmenity && file_exists($this->module->getLocalPath().self::IMG_DIR.$idAmenity.'.jpg');
if (!$hasUpload && !$hasExisting) {
$this->errors[] = $this->l('Please upload an image for this amenity.');
}
}
if (count($this->errors)) {
$this->display = 'edit';
return;
}
$objHotelAmenities = $idAmenity ? new HotelAmenities($idAmenity) : new HotelAmenities();
foreach ($languages as $lang) {
$val = trim(Tools::getValue('amenity_name_'.$lang['id_lang']));
$objHotelAmenities->name[$lang['id_lang']] = $val ?: $nameDefault;
}
$objHotelAmenities->id_parent = $idCategory;
$objHotelAmenities->active = $active;
$objHotelAmenities->logo_type = ($logoType === 'icon') ? 'icon' : 'image';
$objHotelAmenities->logo = ($logoType === 'icon') ? $logoValue : $objHotelAmenities->logo;
if (!$objHotelAmenities->save()) {
$this->errors[] = $this->l('Error saving amenity.');
$this->display = 'edit';
return;
}
if ($logoType === 'icon') {
$imgFile = $this->module->getLocalPath().self::IMG_DIR.$objHotelAmenities->id.'.jpg';
if (file_exists($imgFile)) {
unlink($imgFile);
}
}
if ($logoType === 'image' && isset($_FILES['logo_image']) && $_FILES['logo_image']['tmp_name']) {
$imgFile = $_FILES['logo_image'];
if ($error = ImageManager::validateUpload($imgFile, Tools::getMaxUploadSize())) {
$this->errors[] = $error;
} else {
$imgDir = $this->module->getLocalPath().self::IMG_DIR;
if (!is_dir($imgDir)) {
mkdir($imgDir, 0755, true);
}
if (ImageManager::resize($imgFile['tmp_name'], $imgDir.$objHotelAmenities->id.'.jpg')) {
$objHotelAmenities->logo = $objHotelAmenities->id.'.jpg';
$objHotelAmenities->save();
} else {
$this->errors[] = $this->l('Error uploading amenity image.');
}
}
}
if (count($this->errors)) {
$this->display = 'edit';
return;
}
$conf = $idAmenity ? 4 : 3;
if (Tools::isSubmit('submitHtlAmenityItemAndStay')) {
Tools::redirectAdmin(self::$currentIndex.'&id='.(int)$objHotelAmenities->id.'&id_category='.(int)$idCategory.'&update'.$this->table.'_item&conf='.$conf.'&token='.$this->token);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
return;
}
if (empty($this->errors)) {
parent::postProcess();
}
}
public function ajaxProcessDeleteCategory()
{
$response = array('status' => false);
if ($this->tabAccess['delete']) {
$objHotelAmenities = new HotelAmenities();
if ($objHotelAmenities->deleteCategory((int)Tools::getValue('id_category'))) {
$response['status'] = true;
} else {
$response['msg'] = $this->l('Error deleting category.');
}
} else {
$response['msg'] = $this->l('You do not have permission to delete.');
}
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessDeleteAmenityItem()
{
$response = array('status' => false);
if ($this->tabAccess['delete']) {
$objHotelAmenities = new HotelAmenities((int)Tools::getValue('id_amenity'));
if (Validate::isLoadedObject($objHotelAmenities) && $objHotelAmenities->delete()) {
$response['status'] = true;
} else {
$response['msg'] = $this->l('Error deleting amenity.');
}
} else {
$response['msg'] = $this->l('You do not have permission to delete.');
}
$this->ajaxDie(json_encode($response));
}
public function setMedia()
{
parent::setMedia();
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/hotelAmenity.js');
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/hotelAmenity.css');
}
}

View File

@@ -1,235 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class AdminHotelBedTypesController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'htl_bed_type';
$this->className = 'HotelBedType';
$this->identifier = 'id_bed_type';
$this->context = Context::getContext();
$this->lang = true;
parent::__construct();
$this->_new_list_header_design = true;
// field options for global fields
$this->fields_options = array(
'global' => array(
'title' => $this->l('Dimension Unit Setting'),
'icon' => 'icon-cogs',
'fields' => array(
'WK_DIMENSION_UNIT' => array(
'title' => $this->l('Dimension Unit'),
'type' => 'textLang',
'lang' => true,
'required' => true,
'validation' => 'isGenericName',
'hint' => $this->l('Enter a dimension unit for the bed types.')
),
),
'submit' => array('title' => $this->l('Save'))
),
);
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?'),
'icon' => 'icon-trash'
)
);
}
public function initContent()
{
parent::initContent();
// to customize the view as per our requirements
if ($this->display != 'add' && $this->display != 'edit') {
$this->content = $this->renderOptions();
$this->content .= $this->renderList();
$this->context->smarty->assign('content', $this->content);
}
}
public function initPageHeaderToolbar()
{
if (!$this->display || $this->display == 'list') {
$this->page_header_toolbar_btn['new_product'] = array(
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
'desc' => $this->l('Add new', null, null, false),
'icon' => 'process-icon-new'
);
}
parent::initPageHeaderToolbar();
}
public function initToolbar()
{
$this->toolbar_btn = array();
}
public function renderList()
{
// added here instead of the constructor since the dimension unit will be update afer post processs.
$this->fields_list = array(
'id_bed_type' => array(
'title' => $this->l('ID'),
'align' => 'center',
),
'name' => array(
'title' => $this->l('Name'),
'align' => 'center',
),
'width' => array(
'title' => $this->l('Width'),
'align' => 'center',
'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id)
),
'length' => array(
'title' => $this->l('Lenght'),
'align' => 'center',
'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id)
),
);
return parent::renderList();
}
public function renderForm()
{
if (!$this->loadObject(true)) {
return;
}
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Bed Type'),
'icon' => 'icon-bed'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Bed Type Name'),
'name' => 'name',
'required' => true,
'col' => 4,
'lang' => true,
'hint' => $this->l('Enter the name of Bed type.')
),
array(
'type' => 'text',
'label' => $this->l('Width'),
'name' => 'width',
'required' => true,
'col' => 4,
'hint' => $this->l('Enter the width of the Bed type in ').Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id),
'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id),
),
array(
'type' => 'text',
'label' => $this->l('Length'),
'name' => 'length',
'col' => 4,
'required' => true,
'hint' => $this->l('Enter the length of the Bed type in ').Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id),
'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id),
),
),
'submit' => array(
'title' => $this->l('Save')
),
'buttons' => array(
'save-and-stay' => array(
'title' => $this->l('Save and stay'),
'name' => 'submitAdd'.$this->table.'AndStay',
'type' => 'submit',
'class' => 'btn btn-default pull-right',
'icon' => 'process-icon-save',
),
),
);
return parent::renderForm();
}
public function beforeUpdateOptions()
{
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
$languages = Language::getLanguages(false);
if (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId))
&& Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId)
) {
$this->errors[] = $this->l('Default dimension unit is required at least in ').$objDefaultLanguage['name'];
} else {
foreach ($languages as $lang) {
if (Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang'])
&& (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']))
|| !Validate::isGenericName(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang'])))
) {
$this->errors[] = $this->l('Invalid dimension unit in ').$lang['name'];
}
if (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']))) {
$_POST['WK_DIMENSION_UNIT_'.$lang['id_lang']] = Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId);
}
}
}
}
public function processSave()
{
if (!$this->loadObject(true)) {
return;
}
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
$languages = Language::getLanguages(false);
if (!trim(Tools::getValue('name_'.$defaultLangId))) {
$this->errors[] = $this->l('Bed type name is required at least in ').$objDefaultLanguage['name'];
} else {
foreach ($languages as $lang) {
if (trim(Tools::getValue('name_'.$lang['id_lang'])) && !Validate::isGenericName(Tools::getValue('name_'.$lang['id_lang']))) {
$this->errors[] = $this->l('Invalid bed type name in ').$lang['name'];
}
}
}
if (!(float) Tools::getValue('width')) {
$this->errors[] = $this->l('The width field is required');
}
if (!(float) Tools::getValue('length')) {
$this->errors[] = $this->l('The length field is required');
}
return parent::processSave();
}
}

View File

@@ -31,6 +31,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
protected $date_to;
protected $booking_product;
protected $occupancy;
protected $eventColors;
public function __construct()
{
$this->table = 'htl_booking_detail';
@@ -43,6 +45,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$this->_conf[52] = $this->l('Room in the booking is successfully reallocated');
$this->_conf[53] = $this->l('Room in the booking is successfully swapped');
$this->eventColors = array(
'available' => array('event' => '#7EC77B', 'cell' => '#D9EFD8'),
'partially_available' => array('event' => '#FFC224', 'cell' => '#FFF3CD'),
'booked' => array('event' => '#00AFF0', 'cell' => '#C3E1FB'),
'unavailable' => array('event' => '#FF3838', 'cell' => '#FFC4C4'),
);
}
public function init()
@@ -373,6 +382,11 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$occupancyRequiredForBooking = true;
}
$adminCartsAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminCarts')
);
$this->context->smarty->assign(array(
'adults' => $adults,
'children' => $children,
@@ -386,6 +400,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'link' => $this->context->link,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
'can_add_booking_carts' => (!empty($adminCartsAccess['add']) && (int) $adminCartsAccess['add'] === 1),
'htl_connected_rooms' => HotelConnectedRoom::getConnectedRooms(null, null, $this->id_hotel, $this->context->language->id),
));
@@ -506,13 +521,9 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessGetCalenderData()
public function ajaxProcessGetCalenderData()
{
$events = array();
// No use of adults, child, num_rooms
$adults = 0;
$children = 0;
$num_rooms = 1;
$start_date = date('Y-m-d', strtotime(Tools::getValue('start')));
$last_day_this_month = date('Y-m-d', strtotime(Tools::getValue('end')));
@@ -524,10 +535,6 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$bookingParams = array();
$bookingParams['hotel_id'] = $searchIdHotel;
$bookingParams['id_room_type'] = $searchIdRoomType;
$bookingParams['adults'] = $adults;
$bookingParams['children'] = $children;
$bookingParams['num_rooms'] = $num_rooms;
$bookingParams['for_calendar'] = 1;
$bookingParams['search_available'] = 1;
$bookingParams['search_partial'] = 1;
$bookingParams['search_booked'] = 1;
@@ -538,30 +545,148 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$objBookingDetail = new HotelBookingDetail();
while ($start_date <= $last_day_this_month) {
$cal_date_from = $start_date;
$cal_date_to = date('Y-m-d', strtotime('+1 day', strtotime($cal_date_from)));
$bookingParams['date_from'] = $cal_date_from;
$bookingParams['date_to'] = $cal_date_to;
$eventData = $objBookingDetail->getBookingData($bookingParams);
if (!$eventData) {
$eventData['stats'] = array(
'total_room_type' => 0,
'total_rooms' => 0,
'max_avail_occupancy' => 0,
'num_unavail' => 0,
'num_cart' => 0,
'num_booked' => 0,
'num_avail' => 0,
'num_part_avai' => 0,
$rangeParams = $bookingParams;
$rangeParams['date_from'] = $start_date;
$rangeParams['date_to'] = date('Y-m-d', strtotime('+1 day', strtotime($last_day_this_month)));
$rangeParams['search_available'] = 0;
$rangeParams['search_partial'] = 0;
$bookingData = $objBookingDetail->getBookingData($rangeParams);
$bookedDates = array();
$unavailableDates = array();
$cartDates = array();
$numCart = 0;
if (!empty($bookingData['rm_data'])) {
$roomsByProduct = array();
foreach (HotelRoomInformation::getHotelRoomsInfo($searchIdHotel, $searchIdRoomType) ?: array() as $room) {
$roomsByProduct[$room['id_product']][$room['id']] = array(
'id_room' => $room['id'],
'room_num' => $room['room_num'],
);
}
$eventData['date_format'] = Tools::displayDate($cal_date_from);
$events[strtotime($bookingParams['date_from'])] = array(
foreach ($bookingData['rm_data'] as $key => $roomType) {
$bookingData['rm_data'][$key]['all_rooms'] = isset($roomsByProduct[$roomType['id_product']])
? $roomsByProduct[$roomType['id_product']]
: array();
// booked rooms.
foreach ($roomType['data']['booked'] ?: array() as $bookedRoom) {
foreach ($bookedRoom['detail'] as $detail) {
for (
$d = date('Y-m-d', strtotime($detail['date_from']));
strtotime($d) < strtotime($detail['date_to']);
$d = date('Y-m-d', strtotime('+1 day', strtotime($d)))
) {
$bookedDates[$d][$roomType['id_product']][$bookedRoom['id_room']] = $bookedRoom['id_room'];
}
}
}
// unavailable rooms
foreach ($roomType['data']['unavailable'] ?: array() as $unavailableRoom) {
foreach ($unavailableRoom['detail'] as $detail) {
if ($detail['date_from'] && $detail['date_to']) {
$unavailFrom = $detail['date_from'];
$unavailTo = $detail['date_to'];
} else {
$unavailFrom = $rangeParams['date_from'];
$unavailTo = $rangeParams['date_to'];
}
for (
$d = date('Y-m-d', strtotime($unavailFrom));
strtotime($d) < strtotime($unavailTo);
$d = date('Y-m-d', strtotime('+1 day', strtotime($d)))
) {
$unavailableDates[$d][$roomType['id_product']][$unavailableRoom['id_room']] = $unavailableRoom['id_room'];
}
}
}
// cart-rooms
foreach ($roomType['data']['cart_rooms'] ?: array() as $cartRoom) {
$numCart++;
for (
$d = date('Y-m-d', strtotime($cartRoom['date_from']));
strtotime($d) < strtotime($cartRoom['date_to']);
$d = date('Y-m-d', strtotime('+1 day', strtotime($d)))
) {
$cartDates[$d][$roomType['id_product']][$cartRoom['id_room']] = $cartRoom['id_room'];
}
}
}
}
while ($start_date <= $last_day_this_month) {
$cal_date_from = $start_date;
$stats = array(
'total_room_type' => 0,
'total_rooms' => 0,
'max_avail_occupancy' => 0,
'num_unavail' => 0,
'num_cart' => $numCart,
'num_booked' => 0,
'num_avail' => 0,
'num_part_avai' => 0,
);
if (!empty($bookingData['rm_data'])) {
$stats['total_room_type'] = $bookingData['stats']['total_room_type'];
$stats['total_rooms'] = $bookingData['stats']['total_rooms'];
foreach ($bookingData['rm_data'] as $roomType) {
$allRooms = $roomType['all_rooms'] ?: array();
// available initially all rooms
$available = $allRooms;
$booked = array();
$unavail = array();
// remove booked rooms
if (!empty($bookedDates[$cal_date_from][$roomType['id_product']])) {
$booked = array_intersect_key($allRooms, $bookedDates[$cal_date_from][$roomType['id_product']]);
$available = array_diff_key($available, $booked);
}
// remove unavailable rooms
if (!empty($unavailableDates[$cal_date_from][$roomType['id_product']])) {
$unavail = array_intersect_key($allRooms, $unavailableDates[$cal_date_from][$roomType['id_product']]);
$available = array_diff_key($available, $unavail);
}
// remove cart rooms
if (!empty($cartDates[$cal_date_from][$roomType['id_product']])) {
$available = array_diff_key($available, array_intersect_key($allRooms, $cartDates[$cal_date_from][$roomType['id_product']]));
}
$stats['num_booked'] += count($booked);
$stats['num_unavail'] += count($unavail);
$stats['num_avail'] += count($available);
$stats['max_avail_occupancy'] += count($available) * (int) $roomType['max_guests'];
}
}
$eventData = array(
'stats' => $stats,
'date_format' => Tools::displayDate($cal_date_from),
);
if ($stats['num_avail'] > 0) {
$cellBgColor = $this->eventColors['available']['cell'];
} elseif ($stats['num_part_avai'] > 0) {
$cellBgColor = $this->eventColors['partially_available']['cell'];
} elseif ($stats['num_booked'] == $stats['total_rooms'] && $stats['total_rooms'] != 0) {
$cellBgColor = $this->eventColors['booked']['cell'];
} else {
$cellBgColor = $this->eventColors['unavailable']['cell'];
}
$events[strtotime($cal_date_from)] = array(
'is_notification' => 1,
'title' => $this->l('icon'),
'start' => date('Y-m-d H:i:s', strtotime($bookingParams['date_from'])),
'start' => $cal_date_from,
'display' => 'background',
'backgroundColor' => $cellBgColor,
'data' => $eventData
);
@@ -571,24 +696,25 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$bookingParams['date_to'] = $searchDateTo;
if ($bookingData = $objBookingDetail->getBookingData($bookingParams)) {
if ($bookingData['stats']['num_avail']) {
$eventColor = '#7EC77B';
$title = sprintf($this->l('Available Rooms : %s'), $bookingData['stats']['num_avail']);
$eventColor = $this->eventColors['available']['event'];
$title = sprintf($this->l('%s Available Rooms'), $bookingData['stats']['num_avail']);
} elseif ($bookingData['stats']['num_part_avai']) {
$eventColor = '#FFC224';
$title = sprintf($this->l('Partially Available Rooms : %s'), $bookingData['stats']['num_part_avai']);
$eventColor = $this->eventColors['partially_available']['event'];
$title = sprintf($this->l('%s Partially Available Rooms'), $bookingData['stats']['num_part_avai']);
} elseif ($bookingData['stats']['num_booked'] == $bookingData['stats']['total_rooms'] && $bookingData['stats']['total_rooms'] != 0 && $bookingData['stats']['num_unavail'] == 0) {
$eventColor = $this->eventColors['booked']['event'];
$title = sprintf($this->l('%s Available Rooms'), $bookingData['stats']['num_avail']);
} else {
$eventColor = '#FF3838';
$title = sprintf($this->l('Available Rooms : %s'), $bookingData['stats']['num_avail']);
$eventColor = $this->eventColors['unavailable']['event'];
$title = sprintf($this->l('%s Available Rooms'), $bookingData['stats']['num_avail']);
}
$bookingData['date_from_format'] = Tools::displayDate($searchDateFrom);
$bookingData['date_to_format'] = Tools::displayDate($searchDateTo);
$bookingData['eventColor'] = $eventColor;
$events[] = array(
'title' => $title,
'start' => date('Y-m-d', strtotime($searchDateFrom)),
'end' => date('Y-m-d', strtotime($searchDateTo)),
'backgroundColor' => $eventColor,
'color' => $eventColor,
'textColor' => '#FFF',
'data' => $bookingData
);
}

View File

@@ -1,321 +0,0 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class AdminHotelFeaturesController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'htl_features';
$this->className = 'HotelFeatures';
$this->identifier = 'id';
$this->toolbar_title = $this->l('Manage Hotel Features');
parent::__construct();
$this->display = 'view';
}
public function initToolbar()
{
parent::initToolbar();
$this->page_header_toolbar_btn['addfeatures'] = array(
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
'desc' => $this->l('Add new Features'),
'imgclass' => 'new'
);
}
public function renderView()
{
$objHotelFeatures = new HotelFeatures();
$featuresList = $objHotelFeatures->HotelAllCommonFeaturesArray();
$this->context->smarty->assign('features_list', $featuresList);
return parent::renderView();
}
public function renderForm()
{
if (!$this->loadObject(true)) {
return;
}
$smartyVars = array();
//lang vars
$languages = Language::getLanguages(false);
$currentLangId = $this->default_form_language ? $this->default_form_language : Configuration::get('PS_LANG_DEFAULT');
$currentLang = Language::getLanguage((int) $currentLangId);
$smartyVars['languages'] = $languages;
$smartyVars['currentLang'] = $currentLang;
$smartyVars['ps_img_dir'] = _PS_IMG_.'l/';
if ($id = $this->object->id) {
$smartyVars['edit'] = 1;
if (Validate::isLoadedObject($objFeatures = new HotelFeatures($id))) {
$featureInfo = (array) $objFeatures;
if ($childFeatures = $objFeatures->getChildFeaturesByParentFeatureId($id)) {
$featureInfo['child_features'] = array();
foreach ($childFeatures as $value) {
$objChildFeatures = new HotelFeatures($value['id']);
$featureInfo['child_features'][] = (array) $objChildFeatures;
}
}
$smartyVars['featureInfo'] = $featureInfo;
}
}
$this->context->smarty->assign($smartyVars);
Media::addJsDef(
array(
'currentLang' => $currentLang,
'languages' => $languages,
'img_dir_l' => _PS_IMG_.'l/',
)
);
$this->fields_form = array(
'submit' => array(
'title' => $this->l('Save')
)
);
return parent::renderForm();
}
public function postProcess()
{
if (!$this->loadObject(true)) {
return;
}
if (Tools::isSubmit('submitHtlFeatures') || Tools::isSubmit('submitHtlFeaturesAndStay')) {
$conf = 3;
if ($parentFeatureId = Tools::getValue('id')) {
$conf = 4;
}
$pos = Tools::getValue('position');
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
$languages = Language::getLanguages(false);
if (empty($pos) || !Validate::isUnsignedInt($pos)) {
$this->errors[] = $this->l('Position is Invalid.');
}
if (!trim(Tools::getValue('parent_ftr_name_'.$defaultLangId))) {
$this->errors[] = $this->l('Parent feature name is required at least in ').
$objDefaultLanguage['name'];
} elseif (!Validate::isGenericName(Tools::getValue('parent_ftr_name_'.$defaultLangId))) {
$this->errors[] = $this->l('Parent feature name is invalid.');
} else {
foreach ($languages as $lang) {
// validate non required fields
if (trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) {
if (!Validate::isGenericName(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) {
$this->errors[] = $this->l('Invalid parent feature name in ').$lang['name'];
}
}
}
}
if ($childFeaturesDefLang = Tools::getValue('child_features_'.$defaultLangId)) {
foreach ($childFeaturesDefLang as $kChild => $childftr) {
if (!trim($childftr)) {
$this->errors[] = $this->l('Child features name is required at least in ').
$objDefaultLanguage['name'];
} elseif (!Validate::isGenericName($childftr)) {
$this->errors[] = $this->l('Child features name is invalid : ').Tools::safeOutput($childftr);
} else {
foreach ($languages as $lang) {
if ($childFtrLang = Tools::getValue('child_features_'.$lang['id_lang'])) {
if (!Validate::isGenericName($childFtrLang[$kChild])) {
$this->errors[] = $this->l('Invalid child feature name in ').$lang['name'].
' : '.Tools::safeOutput($childFtrLang[$kChild]);
}
}
}
}
}
} else {
$this->errors[] = $this->l('Please add atleast one Child features.');
}
if (!count($this->errors)) {
if (isset($parentFeatureId) && $parentFeatureId) {
$objHotelFeatures = new HotelFeatures($parentFeatureId);
$childFeatureIds = Tools::getValue('child_feature_id');
foreach ($languages as $lang) {
if (!trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'parent_ftr_name_'.$defaultLangId
);
} else {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'parent_ftr_name_'.$lang['id_lang']
);
}
}
$objHotelFeatures->active = 1;
$objHotelFeatures->position = $pos;
$objHotelFeatures->parent_feature_id = 0;
$objHotelFeatures->save();
if ($childFeaturesDefLang) {
// get previous child features of the parent feature
if ($childFeaturesInfo = $objHotelFeatures->getChildFeaturesByParentFeatureId(
$parentFeatureId
)) {
$prevChildIds = array();
foreach ($childFeaturesInfo as $row) {
$prevChildIds[] = $row['id'];
}
}
$usedFeatures = array();
foreach ($childFeaturesDefLang as $key => $childftr) {
$objHotelFeatures = new HotelFeatures();
// We will only create new child features other wise edit the previous child feature
if ($prevChildIds
&& isset($childFeatureIds[$key])
&& in_array($childFeatureIds[$key], $prevChildIds)
) {
$objHotelFeatures = new HotelFeatures($childFeatureIds[$key]);
// enter child feature id in the used child feature
$usedFeatures[] = $childFeatureIds[$key];
}
foreach ($languages as $lang) {
if (!trim(Tools::getValue('child_features_'.$lang['id_lang'])[$key])) {
$objHotelFeatures->name[$lang['id_lang']] = $childftr;
} else {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'child_features_'.$lang['id_lang']
)[$key];
}
}
$objHotelFeatures->active = 1;
$objHotelFeatures->parent_feature_id = $parentFeatureId;
$objHotelFeatures->save();
}
// delete the child features which are not used now
$notUsedChilds = array_diff($prevChildIds, $usedFeatures);
if ($notUsedChilds = array_diff($prevChildIds, $usedFeatures)) {
foreach ($notUsedChilds as $value) {
if ($value) {
$objHotelFeatures = new HotelFeatures($value);
$objHotelFeatures->delete();
}
}
}
if (Tools::isSubmit('submitHtlFeaturesAndStay')) {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table.
'&conf='.$conf.'&token='.$this->token
);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
} else {
$this->errors[] = $this->l('Some error has been occurred while saving features.');
}
} else {
$objHotelFeatures = new HotelFeatures();
foreach ($languages as $lang) {
if (!trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'parent_ftr_name_'.$defaultLangId
);
} else {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'parent_ftr_name_'.$lang['id_lang']
);
}
}
$objHotelFeatures->active = 1;
$objHotelFeatures->position = $pos;
$objHotelFeatures->parent_feature_id = 0;
$objHotelFeatures->save();
if ($parentFeatureId = $objHotelFeatures->id) {
if ($childFeaturesDefLang) {
foreach ($childFeaturesDefLang as $key => $childftr) {
$objHotelFeatures = new HotelFeatures();
foreach ($languages as $lang) {
if (!trim(Tools::getValue('child_features_'.$lang['id_lang'])[$key])) {
$objHotelFeatures->name[$lang['id_lang']] = $childftr;
} else {
$objHotelFeatures->name[$lang['id_lang']] = Tools::getValue(
'child_features_'.$lang['id_lang']
)[$key];
}
}
$objHotelFeatures->active = 1;
$objHotelFeatures->parent_feature_id = $parentFeatureId;
$objHotelFeatures->save();
}
if (Tools::isSubmit('submitHtlFeaturesAndStay')) {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table.
'&conf='.$conf.'&token='.$this->token
);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
}
} else {
$this->errors[] = $this->l('Some error has been occurred while saving features.');
}
}
}
if ($parentFeatureId) {
$this->display = 'edit';
} else {
$this->display = 'add';
}
}
if (empty($this->errors) || $this->ajax) {
parent::postProcess();
}
}
public function ajaxProcessDeleteFeature()
{
$response = array('status' => false);
if ($this->tabAccess['delete']) {
$idFeature = Tools::getValue('feature_id');
$objHotelFeatures = new HotelFeatures();
if ($objHotelFeatures->deleteHotelFeatures($idFeature)) {
$response['status'] = true;
} else {
$response['msg'] = $this->l('Some error occurred while deleting feature. Please try again.');
}
} else {
$response['msg'] = $this->l('You do not have the permission to delete this.');
}
$this->ajaxDie(json_encode($response));
}
public function setMedia()
{
parent::setMedia();
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
}
}

View File

@@ -26,8 +26,9 @@ require_once 'classes/HotelRoomType.php';
require_once 'classes/HotelRoomInformation.php';
require_once 'classes/HotelBranchInformation.php';
require_once 'classes/HotelImage.php';
require_once 'classes/HotelFeatures.php';
require_once 'classes/HotelBranchFeatures.php';
require_once 'classes/HotelAmenities.php';
require_once 'classes/HotelBranchAmenities.php';
require_once 'classes/HotelRoomTypeAmenities.php';
require_once 'classes/HotelBookingDetail.php';
require_once 'classes/HotelCartBookingData.php';
require_once 'classes/HotelAdvancedPayment.php';
@@ -47,8 +48,6 @@ require_once 'classes/HotelRoomTypeRestrictionDateRange.php';
require_once 'classes/HotelRoomDisableDates.php';
require_once 'classes/HotelBranchRefundRules.php';
require_once 'classes/HotelBedType.php';
require_once 'classes/HotelRoomTypeBedType.php';
require_once 'classes/HotelConnectedRoom.php';
// linked products

View File

@@ -33,7 +33,7 @@ class HotelReservationSystem extends Module
{
$this->name = 'hotelreservationsystem';
$this->tab = 'administration';
$this->version = '1.7.0';
$this->version = '1.7.1';
$this->author = 'Webkul';
$this->need_instance = 0;
$this->bootstrap = true;
@@ -48,7 +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'),
'hotel_features' => array('description' => 'The hotel features','class' => 'HotelFeatures'),
'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'),
'feature_prices' => array('description' => 'Feature prices', 'class' => 'HotelRoomTypeFeaturePricing'),
@@ -473,12 +473,11 @@ class HotelReservationSystem extends Module
$langTables = array(
'htl_room_type_feature_pricing',
'htl_branch_info',
'htl_features',
'htl_amenity',
'htl_room_type_global_demand',
'htl_room_type_global_demand_advance_option',
'htl_order_refund_rules',
'htl_settings_link',
'htl_bed_type'
'htl_settings_link'
);
//If Admin update new language when we do entry in module all lang tables.
HotelHelper::updateLangTables($newIdLang, $langTables);
@@ -520,12 +519,11 @@ class HotelReservationSystem extends Module
$this->installTab('AdminHotelReservationSystemManagement', 'Hotel Reservation System');
$this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelFeatures', 'Manage Hotel Features', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelAmenities', 'Manage Amenities', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminOrderRefundRules', 'Manage Order Refund Rules', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminOrderRefundRequests', 'Manage Order Refund Requests', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelConfigurationSetting', 'General Settings', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelBedTypes', 'Bed Types', 'AdminCatalog');
// Controllers without tabs
$this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
@@ -575,8 +573,7 @@ class HotelReservationSystem extends Module
|| !$this->callInstallTab()
|| !$objHtlHelper->insertDefaultHotelEntries()
|| !$objHtlHelper->createHotelRoomDefaultFeatures()
|| !$objHtlHelper->createHotelDefaultBedTypes()
|| !$objHtlHelper->insertHotelCommonFeatures()
|| !$objHtlHelper->insertHotelCommonAmenities()
) {
return false;
}

View File

@@ -249,10 +249,10 @@ p.room_cat_data
.indi_cont
{
margin: 10px 0px;
display: flex;
align-items: center;
}
.cart-table-thead
{
border-bottom: 1px solid #555!important;
@@ -549,9 +549,6 @@ p.room_cat_data
/* book now full calender */
.fc .fc-daygrid-day.fc-day-today {
background-color: unset;
}
.fc-daygrid-day-top {
justify-content: space-between;}
.fc a.fc-daygrid-day-number {
@@ -563,7 +560,8 @@ p.room_cat_data
color: #FFFFFF;
line-height: 1;
border-radius: 50%;
padding: 5px 8px;
padding: 4px;
margin: 2px 2px 0px 0px;
}
.fc-daygrid-day-top .day-info {
@@ -577,6 +575,57 @@ p.room_cat_data
.fc-today-button:disabled {
display: none;
}
#fullcalendar .fc-daygrid-day-events {
height: 0 ;
min-height: 0;
overflow: visible;
}
#fullcalendar .fc-event.search-result-event:not(.fc-event-start) .fc-event-main {
visibility: hidden;
}
#fullcalendar .fc-event.search-result-event {
background-color: #FFFFFF;
border: none;
border-left: 5px solid;
border-radius: 3px;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05);
margin: 1px 4px;
padding: 2px 4px;
line-height: 1.4;
display: flex;
align-items: center;
overflow: hidden;
}
#fullcalendar .fc-event.search-result-event .fc-event-main {
overflow: hidden;
}
#fullcalendar .fc-event.search-result-event .fc-event-title {
font-size: 14px;
font-weight: 400;
color: #333333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#fullcalendar .fc-event.search-result-event:not(.fc-event-start) {
border-left: none;
padding-left: 13px;
margin-left: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
#fullcalendar .fc-event.search-result-event:not(.fc-event-end) {
margin-right: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.calendar-legend {
display: flex;
justify-content: space-evenly;
align-items: center;
flex-wrap: nowrap;
padding-top: 14px;
}
#room-reallocation-modal .modal-footer {
padding: 15px 0px 0px 0px
@@ -604,4 +653,4 @@ p.room_cat_data
margin-top: 15px;}
.error-border {
outline: rgb(210, 124, 130) solid 1px;
border-radius: 2px;}
border-radius: 2px;}

View File

@@ -0,0 +1,48 @@
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3.0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
*/
/* ---- View ---- */
.htl-amenity-category-heading {
display: flex;
align-items: center;
min-height: 46px;
}
.htl-amenity-category-heading .pull-right {
float: none !important;
margin-left: auto;
order: 2;
}
.htl-amenity-logo-img {
max-height: 32px;
max-width: 32px;
}
/* ---- Form ---- */
.htl-amenity-preview {
margin-bottom: 8px;
}
.htl-amenity-preview img {
max-width: 80px;
max-height: 80px;
border: 1px solid #ddd;
padding: 4px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Some files were not shown because too many files have changed in this diff Show More