Merge branch 'develop' into gli-2939

This commit is contained in:
Amit sharma
2026-06-01 17:41:40 +05:30
179 changed files with 8470 additions and 1307 deletions

View File

@@ -1179,9 +1179,10 @@ abstract class AdminTabCore
if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) {
continue;
}
/* Automatically encrypt password in MD5 */
/* Automatically hash password */
if ($key == 'passwd' && !empty($value)) {
$value = Tools::encrypt($value);
$objHash = new PasswordHashing();
$value = $objHash->passwordHash($value);
}
$object->{$key} = $value;
}

View File

@@ -1833,7 +1833,7 @@ class CartCore extends ObjectModel
$this->id,
[],
0,
null,
isset($product['id_hotel_cart_booking']) ? $product['id_hotel_cart_booking'] : null,
null,
(int)$product['id_product'],
null,

View File

@@ -1477,10 +1477,7 @@ class CartRuleCore extends ObjectModel
*/
public static function isFeatureActive()
{
static $is_feature_active = null;
if ($is_feature_active === null) {
$is_feature_active = (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
}
$is_feature_active = (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
return $is_feature_active;
}

View File

@@ -332,6 +332,14 @@ class CookieCore
$this->logout();
}
if (isset($this->_content['id_customer']) && isset($this->_content['passwd']) && (int)$this->_content['id_customer']) {
if (Validate::isLoadedObject($objCustomer = new Customer((int)$this->_content['id_customer']))) {
if ($objCustomer->passwd != $this->_content['passwd']) {
$this->logout();
}
}
}
if (!isset($this->_content['date_add'])) {
$this->_content['date_add'] = date('Y-m-d H:i:s');
}

View File

@@ -167,7 +167,7 @@ class CustomerCore extends ObjectModel
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 60),
'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false),
'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'),
@@ -383,19 +383,28 @@ class CustomerCore extends ObjectModel
FROM `'._DB_PREFIX_.'customer`
WHERE `email` = \''.pSQL($email).'\'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.(isset($passwd) ? 'AND `passwd` = \''.pSQL(Tools::encrypt($passwd)).'\'' : '').'
AND `deleted` = 0
'.($ignore_guest ? ' AND `is_guest` = 0' : ''));
if (!$result) {
return false;
}
if (isset($passwd)) {
$objHash = new PasswordHashing();
if (!$objHash->validateHash($passwd, $result['passwd'])) {
return false;
}
}
$this->id = $result['id_customer'];
foreach ($result as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
if (isset($passwd) && !$objHash->isPrimaryHash($passwd, $result['passwd'])) {
$this->passwd = $objHash->passwordHash($passwd);
$this->update();
}
return $this;
}
@@ -560,7 +569,7 @@ class CustomerCore extends ObjectModel
*/
public static function checkPassword($id_customer, $passwd)
{
if (!Validate::isUnsignedId($id_customer) || !Validate::isMd5($passwd)) {
if (!Validate::isUnsignedId($id_customer)) {
die(Tools::displayError());
}
$cache_id = 'Customer::checkPassword'.(int)$id_customer.'-'.$passwd;
@@ -852,7 +861,8 @@ class CustomerCore extends ObjectModel
}
$this->is_guest = 0;
$this->passwd = Tools::encrypt($password);
$objHash = new PasswordHashing();
$this->passwd = $objHash->passwordHash($password);
$this->cleanGroups();
$this->addGroups(array(Configuration::get('PS_CUSTOMER_GROUP'))); // add default customer group
$this->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP');
@@ -887,7 +897,8 @@ class CustomerCore extends ObjectModel
public function setWsPasswd($passwd)
{
if ($this->id == 0 || $this->passwd != $passwd) {
$this->passwd = Tools::encrypt($passwd);
$objHash = new PasswordHashing();
$this->passwd = $objHash->passwordHash($passwd);
}
return true;
}

View File

@@ -102,7 +102,7 @@ class EmployeeCore extends ObjectModel
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 32),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 60),
'last_passwd_gen' => array('type' => self::TYPE_STRING),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
@@ -281,11 +281,17 @@ class EmployeeCore extends ObjectModel
SELECT *
FROM `'._DB_PREFIX_.'employee`
WHERE `email` = \''.pSQL($email).'\'
'.($active_only ? ' AND `active` = 1' : '')
.($passwd !== null ? ' AND `passwd` = \''.Tools::encrypt($passwd).'\'' : ''));
'.($active_only ? ' AND `active` = 1' : ''));
if (!$result) {
return false;
}
if ($passwd !== null) {
$objHash = new PasswordHashing();
if (!$objHash->validateHash($passwd, $result['passwd'])) {
return false;
}
}
$this->id = $result['id_employee'];
$this->id_profile = $result['id_profile'];
foreach ($result as $key => $value) {
@@ -293,6 +299,11 @@ class EmployeeCore extends ObjectModel
$this->{$key} = $value;
}
}
if ($passwd !== null && !$objHash->isPrimaryHash($passwd, $result['passwd'])) {
$this->passwd = $objHash->passwordHash($passwd);
$this->update();
}
return $this;
}
@@ -316,7 +327,7 @@ class EmployeeCore extends ObjectModel
*/
public static function checkPassword($id_employee, $passwd)
{
if (!Validate::isUnsignedId($id_employee) || !Validate::isPasswd($passwd, 8)) {
if (!Validate::isUnsignedId($id_employee)) {
die(Tools::displayError());
}
@@ -364,19 +375,20 @@ class EmployeeCore extends ObjectModel
// validate and set password for the employee
public function setWsPasswd($passwd)
{
$objHash = new PasswordHashing();
if ($this->id != 0) {
if ($this->passwd != $passwd) {
if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) {
WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134);
} else {
$this->passwd = Tools::encrypt($passwd);
$this->passwd = $objHash->passwordHash($passwd);
}
}
} else {
if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) {
WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134);
} else {
$this->passwd = Tools::encrypt($passwd);
$this->passwd = $objHash->passwordHash($passwd);
}
}

View File

@@ -1188,7 +1188,8 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
}
if ($field == 'passwd') {
if ($value = Tools::getValue($field)) {
$this->{$field} = Tools::encrypt($value);
$objHash = new PasswordHashing();
$this->{$field} = $objHash->passwordHash($value);
}
} else {
$this->{$field} = $value;

122
classes/PasswordHashing.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class PasswordHashingCore
{
/** @var array Available password hashing methods. */
private $passwordHashMethods = array();
/**
* Check whether the stored hash matches the primary hashing method.
*
* @param string $passwd Plain-text password to validate.
* @param string $hash Stored password hash.
* @param string $staticSalt Static salt used by legacy hash methods.
*
* @return bool
*/
public function isPrimaryHash($passwd, $hash, $staticSalt = _COOKIE_KEY_)
{
if (!count($this->passwordHashMethods)) {
$this->initPasswordHashMethods();
}
$closure = reset($this->passwordHashMethods);
return $closure['verify']($passwd, $hash, $staticSalt);
}
/**
* Validate a password against all supported hashing methods.
*
* @param string $passwd Plain-text password to validate.
* @param string $hash Stored password hash.
* @param string $staticSalt Static salt used by legacy hash methods.
*
* @return bool
*/
public function validateHash($passwd, $hash, $staticSalt = _COOKIE_KEY_)
{
if (!count($this->passwordHashMethods)) {
$this->initPasswordHashMethods();
}
foreach ($this->passwordHashMethods as $closure) {
if ($closure['verify']($passwd, $hash, $staticSalt)) {
return true;
}
}
return false;
}
/**
* Hash a plain-text password with the primary hashing method.
*
* @param string $plaintextPassword Password to hash.
* @param string $staticSalt Static salt reserved for legacy hash methods.
*
* @return string
*/
public function passwordHash($plaintextPassword, $staticSalt = _COOKIE_KEY_)
{
if (!count($this->passwordHashMethods)) {
$this->initPasswordHashMethods();
}
$closure = reset($this->passwordHashMethods);
return $closure['hash']($plaintextPassword, $staticSalt, $closure['option']);
}
/**
* Initialize the supported password hashing methods.
*
* @return void
*/
private function initPasswordHashMethods()
{
$this->passwordHashMethods = array(
'bcrypt' => array(
'option' => array(),
'hash' => function ($passwd, $staticSalt, $option) {
return password_hash($passwd, PASSWORD_BCRYPT);
},
'verify' => function ($passwd, $hash, $staticSalt) {
return password_verify($passwd, $hash);
},
),
'md5' => array(
'option' => array(),
'hash' => function ($passwd, $staticSalt, $option) {
return md5($staticSalt.$passwd);
},
'verify' => function ($passwd, $hash, $staticSalt) {
return md5($staticSalt.$passwd) === $hash;
},
),
);
}
}

View File

@@ -525,7 +525,7 @@ abstract class PaymentModuleCore extends Module
$msg->id_cart = (int)$id_cart;
$msg->id_customer = (int)($order->id_customer);
$msg->id_order = (int)$order->id;
$msg->private = 1;
$msg->private = 0;
$msg->add();
}
}
@@ -707,28 +707,32 @@ abstract class PaymentModuleCore extends Module
if ($old_message && !$old_message['private']) {
$update_message = new Message((int)$old_message['id_message']);
$update_message->id_order = (int)$order->id;
$update_message->id_employee = (isset($this->context->employee) && $this->context->employee->id) ? (int)$this->context->employee->id : 0;
$update_message->private = !Tools::getValue('visibility');
$update_message->update();
if (Tools::getValue('visibility')) {
// Add this message in the customer thread
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_contact = (int)Configuration::get('PS_CUSTOMER_SERVICE_CONTACT');
$customer_thread->id_customer = (int)$order->id_customer;
$customer_thread->id_shop = (int)$this->context->shop->id;
$customer_thread->id_order = (int)$order->id;
$customer_thread->id_lang = (int)$this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->phone = $this->context->customer->phone ? $this->context->customer->phone : '';
$customer_thread->status = CustomerThread::QLO_CUSTOMER_THREAD_STATUS_OPEN;
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->id_employee = (isset($this->context->employee) && $this->context->employee->id) ? (int)$this->context->employee->id : 0;
$customer_message->ip_address = (int)ip2long(Tools::getRemoteAddr());
$customer_message->message = $update_message->message;
$customer_message->private = !Tools::getValue('visibility');
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
}

View File

@@ -141,11 +141,18 @@ class ProfileCore extends ObjectModel
);
}
} else {
$result = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'access` a
LEFT JOIN `'._DB_PREFIX_.'tab` t ON t.id_tab = a.id_tab
WHERE `id_profile` = '.(int)$id_profile);
if ($result = Db::getInstance()->executeS('
SELECT * FROM `'._DB_PREFIX_.'access` a
LEFT JOIN `'._DB_PREFIX_.'tab` t ON t.id_tab = a.id_tab
WHERE `id_profile` = '.(int)$id_profile)
) {
foreach ($result as $key => $profileAccess) {
$result[$key]['view'] = (int) $profileAccess['view'];
$result[$key]['delete'] = (int) $profileAccess['delete'];
$result[$key]['add'] = (int) $profileAccess['add'];
$result[$key]['edit'] = (int) $profileAccess['edit'];
}
}
foreach ($result as $row) {
self::$_cache_accesses[$id_profile][$type][$row[$type]] = $row;

View File

@@ -53,7 +53,7 @@ class ReferrerCore extends ObjectModel
'primary' => 'id_referrer',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'size' => 32),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'size' => 60),
'http_referer_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64),
'request_uri_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64),
'http_referer_like' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64),

View File

@@ -2608,29 +2608,26 @@ FileETag none
public static function getDefaultIndexContent()
{
return '<?php
/**
* 2007-'.date('Y').' PrestaShop
*
/*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-'.date('Y').' PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

View File

@@ -1140,4 +1140,4 @@ class ValidateCore
{
return (preg_match('/^(?:'.Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id).')\s*([0-9]+)$/i', $id));
}
}
}

View File

@@ -37,7 +37,8 @@ class CacheFsCore extends Cache
$keys_filename = $this->getFilename(self::KEYS_NAME);
if (@filemtime($keys_filename)) {
$this->keys = unserialize(file_get_contents($keys_filename));
$keys = @unserialize(file_get_contents($keys_filename));
$this->keys = is_array($keys) ? $keys : array();
}
}

View File

@@ -527,7 +527,10 @@ class AdminControllerCore extends Controller
29 => $this->l('Successful upgrade'),
30 => $this->l('A partial refund was successfully created.'),
31 => $this->l('The discount was successfully generated.'),
32 => $this->l('Successfully signed in to PrestaShop Addons')
32 => $this->l('Successfully signed in to PrestaShop Addons'),
33 => $this->l('The selected module(s) have been successfully enabled.'),
34 => $this->l('The selected module(s) have been successfully disabled.'),
);
if (!$this->identifier) {
@@ -554,8 +557,8 @@ class AdminControllerCore extends Controller
}
if ($this->access_query) {
if (Tools::getValue($this->identifier)) {
$this->access_query .= ' AND a.'.$this->identifier.'='.(int) Tools::getValue($this->identifier);
if (!Db::getInstance()->executeS($this->access_query)) {
$access_query = $this->access_query.' AND a.'.$this->identifier.'='.(int) Tools::getValue($this->identifier);
if (!Db::getInstance()->executeS($access_query)) {
$this->tabAccess['view'] = 0;
$this->tabAccess['add'] = 0;
$this->tabAccess['edit'] = 0;
@@ -886,7 +889,7 @@ class AdminControllerCore extends Controller
}
if (is_array($value)) {
if ($value[0] === '' && $value[1] === '') {
if (isset($value[0], $value[1]) && $value[0] === '' && $value[1] === '') {
$value = '';
} else {
$value = json_encode($value);
@@ -915,7 +918,7 @@ class AdminControllerCore extends Controller
}
if (is_array($value)) {
if ($value[0] === '' && $value[1] === '') {
if (isset($value[0], $value[1]) && $value[0] === '' && $value[1] === '') {
$value = '';
} else {
$value = json_encode($value);
@@ -1427,8 +1430,8 @@ class AdminControllerCore extends Controller
} elseif ($this->postImage($object->id) && !count($this->errors) && $this->_redirect) {
$parent_id = (int)Tools::getValue('id_parent', 1);
// Specific back redirect
if ($back = Tools::getValue('back')) {
$this->redirect_after = urldecode($back).'&conf=4';
if (($back = Tools::secureReferrer(Tools::getValue('back'))) && $back != __PS_BASE_URI__) {
$this->redirect_after=urldecode($back).'&conf=4';
}
// Specific scene feature
// @todo change stay_here submit name (not clear for redirect to scene ... )
@@ -2397,7 +2400,7 @@ class AdminControllerCore extends Controller
$must_have_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST);
if (!empty($must_have_module_list) && $must_have_module_list_xml = @simplexml_load_string($must_have_module_list)) {
$must_have_module_list_array = array();
if (is_object($country_module_list_xml->module)) {
if (is_object($must_have_module_list_xml->module)) {
foreach ($must_have_module_list_xml->module as $l => $mo) {
$all_module_list[] = (string)$mo->name;
}
@@ -3033,7 +3036,8 @@ class AdminControllerCore extends Controller
$upgradeInfo = simplexml_load_string($content);
$this->context->smarty->assign(array(
'upgrade_info' => $upgradeInfo
'upgrade_info' => $upgradeInfo,
'debug_mode' => (bool) _PS_MODE_DEV_,
));
}
@@ -3838,9 +3842,10 @@ class AdminControllerCore extends Controller
if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) {
continue;
}
/* Automatically encrypt password in MD5 */
/* Automatically hash password */
if ($key == 'passwd' && !empty($value)) {
$value = Tools::encrypt($value);
$objHash = new PasswordHashing();
$value = $objHash->passwordHash($value);
}
$object->{$key} = $value;
}
@@ -4817,4 +4822,4 @@ class AdminControllerCore extends Controller
return 0;
}
}
}
}

View File

@@ -498,7 +498,6 @@ class FrontControllerCore extends Controller
'is_occupancy_wise_search' => $isOccupancyWiseSearch,
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'show_full_date' => $this->show_full_date
));

View File

@@ -689,6 +689,7 @@ abstract class ModuleCore
*/
public function uninstall()
{
Hook::exec('actionModuleUninstallBefore', array('object' => $this));
// Check module installation id validation
if (!Validate::isUnsignedId($this->id)) {
$this->_errors[] = Tools::displayError('The module is not installed.');

View File

@@ -457,17 +457,16 @@ class OrderDetailCore extends ObjectModel
$numDays = 1;
}
$unit_price_tax_excl = array_reduce($serviceProductData['additional_services'], function ($unitPriceTaxExcl, $item) {
return $unitPriceTaxExcl + (isset($item['unit_price_tax_excl']) ? $item['unit_price_tax_excl'] : 0);
}, 0);
$quantity = array_reduce($serviceProductData['additional_services'], function ($totalQty, $item) {
return $totalQty + (isset($item['quantity']) ? $item['quantity'] : 0);
}, 0);
$firstServiceProduct = array_shift($serviceProductData['additional_services']);
$unit_price_tax_excl = isset($firstServiceProduct['unit_price_tax_excl']) ? $firstServiceProduct['unit_price_tax_excl'] : 0;
$quantity = $quantity * $numDays;
$firstServiceProduct = array_shift($serviceProductData['additional_services']);
$tax_manager = TaxManagerFactory::getManager($this->vat_address, (int)$firstServiceProduct['id_tax_rules_group']);
$this->tax_calculator = $tax_manager->getTaxCalculator();
} elseif ($serviceProductData = $objServiceProductCartDetail->getServiceProductsInCart(
@@ -478,15 +477,13 @@ class OrderDetailCore extends ObjectModel
$taxGroupInfo['id_room_type'],
$this->product_id
)) {
$unit_price_tax_excl = array_reduce($serviceProductData, function ($unitPriceTaxExcl, $item) {
return $unitPriceTaxExcl + (isset($item['unit_price_tax_excl']) ? $item['unit_price_tax_excl'] : 0);
}, 0);
$quantity = array_reduce($serviceProductData, function ($totalQty, $item) {
return $totalQty + (isset($item['quantity']) ? $item['quantity'] : 0);
}, 0);
$serviceProductData = array_shift($serviceProductData);
$unit_price_tax_excl = isset($serviceProductData['unit_price_tax_excl']) ? $serviceProductData['unit_price_tax_excl'] : 0;
$numDays = 1;
if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $this->product_price_calculation_method)

View File

@@ -542,7 +542,7 @@ class OrderReturnCore extends ObjectModel
* Sets the new order return state
* @param int $newOrderReturnState
*/
public function changeIdOrderReturnState($newOrderReturnState, $idLang = 0)
public function changeIdOrderReturnState($newOrderReturnState, $idLang = 0, $sendMails = true)
{
$objOrder = new Order($this->id_order);
if (!$idLang) {
@@ -555,11 +555,12 @@ class OrderReturnCore extends ObjectModel
$this->state = $newOrderReturnState;
$this->save();
if ($objOrderReturnState->send_email_to_customer
if ($sendMails && (
$objOrderReturnState->send_email_to_customer
|| $objOrderReturnState->send_email_to_superadmin
|| $objOrderReturnState->send_email_to_employee
|| $objOrderReturnState->send_email_to_hotelier
) {
)) {
// Lets create data for the email templates
$objMail = new Mail();
$idHotel = 0;

View File

@@ -53,6 +53,10 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
public const API_SERVICE_PRICE_MODE_PER_BOOKING = 1;
public const API_SERVICE_PRICE_MODE_PER_DAY = 2;
public const API_BOOKING_ROOM_STATUS_ALLOTTED = 1;
public const API_BOOKING_ROOM_STATUS_CHECKIN = 2;
public const API_BOOKING_ROOM_STATUS_CHECKOUT = 3;
public static $definition = array(
'table' => 'htl_booking_detail',
'primary' => 'id',
@@ -158,6 +162,27 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
)
);
public $allowedFilters = array(
'id_property' => 'hbd.id_hotel',
'customer' => 'customer',
'id_customer' => 'o.id_customer',
'id_order' => 'o.id_order',
'reference' => 'o.reference',
'id_room' => 'hbd.id_room',
'is_cancelled' => 'hbd.is_cancelled',
'stay' => 'stay',
'room_status' => 'hbd.id_status',
'booking_status' => 'o.current_state',
'source' => 'o.source',
'booking_date' => 'o.date_add',
'checkin_date' => 'hbd.date_from',
'checkout_date' => 'hbd.date_to',
'id_room_type' => 'hbd.id_product',
'payment_type' => 'op.payment_type',
'payment_method' => 'op.payment_method',
);
/**
* @param WebserviceOutputBuilderCore $obj
* @return WebserviceSpecificManagementInterface
@@ -251,7 +276,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
'facilities' => 'facility',
'services' => 'service',
'cart_rules' => 'cart_rule',
'remarks' => 'remark'
'remarks' => 'remark',
'bookings' => 'booking'
);
$this->output = $this->renderXmlOutputUsingArray($this->output, array(), $parentKeys);
}
@@ -301,19 +327,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$this->renderResponse();
} else {
// @todo: add filters for the booking webservice
// $filters = $this->manageFilters();
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('bookings', array());
$bookings = Db::getInstance()->executeS('SELECT `id_order` FROM `'._DB_PREFIX_.'orders` WHERE 1');
foreach ($bookings as $booking) {
$more_attr = array(
'xlink_resource' => $this->wsObject->wsUrl.$this->wsObject->urlSegment[0].'/'.$booking['id_order'],
'id' => (int) $booking['id_order']
);
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('booking', array('objectsNodeName' => 'bookings'), $more_attr, false);
}
$this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('bookings', array());
$this->output = $this->objOutput->getObjectRender()->overrideContent($this->output);
$this->getBookingsList();
}
break;
@@ -507,7 +521,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$formattedRooms[$key]['occupancy'] = $occupancy;
if (isset($room['id_tax_rules_group'])) {
$formattedRooms[$key]['id_tax_rules_group'] = $room['id_tax_rules_group'];
} else if ($room['total_tax']) {
} else if (isset($room['total_tax'])) {
$formattedRooms[$key]['total_tax'] = $room['total_tax'];
}
}
@@ -1378,7 +1392,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$objCustomer->firstname = $customerDetails['firstname'];
$objCustomer->lastname = $customerDetails['lastname'];
$objCustomer->email = $customerDetails['email'];
$objCustomer->passwd = md5(time()._COOKIE_KEY_);
$objHash = new PasswordHashing();
$objCustomer->passwd = $objHash->passwordHash(Tools::passwdGen(32, 'RANDOM'));
$objCustomer->phone = (isset($customerDetails['phone']) ? $customerDetails['phone'] : '');
$objCustomer->cleanGroups();
$objCustomer->add();
@@ -3539,6 +3554,511 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
}
private function manageBookingFilter($filters)
{
$ret = '';
$allowedFilters = $this->allowedFilters;
foreach ($filters as $field => $raw) {
if (!$this->validateBookingFilterValue($field, $raw)) {
return false;
}
preg_match('/^(.*)\[(.*)\](.*)$/', $raw, $matches);
if (!array_key_exists($field, $allowedFilters)) {
$this->wsObject->setErrorDidYouMean(400, 'This filter does not exist', $field, array_keys($allowedFilters), 32);
return false;
}
if ($field === 'customer') {
$escapedValue = pSQL($raw);
$ret .= ' AND (c.`firstname` LIKE "%' . $escapedValue . '%"
OR c.`email` LIKE "%' . $escapedValue . '%")' . "\n";
continue;
}
$column = $allowedFilters[$field];
if (count($matches) > 1) {
$prefix = $matches[1];
$value = $matches[2];
$suffix = $matches[3];
if ($prefix == '%' || $suffix == '%') {
$ret .= ' AND '.$column.' LIKE "'.pSQL($prefix.$value.$suffix)."\"\n";
continue;
}
if ($prefix == '' && $suffix == '') {
if (strpos($value, '|') > 0) {
$values = explode('|', $value);
$sanitizedValues = array_map(function ($item) {
return '"' . pSQL($item) . '"';
}, $values);
$ret .= ' AND '.$column.' IN (' . implode(',', $sanitizedValues) . ')';
continue;
}
if (preg_match('/^([\d\.:\-\s]+),([\d\.:\-\s]+)$/', $value, $rangeMatches)) {
unset($rangeMatches[0]);
if (count($rangeMatches) > 0) {
sort($rangeMatches);
$ret .= ' AND '.$column.' BETWEEN "'.pSQL($rangeMatches[0]).'" AND "'.pSQL($rangeMatches[1])."\"\n";
}
continue;
}
$ret .= ' AND '.$column.'="'.pSQL($value).'"'."\n";
continue;
}
if ($prefix == '>') {
$ret .= ' AND '.$column.' > "'.pSQL($value)."\"\n";
continue;
}
if ($prefix == '<') {
$ret .= ' AND '.$column.' < "'.pSQL($value)."\"\n";
continue;
}
if ($prefix == '!') {
$multipleValues = explode('|', $value);
foreach ($multipleValues as $multipleValue) {
$ret .= ' AND '.$column.' != "'.pSQL($multipleValue)."\"\n";
}
}
continue;
}
$comparison = Validate::isFloat(pSQL($raw)) ? 'LIKE' : '=';
$ret .= ' AND '.$column.' '.$comparison.' "'.pSQL($raw)."\"\n";
}
return $ret;
}
private function validateBookingFilterValue($field, $raw)
{
preg_match('/^(.*)\[(.*)\](.*)$/', $raw, $matches);
$operator = '';
$value = $raw;
if (count($matches) > 1) {
$operator = $matches[1];
$value = $matches[2];
}
$numericFields = array('id_property', 'id_customer', 'id_order', 'stay', 'room_status', 'booking_status', 'id_room_type', 'id_room', 'is_cancelled');
$dateFields = array('booking_date', 'checkin_date', 'checkout_date');
$stringFields = array('customer', 'source', 'payment_type', 'payment_method','reference');
if (in_array($field, $numericFields)) {
return $this->validateBookingNumericFilter($field, $operator, $value);
}
if (in_array($field, $dateFields)) {
return $this->validateBookingDateFilter($field, $operator, $value);
}
if (in_array($field, $stringFields)) {
return $this->validateBookingStringFilter($field, $operator, $value);
}
return true;
}
private function validateBookingNumericFilter($field, $operator, $value)
{
$values = strpos($value, '|') !== false ? explode('|', $value) : array($value);
foreach ($values as $filterValue) {
if (!Validate::isUnsignedInt($filterValue)) {
$this->wsObject->setError(400, 'Invalid value for filter "'.$field.'".', 39);
return false;
}
}
return true;
}
private function validateBookingDateFilter($field, $operator, $value)
{
if ($operator == '' && preg_match('/^([\d\-:\s]+),([\d\-:\s]+)$/', $value, $matches)) {
if (!Validate::isDate($matches[1]) || !Validate::isDate($matches[2])) {
$this->wsObject->setError(400, 'Invalid value for filter "'.$field.'".', 39);
return false;
}
return true;
}
if (!Validate::isDate($value)) {
$this->wsObject->setError(400, 'Invalid value for filter "'.$field.'".', 39);
return false;
}
return true;
}
private function validateBookingStringFilter($field, $operator, $value)
{
if (!Validate::isString($value)) {
$this->wsObject->setError(400, 'Invalid value for filter "'.$field.'".', 39);
return false;
}
return true;
}
private function manageBookingOrderBySort($sorts)
{
$sqlSort = '';
$invalidSortMessage = 'The "sort" value has to be formed as this example: "field_ASC" or \'[field_1_DESC,field_2_ASC]\'';
if (!$sorts) {
return $sqlSort;
}
preg_match('#^\[(.*)\]$#Ui', $sorts, $matches);
$sortItems = count($matches) > 1 ? explode(',', $matches[1]) : array($sorts);
$sqlSort = ' ORDER BY ';
foreach ($sortItems as $sortItem) {
$delimiterPosition = strrpos($sortItem, '_');
if ($delimiterPosition === false) {
$this->wsObject->setError(400, $invalidSortMessage, 37);
return false;
}
$fieldName = substr($sortItem, 0, $delimiterPosition);
$sortDirection = strtoupper(substr($sortItem, $delimiterPosition + 1));
if (!in_array($sortDirection, array('ASC', 'DESC'))) {
$this->wsObject->setError(400, $invalidSortMessage, 37);
return false;
}
if (!array_key_exists($fieldName, $this->allowedFilters)) {
$this->wsObject->setErrorDidYouMean(
400,
'This sort field does not exist',
$fieldName,
array_keys($this->allowedFilters),
38
);
return false;
}
$sqlSort .= $this->allowedFilters[$fieldName].' '.$sortDirection.', ';
}
$sqlSort = rtrim($sqlSort, ', ');
return $sqlSort;
}
public function getBookingsList()
{
$selectColumns = ['o.`id_order`'];
$fragments = $this->wsObject->urlFragments;
if (!empty($fragments['display'])) {
if ($fragments['display'] === 'full') {
$selectColumns = array(
'o.`id_order`','o.`id_currency`', 'o.`source`','o.`date_add`','o.`id_lang`','o.`current_state`','o.`total_paid_real`','o.`total_paid_tax_incl`','o.`total_paid_tax_excl`','o.`id_cart`',
'hbd.`id_product`','hbd.`date_from`','hbd.`date_to`','hbd.`total_price_tax_incl`','hbd.`total_price_tax_excl`','hbd.`id_room`','hbd.`id`','hbd.`adults`','hbd.`children`','hbd.`id_hotel`','hbd.`room_type_name`','hbd.`child_ages`','hbd.`id_status`',
'c.`id_customer`','c.`firstname`','c.`lastname`','c.`email`','c.`phone`','c.`id_default_group`',
'CONCAT(c.`firstname`, " ", c.`lastname`) AS `customer`',
'crncy.`iso_code`',
'op.`payment_type`', 'op.`payment_method`', 'op.`transaction_id`',
'ocr.`id_order_invoice`', 'ocr.`name` as cart_rule_name', 'ocr.`value` as cart_rule_value', '`ocr`.`id_cart_rule`',
);
}
}
$whereSql = '';
$limitSql = '';
$orderSql = '';
if (!empty($fragments['filter']) && is_array($fragments['filter'])) {
$whereSql = $this->manageBookingFilter($fragments['filter']);
if ($whereSql === false) {
return;
}
}
if (!empty($fragments['sort'])) {
$orderSql = $this->manageBookingOrderBySort($fragments['sort']);
if ($orderSql === false) {
return;
}
}
if (isset($fragments['limit'])) {
$limitArgs = explode(',', $fragments['limit']);
if (count($limitArgs) == 1) {
$limitSql = ' LIMIT ' . (int) $limitArgs[0];
} elseif (count($limitArgs) == 2) {
$limitSql = ' LIMIT ' . (int) $limitArgs[0] . ', ' . (int) $limitArgs[1];
} else {
$this->wsObject->setError(400, 'The "limit" value has to be formed as this example: "5,25" or "10"', 39);
return;
}
}
$id_lang = Configuration::get('PS_LANG_DEFAULT') ;
$sql = '
SELECT ' . implode(', ', $selectColumns) . '
FROM ' . _DB_PREFIX_ . 'orders o
INNER JOIN ' . _DB_PREFIX_ . 'htl_booking_detail hbd
ON o.id_order = hbd.id_order
INNER JOIN ' . _DB_PREFIX_ . 'customer c
ON o.id_customer = c.id_customer
INNER JOIN ' . _DB_PREFIX_ . 'currency crncy
ON o.id_currency = crncy.id_currency
LEFT JOIN ' . _DB_PREFIX_ . 'order_payment_detail opd
ON o.id_order = opd.id_order
LEFT JOIN ' . _DB_PREFIX_ . 'order_payment op
ON opd.id_order_payment = op.id_order_payment
LEFT JOIN ' . _DB_PREFIX_ . 'order_cart_rule ocr
ON o.id_order = ocr.id_order
LEFT JOIN (
SELECT `id_order`,
SUM(DATEDIFF(date_to, date_from)) AS stay
FROM ' . _DB_PREFIX_ . 'htl_booking_detail
GROUP BY id_order
) stay_data ON o.id_order = stay_data.id_order
WHERE 1
' . $whereSql . '
' . $orderSql . '
' . $limitSql;
try {
$results = Db::getInstance()->executeS($sql);
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
$objOrder = new Order();
$resultData = array();
foreach ($results as $result) {
$orderId = (int) $result['id_order'];
if( isset($fragments['display']) && $fragments['display'] === 'full'){
if (!isset($resultData[$orderId])) {
$objCart = new Cart((int) $result['id_cart']);
$total_paid_real = Tools::ps_round($result['total_paid_real'], _PS_PRICE_COMPUTE_PRECISION_);
$total_paid_tax_excl = Tools::ps_round($result['total_paid_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_);
$booking_status = $this->getApiBookingStatus($result['current_state'], $total_paid_real, $total_paid_tax_excl, $objCart->getOrderTotal(true, Cart::BOTH));
$params = array();
$params['id'] = $orderId;
$params['id_property'] = (int) $result['id_hotel'];
$params['currency'] = strtoupper($result['iso_code']);
$params['booking_status'] = $booking_status;
$params['source'] = $result['source'];
$params['booking_date'] = $result['date_add'];
$params['id_language'] = (int) $result['id_lang'];
$params['remarks'] = array();
if ($customerMessages = Message::getMessagesByOrderId($orderId)) {
foreach ($customerMessages as $customerMessage) {
$params['remarks'][] = $customerMessage['message'];
}
}
$params['associations'] = array();
$params['associations']['customer_detail'] = array(
'id_customer' => (int) $result['id_customer'],
'firstname' => $result['firstname'],
'lastname' => $result['lastname'],
'email' => $result['email'],
'phone' => isset($result['phone']) ? $result['phone'] : ''
);
$params['associations']['price_details'] = array(
'total_paid' => Tools::ps_round($result['total_paid_real'], _PS_PRICE_COMPUTE_PRECISION_),
'total_price_without_tax' => Tools::ps_round($result['total_paid_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_),
);
$params['associations']['payment_details'] = array(
'payment_type' => $result['payment_type'],
'payment_method' => $result['payment_method'],
'transaction_id' => $result['transaction_id'],
);
$params['associations']['cart_rules'] = array(
'code' => $result['cart_rule_name'],
'value' => Tools::ps_round($result['cart_rule_value'], _PS_PRICE_COMPUTE_PRECISION_),
'id_order_invoice' => $result['id_order_invoice'],
);
$params['associations']['room_types'] = array();
$resultData[$orderId] = $params;
}
$dateJoin = $result['id_product'] . '_' . strtotime($result['date_from']) . strtotime($result['date_to']);
if (!isset($resultData[$orderId]['associations']['room_types'][$dateJoin])) {
$resultData[$orderId]['associations']['room_types'][$dateJoin] = array(
'id_room_type' => (int) $result['id_product'],
'checkin_date' => $result['date_from'],
'checkout_date' => $result['date_to'],
'total_tax' => ($result['total_price_tax_incl'] - $result['total_price_tax_excl']),
'number_of_rooms' => 1,
'name' => $result['room_type_name'],
'room_status' => $this->validateRoomStatus($result['id_status']),
);
} else {
$resultData[$orderId]['associations']['room_types'][$dateJoin]['total_tax'] +=
($result['total_price_tax_incl'] - $result['total_price_tax_excl']);
$resultData[$orderId]['associations']['room_types'][$dateJoin]['number_of_rooms']++;
}
$resultData[$orderId]['associations']['room_types'][$dateJoin]['total_tax'] =
Tools::ps_round(
$resultData[$orderId]['associations']['room_types'][$dateJoin]['total_tax'],
_PS_PRICE_COMPUTE_PRECISION_
);
$roomInfo = array();
$roomInfo['id_room'] = (int) $result['id_room'];
$roomInfo['id_hotel_booking'] = (int) $result['id'];
$roomInfo['adults'] = (int) $result['adults'];
$roomInfo['child'] = (int) $result['children'];
$roomInfo['child_ages'] = json_decode($result['child_ages'], true);
$roomInfo['unit_price_without_tax'] = Tools::ps_round($result['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_);
$roomInfo['total_tax'] = Tools::ps_round(($result['total_price_tax_incl'] - $result['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_);
if(isset($roomInfo['services'])) {
unset($roomInfo['services']);
}
$useTax = (Group::getPriceDisplayMethod($result['id_default_group']) == PS_TAX_INC) ? 1 : 0;
if ($additionalServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts(
$result['id_order'],
0,
0,
$result['id_product'],
$result['date_from'],
$result['date_to'],
$result['id_room'],
0,
$useTax,
null
)) {
$roomInfo['services'] = array();
foreach ($additionalServices as $additionalService) {
foreach ($additionalService['additional_services'] as $service) {
$services = array();
$services['id_service'] = (int) $service['id_product'];
$services['name'] = $service['name'];
$services['quantity'] = (int) $service['quantity'];
$services['unit_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl'] / $services['quantity']), _PS_PRICE_COMPUTE_PRECISION_);
$services['total_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_);
$services['total_tax'] = Tools::ps_round(($service['total_price_tax_incl'] - $service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_);
$objProduct = new Product($service['id_product']);
$services['per_night'] = 0;
if ($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
$services['per_night'] = 1;
}
$services['price_mode'] = (int) $objProduct->price_calculation_method;
$roomInfo['services'][] = $services;
}
}
}
$resultData[$orderId]['associations']['room_types'][$dateJoin]['rooms'][] = $roomInfo;
}else{
$params['id_order'] = $orderId;
$resultData[$orderId] = $params;
}
}
if (isset($fragments['display']) && $fragments['display'] === 'full') {
$responseData = [];
foreach ($resultData as $order) {
if (isset($order['associations']['room_types'])) {
$order['associations']['room_types'] = array_values(
$order['associations']['room_types']
);
}
$responseData[] = $order;
}
if(!empty($responseData)) {
$this->output['bookings'] = $responseData;
$this->renderResponse();
return;
}
}
$this->output .= $this->objOutput->getObjectRender()
->renderNodeHeader('bookings', []);
foreach ($resultData as $order) {
$more_attr = array(
'xlink_resource' => $this->wsObject->wsUrl.$this->wsObject->urlSegment[0].'/'.$order['id_order'],
'id' => (int) $order['id_order']
);
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('booking', array('objectsNodeName' => 'bookings'), $more_attr, false);
}
$this->output .= $this->objOutput->getObjectRender()
->renderNodeFooter('bookings', []);
$this->output = $this->objOutput->getObjectRender()
->overrideContent($this->output);
} catch (\Throwable $th) {
$this->wsObject->setError(400, 'Invalid request data provided.', 39);
}
}
public function validateRoomStatus($idStatus)
{
$status = self::API_BOOKING_ROOM_STATUS_ALLOTTED;
switch ($idStatus) {
case self::API_BOOKING_ROOM_STATUS_ALLOTTED:
$status = self::API_BOOKING_ROOM_STATUS_ALLOTTED;
break;
case self::API_BOOKING_ROOM_STATUS_CHECKIN:
$status = self::API_BOOKING_ROOM_STATUS_CHECKIN;
break;
case self::API_BOOKING_ROOM_STATUS_CHECKOUT:
$status = self::API_BOOKING_ROOM_STATUS_CHECKOUT;
break;
default:
break;
}
return $status;
}
public function getApiBookingStatus($bookingStatus, $totalAmount, $totalPrice, $cartTotal)
{
$orderStatus = self::API_BOOKING_STATUS_NEW;
switch ($bookingStatus) {
case self::API_BOOKING_STATUS_NEW:
if ($totalAmount > 0 && $totalPrice > 0 && $totalPrice == $totalAmount) {
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
} else if ($totalAmount > 0 && $totalAmount < $cartTotal) {
$orderStatus = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
} else if ($totalAmount >= $cartTotal) {
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
}
break;
case self::API_BOOKING_STATUS_COMPLETED:
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
if (!$totalAmount) {
$totalAmount = $cartTotal;
} else if ($totalAmount > 0 && $totalAmount < $cartTotal) {
$orderStatus = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
}
break;
case self::API_BOOKING_STATUS_CANCELLED:
$orderStatus = Configuration::get('PS_OS_CANCELED');
break;
case self::API_BOOKING_STATUS_REFUNDED:
$orderStatus = Configuration::get('PS_OS_REFUND');
break;
default:
break;
}
return $orderStatus;
}
/**
* Used to get the booking details for the GET, POST and PUT request.
*/
@@ -3706,7 +4226,6 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$roomTypeInfo[$dateJoin]['rooms'][] = $roomInfo;
}
}
$params['associations']['room_types'] = array_values($roomTypeInfo);
$this->output['booking'] = $params;
}
@@ -3750,6 +4269,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
*/
public function renderXmlOutputUsingArray($response, $keyToIgnore = array(), $parentKeys = array(), $parentKey = '', $useEmpty = false)
{
// ddd($response);
$output = '';
foreach ($response as $key => $res) {
if (in_array($key, $keyToIgnore) && $key) {