Merge branch 'ticket-14525-parrain' into develop
This commit is contained in:
commit
5de09f9bb3
@ -1286,23 +1286,45 @@ RewriteRule ^invite/(.*)$ '.__PS_BASE_URI__.'modules/invite/sponsor.php?sponsor=
|
||||
else {
|
||||
// Add
|
||||
if ($sponsor === false) {
|
||||
$result = Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'invite`
|
||||
VALUES (
|
||||
DEFAULT,
|
||||
'.$id_sponsor.',
|
||||
"'.pSQL($customer->email).'",
|
||||
"'.pSQL($customer->lastname).'",
|
||||
"'.pSQL($customer->firstname).'",
|
||||
'.$customer->id.',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NOW(),
|
||||
NOW(),
|
||||
0
|
||||
)');
|
||||
// Last check : if a sponsor has sent a email and customer doesn't use it
|
||||
$checkSentLink = Db::getInstance()->getRow('SELECT id_invite FROM `'._DB_PREFIX_.'invite`
|
||||
WHERE LOWER(email)="'.$customer->email.'" AND `id_customer`=0');
|
||||
if ($checkSentLink === false) {
|
||||
$result = Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'invite`
|
||||
VALUES (
|
||||
DEFAULT,
|
||||
'.$id_sponsor.',
|
||||
"'.pSQL($customer->email).'",
|
||||
"'.pSQL($customer->lastname).'",
|
||||
"'.pSQL($customer->firstname).'",
|
||||
'.$customer->id.',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NOW(),
|
||||
NOW(),
|
||||
0
|
||||
)');
|
||||
}
|
||||
else {
|
||||
$result = Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'invite` SET
|
||||
id_sponsor = '.$id_sponsor.',
|
||||
email = "'.pSQL($customer->email).'",
|
||||
lastname = "'.pSQL($customer->lastname).'",
|
||||
firstname = "'.pSQL($customer->firstname).'",
|
||||
id_customer = '.$customer->id.',
|
||||
id_discount = 0,
|
||||
id_discount_sponsor = 0,
|
||||
credit = 0,
|
||||
credit_sponsor = 0,
|
||||
date_add = NOW(),
|
||||
date_upd = NOW(),
|
||||
when_invite = 0 WHERE id_invite='.$checkSentLink['id_invite'].'
|
||||
');
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
$error_edit = $this->l("Impossible d'enregistrer le parain");
|
||||
|
Loading…
Reference in New Issue
Block a user