Merge branch 'webkul:develop' into fix-disable-dates
This commit is contained in:
@@ -135,6 +135,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$smartyVars['type'] = 'non_orderd';
|
||||
}
|
||||
}
|
||||
$smartyVars['link'] = $this->context->link;
|
||||
|
||||
$tpl = $this->createTemplate('_orders.tpl');
|
||||
$tpl->assign($smartyVars);
|
||||
|
||||
@@ -81,17 +81,18 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'title' => $this->l('Position'),
|
||||
'filter_key' => 'sa!position',
|
||||
'position' => 'position',
|
||||
'align' => 'center'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-xs',
|
||||
'align' => 'center',
|
||||
'ajax' => true,
|
||||
'orderby' => false
|
||||
)
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
// 'active' => array(
|
||||
// 'title' => $this->l('Displayed'),
|
||||
// 'active' => 'status',
|
||||
// 'type' => 'bool',
|
||||
// 'class' => 'fixed-width-xs',
|
||||
// 'align' => 'center',
|
||||
// 'ajax' => true,
|
||||
// 'orderby' => false
|
||||
// )
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
@@ -369,49 +370,49 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function renderKpis()
|
||||
{
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
// public function renderKpis()
|
||||
// {
|
||||
// $time = time();
|
||||
// $kpis = array();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-disabled-categories';
|
||||
$helper->icon = 'icon-off';
|
||||
$helper->color = 'color1';
|
||||
$helper->title = $this->l('Disabled Categories', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_categories';
|
||||
$kpis[] = $helper->generate();
|
||||
// $helper = new HelperKpi();
|
||||
// $helper->id = 'box-disabled-categories';
|
||||
// $helper->icon = 'icon-off';
|
||||
// $helper->color = 'color1';
|
||||
// $helper->title = $this->l('Disabled Categories', null, null, false);
|
||||
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_categories';
|
||||
// $kpis[] = $helper->generate();
|
||||
|
||||
// $helper = new HelperKpi();
|
||||
// $helper->id = 'box-empty-categories';
|
||||
// $helper->icon = 'icon-bookmark-empty';
|
||||
// $helper->color = 'color2';
|
||||
// $helper->href = $this->context->link->getAdminLink('AdminTracking');
|
||||
// $helper->title = $this->l('Empty Categories', null, null, false);
|
||||
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=empty_categories';
|
||||
// $kpis[] = $helper->generate();
|
||||
// // $helper = new HelperKpi();
|
||||
// // $helper->id = 'box-empty-categories';
|
||||
// // $helper->icon = 'icon-bookmark-empty';
|
||||
// // $helper->color = 'color2';
|
||||
// // $helper->href = $this->context->link->getAdminLink('AdminTracking');
|
||||
// // $helper->title = $this->l('Empty Categories', null, null, false);
|
||||
// // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=empty_categories';
|
||||
// // $kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-top-category';
|
||||
$helper->icon = 'icon-money';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Top Category', null, null, false);
|
||||
$helper->subtitle = $this->l('30 days', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=top_category';
|
||||
$kpis[] = $helper->generate();
|
||||
// $helper = new HelperKpi();
|
||||
// $helper->id = 'box-top-category';
|
||||
// $helper->icon = 'icon-money';
|
||||
// $helper->color = 'color3';
|
||||
// $helper->title = $this->l('Top Category', null, null, false);
|
||||
// $helper->subtitle = $this->l('30 days', null, null, false);
|
||||
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=top_category';
|
||||
// $kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-products-per-category';
|
||||
$helper->icon = 'icon-search';
|
||||
$helper->color = 'color4';
|
||||
$helper->title = $this->l('Average number of products per category', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=products_per_category';
|
||||
$kpis[] = $helper->generate();
|
||||
// $helper = new HelperKpi();
|
||||
// $helper->id = 'box-products-per-category';
|
||||
// $helper->icon = 'icon-search';
|
||||
// $helper->color = 'color4';
|
||||
// $helper->title = $this->l('Average number of products per category', null, null, false);
|
||||
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=products_per_category';
|
||||
// $kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpiRow();
|
||||
$helper->kpis = $kpis;
|
||||
return $helper->generate();
|
||||
}
|
||||
// $helper = new HelperKpiRow();
|
||||
// $helper->kpis = $kpis;
|
||||
// return $helper->generate();
|
||||
// }
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
@@ -421,7 +422,7 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$obj = $this->loadObject(true);
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$selected_categories = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? (int)$obj->id_parent : (int)Tools::getValue('id_parent', Category::getRootCategory()->id));
|
||||
$selected_categories = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? (int)$obj->id_parent : (int)Tools::getValue('id_parent', Configuration::get('PS_SERVICE_CATEGORY')));
|
||||
$unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
|
||||
$guest = new Group(Configuration::get('PS_GUEST_GROUP'));
|
||||
$default = new Group(Configuration::get('PS_CUSTOMER_GROUP'));
|
||||
@@ -479,25 +480,25 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'class' => 'copy2friendlyUrl',
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Displayed'),
|
||||
'name' => 'active',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
)
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Displayed'),
|
||||
// 'name' => 'active',
|
||||
// 'required' => false,
|
||||
// 'is_bool' => true,
|
||||
// 'values' => array(
|
||||
// array(
|
||||
// 'id' => 'active_on',
|
||||
// 'value' => 1,
|
||||
// 'label' => $this->l('Enabled')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'active_off',
|
||||
// 'value' => 0,
|
||||
// 'label' => $this->l('Disabled')
|
||||
// )
|
||||
// )
|
||||
// ),
|
||||
array(
|
||||
'type' => 'categories',
|
||||
'label' => $this->l('Parent category'),
|
||||
@@ -509,80 +510,80 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'root_category' => Configuration::get('PS_SERVICE_CATEGORY')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description'),
|
||||
'name' => 'description',
|
||||
'autoload_rte' => true,
|
||||
'lang' => true,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Category Cover Image'),
|
||||
'name' => 'image',
|
||||
'display_image' => true,
|
||||
'image' => $image_url ? $image_url : false,
|
||||
'size' => $image_size,
|
||||
'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->_category->id.'&token='.$this->token.'&deleteImage=1',
|
||||
'hint' => $this->l('This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'),
|
||||
'format' => $format['category']
|
||||
),
|
||||
array(
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Category thumbnail'),
|
||||
'name' => 'thumb',
|
||||
'display_image' => true,
|
||||
'image' => $thumb_url ? $thumb_url : false,
|
||||
'size' => $thumb_size,
|
||||
'format' => $format['medium']
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Meta title'),
|
||||
'name' => 'meta_title',
|
||||
'maxchar' => 70,
|
||||
'lang' => true,
|
||||
'rows' => 5,
|
||||
'cols' => 100,
|
||||
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Meta description'),
|
||||
'name' => 'meta_description',
|
||||
'maxchar' => 160,
|
||||
'lang' => true,
|
||||
'rows' => 5,
|
||||
'cols' => 100,
|
||||
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'tags',
|
||||
'label' => $this->l('Meta keywords'),
|
||||
'name' => 'meta_keywords',
|
||||
'lang' => true,
|
||||
'hint' => $this->l('To add "tags," click in the field, write something, and then press "Enter."').' '.$this->l('Forbidden characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Friendly URL'),
|
||||
'name' => 'link_rewrite',
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'hint' => $this->l('Only letters, numbers, underscore (_) and the minus (-) character are allowed.')
|
||||
),
|
||||
array(
|
||||
'type' => 'group',
|
||||
'label' => $this->l('Group access'),
|
||||
'name' => 'groupBox',
|
||||
'values' => Group::getGroups(Context::getContext()->language->id),
|
||||
'info_introduction' => $this->l('You now have three default customer groups.'),
|
||||
'unidentified' => $unidentified_group_information,
|
||||
'guest' => $guest_group_information,
|
||||
'customer' => $default_group_information,
|
||||
'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.')
|
||||
)
|
||||
// array(
|
||||
// 'type' => 'textarea',
|
||||
// 'label' => $this->l('Description'),
|
||||
// 'name' => 'description',
|
||||
// 'autoload_rte' => true,
|
||||
// 'lang' => true,
|
||||
// 'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'file',
|
||||
// 'label' => $this->l('Category Cover Image'),
|
||||
// 'name' => 'image',
|
||||
// 'display_image' => true,
|
||||
// 'image' => $image_url ? $image_url : false,
|
||||
// 'size' => $image_size,
|
||||
// 'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->_category->id.'&token='.$this->token.'&deleteImage=1',
|
||||
// 'hint' => $this->l('This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'),
|
||||
// 'format' => $format['category']
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'file',
|
||||
// 'label' => $this->l('Category thumbnail'),
|
||||
// 'name' => 'thumb',
|
||||
// 'display_image' => true,
|
||||
// 'image' => $thumb_url ? $thumb_url : false,
|
||||
// 'size' => $thumb_size,
|
||||
// 'format' => $format['medium']
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Meta title'),
|
||||
// 'name' => 'meta_title',
|
||||
// 'maxchar' => 70,
|
||||
// 'lang' => true,
|
||||
// 'rows' => 5,
|
||||
// 'cols' => 100,
|
||||
// 'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'textarea',
|
||||
// 'label' => $this->l('Meta description'),
|
||||
// 'name' => 'meta_description',
|
||||
// 'maxchar' => 160,
|
||||
// 'lang' => true,
|
||||
// 'rows' => 5,
|
||||
// 'cols' => 100,
|
||||
// 'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'tags',
|
||||
// 'label' => $this->l('Meta keywords'),
|
||||
// 'name' => 'meta_keywords',
|
||||
// 'lang' => true,
|
||||
// 'hint' => $this->l('To add "tags," click in the field, write something, and then press "Enter."').' '.$this->l('Forbidden characters:').' <>;=#{}'
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Friendly URL'),
|
||||
// 'name' => 'link_rewrite',
|
||||
// 'lang' => true,
|
||||
// 'required' => true,
|
||||
// 'hint' => $this->l('Only letters, numbers, underscore (_) and the minus (-) character are allowed.')
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'group',
|
||||
// 'label' => $this->l('Group access'),
|
||||
// 'name' => 'groupBox',
|
||||
// 'values' => Group::getGroups(Context::getContext()->language->id),
|
||||
// 'info_introduction' => $this->l('You now have three default customer groups.'),
|
||||
// 'unidentified' => $unidentified_group_information,
|
||||
// 'guest' => $guest_group_information,
|
||||
// 'customer' => $default_group_information,
|
||||
// 'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.')
|
||||
// )
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
@@ -736,6 +737,13 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('The category cannot be a parent of itself.');
|
||||
}
|
||||
}
|
||||
// @todo remove this after adding link_rewrite form option
|
||||
// currently have removed link_rewrite as it is currently not required
|
||||
// so adding link_rewrite in $_POST
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
$_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang']));
|
||||
}
|
||||
|
||||
$object = parent::processAdd();
|
||||
|
||||
//if we create a you root category you have to associate to a shop before to add sub categories in. So we redirect to AdminCategories listing
|
||||
@@ -745,6 +753,22 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
// @todo remove this after adding link_rewrite form option
|
||||
// currently have removed link_rewrite as it is currently not required
|
||||
// so adding link_rewrite in $_POST
|
||||
if (!Validate::isLoadedObject($this->object)) {
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
$_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang']));
|
||||
}
|
||||
} else {
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
$_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function setDeleteMode()
|
||||
{
|
||||
if ($this->delete_mode == 'link' || $this->delete_mode == 'linkanddisable') {
|
||||
|
||||
@@ -175,8 +175,6 @@ class AdminEmployeesControllerCore extends AdminController
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
|
||||
if (empty($this->display)) {
|
||||
$this->page_header_toolbar_btn['new_employee'] = array(
|
||||
'href' => self::$currentIndex.'&addemployee&token='.$this->token,
|
||||
@@ -195,6 +193,8 @@ class AdminEmployeesControllerCore extends AdminController
|
||||
$this->toolbar_title);
|
||||
}
|
||||
}
|
||||
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
|
||||
@@ -139,9 +139,9 @@ class AdminGeolocationControllerCore extends AdminController
|
||||
{
|
||||
$this->display = 'options';
|
||||
if (!$this->isGeoLiteCityAvailable()) {
|
||||
$this->displayWarning($this->l('In order to use Geolocation, please download').'
|
||||
<a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.
|
||||
$this->l('and extract it (using Winrar or Gzip) into the /tools/geoip/ directory.'));
|
||||
$this->displayWarning($this->l('In order to use Geolocation, please download the file').'
|
||||
<a href="https://github.com/mbcc2006/GeoLiteCity-data/blob/master/GeoLiteCity.dat" target="_blank">GeoLiteCity.dat</a> '.
|
||||
$this->l('from GitHub and copy into the /tools/geoip/ directory.'));
|
||||
Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
|
||||
$this->imageType = 'jpg';
|
||||
$this->_defaultOrderBy = 'position';
|
||||
$this->_defaultOrderBy = 'id_product';
|
||||
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
$this->allow_export = true;
|
||||
@@ -99,7 +99,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
$this->available_tabs_lang = array(
|
||||
'Informations' => $this->l('Information'),
|
||||
'Prices' => $this->l('Prices'),
|
||||
'Seo' => $this->l('SEO'),
|
||||
// 'Seo' => $this->l('SEO'),
|
||||
'Images' => $this->l('Images'),
|
||||
'Associations' => $this->l('Associations'),
|
||||
);
|
||||
@@ -108,7 +108,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
$this->available_tabs = array_merge($this->available_tabs, array(
|
||||
'Informations' => 0,
|
||||
'Prices' => 1,
|
||||
'Seo' => 2,
|
||||
// 'Seo' => 2,
|
||||
'Associations' => 3,
|
||||
'Images' => 4,
|
||||
));
|
||||
@@ -948,7 +948,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
$id_groups = Tools::getValue('spm_id_group');
|
||||
$id_customers = Tools::getValue('spm_id_customer');
|
||||
$prices = Tools::getValue('spm_price');
|
||||
$from_quantities = Tools::getValue('spm_from_quantity');
|
||||
$from_quantities = 1;
|
||||
$reductions = Tools::getValue('spm_reduction');
|
||||
$reduction_types = Tools::getValue('spm_reduction_type');
|
||||
$froms = Tools::getValue('spm_from');
|
||||
@@ -1939,7 +1939,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
if ($this->isTabSubmitted('Prices')) {
|
||||
// $this->processAdvancedPayment();
|
||||
$this->processPriceAddition();
|
||||
// $this->processSpecificPricePriorities();
|
||||
$this->processSpecificPricePriorities();
|
||||
}
|
||||
if ($this->isTabSubmitted('Images')) {
|
||||
$this->processImageLegends();
|
||||
@@ -2016,6 +2016,20 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
|
||||
// we have removed seo tab as it is currently not required, but in product object requires link_rewrite
|
||||
// so adding link_rewrite in $_POST
|
||||
if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) {
|
||||
foreach ($languages as $lang) {
|
||||
$_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang']));
|
||||
}
|
||||
} else {
|
||||
foreach ($languages as $lang) {
|
||||
$_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']];
|
||||
}
|
||||
}
|
||||
// end
|
||||
|
||||
// Check required fields
|
||||
foreach ($rules['required'] as $field) {
|
||||
if (!$this->isProductFieldUpdated($field)) {
|
||||
@@ -2855,13 +2869,12 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
$tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories');
|
||||
$tree->setTemplate('tree_associated_categories.tpl')
|
||||
->setHeaderTemplate('tree_associated_header.tpl')
|
||||
->setRootCategory((int)Configuration::get('PS_PRODUCTS_CATEGORY'))
|
||||
->setRootCategory((int)Configuration::get('PS_SERVICE_CATEGORY'))
|
||||
->setUseCheckBox(true)
|
||||
->setUseSearch(false)
|
||||
->setFullTree(0)
|
||||
->setSelectedCategories($categories)
|
||||
->setUseBulkActions(false);
|
||||
// ->setDisablAllCategories(true);
|
||||
|
||||
$data->assign(array('default_category' => $default_category,
|
||||
'selected_cat_ids' => implode(',', array_keys($selected_cat)),
|
||||
|
||||
@@ -72,7 +72,7 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
),
|
||||
'GLOBAL_PREPARATION_TIME' => array(
|
||||
'title' => $this->l('Preparation time'),
|
||||
'hint' => $this->l('Number of days required to prepare a room for stay.'),
|
||||
'hint' => $this->l('Number of days required to prepare a room for a guest\'s stay. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'),
|
||||
'desc' => $this->l('Set to 0 to disable this feature.'),
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xl',
|
||||
|
||||
@@ -252,7 +252,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$occupancyRequiredForBooking = false;
|
||||
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
$occupancyRequiredForBooking = true;
|
||||
}
|
||||
|
||||
@@ -2695,10 +2695,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->context->cart = $cart;
|
||||
$this->context->customer = new Customer($order->id_customer);
|
||||
|
||||
if ($order->with_occupancy) {
|
||||
$objRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($id_product);
|
||||
}
|
||||
/*By Webkul to make entries in HotelCartBookingData */
|
||||
$hotel_room_info_arr = $hotel_room_data['rm_data'][$idProduct]['data']['available'];
|
||||
$chkQty = 0;
|
||||
@@ -2708,7 +2704,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
$objCartBookingData->id_cart = $this->context->cart->id;
|
||||
$objCartBookingData->id_guest = $this->context->cookie->id_guest;
|
||||
$objCartBookingData->id_customer = $this->context->customer->id;
|
||||
$objCartBookingData->id_customer = $order->id_customer;
|
||||
$objCartBookingData->id_currency = $order->id_currency;
|
||||
$objCartBookingData->id_product = $room_info['id_product'];
|
||||
$objCartBookingData->id_room = $room_info['id_room'];
|
||||
@@ -2724,8 +2720,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objCartBookingData->children = $room_occupancy['children'];
|
||||
$objCartBookingData->child_ages = $room_occupancy['children'] ? json_encode($room_occupancy['child_ages']) : json_encode(array());
|
||||
} else {
|
||||
$objCartBookingData->adults = $roomTypeInfo['adults'];
|
||||
$objCartBookingData->children = $roomTypeInfo['children'];
|
||||
$objCartBookingData->adults = $room_info_by_id_product['adults'];
|
||||
$objCartBookingData->children = $room_info_by_id_product['children'];
|
||||
$objCartBookingData->child_ages = json_encode(array());
|
||||
}
|
||||
$objCartBookingData->save();
|
||||
@@ -3036,7 +3032,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDetail->id_cart = $this->context->cart->id;
|
||||
$objBookingDetail->id_room = $objCartBookingData->id_room;
|
||||
$objBookingDetail->id_hotel = $objCartBookingData->id_hotel;
|
||||
$objBookingDetail->id_customer = $this->context->customer->id;
|
||||
$objBookingDetail->id_customer = $order->id_customer;
|
||||
$objBookingDetail->booking_type = $objCartBookingData->booking_type;
|
||||
$objBookingDetail->id_status = 1;
|
||||
$objBookingDetail->comment = $objCartBookingData->comment;
|
||||
@@ -3247,10 +3243,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
if ($order->with_occupancy) {
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
}
|
||||
|
||||
/*By webkul to validate fields before deleting the cart and order data form the tables*/
|
||||
if ($id_hotel == '') {
|
||||
@@ -3308,30 +3306,36 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid quantity.'),
|
||||
)));
|
||||
} elseif (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of adults.'),
|
||||
)));
|
||||
} elseif (!Validate::isUnsignedInt($children)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of children.'),
|
||||
)));
|
||||
}
|
||||
if ($children > 0) {
|
||||
if (!isset($child_ages) || ($children != count($child_ages))) {
|
||||
|
||||
// validations if order is with occupancy
|
||||
if ($order->with_occupancy) {
|
||||
if (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please provide all children age.'),
|
||||
'error' => Tools::displayError('Invalid number of adults.'),
|
||||
)));
|
||||
} else {
|
||||
foreach($child_ages as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid children age.'),
|
||||
)));
|
||||
} elseif (!Validate::isUnsignedInt($children)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of children.'),
|
||||
)));
|
||||
}
|
||||
|
||||
if ($children > 0) {
|
||||
if (!isset($child_ages) || ($children != count($child_ages))) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please provide all children age.'),
|
||||
)));
|
||||
} else {
|
||||
foreach($child_ages as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid children age.'),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5264,6 +5268,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!Validate::isUnsignedInt($qty)) {
|
||||
$this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.');
|
||||
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
|
||||
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
|
||||
}
|
||||
} else {
|
||||
$qty = 1;
|
||||
|
||||
@@ -146,8 +146,8 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => array(
|
||||
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
|
||||
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
|
||||
array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
|
||||
array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
|
||||
),
|
||||
'identifier' => 'id',
|
||||
),
|
||||
@@ -181,8 +181,8 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => array(
|
||||
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
|
||||
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
|
||||
array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
|
||||
array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
|
||||
),
|
||||
'identifier' => 'id',
|
||||
),
|
||||
@@ -442,11 +442,11 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if (Tools::getValue('PS_FRONT_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
|
||||
$_POST['PS_FRONT_ROOM_UNIT_SELECTION_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
|
||||
$_POST['PS_FRONT_ROOM_UNIT_SELECTION_TYPE'] = HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
|
||||
}
|
||||
|
||||
if (Tools::getValue('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
|
||||
$_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
|
||||
$_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
|
||||
}
|
||||
|
||||
if (Tools::getIsset('PS_CATALOG_MODE')) {
|
||||
|
||||
@@ -2081,7 +2081,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// shreesh check if product is virtual, then set categories according to hotel
|
||||
// if (Tools::getValue('is_virtual')) {
|
||||
$id_hotel = Tools::getValue('id_hotel');
|
||||
if (!$id_hotel || !Validate::isUnsignedInt($id_hotel)) {
|
||||
|
||||
@@ -82,12 +82,16 @@ class AdminSearchControllerCore extends AdminController
|
||||
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders'));
|
||||
} else {
|
||||
$row = get_object_vars($order);
|
||||
$row['id_order'] = $row['id'];
|
||||
$customer = $order->getCustomer();
|
||||
$row['customer'] = $customer->firstname.' '.$customer->lastname;
|
||||
$order_state = $order->getCurrentOrderState();
|
||||
$row['osname'] = $order_state->name[$this->context->language->id];
|
||||
$this->_list['orders'] = array($row);
|
||||
$idHotel = HotelBookingDetail::getIdHotelByIdOrder($row['id']);
|
||||
if (in_array($idHotel, HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) {
|
||||
$row['id_order'] = $row['id'];
|
||||
$customer = $order->getCustomer();
|
||||
$row['customer'] = $customer->firstname.' '.$customer->lastname;
|
||||
$order_state = $order->getCurrentOrderState();
|
||||
$row['osname'] = $order_state->name[$this->context->language->id];
|
||||
$this->_list['orders'] = array($row);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$orders = Order::getByReference($this->query);
|
||||
@@ -99,12 +103,15 @@ class AdminSearchControllerCore extends AdminController
|
||||
foreach ($orders as $order) {
|
||||
/** @var Order $order */
|
||||
$row = get_object_vars($order);
|
||||
$row['id_order'] = $row['id'];
|
||||
$customer = $order->getCustomer();
|
||||
$row['customer'] = $customer->firstname.' '.$customer->lastname;
|
||||
$order_state = $order->getCurrentOrderState();
|
||||
$row['osname'] = $order_state->name[$this->context->language->id];
|
||||
$this->_list['orders'][] = $row;
|
||||
$idHotel = HotelBookingDetail::getIdHotelByIdOrder($row['id']);
|
||||
if (in_array($idHotel, HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) {
|
||||
$row['id_order'] = $row['id'];
|
||||
$customer = $order->getCustomer();
|
||||
$row['customer'] = $customer->firstname.' '.$customer->lastname;
|
||||
$order_state = $order->getCurrentOrderState();
|
||||
$row['osname'] = $order_state->name[$this->context->language->id];
|
||||
$this->_list['orders'][] = $row;
|
||||
}
|
||||
}
|
||||
} elseif ($searchType == 3) {
|
||||
$this->errors[] = Tools::displayError('No order was found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
|
||||
@@ -162,7 +169,15 @@ class AdminSearchControllerCore extends AdminController
|
||||
public function searchCatalog()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->_list['products'] = Product::searchByName($this->context->language->id, $this->query);
|
||||
if ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query)) {
|
||||
$objRoomType = new HotelRoomType();
|
||||
foreach ($this->_list['products'] as $key => $product) {
|
||||
$roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
|
||||
if (!in_array($roomInfo['id_hotel'], HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) {
|
||||
unset($this->_list['products'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
|
||||
}
|
||||
|
||||
@@ -299,9 +314,8 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['products'] = array(
|
||||
'id_product' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'manufacturer_name' => array('title' => $this->l('Manufacturer'), 'align' => 'center', 'width' => 200),
|
||||
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
|
||||
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
|
||||
'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
|
||||
@@ -350,7 +364,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
}
|
||||
$this->tpl_view_vars['categories'] = $categories;
|
||||
}
|
||||
if (isset($this->_list['products']) && count($this->_list['products'])) {
|
||||
if (isset($this->_list['products']) && $this->_list['products']&& count($this->_list['products'])) {
|
||||
$view = '';
|
||||
$this->initProductList();
|
||||
|
||||
@@ -376,6 +390,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
$view = $helper->generateList($this->_list['products'], $this->fields_list['products']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_products'] = count($this->_list['products']);
|
||||
$this->tpl_view_vars['products'] = $view;
|
||||
}
|
||||
if (isset($this->_list['customers']) && count($this->_list['customers'])) {
|
||||
@@ -398,6 +413,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
}
|
||||
$view = $helper->generateList($this->_list['customers'], $this->fields_list['customers']);
|
||||
}
|
||||
$this->tpl_view_vars['num_customers'] = count($this->_list['customers']);
|
||||
$this->tpl_view_vars['customers'] = $view;
|
||||
}
|
||||
if (isset($this->_list['orders']) && count($this->_list['orders'])) {
|
||||
@@ -417,6 +433,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
if ($this->_list['orders']) {
|
||||
$view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']);
|
||||
}
|
||||
$this->tpl_view_vars['num_orders'] = count($this->_list['orders']);
|
||||
$this->tpl_view_vars['orders'] = $view;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
if (!$distinct_products) {
|
||||
return '0%';
|
||||
}
|
||||
return round(100 * $distinct_products / AdminStatsController::getTotalProducts()).'%';
|
||||
return round(100 * $distinct_products / AdminStatsController::getTotalRoomTypes()).'%';
|
||||
}
|
||||
|
||||
public static function getOrders($date_from, $date_to, $granularity = false, $id_hotel = false)
|
||||
@@ -354,7 +354,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
public static function getCustomerMainGender()
|
||||
{
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT SUM(IF(g.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral
|
||||
SELECT SUM(IF(c.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral
|
||||
FROM `'._DB_PREFIX_.'customer` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'gender` g ON c.id_gender = g.id_gender
|
||||
WHERE c.active = 1 '.Shop::addSqlRestriction());
|
||||
@@ -1176,9 +1176,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getArrivalsInfoByDate($date, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
$sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`)
|
||||
WHERE hbd.`is_refunded` = 0 AND hbd.`date_from` = "'.pSQL($date).' 00:00:00"
|
||||
AND hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_IN.'
|
||||
@@ -1191,9 +1192,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getDeparturesInfoByDate($date, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
$sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`)
|
||||
WHERE hbd.`is_refunded` = 0 AND hbd.`date_to` = "'.pSQL($date).' 00:00:00"
|
||||
AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.
|
||||
@@ -1205,9 +1207,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getInHousesInfo($idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
$sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`)
|
||||
WHERE hbd.`is_refunded` = 0 AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
@@ -1220,7 +1223,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
{
|
||||
$sql = 'SELECT hbd.`id_customer`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
COUNT(hbd.`id`) AS total_rooms, SUM(hbd.`adults` + hbd.`children`) AS total_guests,
|
||||
hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name`
|
||||
hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`with_occupancy`, o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name`
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl
|
||||
@@ -1237,8 +1240,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
public static function getCancellationsInfoByDate($date, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT orr.`id_order_return`, orr.`id_customer`, hbd.`room_num`, hbd.`id_product`, hbd.`room_type_name`,
|
||||
CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
hbd.`id_hotel`, hbd.`hotel_name`, SUM(hbd.`adults` + hbd.`children`) AS total_guests,
|
||||
o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, hbd.`id_hotel`,
|
||||
hbd.`hotel_name`, SUM(hbd.`adults` + hbd.`children`) AS total_guests,
|
||||
hbd.`date_from`, hbd.`date_to`, orr.`id_order`
|
||||
FROM `'._DB_PREFIX_.'order_return` orr
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (ord.`id_order_return` = orr.`id_order_return`)
|
||||
@@ -1665,9 +1668,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
|
||||
$sql = 'SELECT SUM(total_paid_tax_excl)
|
||||
$sql = 'SELECT SUM(total_paid_tax_excl - refunded_amount)
|
||||
FROM (
|
||||
SELECT o.`id_order`, o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl,
|
||||
IFNULL(orr.`refunded_amount`, 0) AS refunded_amount,
|
||||
(SELECT hbd.`id_hotel`
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
@@ -1677,6 +1681,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
ON (hbd.`id_order` = o.`id_order`)
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi
|
||||
ON (hbi.`id` = hbd.`id_hotel`)
|
||||
LEFT JOIN `' ._DB_PREFIX_.'order_return` orr
|
||||
ON (orr.`id_order` = o.`id_order`)
|
||||
WHERE o.`valid` = 1 AND hbi.`active` = 1 AND hbd.`is_refunded` = 0
|
||||
AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
|
||||
AND o.`source` = "'.pSQL(Configuration::get('PS_SHOP_DOMAIN')).'"'.
|
||||
|
||||
@@ -716,8 +716,6 @@ class AdminThemesControllerCore extends AdminController
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
|
||||
if (empty($this->display)) {
|
||||
$this->page_header_toolbar_btn['import_theme'] = array(
|
||||
'href' => self::$currentIndex.'&action=importtheme&token='.$this->token,
|
||||
@@ -746,6 +744,8 @@ class AdminThemesControllerCore extends AdminController
|
||||
|
||||
$title = implode(' '.Configuration::get('PS_NAVIGATION_PIPE').' ', $this->toolbar_title);
|
||||
$this->page_header_toolbar_title = $title;
|
||||
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
private function checkParentClass($name)
|
||||
|
||||
@@ -50,6 +50,19 @@ class AddressControllerCore extends FrontController
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize address controller
|
||||
* @see FrontController::init()
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->context->customer->id) {
|
||||
$this->_address = new Address(Customer::getCustomerIdAddress($this->context->customer->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start forms process
|
||||
* @see FrontController::postProcess()
|
||||
|
||||
@@ -170,6 +170,8 @@ class AuthControllerCore extends FrontController
|
||||
'informations' => $this->informations,
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'hasAjaxExtraData' => !empty($this->ajaxExtraData),
|
||||
'ajaxExtraData' => $this->ajaxExtraData,
|
||||
'page' => $this->context->smarty->fetch($this->template),
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
@@ -416,309 +418,314 @@ class AuthControllerCore extends FrontController
|
||||
if (Validate::isEmail($email = Tools::getValue('email')) && !empty($email)) {
|
||||
if (Customer::customerExists($email)) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered.', false);
|
||||
} elseif (Customer::customerExists($email, false, false)) {
|
||||
$this->errors[] = Tools::displayError('You are already registered as a guest with this email address.').' <button type="submit" class="btn btn-link alert-link btn-transform" name="submitTransformAccount">'.Tools::displayError('Click here').'</button>'.Tools::displayError('').' to generate a password for your account.';
|
||||
}
|
||||
}
|
||||
// Preparing customer
|
||||
$customer = new Customer();
|
||||
$lastnameAddress = Tools::getValue('lastname');
|
||||
$firstnameAddress = Tools::getValue('firstname');
|
||||
$_POST['lastname'] = Tools::getValue('customer_lastname', $lastnameAddress);
|
||||
$_POST['firstname'] = Tools::getValue('customer_firstname', $firstnameAddress);
|
||||
$addresses_types = array('address');
|
||||
|
||||
if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address')) {
|
||||
$addresses_types[] = 'address_invoice';
|
||||
}
|
||||
|
||||
$error_phone = false;
|
||||
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
|
||||
if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer')) {
|
||||
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) {
|
||||
$error_phone = true;
|
||||
}
|
||||
} elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE'))
|
||||
|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create'))
|
||||
|| (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Tools::getValue('email_create')))
|
||||
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) {
|
||||
$error_phone = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error_phone) {
|
||||
$this->errors[] = Tools::displayError('You must register at least one phone number.');
|
||||
}
|
||||
|
||||
// if PS_CUSTOMER_ADDRESS_CREATION is disabled And customer has no addresses then create customer address
|
||||
// with the details of first hotel which rooms he has in cart
|
||||
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')
|
||||
&& isset($this->context->cart->id)
|
||||
&& $this->context->cart->id
|
||||
) {
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlCart = new HotelCartBookingData();
|
||||
if ($htlCartInfo = $objHtlCart->getCartCurrentDataByCartId($this->context->cart->id)) {
|
||||
if (isset($htlCartInfo[0]['id_hotel']) && ($idHotel = $htlCartInfo[0]['id_hotel'])) {
|
||||
if ($address_info = HotelBranchInformation::getAddress($idHotel)) {
|
||||
$_POST['lastname'] = Tools::getValue('customer_lastname');
|
||||
$_POST['firstname'] = Tools::getValue('customer_firstname');
|
||||
$_POST['address1'] = $address_info['address1'];
|
||||
$_POST['city'] = $address_info['city'];
|
||||
$_POST['postcode'] = $address_info['postcode'];
|
||||
$_POST['alias'] = 'My address';
|
||||
$_POST['id_country'] = $address_info['id_country'];
|
||||
$_POST['id_state'] = $address_info['id_state'];
|
||||
$_POST['auto_generated'] = true;
|
||||
// if form is shorter then address name will be customer name
|
||||
$lastnameAddress = $_POST['lastname'];
|
||||
$firstnameAddress = $_POST['firstname'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End
|
||||
$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
|
||||
|
||||
// Check the requires fields which are settings in the BO
|
||||
$this->errors = $this->errors + $customer->validateFieldsRequiredDatabase();
|
||||
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {
|
||||
if (!count($this->errors)) {
|
||||
|
||||
$this->processCustomerNewsletter($customer);
|
||||
|
||||
$customer->firstname = Tools::ucwords($customer->firstname);
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
}
|
||||
|
||||
// New Guest customer
|
||||
$customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0);
|
||||
$customer->active = 1;
|
||||
|
||||
if (!count($this->errors)) {
|
||||
if ($customer->add()) {
|
||||
if (!$customer->is_guest) {
|
||||
if (!$this->sendConfirmationMail($customer)) {
|
||||
$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateContext($customer);
|
||||
|
||||
$this->context->cart->update();
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
}
|
||||
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0) {
|
||||
$multi = (int)Tools::getValue('multi-shipping');
|
||||
Tools::redirect('index.php?controller=order'.($multi ? '&multi-shipping='.$multi : ''));
|
||||
}
|
||||
// else : redirection to the account
|
||||
else {
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if registration type is in one step, we save the address
|
||||
|
||||
$_POST['lastname'] = $lastnameAddress;
|
||||
$_POST['firstname'] = $firstnameAddress;
|
||||
$post_back = $_POST;
|
||||
// Preparing addresses
|
||||
foreach ($addresses_types as $addresses_type) {
|
||||
$$addresses_type = new Address();
|
||||
$$addresses_type->id_customer = 1;
|
||||
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
foreach ($_POST as $key => &$post) {
|
||||
if ($tmp = Tools::getValue($key.'_invoice')) {
|
||||
$post = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
$_POST = $post_back;
|
||||
}
|
||||
|
||||
if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country)) {
|
||||
$this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
|
||||
}
|
||||
|
||||
if (!$country->active) {
|
||||
$this->errors[] = Tools::displayError('This country is not active.');
|
||||
}
|
||||
|
||||
$postcode = $$addresses_type->postcode;
|
||||
/* Check zip code format */
|
||||
if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
|
||||
} elseif (empty($postcode) && $country->need_zip_code) {
|
||||
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
|
||||
} elseif ($postcode && !Validate::isPostCode($postcode)) {
|
||||
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
|
||||
}
|
||||
|
||||
if ($country->need_identification_number) {
|
||||
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')) {
|
||||
$$addresses_type->dni = null;
|
||||
} elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) {
|
||||
$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
|
||||
}
|
||||
} elseif (!$country->need_identification_number) {
|
||||
$$addresses_type->dni = null;
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) {
|
||||
if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) {
|
||||
$this->errors[] = Tools::displayError('Country is invalid');
|
||||
}
|
||||
}
|
||||
$contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0;
|
||||
$id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0;
|
||||
if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) {
|
||||
$this->errors[] = Tools::displayError('This country requires you to choose a State.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
if (Customer::customerExists(Tools::getValue('email'))) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
|
||||
// Preparing customer
|
||||
$customer = new Customer();
|
||||
$lastnameAddress = Tools::getValue('lastname');
|
||||
$firstnameAddress = Tools::getValue('firstname');
|
||||
$_POST['lastname'] = Tools::getValue('customer_lastname', $lastnameAddress);
|
||||
$_POST['firstname'] = Tools::getValue('customer_firstname', $firstnameAddress);
|
||||
$addresses_types = array('address');
|
||||
|
||||
if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address')) {
|
||||
$addresses_types[] = 'address_invoice';
|
||||
}
|
||||
|
||||
$this->processCustomerNewsletter($customer);
|
||||
$error_phone = false;
|
||||
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
|
||||
if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer')) {
|
||||
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) {
|
||||
$error_phone = true;
|
||||
}
|
||||
} elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE'))
|
||||
|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create'))
|
||||
|| (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Tools::getValue('email_create')))
|
||||
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) {
|
||||
$error_phone = true;
|
||||
}
|
||||
}
|
||||
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
if ($error_phone) {
|
||||
$this->errors[] = Tools::displayError('You must register at least one phone number.');
|
||||
}
|
||||
|
||||
// if PS_CUSTOMER_ADDRESS_CREATION is disabled And customer has no addresses then create customer address
|
||||
// with the details of first hotel which rooms he has in cart
|
||||
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')
|
||||
&& isset($this->context->cart->id)
|
||||
&& $this->context->cart->id
|
||||
) {
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlCart = new HotelCartBookingData();
|
||||
if ($htlCartInfo = $objHtlCart->getCartCurrentDataByCartId($this->context->cart->id)) {
|
||||
if (isset($htlCartInfo[0]['id_hotel']) && ($idHotel = $htlCartInfo[0]['id_hotel'])) {
|
||||
if ($address_info = HotelBranchInformation::getAddress($idHotel)) {
|
||||
$_POST['lastname'] = Tools::getValue('customer_lastname');
|
||||
$_POST['firstname'] = Tools::getValue('customer_firstname');
|
||||
$_POST['address1'] = $address_info['address1'];
|
||||
$_POST['city'] = $address_info['city'];
|
||||
$_POST['postcode'] = $address_info['postcode'];
|
||||
$_POST['alias'] = 'My address';
|
||||
$_POST['id_country'] = $address_info['id_country'];
|
||||
$_POST['id_state'] = $address_info['id_state'];
|
||||
$_POST['auto_generated'] = true;
|
||||
// if form is shorter then address name will be customer name
|
||||
$lastnameAddress = $_POST['lastname'];
|
||||
$firstnameAddress = $_POST['firstname'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End
|
||||
$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
|
||||
|
||||
// Check the requires fields which are settings in the BO
|
||||
$this->errors = $this->errors + $customer->validateFieldsRequiredDatabase();
|
||||
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {
|
||||
if (!count($this->errors)) {
|
||||
|
||||
$this->processCustomerNewsletter($customer);
|
||||
|
||||
$customer->firstname = Tools::ucwords($customer->firstname);
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
}
|
||||
|
||||
// New Guest customer
|
||||
$customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0);
|
||||
$customer->active = 1;
|
||||
|
||||
if (!count($this->errors)) {
|
||||
if ($customer->add()) {
|
||||
if (!$customer->is_guest) {
|
||||
if (!$this->sendConfirmationMail($customer)) {
|
||||
$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateContext($customer);
|
||||
|
||||
$this->context->cart->update();
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
}
|
||||
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0) {
|
||||
$multi = (int)Tools::getValue('multi-shipping');
|
||||
Tools::redirect('index.php?controller=order'.($multi ? '&multi-shipping='.$multi : ''));
|
||||
}
|
||||
// else : redirection to the account
|
||||
else {
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if registration type is in one step, we save the address
|
||||
|
||||
$_POST['lastname'] = $lastnameAddress;
|
||||
$_POST['firstname'] = $firstnameAddress;
|
||||
$post_back = $_POST;
|
||||
// Preparing addresses
|
||||
foreach ($addresses_types as $addresses_type) {
|
||||
$$addresses_type = new Address();
|
||||
$$addresses_type->id_customer = 1;
|
||||
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
foreach ($_POST as $key => &$post) {
|
||||
if ($tmp = Tools::getValue($key.'_invoice')) {
|
||||
$post = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
$_POST = $post_back;
|
||||
}
|
||||
|
||||
if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country)) {
|
||||
$this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
|
||||
}
|
||||
|
||||
if (!$country->active) {
|
||||
$this->errors[] = Tools::displayError('This country is not active.');
|
||||
}
|
||||
|
||||
$postcode = $$addresses_type->postcode;
|
||||
/* Check zip code format */
|
||||
if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
|
||||
} elseif (empty($postcode) && $country->need_zip_code) {
|
||||
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
|
||||
} elseif ($postcode && !Validate::isPostCode($postcode)) {
|
||||
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
|
||||
}
|
||||
|
||||
if ($country->need_identification_number) {
|
||||
if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')) {
|
||||
$$addresses_type->dni = null;
|
||||
} elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) {
|
||||
$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
|
||||
}
|
||||
} elseif (!$country->need_identification_number) {
|
||||
$$addresses_type->dni = null;
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) {
|
||||
if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) {
|
||||
$this->errors[] = Tools::displayError('Country is invalid');
|
||||
}
|
||||
}
|
||||
$contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0;
|
||||
$id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0;
|
||||
if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) {
|
||||
$this->errors[] = Tools::displayError('This country requires you to choose a State.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$customer->active = 1;
|
||||
// New Guest customer
|
||||
if (Tools::isSubmit('is_new_customer')) {
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
} else {
|
||||
$customer->is_guest = 0;
|
||||
if (Customer::customerExists(Tools::getValue('email'))) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
|
||||
}
|
||||
if (!$customer->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
} else {
|
||||
foreach ($addresses_types as $addresses_type) {
|
||||
$$addresses_type->id_customer = (int)$customer->id;
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
foreach ($_POST as $key => &$post) {
|
||||
if ($tmp = Tools::getValue($key.'_invoice')) {
|
||||
$post = $tmp;
|
||||
|
||||
$this->processCustomerNewsletter($customer);
|
||||
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$customer->active = 1;
|
||||
// New Guest customer
|
||||
if (Tools::isSubmit('is_new_customer')) {
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
} else {
|
||||
$customer->is_guest = 0;
|
||||
}
|
||||
if (!$customer->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
} else {
|
||||
foreach ($addresses_types as $addresses_type) {
|
||||
$$addresses_type->id_customer = (int)$customer->id;
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
foreach ($_POST as $key => &$post) {
|
||||
if ($tmp = Tools::getValue($key.'_invoice')) {
|
||||
$post = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
$_POST = $post_back;
|
||||
}
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your address.');
|
||||
}
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
if (!$customer->is_guest) {
|
||||
$this->context->customer = $customer;
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the default customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
|
||||
if (!$this->sendConfirmationMail($customer)) {
|
||||
// webkul - we will not stop process on email delivery fails
|
||||
//$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
$_POST = $post_back;
|
||||
}
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your address.');
|
||||
}
|
||||
} else {
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the guest customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP')));
|
||||
}
|
||||
$this->updateContext($customer);
|
||||
$this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
$this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
if (isset($address_invoice) && Validate::isLoadedObject($address_invoice)) {
|
||||
$this->context->cart->id_address_invoice = (int)$address_invoice->id;
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
if (!$customer->is_guest) {
|
||||
$this->context->customer = $customer;
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the default customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
|
||||
if (!$this->sendConfirmationMail($customer)) {
|
||||
// webkul - we will not stop process on email delivery fails
|
||||
//$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
}
|
||||
} else {
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the guest customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP')));
|
||||
}
|
||||
$this->updateContext($customer);
|
||||
$this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
$this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
if (isset($address_invoice) && Validate::isLoadedObject($address_invoice)) {
|
||||
$this->context->cart->id_address_invoice = (int)$address_invoice->id;
|
||||
}
|
||||
|
||||
if ($this->ajax && Configuration::get('PS_ORDER_PROCESS_TYPE')) {
|
||||
$delivery_option = array((int)$this->context->cart->id_address_delivery => (int)$this->context->cart->id_carrier.',');
|
||||
$this->context->cart->setDeliveryOption($delivery_option);
|
||||
}
|
||||
if ($this->ajax && Configuration::get('PS_ORDER_PROCESS_TYPE')) {
|
||||
$delivery_option = array((int)$this->context->cart->id_address_delivery => (int)$this->context->cart->id_carrier.',');
|
||||
$this->context->cart->setDeliveryOption($delivery_option);
|
||||
}
|
||||
|
||||
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
|
||||
$this->context->cart->update();
|
||||
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
|
||||
$this->context->cart->update();
|
||||
|
||||
// Avoid articles without delivery address on the cart
|
||||
$this->context->cart->autosetProductAddress();
|
||||
// Avoid articles without delivery address on the cart
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
// if registration type is in two steps, we redirect to register address
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {
|
||||
Tools::redirect('index.php?controller=address');
|
||||
}
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
// if registration type is in two steps, we redirect to register address
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {
|
||||
Tools::redirect('index.php?controller=address');
|
||||
}
|
||||
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
}
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
}
|
||||
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0) {
|
||||
Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : ''));
|
||||
}
|
||||
// else : redirection to the account
|
||||
else {
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0) {
|
||||
Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : ''));
|
||||
}
|
||||
// else : redirection to the account
|
||||
else {
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -772,12 +779,21 @@ class AuthControllerCore extends FrontController
|
||||
*/
|
||||
protected function processTransformAccount()
|
||||
{
|
||||
if (!Validate::isEmail($email = trim(Tools::getValue('email_create'))) || empty($email)) {
|
||||
if (!Validate::isEmail($email = trim(Tools::getValue('email_create', Tools::getValue('email')))) || empty($email)) {
|
||||
$this->errors[] = Tools::displayError('Invalid email address.');
|
||||
} elseif ($id_customer = Customer::customerExists($email, true, false)) {
|
||||
$customer = new Customer($id_customer);
|
||||
if ($customer->transformToCustomer($this->context->language->id)) {
|
||||
$this->confirmations[] = 'TRANSFORM_OK';
|
||||
|
||||
$back = '';
|
||||
if ($back == Tools::secureReferrer(Tools::getValue('back'))) {
|
||||
$back = html_entity_decode($back);
|
||||
} else {
|
||||
$back = Tools::safeOutput($back);
|
||||
}
|
||||
$this->ajaxExtraData['redirect_link'] = $this->context->link->getPageLink('authentication').
|
||||
($back ? '?back='.$back.'&' : '?').'guest_transform_success=1';
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Your guest account could not be transformed to a customer account.');
|
||||
}
|
||||
|
||||
@@ -285,11 +285,11 @@ class CartControllerCore extends FrontController
|
||||
|
||||
if ($product->booking_product) {
|
||||
$occupancyRequiredForBooking = false;
|
||||
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
$occupancyRequiredForBooking = true;
|
||||
}
|
||||
|
||||
if ($occupancyRequiredForBooking) {
|
||||
if ($occupancyRequiredForBooking && $operator == 'up') {
|
||||
if ($occupancy = json_decode(Tools::getValue('occupancy'), true)) {
|
||||
$this->qty = count($occupancy);
|
||||
} else {
|
||||
@@ -395,16 +395,26 @@ class CartControllerCore extends FrontController
|
||||
if (Tools::getValue('op', 'up') == 'up') {
|
||||
if ($total_available_rooms < $req_rm) {
|
||||
die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms)));
|
||||
} else {
|
||||
// validate normal products if available
|
||||
if ($serviceProducts) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
foreach ($serviceProducts as $key => $standartProduct) {
|
||||
if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($this->id_product, $standartProduct['id_product'])) {
|
||||
unset($serviceProducts[$key]);
|
||||
} else {
|
||||
// validate service products if available
|
||||
if ($serviceProducts) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
foreach ($serviceProducts as $key => $serviceProduct) {
|
||||
if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($this->id_product, $serviceProduct['id_product'])) {
|
||||
unset($serviceProducts[$key]);
|
||||
} else {
|
||||
if (Validate::isLoadedObject($objServiceProduct = new Product($serviceProduct['id_product']))) {
|
||||
if (!$objServiceProduct->allow_multiple_quantity && $serviceProduct['quantity'] > 1) {
|
||||
$serviceProducts[$key]['quantity'] = 1;
|
||||
} else if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $serviceProduct['quantity'] ) {
|
||||
$serviceProducts[$key]['quantity'] = $objServiceProduct->max_quantity;
|
||||
}
|
||||
} else {
|
||||
$response['error'] = Tools::displayError('Service not Found');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -621,6 +631,8 @@ class CartControllerCore extends FrontController
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!Validate::isUnsignedInt($qty)) {
|
||||
$this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.');
|
||||
} elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
|
||||
$this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
|
||||
}
|
||||
} else {
|
||||
$qty = 1;
|
||||
|
||||
@@ -49,16 +49,16 @@ class GuestTrackingControllerCore extends FrontController
|
||||
{
|
||||
if (Tools::isSubmit('submitGuestTracking') || Tools::isSubmit('submitTransformGuestToCustomer')) {
|
||||
// These lines are here for retrocompatibility with old theme
|
||||
$id_order = Tools::getValue('id_order');
|
||||
$idOrder = Tools::getValue('id_order');
|
||||
$order_collection = array();
|
||||
if ($id_order) {
|
||||
if (is_numeric($id_order)) {
|
||||
$order = new Order((int)$id_order);
|
||||
if ($idOrder) {
|
||||
if (is_numeric($idOrder)) {
|
||||
$order = new Order((int)$idOrder);
|
||||
if (Validate::isLoadedObject($order)) {
|
||||
$order_collection = Order::getByReference($order->reference);
|
||||
}
|
||||
} else {
|
||||
$order_collection = Order::getByReference($id_order);
|
||||
$order_collection = Order::getByReference($idOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class GuestTrackingControllerCore extends FrontController
|
||||
|
||||
$email = Tools::getValue('email');
|
||||
|
||||
if (empty($order_reference) && empty($id_order)) {
|
||||
if (empty($order_reference) && empty($idOrder)) {
|
||||
$this->errors[] = Tools::displayError('Please provide your order\'s reference number.');
|
||||
} elseif (empty($email)) {
|
||||
$this->errors[] = Tools::displayError('Please provide a valid email address.');
|
||||
@@ -185,6 +185,7 @@ class GuestTrackingControllerCore extends FrontController
|
||||
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlBranchInfo = new HotelBranchInformation();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomType = new HotelRoomType();
|
||||
|
||||
$nonRequestedRooms = 0;
|
||||
@@ -225,130 +226,253 @@ class GuestTrackingControllerCore extends FrontController
|
||||
if ($orderProducts = $order->getProducts()) {
|
||||
$total_demands_price_te = 0;
|
||||
$total_demands_price_ti = 0;
|
||||
$total_convenience_fee_te = 0;
|
||||
$total_convenience_fee_ti = 0;
|
||||
// ddd($orderProducts);
|
||||
foreach ($orderProducts as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processedProducts)) {
|
||||
continue;
|
||||
}
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
if ($type_value['is_booking_product']) {
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($type_value['product_id']);
|
||||
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
$cartHotelData[$type_key]['adults'] = $rm_dtl['adults'];
|
||||
$cartHotelData[$type_key]['children'] = $rm_dtl['children'];
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$prod_ord_dtl_name = $order_details_obj->product_name;
|
||||
$cartHotelData[$type_key]['name'] = $prod_ord_dtl_name;
|
||||
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
$cartHotelData[$type_key]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['children'] = $data_v['children'];
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$cartHotelData[$type_key]['name'] = $order_details_obj->product_name;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
} else {
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0
|
||||
);
|
||||
$total_demands_price_ti += $extraDemandPriceTI;
|
||||
$total_demands_price_te += $extraDemandPriceTE;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
$cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name'];
|
||||
// add additional services products in hotel detail.
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0
|
||||
);
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0;
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
}
|
||||
$extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI;
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0;
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
}
|
||||
$extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE;
|
||||
$total_demands_price_ti += $extraDemandPriceTI;
|
||||
$total_demands_price_te += $extraDemandPriceTE;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
// calculate averages now
|
||||
foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
|
||||
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
$value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6));
|
||||
$value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6));
|
||||
}
|
||||
} else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) {
|
||||
if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) {
|
||||
$total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
$total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// get all products that are independent.
|
||||
if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) {
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
|
||||
//enter hotel name
|
||||
$hotelInfo = $objHtlBranchInfo->hotelBranchesInfo(
|
||||
Configuration::get('PS_LANG_DEFAULT'),
|
||||
2,
|
||||
0,
|
||||
$data_v['id_hotel']
|
||||
);
|
||||
$cartHotelData[$type_key]['hotel_name'] = $hotelInfo['hotel_name'];
|
||||
if (!empty($cover_image_arr)) {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
$cartServiceProducts[] = $type_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,8 +483,15 @@ class GuestTrackingControllerCore extends FrontController
|
||||
null, $this->context->language->id
|
||||
);
|
||||
|
||||
$customerGuestDetail = false;
|
||||
if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) {
|
||||
$customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'total_convenience_fee_ti' => $total_convenience_fee_ti,
|
||||
'total_convenience_fee_te' => $total_convenience_fee_te,
|
||||
'total_demands_price_ti' => $total_demands_price_ti,
|
||||
'total_demands_price_te' => $total_demands_price_te,
|
||||
'any_back_order' => $anyBackOrder,
|
||||
@@ -369,6 +500,7 @@ class GuestTrackingControllerCore extends FrontController
|
||||
'order_has_invoice' => $order->hasInvoice(),
|
||||
'cart_htl_data' => $cartHotelData,
|
||||
'non_requested_rooms' => $nonRequestedRooms,
|
||||
'customerGuestDetail' => $customerGuestDetail,
|
||||
)
|
||||
);
|
||||
//end
|
||||
|
||||
@@ -163,110 +163,117 @@ class OrderDetailControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('Order ID required');
|
||||
} else {
|
||||
$order = new Order($id_order);
|
||||
// Here handle request from the ajax on order details page i.e refund, additional qty etc
|
||||
$method = Tools::getValue('method');
|
||||
// extra demands popup ajax
|
||||
if ($method == 'getRoomTypeBookingDemands') {
|
||||
$response = array('reload' => false);
|
||||
if (($idProduct = Tools::getValue('id_product'))
|
||||
&& ($idOrder = Tools::getValue('id_order'))
|
||||
&& ($dateFrom = Tools::getValue('date_from'))
|
||||
&& ($dateTo = Tools::getValue('date_to'))
|
||||
) {
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
$useTax = 0;
|
||||
$customer = Context::getContext()->customer;
|
||||
if (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC) {
|
||||
$useTax = 1;
|
||||
}
|
||||
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$idProduct,
|
||||
0,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
1,
|
||||
0,
|
||||
$useTax
|
||||
)) {
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
|
||||
// Here handle request from the ajax on order details page i.e refund, additional qty etc
|
||||
$method = Tools::getValue('method');
|
||||
// extra demands popup ajax
|
||||
if ($method == 'getRoomTypeBookingDemands') {
|
||||
$response = array('reload' => false);
|
||||
if (($idProduct = Tools::getValue('id_product'))
|
||||
&& ($idOrder = Tools::getValue('id_order'))
|
||||
&& ($dateFrom = Tools::getValue('date_from'))
|
||||
&& ($dateTo = Tools::getValue('date_to'))
|
||||
) {
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
$useTax = 0;
|
||||
$customer = Context::getContext()->customer;
|
||||
if (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC) {
|
||||
$useTax = 1;
|
||||
}
|
||||
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$idProduct,
|
||||
0,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
1,
|
||||
0,
|
||||
$useTax
|
||||
)) {
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'useTax' => $useTax,
|
||||
'extraDemands' => $extraDemands,
|
||||
)
|
||||
);
|
||||
}
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
0,
|
||||
0,
|
||||
$useTax
|
||||
)) {
|
||||
$this->context->smarty->assign(array(
|
||||
'useTax' => $useTax,
|
||||
'extraDemands' => $extraDemands,
|
||||
)
|
||||
);
|
||||
'additionalServices' => $additionalServices,
|
||||
));
|
||||
}
|
||||
$response['extra_demands'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl');
|
||||
}
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
0,
|
||||
0,
|
||||
$useTax
|
||||
)) {
|
||||
$this->context->smarty->assign(array(
|
||||
'useTax' => $useTax,
|
||||
'additionalServices' => $additionalServices,
|
||||
));
|
||||
}
|
||||
$response['extra_demands'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
} elseif ($method == 'submitRefundRequest') { // room cancellation ajax
|
||||
$hasError = 0;
|
||||
if (!$refundReason = Tools::getValue('cancellation_reason')) {
|
||||
$hasError = 1;
|
||||
} elseif (!Validate::isCleanHtml($refundReason)) {
|
||||
$hasError = 1;
|
||||
}
|
||||
if ($bookingRefunds = Tools::getValue('bookings_to_refund')) {
|
||||
if (!count($bookingRefunds = json_decode($bookingRefunds, true))) {
|
||||
die(json_encode($response));
|
||||
} elseif ($method == 'submitRefundRequest') { // room cancellation ajax
|
||||
$hasError = 0;
|
||||
if (!$refundReason = Tools::getValue('cancellation_reason')) {
|
||||
$hasError = 1;
|
||||
} else {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
if (OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) {
|
||||
$hasError = 1;
|
||||
break;
|
||||
} elseif (!Validate::isCleanHtml($refundReason)) {
|
||||
$hasError = 1;
|
||||
}
|
||||
if ($bookingRefunds = Tools::getValue('bookings_to_refund')) {
|
||||
if (!count($bookingRefunds = json_decode($bookingRefunds, true))) {
|
||||
$hasError = 1;
|
||||
} else {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHotelBookingDetail = new HotelBookingDetail($idHtlBooking);
|
||||
if ($objHotelBookingDetail->id_customer != $order->id_customer
|
||||
|| OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)
|
||||
) {
|
||||
$hasError = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$hasError = 1;
|
||||
}
|
||||
} else {
|
||||
$hasError = 1;
|
||||
}
|
||||
if (!$hasError) {
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = 0;
|
||||
$objOrderReturn->by_admin = 0;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
if (!$hasError) {
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = 0;
|
||||
$objOrderReturn->by_admin = 0;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Emails to customer, admin on refund request state change
|
||||
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
|
||||
// Emails to customer, admin on refund request state change
|
||||
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
|
||||
|
||||
die(json_encode(array('status' => 1)));
|
||||
die(json_encode(array('status' => 1)));
|
||||
}
|
||||
die(json_encode(array('status' => 0)));
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => 0)));
|
||||
}
|
||||
// END ajax request handle
|
||||
@@ -479,40 +486,40 @@ class OrderDetailControllerCore extends FrontController
|
||||
1,
|
||||
0
|
||||
);
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$id_order,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$id_order,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
}
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$id_order,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$id_order,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
// calculate averages now
|
||||
foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
|
||||
@@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
// check all service products are available
|
||||
RoomTypeServiceProductCartDetail::validateServiceProductsInCart();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// check ORDER RESTRICT condition before payment by the customer
|
||||
@@ -452,7 +455,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
|
||||
$this->context->smarty->assign('checkout_process_steps', $this->checkoutProcess->getSteps());
|
||||
|
||||
// @todo shreesh get this checked with sumit sir
|
||||
// set room type demands
|
||||
// $objGlobalDemand = new HotelRoomTypeGlobalDemand();
|
||||
// $allDemands = $objGlobalDemand->getAllDemands();
|
||||
|
||||
@@ -114,6 +114,10 @@ class ProductControllerCore extends FrontController
|
||||
$this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
|
||||
}
|
||||
|
||||
if (!$this->product->booking_product) {
|
||||
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
|
||||
}
|
||||
|
||||
if (!Validate::isLoadedObject($this->product)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
@@ -192,12 +196,6 @@ class ProductControllerCore extends FrontController
|
||||
$this->context->cookie->last_visited_category = (int)$this->category->id_category;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->product->booking_product) {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
header('Status: 403 Forbidden');
|
||||
$this->errors[] = Tools::displayError('You do not have access to this Product.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,11 +355,12 @@ class ProductControllerCore extends FrontController
|
||||
// booking preparation time
|
||||
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id);
|
||||
|
||||
$objHotelImage = new HotelImage();
|
||||
$hotelImageLink = null;
|
||||
if ($coverImage = HotelImage::getCover($hotel_id)) {
|
||||
$hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/';
|
||||
$hotelImageLink = $this->context->link->getMediaLink(
|
||||
$hotelImagesBaseDir.$coverImage['hotel_image_id'].'.jpg'
|
||||
$objHotelImage->getImageLink($coverImage['id'], ImageType::getFormatedName('large'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -591,7 +590,7 @@ class ProductControllerCore extends FrontController
|
||||
'id_cart' => $idCart,
|
||||
'id_guest' => $idGuest,
|
||||
);
|
||||
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
$bookingParams['occupancy'] = $occupancy;
|
||||
$quantity = count($occupancy);
|
||||
} else {
|
||||
@@ -603,6 +602,7 @@ class ProductControllerCore extends FrontController
|
||||
$quantity = 1;
|
||||
}
|
||||
|
||||
$totalAvailableRooms = 0;
|
||||
if ($hotelRoomData = $objBookingDetail->DataForFrontSearch($bookingParams)) {
|
||||
$totalAvailableRooms = $hotelRoomData['stats']['num_avail'];
|
||||
$quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity;
|
||||
@@ -689,10 +689,22 @@ class ProductControllerCore extends FrontController
|
||||
$serviceProductsPrice = 0;
|
||||
if ($roomServiceProducts = json_decode($roomServiceProducts, true)) {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
foreach ($roomServiceProducts as &$product) {
|
||||
$objProduct = new ProductCore($product['id_product'], false, $this->context->language->id);
|
||||
$product['name'] = $objProduct->name;
|
||||
$product['allow_multiple_quantity'] = $objProduct->allow_multiple_quantity;
|
||||
if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $product['id_product'])) {
|
||||
unset($product);
|
||||
continue;
|
||||
} else {
|
||||
$objServiceProduct = new ProductCore($product['id_product'], false, $this->context->language->id);
|
||||
if (!$objServiceProduct->allow_multiple_quantity && $product['quantity'] > 1) {
|
||||
$product['quantity'] = 1;
|
||||
} else if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $product['quantity'] ) {
|
||||
$product['quantity'] = $objServiceProduct->max_quantity;
|
||||
}
|
||||
|
||||
}
|
||||
$product['name'] = $objServiceProduct->name;
|
||||
$product['allow_multiple_quantity'] = $objServiceProduct->allow_multiple_quantity;
|
||||
$productPrice = $objRoomTypeServiceProductPrice->getProductPrice($product['id_product'], $idProduct, $product['quantity'], $useTax);
|
||||
$product['price'] = $productPrice;
|
||||
$serviceProductsPrice += $productPrice;
|
||||
@@ -1244,7 +1256,8 @@ class ProductControllerCore extends FrontController
|
||||
$hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/';
|
||||
foreach ($hotelImages as &$hotelImage) {
|
||||
$hotelImage['link'] = $this->context->link->getMediaLink(
|
||||
$hotelImagesBaseDir.$hotelImage['hotel_image_id'].'.jpg'
|
||||
$objHotelImage->getImageLink($hotelImage['id'],
|
||||
ImageType::getFormatedName('large'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1318,12 +1331,14 @@ class ProductControllerCore extends FrontController
|
||||
public function displayAjaxCheckServiceProductWithRoomType()
|
||||
{
|
||||
$response = array(
|
||||
'status' => false
|
||||
'success' => false
|
||||
);
|
||||
|
||||
if ($this->isTokenValid()) {
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$idServiceProduct = Tools::getValue('service_product');
|
||||
$addedServiceProduct = Tools::getValue('added_service_product');
|
||||
$qty = Tools::getValue('qty');
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idProduct))) {
|
||||
if (!Product::isBookingProduct($idProduct)) {
|
||||
$response['error'] = Tools::displayError('Room Type info not Found');
|
||||
@@ -1334,7 +1349,37 @@ class ProductControllerCore extends FrontController
|
||||
if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) {
|
||||
$response['error'] = Tools::displayError('Selected product is not available with current room type');
|
||||
} else {
|
||||
$response['status'] = true;
|
||||
if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) {
|
||||
$response['success'] = true;
|
||||
if (!$objServiceProduct->allow_multiple_quantity) {
|
||||
if (!empty($addedServiceProduct)) {
|
||||
if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) {
|
||||
$response['add'] = true;
|
||||
$response['msg'] = 'Service is added to cart.';
|
||||
} else {
|
||||
$response['msg'] = 'Service already added.';
|
||||
}
|
||||
} else {
|
||||
$response['add'] = true;
|
||||
$response['msg'] = 'Service is added to cart.';
|
||||
}
|
||||
} else {
|
||||
$totalQty = $qty;
|
||||
if (!empty($addedServiceProduct)) {
|
||||
if (($key = array_search($idServiceProduct, array_column($addedServiceProduct, 'id_product')))!== false) {
|
||||
$totalQty += $addedServiceProduct[$key]['quantity'];
|
||||
}
|
||||
}
|
||||
if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $totalQty ) {
|
||||
$response['msg'] = Tools::displayError(sprintf('Cannot add more than %d quantity.', $objServiceProduct->max_quantity));
|
||||
} else {
|
||||
$response['add'] = true;
|
||||
$response['msg'] = Tools::displayError('Service is added to cart.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['error'] = Tools::displayError('Service not Found');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['error'] = Tools::displayError('Room Type not Found');
|
||||
|
||||
Reference in New Issue
Block a user