Merge pull request #1717 from varunkewlani322/gli-2991

Updated: Hotel amenities, and room features, and added room amenities
This commit is contained in:
Rohit Jain
2026-08-14 20:03:49 +05:30
committed by GitHub
163 changed files with 2287 additions and 2134 deletions

View File

@@ -0,0 +1,124 @@
{**
* 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
*}
{if isset($product->id)}
<div id="product-amenities" class="panel product-tab">
<input type="hidden" name="submitted_tabs[]" value="Amenities" />
<h3>{l s='Amenities'}</h3>
<div class="alert alert-info">
<p>{l s='If you want to add a new amenity, please use the following link.'}
<a href="{$link->getAdminLink('AdminHotelAmenities')|escape:'html':'UTF-8'}" class="btn btn-link button" target="_blank">
<i class="icon-plus-sign"></i> {l s='Manage amenities'} <i class="icon-external-link-sign"></i>
</a>
</p>
</div>
{if isset($room_type_amenities_tree) && $room_type_amenities_tree}
<div class="form-group">
<label for="room-type-amenities-tree" class="control-label col-sm-3">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Select the amenities available for this room type.'}">
{l s='Select amenities'}
</span>
</label>
<div class="col-sm-7 room_features_tree">
{$room_type_amenities_tree}
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Select which of the chosen amenities should be featured for this room type.'}">
{l s='Featured amenities'}
</span>
</label>
<div class="col-sm-7">
<select name="featured_amenities[]" id="rt_featured_amenities" class="form-control" multiple>
</select>
</div>
</div>
{else}
<div class="alert alert-warning">
<i class="icon-warning-sign"></i> {l s='No amenities have been defined yet.'}
</div>
{/if}
<div class="panel-footer">
<a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}{if isset($smarty.request.page) && $smarty.request.page > 1}&amp;submitFilterproduct={$smarty.request.page|intval}{/if}" class="btn btn-default"><i class="process-icon-cancel"></i> {l s='Cancel'}</a>
<button type="submit" name="submitAddproduct" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save'}</button>
<button type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save and stay'}</button>
</div>
</div>
<script type="text/javascript">
(function ($) {
var featuredIds = {if isset($featured_amenity_ids)}{$featured_amenity_ids|json_encode}{else}[]{/if};
var chosenReady = false;
function syncAmenitiesToFeatured() {
var $select = $('#rt_featured_amenities');
var existing = {};
$select.find('option').each(function () {
existing[$(this).val()] = true;
});
$('input[name="room_type_amenities[]"]').each(function () {
var $checkbox = $(this);
var id = $checkbox.val();
var name = $checkbox.siblings('label.tree-toggler').text().trim();
if ($checkbox.is(':checked')) {
if (!existing[id]) {
var selected = featuredIds.indexOf(parseInt(id)) !== -1;
$select.append($('<option></option>').val(id).text(name).prop('selected', selected));
}
} else {
$select.find('option[value="' + id + '"]').remove();
}
});
if (chosenReady) {
$select.trigger('chosen:updated');
}
}
$(document).on('click', '#room-type-amenities-tree :input[type="checkbox"]', function () {
setTimeout(syncAmenitiesToFeatured, 0);
});
$(document).on('click', '#check-all-room-type-amenities-tree, #uncheck-all-room-type-amenities-tree', function () {
setTimeout(syncAmenitiesToFeatured, 0);
});
function initChosen() {
var $select = $('#rt_featured_amenities');
syncAmenitiesToFeatured();
$select.chosen({ disable_search_threshold: 5, search_contains: true });
chosenReady = true;
$select.trigger('chosen:updated');
}
var $tabContent = $('#product-tab-content-Amenities');
if ($tabContent.is(':visible')) {
initChosen();
} else {
$tabContent.one('displayed', initChosen);
}
}(jQuery));
</script>
{/if}

View File

@@ -28,162 +28,35 @@
<input type="hidden" name="submitted_tabs[]" value="Features" />
<h3>{l s='Assign features to this room type'}</h3>
{if isset($room_type_features_tree) && $room_type_features_tree}
<div class="alert alert-info">
{l s='You can specify a value for each relevant feature regarding this room type. Empty fields will not be displayed.'}<br/>
{l s='You can either create a specific value, or select among the existing pre-defined values you\'ve previously added.'}
<p>{l s='If you want to add a new feature, please use the following link.'}
<a href="{$link->getAdminLink('AdminFeatures')|escape:'html':'UTF-8'}" class="btn btn-link button" target="_blank">
<i class="icon-plus-sign"></i> {l s='Add a new feature'} <i class="icon-external-link-sign"></i>
</a>
</p>
</div>
<div class="form-group">
<label for="room-type-features-tree" class="control-label col-sm-3">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Select the feature values available for this room type.'}">
{l s='Select feature values'}
</span>
</label>
<div class="col-sm-7 room_features_tree">
{$room_type_features_tree}
</div>
</div>
{else}
<div class="alert alert-warning">
<i class="icon-warning-sign"></i> {l s='No features have been defined'}
</div>
{/if}
<table class="table">
<thead>
<tr>
<th></th>
<th><span class="title_box">{l s='Feature'}</span></th>
<th><span class="title_box">{l s='Feature Image'}</span></th>
<!-- <th><span class="title_box"><u>{l s='or'}</u> {l s='Customized value'}</span></th> --><!-- by webkul -->
</tr>
</thead>
<tbody>
{foreach from=$available_features item=available_feature}
<tr>
{foreach from=$available_feature.featureValues item=value}
<td>
<input type="checkbox" class="checkbox select_hotel_feature" name="feature_{$available_feature.id_feature}_check" value="{$value.id_feature_value}" {if $available_feature.current_item == $value.id_feature_value}checked="checked"{/if}/>
</td>
<td>{$available_feature.name}</td>
<td>
<input type="hidden" id="feature_{$available_feature.id_feature}_value" name="feature_{$available_feature.id_feature}_value" value="{$value.id_feature_value}">
<img class="img img-responsive" width="15px" src="{$base_url}img/rf/{$value.value}" title="Room image" />
</td>
{/foreach}
{*--<td>
{if sizeof($available_feature.featureValues)}
<select id="feature_{$available_feature.id_feature}_value" name="feature_{$available_feature.id_feature}_value"
onchange="$('.custom_{$available_feature.id_feature}_').val('');">
<option value="0">---</option>
{foreach from=$available_feature.featureValues item=value}
<option value="{$value.id_feature_value}"{if $available_feature.current_item == $value.id_feature_value}selected="selected"{/if} >
{$value.value|truncate:40}
</option>
{/foreach}
</select>
{else}
<input type="hidden" name="feature_{$available_feature.id_feature}_value" value="0" />
<span>{l s='N/A'} -
<a href="{$link->getAdminLink('AdminFeatures')|escape:'html':'UTF-8'}&amp;addfeature_value&amp;id_feature={$available_feature.id_feature}"
class="confirm_leave btn btn-link"><i class="icon-plus-sign"></i> {l s='Add pre-defined values first'} <i class="icon-external-link-sign"></i></a>
</span>
{/if} *}<!-- By Webkul -->
</td>
{* <td>
<div class="row lang-0" style='display: none;'>
<div class="col-lg-9">
<textarea class="custom_{$available_feature.id_feature}_ALL textarea-autosize" name="custom_{$available_feature.id_feature}_ALL"
cols="40" style='background-color:#CCF' rows="1" onkeyup="{foreach from=$languages key=k item=language}$('.custom_{$available_feature.id_feature}_{$language.id_lang}').val($(this).val());{/foreach}" >{$available_feature.val[1].value|escape:'html':'UTF-8'|default:""}</textarea>
</div>
{if $languages|count > 1}
<div class="col-lg-3">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
{l s='ALL'}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{foreach from=$languages item=language}
<li>
<a href="javascript:void(0);" onclick="restore_lng($(this),{$language.id_lang});">{$language.iso_code}</a>
</li>
{/foreach}
</ul>
</div>
{/if}
</div>
{foreach from=$languages key=k item=language}
{if $languages|count > 1}
<div class="row translatable-field lang-{$language.id_lang}">
<div class="col-lg-9">
{/if}
<textarea
class="custom_{$available_feature.id_feature}_{$language.id_lang} textarea-autosize"
name="custom_{$available_feature.id_feature}_{$language.id_lang}"
cols="40"
rows="1"
onkeyup="if (isArrowKey(event)) return ;$('#feature_{$available_feature.id_feature}_value').val(0);" >{$available_feature.val[$language.id_lang].value|escape:'html':'UTF-8'|default:""}</textarea>
{if $languages|count > 1}
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
{$language.iso_code}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" onclick="all_languages($(this));">{l s='ALL'}</a></li>
{foreach from=$languages item=language}
<li>
<a href="javascript:hideOtherLanguage({$language.id_lang});">{$language.iso_code}</a>
</li>
{/foreach}
</ul>
</div>
</div>
{/if}
{/foreach}
</td> *}<!-- By Webkul -->
</tr>
{foreachelse}
<tr>
<td colspan="3" style="text-align:center;"><i class="icon-warning-sign"></i> {l s='No features have been defined'}</td>
</tr>
{/foreach}
</tbody>
</table>
<a href="{$link->getAdminLink('AdminFeatures')|escape:'html':'UTF-8'}&amp;addfeature" class="btn btn-link confirm_leave button">
<i class="icon-plus-sign"></i> {l s='Add a new feature'} <i class="icon-external-link-sign"></i>
</a>
<div class="panel-footer">
<a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}{if isset($smarty.request.page) && $smarty.request.page > 1}&amp;submitFilterproduct={$smarty.request.page|intval}{/if}" class="btn btn-default"><i class="process-icon-cancel"></i> {l s='Cancel'}</a>
<button type="submit" name="submitAddproduct" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save'}</button>
<button type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save and stay'}</button>
</div>
</div>
<script type="text/javascript">
if (tabs_manager.allow_hide_other_languages)
hideOtherLanguage({$default_form_language});
{literal}
$(".textarea-autosize").autosize();
function all_languages(pos)
{
{/literal}
{if isset($languages) && is_array($languages)}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.lang-{$language.id_lang}').addClass('nolang-{$language.id_lang}').removeClass('lang-{$language.id_lang}');
{/foreach}
{/if}
pos.parents('td').find('.translatable-field').hide();
pos.parents('td').find('.lang-0').show();
{literal}
}
function restore_lng(pos,i)
{
{/literal}
{if isset($languages) && is_array($languages)}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.nolang-{$language.id_lang}').addClass('lang-{$language.id_lang}').removeClass('nolang-{$language.id_lang}');
{/foreach}
{/if}
{literal}
pos.parents('td').find('.lang-0').hide();
hideOtherLanguage(i);
}
</script>
{/literal}
{/if}

View File

@@ -465,21 +465,6 @@
</div>
{/if}
<div class="form-group" id="bed_types_selection">
<label class="control-label col-sm-3">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Select all bed types available for this room type.'}">
{l s='Bed Types'}
</span>
</label>
<div class="col-sm-5">
<select name="id_bed_types[]" id="id_bed_types" class="form-control chosen" multiple>
{foreach from=$bed_types_info item=bed_type_info}
<option value="{$bed_type_info['id_bed_type']}" {if isset($selected_bed_types) && in_array($bed_type_info['id_bed_type'], $selected_bed_types)}selected{/if}>{$bed_type_info['name']}</option>
{/foreach}
</select>
</div>
</div>
{* <div class="form-group">
<label class="control-label col-lg-3" for="tags_{$id_lang}">
<span class="label-tooltip" data-toggle="tooltip"

View File

@@ -1,5 +1,4 @@
<?php
/**
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
@@ -19,14 +18,9 @@
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
*}
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;
<div class="tree-panel-heading-controls clearfix">
{if isset($title) && $title}<span class="tree-panel-label-title">{$title}</span>{/if}
{if isset($toolbar)}{$toolbar}{/if}
</div>

View File

@@ -1073,9 +1073,6 @@ class ProductCore extends ObjectModel
if (!$this->deleteServiceInfo()) {
return false;
}
} else {
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$objHotelRoomTypeBedType->deleteRoomTypeBedTypes(false, $this->id);
}
Hook::exec('actionProductDelete', array('id_product' => (int)$this->id, 'product' => $this));
@@ -1083,6 +1080,7 @@ class ProductCore extends ObjectModel
!GroupReduction::deleteProductReduction($this->id) ||
!$this->deleteCategories(true) ||
!$this->deleteProductFeatures() ||
!HotelRoomTypeAmenities::deleteByProduct((int)$this->id) ||
!$this->deleteTags() ||
!$this->deleteAttributesImpacts() ||
!$this->deleteAttachments(false) ||
@@ -6873,4 +6871,55 @@ class ProductCore extends ObjectModel
return $price * (int)$quantity;
}
/**
* Prepare grouped core features and values for a room type, with selection state.
*
* @param int $idProduct
* @param int $idLang defaults to current context language
* @return array
*/
public static function getRoomTypeFeatureTreeData($idProduct, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$product = new self((int) $idProduct);
$features = Feature::getFeatures(
$idLang,
(Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
);
$selectedFeatureValues = array();
foreach ($product->getFeatures() as $productFeature) {
$selectedFeatureValues[(int) $productFeature['id_feature']][] = (int) $productFeature['id_feature_value'];
}
foreach ($features as &$feature) {
$featureValues = FeatureValue::getFeatureValuesWithLang(
$idLang,
(int) $feature['id_feature']
);
$feature['value'] = (int) $feature['id_feature'];
$feature['input_name'] = 'feature_value_parents';
$feature['children'] = array();
$selectedValues = isset($selectedFeatureValues[(int) $feature['id_feature']])
? $selectedFeatureValues[(int) $feature['id_feature']]
: array();
foreach ($featureValues as $featureValue) {
$featureValue['name'] = $featureValue['value'];
$featureValue['value'] = (int) $featureValue['id_feature_value'];
$featureValue['input_name'] = 'feature_values['.(int) $feature['id_feature'].']';
$featureValue['selected'] = in_array((int) $featureValue['id_feature_value'], $selectedValues);
$feature['children'][] = $featureValue;
}
if ($feature['children'] && count($selectedValues) === count($feature['children'])) {
$feature['selected'] = true;
}
}
return $features;
}
}

View File

@@ -91,13 +91,22 @@ class AdminFeaturesControllerCore extends AdminController
parent::__construct();
}
public function init()
{
parent::init();
if (($id = Tools::getValue('id_feature')) && Tools::getIsset('viewfeature')) {
self::$currentIndex .= '&id_feature='.(int)$id.'&viewfeature';
}
}
/**
* AdminController::renderList() override
* @see AdminController::renderList()
*/
public function renderList()
{
/*$this->addRowAction('view');*//*by webkul*/
$this->addRowAction('view');
$this->addRowAction('edit');
$this->addRowAction('delete');
@@ -154,7 +163,6 @@ class AdminFeaturesControllerCore extends AdminController
);
$this->_where = sprintf('AND `id_feature` = %d', (int)$id);
self::$currentIndex = self::$currentIndex.'&id_feature='.(int)$id.'&viewfeature';
$this->processFilter();
return parent::renderList();
}
@@ -322,8 +330,14 @@ class AdminFeaturesControllerCore extends AdminController
break;
case 'view':
$bread_extended[] = $this->feature_name[$this->context->employee->id_lang];
$this->addMetaTitle($bread_extended[count($bread_extended) - 1]);
if (!$this->feature_name && ($id = Tools::getValue('id_feature'))) {
$obj = new Feature((int)$id);
$this->feature_name = $obj->name;
}
if ($this->feature_name) {
$bread_extended[] = $this->feature_name[$this->context->employee->id_lang];
$this->addMetaTitle($bread_extended[count($bread_extended) - 1]);
}
break;
case 'editFeatureValue':
@@ -334,7 +348,7 @@ class AdminFeaturesControllerCore extends AdminController
}
if (Validate::isLoadedObject($obj = new FeatureValue((int)Tools::getValue('id_feature_value')))) {
$bread_extended[] = sprintf($this->l('Edit: %s'), $obj->value[$this->context->employee->id_lang]);
$bread_extended[] = sprintf($this->l('Edit: %s'), $obj->value[$this->context->employee->id_lang]);
}
} else {
$bread_extended[] = $this->l('Edit Value');
@@ -549,13 +563,15 @@ class AdminFeaturesControllerCore extends AdminController
{
$object = parent::processAdd();
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) {
if ($this->table == 'feature_value' && ($this->display == 'edit' || $this->display == 'add')) {
$this->redirect_after = self::$currentIndex.'&addfeature_value&id_feature='.(int)Tools::getValue('id_feature').'&token='.$this->token;
if ('feature_value' === $this->table && !count($this->errors)) {
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && ($this->display == 'edit' || $this->display == 'add')) {
$this->redirect_after = self::$currentIndex.'&addfeature_value&id_feature='.(int)Tools::getValue('id_feature').'&conf=3&token='.$this->token;
} else {
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int) $object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
$this->redirect_after = self::$currentIndex.'&id_feature='.(int)Tools::getValue('id_feature').'&viewfeature&conf=3&token='.$this->token;
}
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && count($this->errors) && $this->table == 'feature_value') { // enter only if feature is submitted
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) {
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int) $object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && count($this->errors) && 'feature_value' === $this->table) { // enter only if feature is submitted
$this->display = 'editFeatureValue';
}
@@ -570,8 +586,14 @@ class AdminFeaturesControllerCore extends AdminController
{
$object = parent::processUpdate();
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) {
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int) Tools::getValue('id_feature').'&conf=4&update'.$this->table.'&token='.$this->token;
if ('feature_value' === $this->table && !count($this->errors)) {
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
$this->redirect_after = self::$currentIndex.'&addfeature_value&id_feature='.(int)Tools::getValue('id_feature').'&conf=4&token='.$this->token;
} else {
$this->redirect_after = self::$currentIndex.'&id_feature='.(int)Tools::getValue('id_feature').'&viewfeature&conf=4&token='.$this->token;
}
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) {
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int)$object->id.'&conf=4&update'.$this->table.'&token='.$this->token;
}
return $object;
@@ -628,24 +650,12 @@ class AdminFeaturesControllerCore extends AdminController
$this->errors[] = $this->l('Some error occurred while uploding room feature logo. Please try again.');
}
}
if ($featureValues = FeatureValue::getFeatureValuesWithLang(
$this->context->language->id,
$objFeature->id
)) {
$objFeatureValue = new FeatureValue($featureValues[0]['id_feature_value']);
} else {
$objFeatureValue = new FeatureValue();
}
$objFeatureValue->id_feature = $objFeature->id;
foreach (Language::getLanguages(true) as $lang) {
$objFeatureValue->value[$lang['id_lang']] = $objFeature->id.'.jpg';
}
$objFeatureValue->save();
return $objFeature;
}
return $objFeature;
}
return parent::processSave();
}
/**

View File

@@ -3326,7 +3326,7 @@ class AdminImportControllerCore extends AdminController
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_image`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_access`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_booking_detail`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_features`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_amenity`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_cart_booking_data`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_refund_rules`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_order_restrict_date`');

View File

@@ -107,6 +107,7 @@ class AdminProductsControllerCore extends AdminController
'Images' => $this->l('Images'),
'ServiceProduct' => $this->l('Service Products'),
// 'Associations' => $this->l('Associations'),
'Amenities' => $this->l('Amenities'),
'Features' => $this->l('Features'),
'Configuration' => $this->l('Rooms'),
'Occupancy' => $this->l('Occupancy'),
@@ -121,9 +122,10 @@ class AdminProductsControllerCore extends AdminController
'Seo' => 2,
// 'Associations' => 3,
'Images' => 4,
'Features' => 5,
'Configuration' => 6,
'Occupancy' => 7,
'Amenities' => 5,
'Features' => 6,
'Configuration' => 7,
'Occupancy' => 8,
'ServiceProduct' => 9,
'LengthOfStay' => 10,
'AdditionalFacilities' => 11,
@@ -944,12 +946,6 @@ class AdminProductsControllerCore extends AdminController
$id_hotel_new = $room_type_info['id_hotel'];
}
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
if ($roomTypeBedTypes = $objHotelRoomTypeBedType->getRoomTypeBedTypes($id_product_old)) {
$roomTypeBedTypes = array_column($roomTypeBedTypes, 'id_bed_type');
$objHotelRoomTypeBedType->updateRoomTypeBedTypes($roomTypeBedTypes, $product->id);
}
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
} else {
@@ -1143,34 +1139,45 @@ class AdminProductsControllerCore extends AdminController
}
if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) {
// delete all objects
$product->deleteFeatures();
// add new objects
$languages = Language::getLanguages(false);
foreach ($_POST as $key => $val) {
if (preg_match('/^feature_([0-9]+)_check/i', $key, $match)) {
if ($val) {
$product->addFeaturesToDB($match[1], $val);
} else {
if ($default_value = $this->checkFeatures($languages, $match[1])) {
$id_value = $product->addFeaturesToDB($match[1], 0, 1);
foreach ($languages as $language) {
if ($cust = Tools::getValue('custom_'.$match[1].'_'.(int)$language['id_lang'])) {
$product->addFeaturesCustomToDB($id_value, (int)$language['id_lang'], $cust);
} else {
$product->addFeaturesCustomToDB($id_value, (int)$language['id_lang'], $default_value);
}
}
}
}
}
if (!$this->saveRoomTypeFeatures($product)) {
$this->errors[] = Tools::displayError('An error occurred while saving room type features.');
}
} else {
$this->errors[] = Tools::displayError('A room type must be created before adding features.');
}
}
/**
* Save assigned core feature values for a room type.
*
* @param Product $product
*
* @return bool
*/
protected function saveRoomTypeFeatures(Product $product)
{
$product->deleteFeatures();
$featureValues = Tools::getValue('feature_values', array());
if (!is_array($featureValues) || empty($featureValues)) {
return true;
}
foreach ($featureValues as $idFeature => $selectedValues) {
$idFeature = (int)$idFeature;
if (!$idFeature) {
continue;
}
foreach (array_unique(array_map('intval', $selectedValues)) as $idFeatureValue) {
if ($idFeatureValue) {
$product->addFeaturesToDB($idFeature, $idFeatureValue);
}
}
}
return true;
}
/**
* This function is never called at the moment (specific prices cannot be edited)
*/
@@ -1925,14 +1932,29 @@ class AdminProductsControllerCore extends AdminController
$this->copyFromPost($this->object, $this->table);
$this->object->booking_product = true;
if ($this->object->add()) {
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$objHotelRoomTypeBedType->updateRoomTypeBedTypes(Tools::getValue('id_bed_types'), $this->object->id);
// associateroom type to hotel
// if ($this->object->is_virtual) {
// }
$this->assignRoomType($this->object);
if ($this->isTabSubmitted('Amenities')) {
$categories = HotelAmenities::getCategories();
if ($categories && !HotelAmenities::getAmenities()) {
$this->errors[] = Tools::displayError('No amenities have been created. Please add amenities to at least one category before assigning them.');
return false;
}
$selectedAmenities = Tools::getValue('room_type_amenities', array());
$featuredAmenities = Tools::getValue('featured_amenities', array());
if (!(new HotelRoomTypeAmenities())->saveRoomTypeAmenities((int)$this->object->id, $selectedAmenities, $featuredAmenities)) {
$this->errors[] = Tools::displayError('An error occurred while saving room type amenities.');
return false;
}
}
if ($this->isTabSubmitted('Features') && !$this->saveRoomTypeFeatures($this->object)) {
$this->errors[] = Tools::displayError('An error occurred while saving room type features.');
return false;
}
PrestaShopLogger::addLog(sprintf($this->l('%s addition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
@@ -2175,8 +2197,18 @@ class AdminProductsControllerCore extends AdminController
}
if ($object->update()) {
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$objHotelRoomTypeBedType->updateRoomTypeBedTypes(Tools::getValue('id_bed_types'), $object->id);
if ($this->isTabSubmitted('Amenities')) {
$selectedAmenities = Tools::getValue('room_type_amenities', array());
$featuredAmenities = Tools::getValue('featured_amenities', array());
if (!(new HotelRoomTypeAmenities())->saveRoomTypeAmenities((int)$object->id, $selectedAmenities, $featuredAmenities)) {
$this->errors[] = Tools::displayError('An error occurred while saving room type amenities.');
return false;
}
}
if ($this->isTabSubmitted('Features') && !$this->saveRoomTypeFeatures($object)) {
$this->errors[] = Tools::displayError('An error occurred while saving room type features.');
return false;
}
// update position in category
$object->setPositionInCategory(Tools::getValue('category_position'));
@@ -2200,9 +2232,6 @@ class AdminProductsControllerCore extends AdminController
if ($this->isTabSubmitted('Suppliers')) {
// $this->processSuppliers();
}
if ($this->isTabSubmitted('Features')) {
$this->processFeatures();
}
if ($this->isTabSubmitted('Combinations')) {
$this->processProductAttribute();
}
@@ -4601,15 +4630,6 @@ class AdminProductsControllerCore extends AdminController
$data->assign('htl_full_info', $hotelFullInfo);
}
$objHotelBedType = new HotelBedType();
$bedTypes = $objHotelBedType->getAllBedTypes($this->context->language->id);
$data->assign('bed_types_info', $bedTypes);
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
if ($selectedBedTypes = $objHotelRoomTypeBedType->getRoomTypeBedTypes($product->id)) {
$selectedBedTypes = array_column($selectedBedTypes, 'id_bed_type');
$data->assign('selected_bed_types', $selectedBedTypes);
}
$this->tpl_form_vars['product'] = $product;
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
@@ -4851,37 +4871,17 @@ class AdminProductsControllerCore extends AdminController
} else {
if ($obj->id) {
if ($this->product_exists_in_shop) {
$features = Feature::getFeatures($this->context->language->id, (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP));
foreach ($features as $k => $tab_features) {
$features[$k]['current_item'] = false;
$features[$k]['val'] = array();
$custom = true;
foreach ($obj->getFeatures() as $tab_products) {
if ($tab_products['id_feature'] == $tab_features['id_feature']) {
$features[$k]['current_item'] = $tab_products['id_feature_value'];
}
}
$features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int)$tab_features['id_feature']);
if (count($features[$k]['featureValues'])) {
foreach ($features[$k]['featureValues'] as $value) {
if ($features[$k]['current_item'] == $value['id_feature_value']) {
$custom = false;
}
}
}
if ($custom) {
$feature_values_lang = FeatureValue::getFeatureValueLang($features[$k]['current_item']);
foreach ($feature_values_lang as $feature_value) {
$features[$k]['val'][$feature_value['id_lang']] = $feature_value;
}
}
$features = Product::getRoomTypeFeatureTreeData($obj->id);
if ($features) {
$tree = new HelperTree('room-type-features-tree', $features);
$tree->setShowCollapseExpandButton(true)
->setUseCheckBox(true)
->setAutoSelectChildren(true)
->setUseBulkActions(true)
->setUseSearch(true)
->setHeaderTemplate('tree_header_room.tpl');
$data->assign('room_type_features_tree', $tree->render());
}
$data->assign('available_features', $features);
$data->assign('product', $obj);
$data->assign('link', $this->context->link);
$data->assign('default_form_language', $this->default_form_language);
@@ -4895,6 +4895,50 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
/**
* Prepare the amenities form tab for a room type.
*
* @param Product $obj
*
* @throws Exception
* @throws SmartyException
*/
public function initFormAmenities($obj)
{
if (!$this->default_form_language) {
$this->getLanguages();
}
$data = $this->createTemplate($this->tpl_form);
$data->assign('default_form_language', $this->default_form_language);
$data->assign('languages', $this->_languages);
$data->assign('link', $this->context->link);
$data->assign('product', $obj);
if ($obj->id) {
if ($this->product_exists_in_shop) {
$roomTypeAmenities = HotelRoomTypeAmenities::getRoomTypeAmenitiesTreeData((int) $obj->id);
if ($roomTypeAmenities) {
$tree = new HelperTree('room-type-amenities-tree', $roomTypeAmenities);
$tree->setShowCollapseExpandButton(true)
->setUseCheckBox(true)
->setAutoSelectChildren(true)
->setUseBulkActions(true)
->setUseSearch(true)
->setHeaderTemplate('tree_header_room.tpl');
$data->assign('room_type_amenities_tree', $tree->render());
$data->assign('featured_amenity_ids', array_column(HotelRoomTypeAmenities::getAmenities((int)$obj->id, 0, true), 'id'));
}
} else {
$this->displayWarning($this->l('You must save the room type in this shop before adding amenities.'));
}
} else {
$this->displayWarning($this->l('You must save this room type before adding amenities.'));
}
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
public function getModalDuplicateOptions()
{
$idsHotel = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);

View File

@@ -38,7 +38,7 @@ class AdminSearchControllerCore extends AdminController
'AdminOrderRefundRules' => 1,
'AdminRoomTypeGlobalDemand' => 1,
'AdminGroups' => 1,
'AdminHotelFeatures' => 1,
'AdminHotelAmenities' => 1,
'AdminCustomers' => 1,
'AdminAddHotel' => 1,
'AdminNormalProducts' => 1,
@@ -190,7 +190,7 @@ class AdminSearchControllerCore extends AdminController
if (!$searchType) {
$this->searchAddress();
$this->searchHotelFeatures();
$this->searchHotelAmenities();
$this->searchAdditionalFacilities();
$this->searchRefundRules();
}
@@ -428,23 +428,23 @@ class AdminSearchControllerCore extends AdminController
}
}
public function searchHotelFeatures()
public function searchHotelAmenities()
{
if (class_exists('HotelFeatures')) {
if (isset($this->controllerAccess['AdminHotelFeatures']) && $this->controllerAccess['AdminHotelFeatures']) {
$objHotelFeatures = new HotelFeatures();
if ($hotelFeatures = $objHotelFeatures->searchByName($this->query, $this->context->language->id)) {
$features = array();
foreach ($hotelFeatures as $key => $hotelFeature) {
$features[$hotelFeature['id']]['name'] = $hotelFeature['name'];
if ($hotelFeature['parent_feature_id']) {
$features[$hotelFeature['id']]['id'] = $hotelFeature['parent_feature_id'];
if (class_exists('HotelAmenities')) {
if (isset($this->controllerAccess['AdminHotelAmenities']) && $this->controllerAccess['AdminHotelAmenities']) {
$objHotelAmenities = new HotelAmenities();
if ($hotelAmenities = $objHotelAmenities->searchByName($this->query, $this->context->language->id)) {
$amenities = array();
foreach ($hotelAmenities as $key => $hotelAmenity) {
$amenities[$hotelAmenity['id_amenity']]['name'] = $hotelAmenity['name'];
if ($hotelAmenity['id_parent']) {
$amenities[$hotelAmenity['id_amenity']]['id'] = $hotelAmenity['id_parent'];
} else {
$features[$hotelFeature['id']]['id'] = $hotelFeature['id'];
$amenities[$hotelAmenity['id_amenity']]['id'] = $hotelAmenity['id_amenity'];
}
}
$this->_list['hotel_features'] = $features;
$this->_list['hotel_amenities'] = $amenities;
}
}
}
@@ -681,10 +681,10 @@ class AdminSearchControllerCore extends AdminController
);
}
protected function initHotelFeatureList()
protected function initHotelAmenityList()
{
$this->show_toolbar = false;
$this->fields_list['hotel_features'] = array(
$this->fields_list['hotel_amenities'] = array(
'name' => array('title' => $this->l('name'), 'width' => 'auto'),
);
}
@@ -929,26 +929,26 @@ class AdminSearchControllerCore extends AdminController
$this->tpl_view_vars['customers'] = $view;
}
if (isset($this->_list['hotel_features']) && count($this->_list['hotel_features'])) {
if (isset($this->_list['hotel_amenities']) && count($this->_list['hotel_amenities'])) {
$view = '';
$this->initHotelFeatureList();
$this->initHotelAmenityList();
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->identifier = 'id';
$helper->identifier = 'id_amenity';
$helper->actions = array('edit', 'view');
$helper->show_toolbar = false;
$helper->table = 'htl_features';
$helper->currentIndex = $this->context->link->getAdminLink('AdminHotelFeatures', false);
$helper->token = Tools::getAdminTokenLite('AdminHotelFeatures');
$helper->table = 'htl_amenity';
$helper->currentIndex = $this->context->link->getAdminLink('AdminHotelAmenities', false);
$helper->token = Tools::getAdminTokenLite('AdminHotelAmenities');
if ($this->_list['hotel_features']) {
$view = $helper->generateList($this->_list['hotel_features'], $this->fields_list['hotel_features']);
if ($this->_list['hotel_amenities']) {
$view = $helper->generateList($this->_list['hotel_amenities'], $this->fields_list['hotel_amenities']);
}
$this->tpl_view_vars['num_hotel_features'] = count($this->_list['hotel_features']);
$this->tpl_view_vars['hotel_features'] = $view;
$this->tpl_view_vars['num_hotel_amenities'] = count($this->_list['hotel_amenities']);
$this->tpl_view_vars['hotel_amenities'] = $view;
}
if (isset($this->_list['groups']) && count($this->_list['groups'])) {
$view = '';

View File

@@ -245,7 +245,6 @@ class CategoryControllerCore extends FrontController
}
}
$feat_img_dir = _PS_IMG_.'rf/';
$ratting_img = _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png';
$this->context->smarty->assign(array(
'warning_num' => $warning_num,
@@ -258,7 +257,7 @@ class CategoryControllerCore extends FrontController
'display_all_room_types' => $displayAllRoomsTypes,
'id_hotel' => $id_hotel,
'currency' => $currency,
'feat_img_dir' => $feat_img_dir,
'amenity_img_dir' => _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/',
'ratting_img' => $ratting_img,
));

View File

@@ -352,12 +352,12 @@ class ProductControllerCore extends FrontController
$hotel_location = $addressInfo['city'].
($addressInfo['id_state']?', '.$addressInfo['state']:'').', '.$addressInfo['country'];
$obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
$obj_hotel_amenities_ids = $obj_hotel_branch->getAmenitiesOfHotelByHotelId($hotel_id);
if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
foreach ($obj_hotel_feaures_ids as $key => $value) {
$obj_htl_ftr = new HotelFeatures();
$htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
if (isset($obj_hotel_amenities_ids) && $obj_hotel_amenities_ids) {
foreach ($obj_hotel_amenities_ids as $key => $value) {
$obj_htl_amenity = new HotelAmenities();
$htl_info = $obj_htl_amenity->getAmenityInfoById($value['amenity_id']);
$htl_features[] = $htl_info['name'];
}
}
@@ -415,19 +415,9 @@ class ProductControllerCore extends FrontController
}
}
$objHotelBedType = new HotelBedType();
if ($bedTypes = $objHotelBedType->getAllBedTypes($this->context->language->id)) {
foreach ($bedTypes as $bedTypeKey => $bedType) {
$bedTypes[$bedTypeKey]['area'] = Tools::ps_round($bedType['width'], 2).' * '.Tools::ps_round($bedType['length'], 2);
}
$bedTypes = array_column($bedTypes, null, 'id_bed_type');
}
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
if ($selectedBedTypes = $objHotelRoomTypeBedType->getRoomTypeBedTypes($this->product->id)) {
$selectedBedTypes = array_column($selectedBedTypes, 'id_bed_type');
}
$roomFeatures = $this->product->getFrontFeatures($this->context->language->id);
$roomAmenities = HotelRoomTypeAmenities::getAmenities($this->product->id, $this->context->language->id);
$hotelAmenities = HotelBranchAmenities::getAmenities($hotel_id, $this->context->language->id);
$this->context->smarty->assign(
array(
@@ -455,14 +445,14 @@ class ProductControllerCore extends FrontController
'hotel_description' => $hotel_info_by_id['description'],
'hotel_policies' => $hotel_policies,
'hotel_features' => $htl_features,
'room_type_features' => $roomFeatures,
'room_dynamic_amenities' => $roomAmenities,
'hotel_dynamic_amenities' => $hotelAmenities,
'amenity_img_dir' => _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/',
'hotel_image_link' => $hotelImageLink,
'hotel_has_images' => (bool) HotelImage::getCover($hotel_id),
'ftr_img_src' => _PS_IMG_.'rf/',
'order_date_restrict' => $order_date_restrict,
'PS_SERVICE_PRODUCT_CATEGORY_FILTER' => Configuration::get('PS_SERVICE_PRODUCT_CATEGORY_FILTER'),
'bed_types_info' => $bedTypes,
'selected_bed_types' => $selectedBedTypes,
'dimension_unit' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id),
)
);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
img/rf/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/rf/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
img/rf/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
img/rf/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 524 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/rf/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
img/rf/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -831,7 +831,7 @@ CREATE TABLE `PREFIX_feature_product` (
`id_feature` int(10) unsigned NOT NULL,
`id_product` int(10) unsigned NOT NULL,
`id_feature_value` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_feature`,`id_product`),
PRIMARY KEY (`id_feature`,`id_product`,`id_feature_value`),
KEY `id_feature_value` (`id_feature_value`),
KEY `id_product` (`id_product`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION;

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

@@ -1779,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;
}

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

@@ -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

@@ -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

@@ -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

@@ -604,4 +604,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

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