Merge pull request #1188 from vishal-singh-webkul/gli-2055_3
Updated: Hotel features assigning process in the back office.
This commit is contained in:
@@ -86,16 +86,27 @@
|
||||
|
||||
{if isset($auto_select_children) && $auto_select_children == true}
|
||||
$('#{$id|escape:'html':'UTF-8'}').find(':input[type=checkbox]').on('click', function(){
|
||||
if ($(this).is(":checked")) {
|
||||
$(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
|
||||
$(this).prop('checked', true);
|
||||
$(this).parent().addClass('tree-selected');
|
||||
});
|
||||
} else {
|
||||
$(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
|
||||
$(this).prop('checked', false);
|
||||
$(this).parent().removeClass('tree-selected');
|
||||
});
|
||||
if ($(this).closest('.tree-item').length ==0) {
|
||||
if ($(this).is(":checked")) {
|
||||
$(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
|
||||
$(this).prop('checked', true);
|
||||
$(this).parent().addClass('tree-selected');
|
||||
});
|
||||
} else {
|
||||
$(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
|
||||
$(this).prop('checked', false);
|
||||
$(this).parent().removeClass('tree-selected');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ($(this).closest('.tree-item').length) {
|
||||
if (!$(this).is(":checked")) {
|
||||
$(this).parents('.tree-folder').find(':input[type=checkbox]:first').each(function(){
|
||||
$(this).prop('checked', false);
|
||||
$(this).parent().removeClass('tree-selected');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
{/if}
|
||||
|
||||
@@ -171,6 +171,36 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
$smartyVars['order_restrict_date_info'] = $restrictDateInfo;
|
||||
$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);
|
||||
$tree->setShowCollapseExpandButton(true)
|
||||
->setUseCheckBox(true)
|
||||
->setAutoSelectChildren(true)
|
||||
->setUseBulkActions(true);
|
||||
$treeContent = $tree->render();
|
||||
$smartyVars['hotel_feature_tree'] = $treeContent;
|
||||
}
|
||||
} else {
|
||||
$idCountry = Tools::getValue('hotel_country');
|
||||
}
|
||||
@@ -226,6 +256,7 @@ 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());
|
||||
|
||||
// check if field is atleast in default language. Not available in default prestashop
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
@@ -640,6 +671,12 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$objHotelOrderRestrictDate->preparation_time = $preparationTime;
|
||||
}
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to 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 <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class AdminAssignHotelFeaturesController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'htl_branch_features';
|
||||
$this->className = 'HotelBranchFeatures';
|
||||
$this->identifier = 'id';
|
||||
$this->context = Context::getContext();
|
||||
|
||||
// START send access query information to the admin controller
|
||||
$this->access_select = ' SELECT a.`id` FROM '._DB_PREFIX_.'htl_branch_features a';
|
||||
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'htl_branch_info hbi ON (hbi.id = a.id_hotel)';
|
||||
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
|
||||
$this->access_where = ' WHERE hbi.id IN ('.implode(',', $acsHtls).')';
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hi ON (hi.`id` = a.`id_hotel`)';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hil
|
||||
ON (hi.`id` = hil.`id` AND hil.id_lang = '.(int)$this->context->language->id.')';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'address` addr ON (addr.`id_hotel` = hi.`id`)';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = addr.`id_state`)';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = addr.`id_country`
|
||||
AND cl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
|
||||
$this->_select .= 'addr.`city` as htl_city, hi.`id` as htl_id, hil.`hotel_name` as htl_name,
|
||||
s.`name` as `state_name`, cl.`name`';
|
||||
$this->_group = 'GROUP BY a.`id_hotel`';
|
||||
|
||||
$this->fields_list = array(
|
||||
'htl_id' => array(
|
||||
'title' => $this->l('Hotel ID'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'hi!id',
|
||||
),
|
||||
'htl_name' => array(
|
||||
'title' => $this->l('Hotel Name'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'hil!hotel_name',
|
||||
),
|
||||
'htl_city' => array(
|
||||
'title' => $this->l('City'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'addr!city',
|
||||
),
|
||||
|
||||
'state_name' => array(
|
||||
'title' => $this->l('State'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 's!name',
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Country'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'cl!name',
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Date Added'),
|
||||
'align' => 'center',
|
||||
'type' => 'datetime',
|
||||
'filter_key' => 'a!date_add',
|
||||
)
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'icon' => 'icon-trash',
|
||||
'confirm' => $this->l('Delete selected items?')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
$this->page_header_toolbar_btn['new_feature'] = array(
|
||||
'href' => $this->context->link->getAdminLink('AdminHotelFeatures'),
|
||||
'desc' => $this->l('Hotel Features'),
|
||||
'imgclass' => 'back'
|
||||
);
|
||||
|
||||
$this->page_header_toolbar_btn['assignfeatures'] = array(
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Assign Features'),
|
||||
'imgclass' => 'new'
|
||||
);
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$smartyVars = array();
|
||||
if ($this->display == 'add') {
|
||||
$objHotelFeatures = new HotelFeatures();
|
||||
$featuresList = $objHotelFeatures->HotelAllCommonFeaturesArray();
|
||||
$objBranchInfo = new HotelBranchInformation();
|
||||
$unassignedFtrsHotels = $objBranchInfo->getUnassignedFeaturesHotelIds();
|
||||
// filter hotels as per accessed hotels
|
||||
$unassignedFtrsHotels = HotelBranchInformation::filterDataByHotelAccess(
|
||||
$unassignedFtrsHotels,
|
||||
$this->context->employee->id_profile,
|
||||
1
|
||||
);
|
||||
|
||||
$smartyVars['hotels'] = $unassignedFtrsHotels;
|
||||
$smartyVars['features_list'] = $featuresList;
|
||||
} elseif ($this->display == 'edit') {
|
||||
$id = Tools::getValue('id');
|
||||
$objBranchFeatures = new HotelBranchFeatures($id);
|
||||
$smartyVars['edit'] = 1;
|
||||
$objHotelFeatures = new HotelFeatures();
|
||||
$objBranchInfo = new HotelBranchInformation();
|
||||
|
||||
$features_hotel = $objBranchInfo->getFeaturesOfHotelByHotelId($objBranchFeatures->id_hotel);
|
||||
$featuresList = $objHotelFeatures->HotelBranchSelectedFeaturesArray($features_hotel);
|
||||
|
||||
$hotels = $objBranchInfo->hotelsNameAndId();
|
||||
$smartyVars['hotel_id'] = $objBranchFeatures->id_hotel;
|
||||
$smartyVars['hotels'] = $hotels;
|
||||
$smartyVars['features_list'] = $featuresList;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
|
||||
$this->fields_form = array(
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save')
|
||||
)
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function processSave()
|
||||
{
|
||||
if ($editId = Tools::getValue('edit_hotel_id')) {
|
||||
$objBranchFeatures = new HotelBranchFeatures();
|
||||
$objBranchFeatures->deleteBranchFeaturesByHotelId($editId);
|
||||
}
|
||||
if (!$hotelFeatures = Tools::getValue('hotel_fac')) {
|
||||
$this->errors[] = $this->l('Please select at least one feature to assign to a hotel.');
|
||||
}
|
||||
if (!$idHotel = Tools::getValue('id_hotel')) {
|
||||
$this->errors[] = $this->l('Please select a hotel first.');
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
$objHotelFeatures = new HotelBranchFeatures();
|
||||
if (!$objHotelFeatures->assignFeaturesToHotel($idHotel, $hotelFeatures)) {
|
||||
$this->errors[] = $this->l('Some problem occure while assigning Features to the hotel.');
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id='.(int)$idHotel.'&update'.$this->table.'&conf=3&token='.$this->token
|
||||
);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->display = 'add';
|
||||
}
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
$object = $this->loadObject();
|
||||
if ($object->id) {
|
||||
$objBranchFeatures = new HotelBranchFeatures();
|
||||
$objBranchFeatures->deleteBranchFeaturesByHotelId($object->id_hotel);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while deleting the object.').'<b>'.$this->table.'</b> '.
|
||||
$this->l('(cannot load object)');
|
||||
}
|
||||
parent::processDelete();
|
||||
}
|
||||
|
||||
protected function processBulkDelete()
|
||||
{
|
||||
if (is_array($this->boxes) && !empty($this->boxes)) {
|
||||
foreach ($this->boxes as $key => $value) {
|
||||
$objBranchFeatures = new HotelBranchFeatures($value);
|
||||
$objBranchFeatures->deleteBranchFeaturesByHotelId($objBranchFeatures->id_hotel);
|
||||
}
|
||||
parent::processBulkDelete();
|
||||
} else {
|
||||
$this->errors[] = $this->l('You must select at least one element to delete.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,6 @@ class AdminHotelFeaturesController extends ModuleAdminController
|
||||
'desc' => $this->l('Add new Features'),
|
||||
'imgclass' => 'new'
|
||||
);
|
||||
|
||||
$this->page_header_toolbar_btn['new'] = array(
|
||||
'href' => $this->context->link->getAdminLink('AdminAssignHotelFeatures'),
|
||||
'desc' => $this->l('Assign Features To Hotel'),
|
||||
);
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
|
||||
@@ -577,7 +577,6 @@ class HotelReservationSystem extends Module
|
||||
$this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false);
|
||||
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
|
||||
$this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', 'AdminHotelConfigurationSetting', false);
|
||||
$this->installTab('AdminAssignHotelFeatures', 'Assign Hotel Features', false, false);
|
||||
$this->installTab('AdminBookingDocument', 'Booking Documents', false, false);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -83,6 +83,12 @@
|
||||
{l s='Refund Policies' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#hotel-features" data-toggle="tab">
|
||||
<i class="icon-list-alt"></i>
|
||||
{l s='Features' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
{hook h='displayAdminAddHotelFormTab' id_hotel=$hook_arg_id_hotel}
|
||||
</ul>
|
||||
<div class="tab-content panel collapse in">
|
||||
@@ -488,6 +494,29 @@
|
||||
|
||||
{hook h='displayAdminAddHotelFormRefundPoliciesTabAfter' id_hotel=$hook_arg_id_hotel}
|
||||
</div>
|
||||
<div class="tab-pane" id="hotel-features">
|
||||
{hook h='displayAdminAddHotelFormFeaturesTabBefore' id_hotel=$hook_arg_id_hotel}
|
||||
{if isset($hotel_feature_tree)}
|
||||
<div class="form-group">
|
||||
<label for="hotel_feature" class="control-label col-sm-3">
|
||||
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title='{l s='Select features for this hotel.' mod='hotelreservationsystem'}'>{l s='Select feature' mod='hotelreservationsystem'}</span>
|
||||
</label>
|
||||
<div class="col-xs-7 hotel_features_tree">
|
||||
{$hotel_feature_tree}
|
||||
</div>
|
||||
</div>
|
||||
{elseif isset($hotel_info.id) && $hotel_info.id}
|
||||
<div class="alert alert-warning">
|
||||
{l s='No features created yet.' mod='hotelreservationsystem'} {l s='You can create features by visiting ' mod='hotelreservationsystem'} <a target="_blank" href="{$link->getAdminLink('AdminHotelFeatures')}">{l s='manage hotel features.' mod='hotelreservationsystem'}</a>
|
||||
</div>
|
||||
{else}
|
||||
<div class="alert alert-warning">
|
||||
{l s='Please save hotel information before assigning hotel features.' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{hook h='displayAdminAddHotelFormFeaturesTabAfter' id_hotel=$hook_arg_id_hotel}
|
||||
</div>
|
||||
{hook h='displayAdminAddHotelFormTabContent' id_hotel=$hook_arg_id_hotel}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user