Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Christophe Latour 2017-10-19 18:11:43 +02:00
commit 6e9d53cff3

View File

@ -233,15 +233,17 @@ class LoyaltyModule extends ObjectModel
SELECT f.id_order AS id, f.date_add AS date, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
FROM `'._DB_PREFIX_.'loyalty` f
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
LEFT JOIN `ps_order_state_current` oc ON (oc.id_order = f.id_order)
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = f.`id_order`)
WHERE f.id_customer = '.(int)($id_customer).'
'.(($onlyValidate)?'':' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
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
'.(($onlyValidate)? '' : ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
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){
$query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getDefaultId();
}
$query .= ' AND oc.`id_order_state` != 8 GROUP BY f.id_loyalty '.
$query .= ' GROUP BY f.id_loyalty '.
($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : '');
return Db::getInstance()->ExecuteS($query);