Merge branch 'develop' into book_noww_testing_issues

This commit is contained in:
Sumit Panwar
2024-10-01 11:27:32 +05:30
30 changed files with 3910 additions and 185 deletions

View File

@@ -412,21 +412,23 @@
</span>
</div>
</div>
<div id="max_quantity_container" class="form-group" {if ($product->auto_add_to_cart && $product->isAssociatedToShop()) || !$product->allow_multiple_quantity}style="display:none;"{/if}>
<label class="control-label col-lg-3" for="max_quantity">
<span class="label-tooltip" data-toggle="tooltip"
title="{l s='Enter max allowed quantity per room, enter 0 for unlimited.'}">
{l s='Max quantity allow'}
</span>
</label>
<div class="col-lg-3">
<input type="text" id="max_quantity" name="max_quantity" value="{$product->max_quantity|escape:'html':'UTF-8'}" />
<div id="max_quantity_container" {if ($product->auto_add_to_cart && $product->isAssociatedToShop()) || !$product->allow_multiple_quantity}style="display:none;"{/if}>
<div class="form-group">
<label class="control-label col-lg-3" for="max_quantity">
<span class="label-tooltip" data-toggle="tooltip"
title="{l s='Enter max allowed quantity per room, enter 0 for unlimited.'}">
{l s='Max quantity allow'}
</span>
</label>
<div class="col-lg-3">
<input type="text" id="max_quantity" name="max_quantity" value="{$product->max_quantity|escape:'html':'UTF-8'}" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6 col-lg-offset-3">
<div class="alert alert-info">
{l s='By default all products have infinte quantity, Using this setting you can restrict customer to purchase only one product per room.'}
<div class="form-group">
<div class="col-lg-6 col-lg-offset-3">
<div class="alert alert-info">
{l s='By default all products have infinte quantity, Using this setting you can restrict customer to purchase only one product per room.'}
</div>
</div>
</div>
</div>

View File

@@ -305,7 +305,7 @@
<select id="filter_input_{$key}" class="filter center" name="{$field_name}">
<option value="">-</option>
<option value="1" {if isset($smarty.post.$field_name) && $smarty.post.$field_name == 1} selected="selected"{elseif $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option>
<option value="0" {if isset($smarty.post.$field_name) && $smarty.post.$field_name == 0} selected="selected"{elseif $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
<option value="0" {if isset($smarty.post.$field_name) && $smarty.post.$field_name != '' && $smarty.post.$field_name == 0} selected="selected"{elseif $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
</select>
{elseif $params.type == 'date' || $params.type == 'datetime'}
<div class="date_range">
@@ -387,7 +387,7 @@
<option value="" {if $params.value == ''} selected="selected" {/if}>-</option>
{if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display}
<option value="{$option_value}" {if isset($smarty.post.$field_name) && $smarty.post.$field_name == $option_value} selected="selected"{elseif (string)$option_display === (string)$params.value || (string)$option_value === (string)$params.value} selected="selected"{/if}>{$option_display}</option>
<option value="{$option_value}" {if isset($smarty.post.$field_name) && $smarty.post.$field_name != '' && $smarty.post.$field_name == $option_value} selected="selected"{elseif (string)$option_display === (string)$params.value || (string)$option_value === (string)$params.value} selected="selected"{/if}>{$option_display}</option>
{/foreach}
{/if}
</select>

View File

@@ -539,10 +539,10 @@ class AddressCore extends ObjectModel
cl.`name` AS `country_name`, s.`name` AS `state_name`
FROM `'._DB_PREFIX_.'address` a
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl
ON cl.`id_country` = a.`id_country`
ON cl.`id_country` = a.`id_country` AND cl.`id_lang` ='.(int) $idLang.'
LEFT JOIN `'._DB_PREFIX_.'state` s
ON s.`id_country` = cl.`id_country`
WHERE id_customer > 0 AND
ON s.`id_country` = cl.`id_country` AND s.`id_state` = a.`id_state`
WHERE id_customer > 0 AND a.`deleted` = 0 AND
(a.`address1` LIKE \'%'.$query.'%\' OR
a.`postcode` LIKE \'%'.$query.'%\' OR
a.`city` LIKE \'%'.$query.'%\' OR

View File

@@ -141,6 +141,10 @@ class CustomerCore extends ObjectModel
const STATUS_DELETED = 2;
protected $webserviceParameters = array(
'objectMethods' => array(
'add' => 'addWs',
'update' => 'updateWs'
),
'fields' => array(
'id_default_group' => array('xlink_resource' => 'groups'),
'id_lang' => array('xlink_resource' => 'languages'),
@@ -150,6 +154,7 @@ class CustomerCore extends ObjectModel
'secure_key' => array('setter' => null),
'deleted' => array(),
'passwd' => array('setter' => 'setWsPasswd'),
'phone' => array()
),
'associations' => array(
'groups' => array('resource' => 'group'),
@@ -208,6 +213,32 @@ class CustomerCore extends ObjectModel
if ($this->email) {
$this->phone = CartCustomerGuestDetail::getCustomerPhone($this->email);
}
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
$this->webserviceParameters['fields']['phone']['required'] = true;
}
}
public function validateFields($die = true, $error_return = false)
{
if (isset($this->webservice_validation) && $this->webservice_validation) {
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
if (!$this->phone) {
$message = Tools::displayError('Phone is required field.');
} else if (!Validate::isPhoneNumber(trim($this->phone))) {
$message = Tools::displayError('Invalid phone.');
}
}
if (isset($message)) {
if ($die) {
throw new PrestaShopException($message);
}
return $error_return ? $message : false;
}
}
return parent::validateFields($die, $error_return);
}
public function add($autodate = true, $null_values = true)
@@ -262,6 +293,24 @@ class CustomerCore extends ObjectModel
return parent::update(true);
}
public function addWs($autodate = true, $null_values = false)
{
if ($this->phone) {
CartCustomerGuestDetail::updateCustomerPhoneNumber($this->email, $this->phone);
}
return $this->add($autodate, $null_values);
}
public function updateWs($autodate = true, $null_values = false)
{
if ($this->phone) {
CartCustomerGuestDetail::updateCustomerPhoneNumber($this->email, $this->phone);
}
return $this->update($autodate, $null_values);
}
public function delete()
{
if (!count(Order::getCustomerOrders((int)$this->id))) {

View File

@@ -154,7 +154,8 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
'invoice_address' => $formatted_invoice_address,
'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
'tax_excluded_display' => $tax_excluded_display,
'total_cart_rule' => $total_cart_rule
'total_cart_rule' => $total_cart_rule,
'customer' => $customer
));
$tpls = array(
@@ -256,7 +257,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
SELECT od.`tax_computation_method`
FROM `' . _DB_PREFIX_ . 'order_detail_tax` odt
LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` od ON (od.`id_order_detail` = odt.`id_order_detail`)
WHERE od.`id_order` = ' . (int) $this->order->id_order . '
WHERE od.`id_order` = ' . (int) $this->order->id . '
AND od.`tax_computation_method` = ' . (int) TaxCalculator::ONE_AFTER_ANOTHER_METHOD)
|| Configuration::get('PS_INVOICE_TAXES_BREAKDOWN');
}
@@ -271,8 +272,8 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
$breakdown = array();
$order_detail = array_filter($this->order->products, function($v) {
return ($v['is_booking_product']
|| ($v['product_auto_add']
return ((isset($v['is_booking_product']) && $v['is_booking_product'])
|| ((isset($v['product_auto_add']) && $v['product_auto_add'])
&& $v['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE
&& $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM)
);

View File

@@ -27,5 +27,6 @@ class WebserviceOrderCore extends PaymentModule
{
$this->displayName = $this->l('Order from API');
$this->validateOrderAmount = false;
$this->payment_type = OrderPayment::PAYMENT_TYPE_ONLINE;
}
}

View File

@@ -626,7 +626,21 @@ class WebserviceOutputBuilderCore
}
$output_details = '';
foreach ($objects_assoc as $object_assoc) {
if ($depth == 0 || $class_name === null) {
if (isset($association['only_leaf_nodes']) && $association['only_leaf_nodes']) {
unset($association['only_leaf_nodes']);
unset($association['getter']);
unset($association['setter']);
foreach ($association as $associationKey => $resource) {
$field = array();
$field['sqlId'] = $associationKey;
$field['value'] = null;
if (!is_null($this->schemaToDisplay)) {
$field['synopsis_details'] = $this->getSynopsisDetails($resource);
}
$output_details .= $this->setIndent($depth - 1).$this->objectRender->renderField($field);
}
} elseif ($depth == 0 || $class_name === null) {
$value = null;
if (!empty($object_assoc)) {
$value = $object_assoc;
@@ -676,7 +690,30 @@ class WebserviceOutputBuilderCore
$output .= $this->setIndent($depth - 1).$this->objectRender->renderNodeHeader($resource_name, array(), $more_attr);
foreach ($fields_assoc as $field_name => $field) {
if (!is_array($this->fieldsToDisplay) || in_array($field_name, $this->fieldsToDisplay[$assoc_name])) {
if (isset($field['resource']) && isset($field['fields'])) {
$parent_details = array(
'object_id' => null,
'entity_name' => $field['resource'],
'entities_name' => $field_name,
);
$output_details = '';
$output_details = $this->renderFlatAssociation(
$object,
$depth,
$field_name,
$field['resource'],
$field['fields'],
$object_assoc,
$parent_details
);
if ($output_details != '') {
$output .= $this->setIndent($depth).$this->objectRender->renderNodeHeader($field_name, array());
$output .= $output_details;
$output .= $this->setIndent($depth).$this->objectRender->renderNodeFooter($field_name, array());
} else {
$output .= $this->setIndent($depth).$this->objectRender->renderNodeHeader($field_name, array());
}
} elseif (!is_array($this->fieldsToDisplay) || in_array($field_name, $this->fieldsToDisplay[$assoc_name])) {
if (isset($field['id']) && !isset($field['sqlId'])) {
$field['sqlId'] = 'id';
$field['value'] = isset($object_assoc['id']) ? $object_assoc['id'] : null;

View File

@@ -104,7 +104,7 @@ class WebserviceOutputJSON implements WebserviceOutputInterface
}
// Case 1 : fields of the current entity (not an association)
if (!$is_association) {
$this->currentEntity[$field['sqlId']] = $field['value'];
$this->currentEntity[$field['sqlId']] = $field['value'];
} else { // Case 2 : fields of an associated entity to the current one
$this->currentAssociatedEntity[] = array('name' => $field['entities_name'], 'key' => $field['sqlId'], 'value' => $field['value']);
}
@@ -146,7 +146,7 @@ class WebserviceOutputJSON implements WebserviceOutputInterface
}
$this->currentEntity = array();
}
if (count($this->currentAssociatedEntity)) {
if (is_array($this->currentAssociatedEntity) && count($this->currentAssociatedEntity)) {
$current = array();
foreach ($this->currentAssociatedEntity as $element) {
$current[$element['key']] = $element['value'];
@@ -159,9 +159,6 @@ class WebserviceOutputJSON implements WebserviceOutputInterface
public function overrideContent($content)
{
array_walk($this->content, function (&$item) {
$item = array_filter($item);
});
$content = json_encode($this->content, JSON_UNESCAPED_UNICODE);
return (false !== $content) ? $content : '';
@@ -187,20 +184,23 @@ class WebserviceOutputJSON implements WebserviceOutputInterface
}
public function renderAssociationFooter($obj, $params, $assoc_name)
{
return;
}
public function renderErrorsHeader()
{
return '';
}
public function renderErrorsFooter()
{
return '';
}
public function renderAssociationField($field)
{
return '';
}
public function renderi18nField($field)
{
return '';

View File

@@ -255,7 +255,8 @@ class WebserviceRequestCore
public static function getResources()
{
$resources = array(
'addresses' => array('description' => 'The Customer, Manufacturer and Customer addresses','class' => 'Address'),
'addresses' => array('description' => 'The Customer address','class' => 'Address'),
'bookings' => array('description' => 'The Customer bookings', 'specific_management' => 'true','forbidden_method' => array('DELETE')),
'carriers' => array('description' => 'The Carriers','class' => 'Carrier'),
'carts' => array('description' => 'Customer\'s carts', 'class' => 'Cart'),
'cart_rules' => array('description' => 'Cart rules management', 'class' => 'CartRule'),

File diff suppressed because it is too large Load Diff

View File

@@ -140,6 +140,9 @@ class AdminAddressesControllerCore extends AdminController
'name' => 'email'
),
);
} else if (isset($this->object->id) && $this->object->id_hotel) {
$this->errors[] = Tools::displayError('The object cannot be loaded (or found)');
return false;
}
$this->fields_form = array(

View File

@@ -752,10 +752,12 @@ class AdminCartRulesControllerCore extends AdminController
public function renderForm()
{
$limit = 40;
$this->toolbar_btn['save-and-stay'] = array(
'href' => '#',
'desc' => $this->l('Save and Stay')
);
if (!Tools::getValue('liteDisplaying')) {
$this->toolbar_btn['save-and-stay'] = array(
'href' => '#',
'desc' => $this->l('Save and Stay')
);
}
/** @var CartRule $current_object */
$current_object = $this->loadObject(true);

View File

@@ -207,7 +207,7 @@ class AdminCartsControllerCore extends AdminController
$date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
$date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to);
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$date_from.'&date_to='.$date_to;
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day'));
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
$this->kpis[] = $helper;

View File

@@ -66,9 +66,8 @@ class AdminCustomerThreadsControllerCore extends AdminController
$this->access_select = ' SELECT a.`id_customer_thread` FROM '._DB_PREFIX_.'customer_thread a';
$this->access_join = ' LEFT JOIN '._DB_PREFIX_.'orders ord ON (a.id_order = ord.id_order)';
$this->access_join .= ' LEFT JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
$this->access_where = ' WHERE 1 ';
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
$this->access_where .= ' AND IF(a.`id_order`, hbd.`id_hotel` IN ('.implode(',', $acsHtls).'), 1)';
$this->access_where = ' AND IF(a.`id_order`, hbd.`id_hotel` IN ('.implode(',', $acsHtls).'), 1)';
}
$this->fields_list = array(

View File

@@ -375,6 +375,10 @@ class AdminCustomersControllerCore extends AdminController
/** @var Customer $obj */
if (!($obj = $this->loadObject(true))) {
return;
} else if ($this->object->deleted == Customer::STATUS_DELETED) {
$this->warnings[] = $this->l('This is a deleted customer and you cannot update the information of a deleted customer.');
} else if ($this->object->deleted == Customer::STATUS_BANNED) {
$this->warnings[] = $this->l('This is a banned customer and you cannot update the information of a banned customer.');
}
$genders = Gender::getGenders();
@@ -761,7 +765,7 @@ class AdminCustomersControllerCore extends AdminController
$nbDaysNewCustomers = Validate::isUnsignedInt(Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS')) ? Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS') : 30;
$date_from = date('Y-m-d', strtotime('-'.$nbDaysNewCustomers.' day'));
$date_to = date('Y-m-d');
$helper->href = $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_date_add[]='.$date_from.'&customerFilter_date_add[]='.$date_to;
$helper->href = $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_a!date_add[]='.$date_from.'&customerFilter_a!date_add[]='.$date_to;
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysNewCustomers);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_new_customers';
$helper->tooltip = $this->l('The total number of new customers who registered in given period of time.', null, null, false);
@@ -1114,6 +1118,14 @@ class AdminCustomersControllerCore extends AdminController
public function processUpdate()
{
if (Validate::isLoadedObject($this->object)) {
if ($this->object->deleted == Customer::STATUS_DELETED) {
$this->errors[] = $this->l('You can not update a deleted customer.');
return false;
} else if ($this->object->deleted == Customer::STATUS_BANNED) {
$this->errors[] = $this->l('You can not update a banned customer.');
return false;
}
$customer_email = trim(strval(Tools::getValue('email')));
// check if e-mail already used

View File

@@ -318,8 +318,10 @@ class AdminImportControllerCore extends AdminController
);
break;
case $this->entities[$this->l('Customers')]:
//Overwrite required_fields AS only email is required whereas other entities
$this->required_fields = array('email', 'passwd', 'lastname', 'firstname');
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
$this->required_fields[] = 'phone';
}
$this->available_fields = array(
'no' => array('label' => $this->l('Ignore this column')),
@@ -331,6 +333,7 @@ class AdminImportControllerCore extends AdminController
'birthday' => array('label' => $this->l('Birthday (yyyy-mm-dd)')),
'lastname' => array('label' => $this->l('Last Name *')),
'firstname' => array('label' => $this->l('First Name *')),
'phone' => array('label' => $this->l('Phone'). (Configuration::get('PS_ONE_PHONE_AT_LEAST') ? ' *' : '' )),
'newsletter' => array('label' => $this->l('Newsletter (0/1)')),
'optin' => array('label' => $this->l('Opt-in (0/1)')),
'group' => array('label' => $this->l('Groups (x,y,z...)')),
@@ -2699,6 +2702,10 @@ class AdminImportControllerCore extends AdminController
$convert = Tools::getValue('convert');
$force_ids = Tools::getValue('forceIDs');
$phoneRequired = false;
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
$phoneRequired = true;
}
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if ($convert) {
@@ -2707,7 +2714,13 @@ class AdminImportControllerCore extends AdminController
$info = AdminImportController::getMaskedRow($line);
$has_required_fields = $this->checkRequiredFields($info, 'firstname');
if ($has_required_fields) {
if ($phoneRequired && !Validate::isPhoneNumber(trim($info['phone']))) {
$this->errors[] = sprintf(
Tools::displayError('Invalid phone for %1$s (ID: %2$s).'),
$info['email'],
(isset($info['id']) && !empty($info['id']))? $info['id'] : 'null'
);
} else if ($has_required_fields) {
AdminImportController::setDefaultValues($info);
$customerExists = false;
if (isset($info['id'])
@@ -2723,7 +2736,7 @@ class AdminImportControllerCore extends AdminController
$customer->force_id = $info['id'];
}
} else {
$customer = new Customer();
$customer = new Customer();
}
$customer_exist = false;
@@ -2833,6 +2846,9 @@ class AdminImportControllerCore extends AdminController
if ($res && isset($customer_groups)) {
$customer->updateGroup($customer_groups);
if ($phoneRequired) {
CartCustomerGuestDetail::updateCustomerPhoneNumber($customer->email, $customer->phone);
}
}
}
}

View File

@@ -2546,7 +2546,7 @@ class AdminOrdersControllerCore extends AdminController
$dateFrom = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
$dateTo = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $dateFrom, $dateTo);
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$dateFrom.'&date_to='.$dateTo;
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day'));
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
$helper->tooltip = $this->l('Total number of abandoned carts in given period of time.', null, null, false);
$this->kpis[] = $helper;

View File

@@ -3072,25 +3072,22 @@ class AdminProductsControllerCore extends AdminController
if ($serviceProductPriceInfo) {
$associationInfo['custom_price'] = $serviceProductPriceInfo['price'];
$associationInfo['id_tax_rules_group'] = $serviceProductPriceInfo['id_tax_rules_group'];
if ($serviceProductPriceInfo['id_tax_rules_group'] == 0) {
$associationInfo['tax_rules_group_name'] = $this->l('No tax');
} else {
$objTaxRuleGroup = new TaxRulesGroup(
$serviceProductPriceInfo['id_tax_rules_group'],
$this->context->language->id
);
$associationInfo['tax_rules_group_name'] = $this->l('No tax');
if (Validate::isLoadedObject($objTaxRuleGroup = new TaxRulesGroup(
$serviceProductPriceInfo['id_tax_rules_group'],
$this->context->language->id
))) {
$associationInfo['tax_rules_group_name'] = $objTaxRuleGroup->name;
}
$associationInfo['id_room_type_service_product_price'] = $serviceProductPriceInfo['id_room_type_service_product_price'];
}
if ($objProduct->id_tax_rules_group == 0) {
$associationInfo['default_tax_rules_group_name'] = $this->l('No tax');
} else {
$objTaxRuleGroup = new TaxRulesGroup(
$objProduct->id_tax_rules_group,
$this->context->language->id
);
$associationInfo['default_tax_rules_group_name'] = $this->l('No tax');
if (Validate::isLoadedObject($objTaxRuleGroup = new TaxRulesGroup(
$objProduct->id_tax_rules_group,
$this->context->language->id
))) {
$associationInfo['default_tax_rules_group_name'] = $objTaxRuleGroup->name;
}
@@ -3100,9 +3097,13 @@ class AdminProductsControllerCore extends AdminController
$associatedServiceProducts[$associationInfo['position']] = $serviceProduct;
} else {
$serviceProduct['is_associated'] = false;
$objTaxRulesGroup = new TaxRulesGroup($serviceProduct['id_tax_rules_group'], $this->context->language->id);
$serviceProduct['tax_rules_group_name'] = $objTaxRulesGroup->name;
$serviceProduct['tax_rules_group_name'] = $this->l('No tax');
if (Validate::isLoadedObject($objTaxRulesGroup = new TaxRulesGroup(
$serviceProduct['id_tax_rules_group'],
$this->context->language->id
))) {
$serviceProduct['tax_rules_group_name'] = $objTaxRulesGroup->name;
}
$unassociatedServiceProducts[] = $serviceProduct;
}
@@ -3135,35 +3136,9 @@ class AdminProductsControllerCore extends AdminController
}
if (Validate::isLoadedObject($objProduct = new Product($idProduct))) {
// validate submitted details
$availableServiceProducts = Tools::getValue('available_service_products');
$objServiceProducts = array();
foreach ($availableServiceProducts as $idServiceProduct) {
$prefix = 'service_product_'.$idServiceProduct.'_';
$isAssociated = in_array(Tools::getValue($prefix.'associated'), array('on', 'true', '1'));
$price = Tools::getValue($prefix.'price');
$idTaxRulesGroup = Tools::getValue($prefix.'id_tax_rules_group');
if ($isAssociated) {
$objServiceProduct = new Product($idServiceProduct, false, $this->context->language->id);
if (Validate::isLoadedObject($objServiceProduct)) {
// cache for faster access in next foreach loop
$objServiceProducts[$idServiceProduct] = $objServiceProduct;
if (!$price) {
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is empty.'), $objServiceProduct->name);
} elseif (!Validate::isPrice($price)) {
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is invalid.'), $objServiceProduct->name);
}
} else{
$this->errors[] = sprintf($this->l('Service product #%s is not available.'), $idServiceProduct);
}
}
}
if (!count($this->errors)) {
// save submitted details
if ($availableServiceProducts = Tools::getValue('available_service_products')) {
// validate submitted details
$objServiceProducts = array();
foreach ($availableServiceProducts as $idServiceProduct) {
$prefix = 'service_product_'.$idServiceProduct.'_';
@@ -3172,59 +3147,86 @@ class AdminProductsControllerCore extends AdminController
$idTaxRulesGroup = Tools::getValue($prefix.'id_tax_rules_group');
if ($isAssociated) {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$objServiceProduct = new Product($idServiceProduct, false, $this->context->language->id);
if (Validate::isLoadedObject($objServiceProduct)) {
// cache for faster access in next foreach loop
$objServiceProducts[$idServiceProduct] = $objServiceProduct;
// if already associated
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$priceInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
$idServiceProduct,
$idProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
);
if (!$price) {
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is empty.'), $objServiceProduct->name);
} elseif (!Validate::isPrice($price)) {
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is invalid.'), $objServiceProduct->name);
}
} else{
$this->errors[] = sprintf($this->l('Service product #%s is not available.'), $idServiceProduct);
}
}
}
$objRoomTypeServiceProductPrice = null;
if ($priceInfo) {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice($priceInfo['id_room_type_service_product_price']);
if (!count($this->errors)) {
// save submitted details
foreach ($availableServiceProducts as $idServiceProduct) {
$prefix = 'service_product_'.$idServiceProduct.'_';
$isAssociated = in_array(Tools::getValue($prefix.'associated'), array('on', 'true', '1'));
$price = Tools::getValue($prefix.'price');
$idTaxRulesGroup = Tools::getValue($prefix.'id_tax_rules_group');
if ($isAssociated) {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
// if already associated
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$priceInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
$idServiceProduct,
$idProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
);
$objRoomTypeServiceProductPrice = null;
if ($priceInfo) {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice($priceInfo['id_room_type_service_product_price']);
} else {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
$objRoomTypeServiceProductPrice->id_element = $idProduct;
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
}
$objRoomTypeServiceProductPrice->price = $price;
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
$objRoomTypeServiceProductPrice->save();
} else {
// create new association
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$objRoomTypeServiceProduct->addRoomProductLink(
$idServiceProduct,
$idProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
);
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
$objRoomTypeServiceProductPrice->id_element = $idProduct;
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
$objRoomTypeServiceProductPrice->price = $price;
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
$objRoomTypeServiceProductPrice->save();
}
$objRoomTypeServiceProductPrice->price = $price;
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
$objRoomTypeServiceProductPrice->save();
} else {
// create new association
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$objRoomTypeServiceProduct->addRoomProductLink(
// remove association
RoomTypeServiceProduct::deleteRoomProductLink(
$idServiceProduct,
$idProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
$idProduct
);
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
$objRoomTypeServiceProductPrice->id_element = $idProduct;
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
$objRoomTypeServiceProductPrice->price = $price;
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
$objRoomTypeServiceProductPrice->save();
RoomTypeServiceProductPrice::deleteRoomProductPrices(
$idServiceProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
$idProduct
);
}
} else {
// remove association
RoomTypeServiceProduct::deleteRoomProductLink(
$idServiceProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
$idProduct
);
RoomTypeServiceProductPrice::deleteRoomProductPrices(
$idServiceProduct,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
$idProduct
);
}
}
}

View File

@@ -238,24 +238,13 @@ class AdminSearchControllerCore extends AdminController
) {
$objRoomType = new HotelRoomType();
$accessibleHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
foreach ($this->_list['products'] as $key => $product) {
if ($roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) {
if (!in_array($roomInfo['id_hotel'], $accessibleHotels)) {
unset($this->_list['products'][$key]);
}
} else if ($associatedData = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product['id_product'])) {
$count = 0;
foreach ($associatedData['room_type'] as $id_room_type) {
$objRoomType = new HotelRoomType($id_room_type);
if (in_array($objRoomType->id_hotel, $accessibleHotels)) {
$count += 1;
}
}
if ($count) {
$this->_list['service_products'][] = $this->_list['products'][$key];
}
} else if (!Product::isBookingProduct($product['id_product'])) {
$this->_list['service_products'][] = $this->_list['products'][$key];
unset($this->_list['products'][$key]);
}

View File

@@ -324,7 +324,7 @@ class AdminTabsControllerCore extends AdminController
break;
}
}
} else {
} else if ($this->display == 'add') {
// Temporary add the position depend of the selection of the parent category
if (!Tools::isSubmit('id_tab')) { // @todo Review
$_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));

View File

@@ -1,10 +1,10 @@
Customer ID;Active (0/1);Titles ID (Mr = 1, Mrs = 2, else 0);Email *;Password *;Birthday (yyyy-mm-dd);Last Name *;First Name *;Newsletter (0/1);Opt-in (0/1);Groups (x,y,z...);Default Group ID
1;1;1;peterpan@qloapps.com;123456789;1987-04-02;Pan;Peter;1;0;Customer;3
2;1;2;monkeydluffy@qloapps.com;123456789;1989-11-12;Luffy;Monkey D;1;0;Customer;3
3;1;2;tigerlily@qloapps.com;123456789;1982-02-28;Lily;Tiger;1;0;Customer;3
4;1;1;jameshook@qloapps.com;123456789;1952-12-04;Hook;James;0;1;Guest;2
5;1;2;tinkerbell@qloapps.com;123456789;1900-01-01;Bell;Tinker;1;1;Customer;3
6;1;1;bobsmee@qloapps.com;123456789;1971-10-21;Smee;Bob;1;1;Customer;3
7;1;1;tictaccrocodile@qloapps.com;123456789;1991-09-27;Crocodile;Tictac;0;0;Guest;2
8;1;1;jackbanning@qloapps.com;123456789;2003-07-05;Banning;Jack;0;0;Visitor;1
9;0;2;maggiedoe@qloapps.com;123456789;2006-02-27;Doe;Maggie;0;0;Visitor;1
Customer ID;Active (0/1);Titles ID (Mr = 1, Mrs = 2, else 0);Email *;Password *;Birthday (yyyy-mm-dd);Last Name *;First Name *;Phone;Newsletter (0/1);Opt-in (0/1);Groups (x,y,z...);Default Group ID
1;1;1;peterpan@qloapps.com;123456789;1987-04-02;Pan;Peter;1234567890;1;0;Customer;3
2;1;2;monkeydluffy@qloapps.com;123456789;1989-11-12;Luffy;Monkey D;1234567890;1;0;Customer;3
3;1;2;tigerlily@qloapps.com;123456789;1982-02-28;Lily;Tiger;1234567890;1;0;Customer;3
4;1;1;jameshook@qloapps.com;123456789;1952-12-04;Hook;James;1234567890;0;1;Guest;2
5;1;2;tinkerbell@qloapps.com;123456789;1900-01-01;Bell;Tinker;1234567890;1;1;Customer;3
6;1;1;bobsmee@qloapps.com;123456789;1971-10-21;Smee;Bob;1234567890;1;1;Customer;3
7;1;1;tictaccrocodile@qloapps.com;123456789;1991-09-27;Crocodile;Tictac;1234567890;0;0;Guest;2
8;1;1;jackbanning@qloapps.com;123456789;2003-07-05;Banning;Jack;1234567890;0;0;Visitor;1
9;0;2;maggiedoe@qloapps.com;123456789;2006-02-27;Doe;Maggie;1234567890;0;0;Visitor;1
1 Customer ID Active (0/1) Titles ID (Mr = 1, Mrs = 2, else 0) Email * Password * Birthday (yyyy-mm-dd) Last Name * First Name * Phone Newsletter (0/1) Opt-in (0/1) Groups (x,y,z...) Default Group ID
2 1 1 1 peterpan@qloapps.com 123456789 1987-04-02 Pan Peter 1234567890 1 0 Customer 3
3 2 1 2 monkeydluffy@qloapps.com 123456789 1989-11-12 Luffy Monkey D 1234567890 1 0 Customer 3
4 3 1 2 tigerlily@qloapps.com 123456789 1982-02-28 Lily Tiger 1234567890 1 0 Customer 3
5 4 1 1 jameshook@qloapps.com 123456789 1952-12-04 Hook James 1234567890 0 1 Guest 2
6 5 1 2 tinkerbell@qloapps.com 123456789 1900-01-01 Bell Tinker 1234567890 1 1 Customer 3
7 6 1 1 bobsmee@qloapps.com 123456789 1971-10-21 Smee Bob 1234567890 1 1 Customer 3
8 7 1 1 tictaccrocodile@qloapps.com 123456789 1991-09-27 Crocodile Tictac 1234567890 0 0 Guest 2
9 8 1 1 jackbanning@qloapps.com 123456789 2003-07-05 Banning Jack 1234567890 0 0 Visitor 1
10 9 0 2 maggiedoe@qloapps.com 123456789 2006-02-27 Doe Maggie 1234567890 0 0 Visitor 1

View File

@@ -217,15 +217,15 @@ class AdminCustomNavigationLinkSettingController extends ModuleAdminController
}
if ($cmsCategories = CMSCategory::getCategories($this->context->language->id, false, false)) {
if (!isset($smartyVars['id_cms_category'])) {
$smartyVars['id_cms_category'] = $cmsCategories[0]['id_cms_category'];
}
foreach ($cmsCategories as $cmsCatKey => $cmsCategory) {
if (!isset($categoryWiseCmsPages[$cmsCategory['id_cms_category']])) {
unset($cmsCategories[$cmsCatKey]);
}
}
if (!isset($smartyVars['id_cms_category']) && $cmsCategories) {
$smartyVars['id_cms_category'] = reset($cmsCategories)['id_cms_category'];
}
}
$smartyVars['categoryWiseCmsPages'] = $categoryWiseCmsPages;

View File

@@ -156,7 +156,7 @@ class Blocknewsletter extends Module
public function hookActionValidateCartRule($params)
{
$customer = new Customer($params['context']->cart->id_customer);
if ($params['cart_rule']->code == Configuration::get('NW_VOUCHER_CODE')) {
if ($params['cart_rule']->code && $params['cart_rule']->code == Configuration::get('NW_VOUCHER_CODE')) {
if ($customer->id && !$customer->is_guest) {
if (count(Order::getCustomerOrders($customer->id))) {
$params['isValidatedByModules'] = false;

View File

@@ -93,7 +93,7 @@ class Dashactivity extends Module
array(
'dashactivity_config_form' => $this->renderConfigForm(),
'link' => $this->context->link,
'new_customer_filter_link' => $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_date_add[]='.$date_from.'&customerFilter_date_add[]='.$date_to
'new_customer_filter_link' => $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_a!date_add[]='.$date_from.'&customerFilter_a!date_add[]='.$date_to
)
);

View File

@@ -262,7 +262,7 @@ class DashProducts extends Module
(!is_null($id_hotel) ? HotelBranchInformation::addHotelRestriction($id_hotel, 'hbd') : '').'
GROUP BY hbd.`id_product`
ORDER BY `sales` DESC
LIMIT '.(int) Configuration::get('DASHPRODUCT_NBR_SHOW_BEST_SELLER', 10)
LIMIT '.(int) Configuration::get('DASHPRODUCT_NBR_SHOW_BEST_SELLER')
);
$body = array();
@@ -366,6 +366,7 @@ class DashProducts extends Module
$products = $this->getTotalViewed($date_from, $date_to, (int)Configuration::get('DASHPRODUCT_NBR_SHOW_MOST_VIEWED'), $id_hotel);
$body = array();
if (is_array($products) && count($products)) {
$objHotelRoomType = new HotelRoomType();
foreach ($products as $product) {
$product_obj = new Product((int)$product['id_object'], true, $this->context->language->id);
if (!Validate::isLoadedObject($product_obj)) {
@@ -379,8 +380,8 @@ class DashProducts extends Module
$img = ImageManager::thumbnail($path_to_image, 'product_mini_'.$product_obj->id.'.'.$this->context->controller->imageType, 45, $this->context->controller->imageType);
}
$objHotelRoomType = new HotelRoomType($product_obj->id);
$objHotelBranch = new HotelBranchInformation($objHotelRoomType->id_hotel, $this->context->language->id);
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product_obj->id);
$objHotelBranch = new HotelBranchInformation($roomTypeInfo['id_hotel'], $this->context->language->id);
$tr = array();
$tr[] = array(

View File

@@ -527,7 +527,7 @@ class HotelCartBookingData extends ObjectModel
}
}
if ($res && $objCart->updateQty((int)($roomsRequired * $num_days), $id_product)) {
if ($id_room) {
if ($roomsRequired == 1) {
return $obj_htl_cart_booking_data->id;
} else {
return true;
@@ -1020,7 +1020,7 @@ class HotelCartBookingData extends ObjectModel
$context->language->id
);
$errors[] = sprintf(
'You can not book rooms for hotel \'%s\' after date %s. Please remove rooms from %s - %s to proceed.',
$objModule->l('You can not book rooms for hotel "%s" after date %s. Please remove rooms from %s - %s to proceed.', 'HotelOrderRestrictDate'),
$objHotelBranchInformation->hotel_name,
Tools::displayDate($maxOrderDate),
Tools::displayDate($roomData['date_from']),
@@ -1040,7 +1040,7 @@ class HotelCartBookingData extends ObjectModel
$context->language->id
);
$errors[] = sprintf(
'You can not book rooms for hotel \'%s\' before date %s. Please remove rooms from %s - %s to proceed.',
$objModule->l('You can not book rooms for hotel "%s" before date %s. Please remove rooms from %s - %s to proceed.', 'HotelOrderRestrictDate'),
$objHotelBranchInformation->hotel_name,
Tools::displayDate($minOrderDate),
Tools::displayDate($roomData['date_from']),
@@ -1066,9 +1066,9 @@ class HotelCartBookingData extends ObjectModel
}
}
if ($isRoomBooked) {
$errors[] = sprintf($objModule->l('The Room \'%s\' has been booked by another customer from \'%s\' to \'%s\' Please remove rooms from cart to proceed', 'HotelOrderRestrictDate'), $product['name'], date('d-m-Y', strtotime($roomData['date_from'])), date('d-m-Y', strtotime($roomData['date_to'])));
$errors[] = sprintf($objModule->l('The Room "%s" has been booked by another customer from "%s" to "%s" Please remove rooms from cart to proceed', 'HotelOrderRestrictDate'), $product['name'], date('d-m-Y', strtotime($roomData['date_from'])), date('d-m-Y', strtotime($roomData['date_to'])));
} else {
$errors[] = sprintf($objModule->l('The Room \'%s\' is no longer avalable from \'%s\' to \'%s\' Please remove rooms from cart to proceed', 'HotelOrderRestrictDate'), $product['name'], date('d-m-Y', strtotime($roomData['date_from'])), date('d-m-Y', strtotime($roomData['date_to'])));
$errors[] = sprintf($objModule->l('The Room "%s" is no longer available from "%s" to "%s" Please remove rooms from cart to proceed', 'HotelOrderRestrictDate'), $product['name'], date('d-m-Y', strtotime($roomData['date_from'])), date('d-m-Y', strtotime($roomData['date_to'])));
}
}
}

View File

@@ -2229,15 +2229,7 @@ class HotelHelper
$idProduct = $objProduct->id;
// add to applicable categories
$objCategory = new Category($serviceProduct['id_category_default']);
if ($categories = $objCategory->getParentsCategories()) {
$idsCategory = array();
foreach ($categories as $category) {
$idsCategory[] = $category['id_category'];
}
$objProduct->addToCategories($idsCategory);
}
$objProduct->addToCategories($serviceProduct['id_category_default']);
Search::indexation(Tools::link_rewrite($serviceProdDataDefult['name']), $idProduct);
StockAvailable::updateQuantity($idProduct, null, 999999999);

View File

@@ -51,7 +51,7 @@ class HotelReservationSystem extends Module
'feature_prices' => array('description' => 'Feature prices', 'class' => 'HotelRoomTypeFeaturePricing'),
'advance_payments' => array('description' => 'Room type advance payment', 'class' => 'HotelAdvancedPayment'),
'cart_bookings' => array('description' => 'Cart bookings', 'class' => 'HotelCartBookingData'),
'bookings' => array('description' => 'Order bookings', 'class' => 'HotelBookingDetail'),
'room_bookings' => array('description' => 'Room bookings', 'class' => 'HotelBookingDetail'),
'booking_extra_demands' => array('description' => 'Booking extra demands', 'class' => 'HotelBookingDemands'),
'extra_demands' => array('description' => 'Extra demands', 'class' => 'HotelRoomTypeGlobalDemand'),
'extra_services' => array('description' => 'Extra services', 'class' => 'Product', 'parameters_attribute' => 'webserviceRoomTypeServicesParameters'),

View File

@@ -593,6 +593,7 @@ $(document).ready(function() {
$(document).on('click', '.booking_occupancy_wrapper .remove-room-link', function(e) {
e.preventDefault();
e.stopPropagation();
booking_occupancy_inner = $(this).closest('.booking_occupancy_inner');
$(this).closest('.occupancy_info_block').remove();
@@ -780,8 +781,8 @@ $(document).ready(function() {
occupancy_block += '</div>';
occupancy_block += '</div>';
occupancy_block += '</div>';
occupancy_block += '<hr class="occupancy-info-separator col-sm-12">';
occupancy_block += '</div>';
occupancy_block += '<hr class="occupancy-info-separator col-sm-12">';
$(booking_occupancy_wrapper).find('.booking_occupancy_inner').append(occupancy_block);

View File

@@ -29,6 +29,8 @@ class QhrHotelReviewHelper
return (bool) !Db::getInstance()->getValue(
'SELECT COUNT(*) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
WHERE hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_OUT.'
AND hbd.`is_refunded` != 1
AND hbd.`is_cancelled` != 1
AND hbd.`id_order` = '.(int) $idOrder
);
}
@@ -57,6 +59,11 @@ class QhrHotelReviewHelper
return false;
}
$objOrder = new Order($idOrder);
if ($objOrder->hasCompletelyRefunded()) {
return false;
}
if (self::getIsOrderCheckedOut($idOrder)) {
return true;
}
@@ -120,12 +127,6 @@ class QhrHotelReviewHelper
);
}
public static function getPathForCreation($idHotelReview)
{
$folders = str_split((string)$id_image);
return implode('/', $folders).'/';
}
public static function createDirectory($dir)
{
if (!file_exists($dir)) {