Refactor Room Features and Hotel Amenities for QloApps 1.8
This commit is contained in:
@@ -29,119 +29,42 @@
|
||||
<h3>{l s='Assign features to this room type'}</h3>
|
||||
|
||||
<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.'}
|
||||
{l s='Select one value for each room feature. Unselected features will not be displayed for this room type.'}
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="feature-tree-wrapper">
|
||||
{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'}&addfeature_value&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 class="panel panel-default room-feature-group">
|
||||
<div class="panel-heading">
|
||||
<strong>{$available_feature.name|escape:'html':'UTF-8'}</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{if isset($available_feature.featureValues) && $available_feature.featureValues}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="feature_{$available_feature.id_feature}_check" value="" {if !$available_feature.current_item}checked="checked"{/if} />
|
||||
{l s='None'}
|
||||
</label>
|
||||
</div>
|
||||
{foreach from=$available_feature.featureValues item=value}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="feature_{$available_feature.id_feature}_check" value="{$value.id_feature_value|intval}" {if $value.selected}checked="checked"{/if} />
|
||||
{$value.value|escape:'html':'UTF-8'}
|
||||
</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
{else}
|
||||
<p class="text-muted">{l s='No values available for this feature.'}</p>
|
||||
{/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>
|
||||
</div>
|
||||
{foreachelse}
|
||||
<div class="alert alert-warning">
|
||||
<i class="icon-warning-sign"></i> {l s='No features have been defined'}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
<a href="{$link->getAdminLink('AdminFeatures')|escape:'html':'UTF-8'}&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>
|
||||
@@ -152,38 +75,4 @@
|
||||
<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}
|
||||
|
||||
@@ -465,18 +465,44 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="form-group" id="bed_types_selection">
|
||||
<div class="form-group" id="room_type_amenities_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 class="label-tooltip" data-toggle="tooltip" title="{l s='Select the amenities available for this room type.'}">
|
||||
{l s='Amenities'}
|
||||
</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 class="col-sm-9">
|
||||
{if isset($room_type_amenities) && $room_type_amenities}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
{foreach from=$room_type_amenities item=amenity_group}
|
||||
<div class="room-type-amenity-group" style="margin-bottom:15px;">
|
||||
<div class="room-type-amenity-parent" style="font-weight:600; margin-bottom:8px;">
|
||||
{$amenity_group.name|escape:'html':'UTF-8'}
|
||||
</div>
|
||||
{if isset($amenity_group.children) && $amenity_group.children}
|
||||
<div class="row">
|
||||
{foreach from=$amenity_group.children item=amenity}
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="room_type_amenities[]" value="{$amenity.id|intval}" {if isset($amenity.selected) && $amenity.selected}checked="checked"{/if} />
|
||||
{$amenity.name|escape:'html':'UTF-8'}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<div class="alert alert-info">
|
||||
{l s='No amenities have been defined yet.'}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -944,12 +944,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 +1137,162 @@ 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->saveRoomTypeFeatureAssignments($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 saveRoomTypeFeatureAssignments(Product $product)
|
||||
{
|
||||
$product->deleteFeatures();
|
||||
|
||||
$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);
|
||||
} elseif ($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save selected room type amenities.
|
||||
*
|
||||
* @param int $idProduct
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function saveRoomTypeAmenities($idProduct)
|
||||
{
|
||||
$idProduct = (int) $idProduct;
|
||||
$selectedAmenities = Tools::getValue('room_type_amenities', array());
|
||||
if (!is_array($selectedAmenities)) {
|
||||
$selectedAmenities = array($selectedAmenities);
|
||||
}
|
||||
|
||||
$selectedAmenities = array_map('intval', $selectedAmenities);
|
||||
$selectedAmenities = array_values(array_unique(array_filter($selectedAmenities)));
|
||||
|
||||
if (!Db::getInstance()->delete('htl_room_type_features', '`id_product` = '.$idProduct)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($selectedAmenities as $idAmenity) {
|
||||
if (!Db::getInstance()->insert('htl_room_type_features', array(
|
||||
'id_product' => $idProduct,
|
||||
'feature_id' => (int) $idAmenity,
|
||||
'date_add' => date('Y-m-d H:i:s'),
|
||||
'date_upd' => date('Y-m-d H:i:s'),
|
||||
))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected room type amenity ids.
|
||||
*
|
||||
* @param int $idProduct
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getSelectedRoomTypeAmenityIds($idProduct)
|
||||
{
|
||||
$selectedAmenities = Db::getInstance()->executeS(
|
||||
'SELECT `feature_id`
|
||||
FROM `'._DB_PREFIX_.'htl_room_type_features`
|
||||
WHERE `id_product` = '.(int) $idProduct
|
||||
);
|
||||
|
||||
if (!$selectedAmenities) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array_map('intval', array_column($selectedAmenities, 'feature_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare amenities tree data for room type form.
|
||||
*
|
||||
* @param int $idProduct
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRoomTypeAmenitiesTree($idProduct)
|
||||
{
|
||||
$selectedAmenityRows = array();
|
||||
foreach ($this->getSelectedRoomTypeAmenityIds($idProduct) as $selectedAmenityId) {
|
||||
$selectedAmenityRows[] = array('feature_id' => $selectedAmenityId);
|
||||
}
|
||||
|
||||
$objHotelFeatures = new HotelFeatures();
|
||||
$roomTypeAmenities = $objHotelFeatures->HotelBranchSelectedFeaturesArray(
|
||||
$selectedAmenityRows,
|
||||
$this->context->language->id
|
||||
);
|
||||
|
||||
return $roomTypeAmenities ? $roomTypeAmenities : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare grouped core features and values for the room type feature tree.
|
||||
*
|
||||
* @param Product $product
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRoomTypeFeatureTree(Product $product)
|
||||
{
|
||||
$features = Feature::getFeatures(
|
||||
$this->context->language->id,
|
||||
(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) {
|
||||
$feature['current_item'] = isset($selectedFeatureValues[(int) $feature['id_feature']])
|
||||
? $selectedFeatureValues[(int) $feature['id_feature']]
|
||||
: 0;
|
||||
$feature['featureValues'] = FeatureValue::getFeatureValuesWithLang(
|
||||
$this->context->language->id,
|
||||
(int) $feature['id_feature']
|
||||
);
|
||||
|
||||
foreach ($feature['featureValues'] as &$featureValue) {
|
||||
$featureValue['selected'] = ((int) $feature['current_item'] === (int) $featureValue['id_feature_value']);
|
||||
}
|
||||
}
|
||||
|
||||
return $features;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is never called at the moment (specific prices cannot be edited)
|
||||
*/
|
||||
@@ -1924,14 +2046,20 @@ 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('Informations') && !$this->saveRoomTypeAmenities($this->object->id)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving room type amenities.');
|
||||
return false;
|
||||
}
|
||||
if ($this->isTabSubmitted('Features') && !$this->saveRoomTypeFeatureAssignments($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);
|
||||
|
||||
@@ -2109,8 +2237,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if ($object->update()) {
|
||||
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
|
||||
$objHotelRoomTypeBedType->updateRoomTypeBedTypes(Tools::getValue('id_bed_types'), $object->id);
|
||||
if ($this->isTabSubmitted('Informations') && !$this->saveRoomTypeAmenities($object->id)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving room type amenities.');
|
||||
return false;
|
||||
}
|
||||
if ($this->isTabSubmitted('Features') && !$this->saveRoomTypeFeatureAssignments($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'));
|
||||
@@ -2134,9 +2268,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($this->isTabSubmitted('Suppliers')) {
|
||||
// $this->processSuppliers();
|
||||
}
|
||||
if ($this->isTabSubmitted('Features')) {
|
||||
$this->processFeatures();
|
||||
}
|
||||
if ($this->isTabSubmitted('Combinations')) {
|
||||
$this->processProductAttribute();
|
||||
}
|
||||
@@ -4534,15 +4665,15 @@ 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);
|
||||
$roomTypeAmenities = $this->getRoomTypeAmenitiesTree((int) $product->id);
|
||||
if (!is_array($roomTypeAmenities) || empty($roomTypeAmenities)) {
|
||||
$roomTypeAmenities = array();
|
||||
}
|
||||
|
||||
$data->assign('bed_types_info', array());
|
||||
$data->assign('selected_bed_types', array());
|
||||
$data->assign('room_type_amenities', $roomTypeAmenities);
|
||||
|
||||
$this->tpl_form_vars['product'] = $product;
|
||||
$this->tpl_form_vars['custom_form'] = $data->fetch();
|
||||
}
|
||||
@@ -4784,36 +4915,7 @@ 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 = $this->getRoomTypeFeatureTree($obj);
|
||||
$data->assign('available_features', $features);
|
||||
$data->assign('product', $obj);
|
||||
$data->assign('link', $this->context->link);
|
||||
|
||||
@@ -409,19 +409,8 @@ 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');
|
||||
}
|
||||
$roomDynamicFeatures = $this->getRoomDynamicFeatures($this->product->id);
|
||||
$roomDynamicAmenities = $this->getRoomDynamicAmenities($this->product->id);
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
@@ -449,14 +438,12 @@ class ProductControllerCore extends FrontController
|
||||
'hotel_description' => $hotel_info_by_id['description'],
|
||||
'hotel_policies' => $hotel_policies,
|
||||
'hotel_features' => $htl_features,
|
||||
'room_dynamic_features' => $roomDynamicFeatures,
|
||||
'room_dynamic_amenities' => $roomDynamicAmenities,
|
||||
'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),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -580,6 +567,68 @@ class ProductControllerCore extends FrontController
|
||||
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get assigned dynamic room features for the room detail page.
|
||||
*
|
||||
* @param int $idProduct
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRoomDynamicFeatures($idProduct)
|
||||
{
|
||||
$features = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT fl.`name` AS `feature_name`, fvl.`value` AS `feature_value`, f.`position`
|
||||
FROM `'._DB_PREFIX_.'feature_product` fp
|
||||
INNER JOIN `'._DB_PREFIX_.'feature` f ON (f.`id_feature` = fp.`id_feature`)
|
||||
INNER JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||
ON (fl.`id_feature` = fp.`id_feature` AND fl.`id_lang` = '.(int) $this->context->language->id.')
|
||||
INNER JOIN `'._DB_PREFIX_.'feature_value_lang` fvl
|
||||
ON (fvl.`id_feature_value` = fp.`id_feature_value` AND fvl.`id_lang` = '.(int) $this->context->language->id.')
|
||||
WHERE fp.`id_product` = '.(int) $idProduct.'
|
||||
ORDER BY f.`position` ASC, fl.`name` ASC'
|
||||
);
|
||||
|
||||
if (!$features) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($features as $feature) {
|
||||
$result[] = array(
|
||||
'name' => $feature['feature_name'],
|
||||
'value' => $feature['feature_value'],
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get assigned dynamic room amenities for the room detail page.
|
||||
*
|
||||
* @param int $idProduct
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRoomDynamicAmenities($idProduct)
|
||||
{
|
||||
$amenities = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT hfl.`name`
|
||||
FROM `'._DB_PREFIX_.'htl_room_type_features` hrtf
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
|
||||
ON (hfl.`id` = hrtf.`feature_id` AND hfl.`id_lang` = '.(int) $this->context->language->id.')
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_features` hf ON (hf.`id` = hrtf.`feature_id`)
|
||||
WHERE hrtf.`id_product` = '.(int) $idProduct.'
|
||||
ORDER BY hf.`position` ASC, hfl.`name` ASC'
|
||||
);
|
||||
|
||||
if (!$amenities) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $amenities;
|
||||
}
|
||||
|
||||
public function assignRoomServiceProductVars()
|
||||
{
|
||||
// get service products for room type
|
||||
|
||||
@@ -41,6 +41,10 @@ class HotelBedType extends ObjectModel
|
||||
|
||||
public function getAllBedTypes($idLang)
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTables()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$idLang) {
|
||||
$idLang = Context::getContext()->language->id;
|
||||
}
|
||||
@@ -54,9 +58,25 @@ class HotelBedType extends ObjectModel
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTables()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
|
||||
$objHotelRoomTypeBedType->deleteRoomTypeBedTypes($this->id);
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the deprecated bed type schema still exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasLegacyBedTypeTables()
|
||||
{
|
||||
return (bool) Db::getInstance()->getValue(
|
||||
'SHOW TABLES LIKE \'' . pSQL(_DB_PREFIX_.$this->table) . '\''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1139,103 +1139,59 @@ class HotelHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createHotelRoomDefaultFeatures()
|
||||
/**
|
||||
* Seed default core room features and values used by room types.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function seedDefaultDynamicRoomFeatures()
|
||||
{
|
||||
$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->getDefaultDynamicRoomFeatures() 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default room feature/value seed set.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultDynamicRoomFeatures()
|
||||
{
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
public function createHotelDefaultBedTypes()
|
||||
{
|
||||
$htlBedTypes = array(
|
||||
|
||||
@@ -94,12 +94,23 @@ class HotelReservationSystemDb
|
||||
"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,
|
||||
`feature_id` int(10) unsigned NOT 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_room_type_features` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(10) unsigned NOT NULL,
|
||||
`feature_id` int(10) unsigned NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `feature_id` (`feature_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,
|
||||
@@ -494,26 +505,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 +520,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`;",
|
||||
@@ -569,6 +561,41 @@ class HotelReservationSystemDb
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the schema changes required for the dynamic room feature migration.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function migrateToDynamicRoomFeatureSchema()
|
||||
{
|
||||
$sql = array(
|
||||
'UPDATE `'._DB_PREFIX_.'htl_branch_features` SET `feature_id` = NULL WHERE `feature_id` = ""',
|
||||
'ALTER TABLE `'._DB_PREFIX_.'htl_branch_features`
|
||||
MODIFY `feature_id` int(10) unsigned DEFAULT NULL',
|
||||
'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'htl_room_type_features` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(10) unsigned NOT NULL,
|
||||
`feature_id` int(10) unsigned NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `feature_id` (`feature_id`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1',
|
||||
'DROP TABLE IF EXISTS `'._DB_PREFIX_.'htl_room_type_bed_type`',
|
||||
'DROP TABLE IF EXISTS `'._DB_PREFIX_.'htl_bed_type_lang`',
|
||||
'DROP TABLE IF EXISTS `'._DB_PREFIX_.'htl_bed_type`',
|
||||
);
|
||||
|
||||
foreach ($sql as $query) {
|
||||
if (!Db::getInstance()->execute($query)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function dropTables()
|
||||
{
|
||||
return Db::getInstance()->execute(
|
||||
@@ -579,6 +606,7 @@ class HotelReservationSystemDb
|
||||
`'._DB_PREFIX_.'htl_branch_info_lang`,
|
||||
`'._DB_PREFIX_.'htl_image`,
|
||||
`'._DB_PREFIX_.'htl_branch_features`,
|
||||
`'._DB_PREFIX_.'htl_room_type_features`,
|
||||
`'._DB_PREFIX_.'htl_features`,
|
||||
`'._DB_PREFIX_.'htl_features_lang`,
|
||||
`'._DB_PREFIX_.'htl_cart_booking_data`,
|
||||
|
||||
@@ -37,6 +37,10 @@ class HotelRoomTypeBedType extends ObjectModel
|
||||
|
||||
public function getRoomTypeBedTypes($idProduct)
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTable()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.$this->table.'`
|
||||
WHERE `id_product` ='.(int) $idProduct;
|
||||
|
||||
@@ -45,6 +49,10 @@ class HotelRoomTypeBedType extends ObjectModel
|
||||
|
||||
public function updateRoomTypeBedTypes($idBedTypes, $idProduct)
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$res = true;
|
||||
if ($roomTypeBedTypes = $this->getRoomTypeBedTypes($idProduct)) {
|
||||
$roomTypeBedTypes = array_column($roomTypeBedTypes, 'id_room_type_bed_type', 'id_bed_type');
|
||||
@@ -74,6 +82,10 @@ class HotelRoomTypeBedType extends ObjectModel
|
||||
|
||||
public function deleteRoomTypeBedTypesById($idRoomTypeBedTypes)
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$res = true;
|
||||
if ($idRoomTypeBedTypes) {
|
||||
foreach ($idRoomTypeBedTypes as $idRoomTypeBedType) {
|
||||
@@ -87,10 +99,26 @@ class HotelRoomTypeBedType extends ObjectModel
|
||||
|
||||
public function deleteRoomTypeBedTypes($idBedType = false, $idProduct = false)
|
||||
{
|
||||
if (!$this->hasLegacyBedTypeTable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->delete(
|
||||
$this->table,
|
||||
' 1 '.($idBedType ? ' AND `id_bed_type`='.(int) $idBedType : '').($idProduct ? ' AND `id_product`='.(int) $idProduct : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the deprecated room-type bed mapping table still exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasLegacyBedTypeTable()
|
||||
{
|
||||
return (bool) Db::getInstance()->getValue(
|
||||
'SHOW TABLES LIKE \'' . pSQL(_DB_PREFIX_.$this->table) . '\''
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -511,8 +511,7 @@ class HotelReservationSystem extends Module
|
||||
'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);
|
||||
@@ -554,12 +553,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('AdminHotelFeatures', '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);
|
||||
@@ -605,11 +603,11 @@ class HotelReservationSystem extends Module
|
||||
$objHtlHelper = new HotelHelper();
|
||||
if (!parent::install()
|
||||
|| !$objModuleDb->createTables()
|
||||
|| !$objModuleDb->migrateToDynamicRoomFeatureSchema()
|
||||
|| !$this->registerModuleHooks()
|
||||
|| !$this->callInstallTab()
|
||||
|| !$objHtlHelper->insertDefaultHotelEntries()
|
||||
|| !$objHtlHelper->createHotelRoomDefaultFeatures()
|
||||
|| !$objHtlHelper->createHotelDefaultBedTypes()
|
||||
|| !$objHtlHelper->seedDefaultDynamicRoomFeatures()
|
||||
|| !$objHtlHelper->insertHotelCommonFeatures()
|
||||
) {
|
||||
return false;
|
||||
|
||||
@@ -727,9 +727,8 @@ class QloCleaner extends Module
|
||||
array('htl_room_type_service_product', 'id_element', 'product', 'id_product'),
|
||||
array('htl_room_type_service_product_price', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_service_product_price', 'id_element', 'product', 'id_product'),
|
||||
array('htl_bed_type_lang', 'id_lang', 'lang', 'id_lang'),
|
||||
array('htl_room_type_bed_type', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_bed_type', 'id_bed_type', 'htl_bed_type', 'id_bed_type'),
|
||||
array('htl_room_type_features', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_features', 'feature_id', 'htl_features', 'id'),
|
||||
|
||||
)
|
||||
);
|
||||
@@ -831,9 +830,7 @@ class QloCleaner extends Module
|
||||
'htl_room_type_global_demand',
|
||||
'htl_room_type_service_product',
|
||||
'htl_room_type_service_product_price',
|
||||
'htl_bed_type',
|
||||
'htl_bed_type_lang',
|
||||
'htl_room_type_bed_type',
|
||||
'htl_room_type_features',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -262,34 +262,16 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/block}
|
||||
{block name='product_info_tab_room_bed_type'}
|
||||
{if isset($selected_bed_types) && $selected_bed_types && isset($bed_types_info) && $bed_types_info}
|
||||
<div class="info_margin_div">
|
||||
<div class="room_info_heading">
|
||||
<span>{l s='Bed Types'}</span>
|
||||
</div>
|
||||
<div class="room_info_content">
|
||||
{foreach $selected_bed_types as $selected_bed_type}
|
||||
{if isset($bed_types_info[$selected_bed_type])}
|
||||
<p>{$bed_types_info[$selected_bed_type]['name']}: {$bed_types_info[$selected_bed_type]['area']} {l s='sq.'}{$dimension_unit}</p>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/block}
|
||||
{block name='product_info_tab_room_features'}
|
||||
{if isset($features) && $features}
|
||||
{if isset($room_dynamic_features) && $room_dynamic_features}
|
||||
<div class="info_margin_div">
|
||||
<div class="room_info_heading">
|
||||
<span>{l s='Room Features'}</span>
|
||||
</div>
|
||||
<div class="room_info_content row">
|
||||
{foreach from=$features key=ftr_k item=ftr_v}
|
||||
<div class="col-md-3 col-sm-4 col-xs-6">
|
||||
<div class="rm_ftr_wrapper" title="{$ftr_v.name|escape:'html':'UTF-8'}" alt="{$ftr_v.name|escape:'html':'UTF-8'}" >
|
||||
<img src="{$link->getMediaLink("`$ftr_img_src|escape:'html':'UTF-8'`{$ftr_v.value|escape:'html':'UTF-8'}")}"> {$ftr_v.name|escape:'html':'UTF-8'}
|
||||
</div>
|
||||
{foreach from=$room_dynamic_features item=feature}
|
||||
<div class="col-sm-6 col-xs-12">
|
||||
<p><strong>{$feature.name|escape:'html':'UTF-8'}:</strong> {$feature.value|escape:'html':'UTF-8'}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
@@ -299,14 +281,14 @@
|
||||
{* Block for booking products *}
|
||||
{if isset($id_hotel) && $id_hotel}
|
||||
{block name='product_info_tab_hotel_features'}
|
||||
{if isset($hotel_features) && $hotel_features}
|
||||
{if isset($room_dynamic_amenities) && $room_dynamic_amenities}
|
||||
<div class="info_margin_div">
|
||||
<div class="room_info_heading">
|
||||
<span>{l s='Hotel Features'}</span>
|
||||
<span>{l s='Amenities'}</span>
|
||||
</div>
|
||||
<div class="room_info_content row">
|
||||
{foreach from=$hotel_features key=ftr_k item=ftr_v}
|
||||
<div class="col-sm-4 col-xs-12"><i class="circle-small">o</i> {$ftr_v|escape:'html':'UTF-8'}</div>
|
||||
{foreach from=$room_dynamic_amenities item=amenity}
|
||||
<div class="col-sm-4 col-xs-12"><i class="circle-small">o</i> {$amenity.name|escape:'html':'UTF-8'}</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user