Merge branch 'ticket/r16348-credit-expired'
This commit is contained in:
commit
fc107f5d6d
@ -210,8 +210,11 @@ class LoyaltyModule extends ObjectModel
|
|||||||
SELECT f.`id_loyalty`,f.`id_loyalty_state`,f.`discount_value`
|
SELECT f.`id_loyalty`,f.`id_loyalty_state`,f.`discount_value`
|
||||||
FROM `'._DB_PREFIX_.'loyalty` f
|
FROM `'._DB_PREFIX_.'loyalty` f
|
||||||
WHERE f.`id_customer` = '.(int)($id_customer);
|
WHERE f.`id_customer` = '.(int)($id_customer);
|
||||||
if ($notCancel === true)
|
if ($notCancel === true) {
|
||||||
$query .= ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId();
|
$query .= ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query .= ' AND f.date_add > (NOW() - INTERVAL 1 YEAR)';
|
||||||
|
|
||||||
return Db::getInstance()->ExecuteS($query);
|
return Db::getInstance()->ExecuteS($query);
|
||||||
}
|
}
|
||||||
@ -238,11 +241,15 @@ class LoyaltyModule extends ObjectModel
|
|||||||
AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = f.`id_order` GROUP BY moh.`id_order`)
|
AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = f.`id_order` GROUP BY moh.`id_order`)
|
||||||
AND oh.`id_order_state` != 8
|
AND oh.`id_order_state` != 8
|
||||||
'.(($onlyValidate)? '' : ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
|
'.(($onlyValidate)? '' : ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
|
||||||
|
|
||||||
if ($onlyValidate) {
|
if ($onlyValidate) {
|
||||||
$query .= ' AND (f.id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' OR f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId().')';
|
$query .= ' AND (f.id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' OR f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId().')';
|
||||||
} elseif ($onlyDefault){
|
} elseif ($onlyDefault){
|
||||||
$query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getDefaultId();
|
$query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getDefaultId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query .= ' AND f.date_add > (NOW() - INTERVAL 1 YEAR)';
|
||||||
|
|
||||||
$query .= ' GROUP BY f.id_loyalty '.
|
$query .= ' GROUP BY f.id_loyalty '.
|
||||||
($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : '');
|
($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : '');
|
||||||
|
|
||||||
@ -268,10 +275,11 @@ class LoyaltyModule extends ObjectModel
|
|||||||
|
|
||||||
public static function registerDiscountCustom($discount, $orders)
|
public static function registerDiscountCustom($discount, $orders)
|
||||||
{
|
{
|
||||||
if (!Validate::isLoadedObject($discount))
|
if (!Validate::isLoadedObject($discount)) {
|
||||||
die(Tools::displayError('Incorrect object Discount.'));
|
die(Tools::displayError('Incorrect object Discount.'));
|
||||||
foreach ($orders AS $item)
|
}
|
||||||
{
|
|
||||||
|
foreach ($orders AS $item) {
|
||||||
$f = new LoyaltyModule((int)$item['id_loyalty']);
|
$f = new LoyaltyModule((int)$item['id_loyalty']);
|
||||||
|
|
||||||
if ($f->discount_value == 0) {
|
if ($f->discount_value == 0) {
|
||||||
|
@ -95,14 +95,15 @@ if (Tools::getValue('transform-points') == 'true' AND $total_discount > 0)
|
|||||||
SELECT UNIX_TIMESTAMP(date_add) n
|
SELECT UNIX_TIMESTAMP(date_add) n
|
||||||
FROM '._DB_PREFIX_.'loyalty
|
FROM '._DB_PREFIX_.'loyalty
|
||||||
WHERE id_discount = 0 AND id_customer = '.(int)$cookie->id_customer.'
|
WHERE id_discount = 0 AND id_customer = '.(int)$cookie->id_customer.'
|
||||||
ORDER BY date_add DESC');
|
ORDER BY date_add DESC
|
||||||
|
');
|
||||||
|
|
||||||
if (Configuration::get('PS_ORDER_RETURN'))
|
if (Configuration::get('PS_ORDER_RETURN')) {
|
||||||
$dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS');
|
$dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS');
|
||||||
|
}
|
||||||
|
|
||||||
$voucher->date_from = date('Y-m-d H:i:s', $dateFrom);
|
$voucher->date_from = date('Y-m-d H:i:s', $dateFrom);
|
||||||
$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000); // + 1 year
|
$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + (60 * 60 * 24 * 365)); // + 1 year
|
||||||
|
|
||||||
$voucher->minimal = (float)Configuration::get('PS_LOYALTY_MINIMAL');
|
$voucher->minimal = (float)Configuration::get('PS_LOYALTY_MINIMAL');
|
||||||
$voucher->active = 1;
|
$voucher->active = 1;
|
||||||
|
|
||||||
@ -130,7 +131,8 @@ if (Tools::getValue('transform-points') == 'true' AND $total_discount > 0)
|
|||||||
$voucher->add();
|
$voucher->add();
|
||||||
|
|
||||||
/* Register order(s) which contributed to create this voucher */
|
/* Register order(s) which contributed to create this voucher */
|
||||||
$orderToConvert = LoyaltyModule::getAllByIdCustomerCustom((int)($cookie->id_customer), (int)($cookie->id_lang), true, false, $nb = 10, $page = 1);
|
$orderToConvert = LoyaltyModule::getAllByIdCustomerCustom(
|
||||||
|
(int)($cookie->id_customer), (int)($cookie->id_lang), true, false, $nb = 10, $page = 1);
|
||||||
LoyaltyModule::registerDiscountCustom($voucher, $orderToConvert);
|
LoyaltyModule::registerDiscountCustom($voucher, $orderToConvert);
|
||||||
|
|
||||||
Tools::redirect('modules/loyalty/loyalty-program.php');
|
Tools::redirect('modules/loyalty/loyalty-program.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user