privilegedemarque/modules/referralprogram/allocation.php
Serveur preprod f0c0c48223 first push
2016-04-14 16:14:31 +02:00

48 lines
1.6 KiB
PHP

<?php
/**
* Permet d'affecter manuellement des clients aux parrains
*/
/**
* Historique oallocation
*
* 08/03/2016
* parrainée : MICHELE.RIGAUDIERE@YAHOO.FR - 125321
* parrain : MICHELINE.BRICLOT@ORANGE.FR - 120814
*
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/referralprogram.php');
$id_newcustomer = 125321;
$newCustomer = new Customer((int) $id_newcustomer);
$id_customer = 120814;
$sponsor = new Customer((int) $id_customer);
// if ($sponsor = $sponsor->getByEmail($sponsorEmail, NULL, $this->context))
if ($sponsor) {
include_once(dirname(__FILE__).'/ReferralProgramModule.php');
/* If the customer was not invited by the sponsor, we create the invitation dynamically */
if (!$id_referralprogram = ReferralProgramModule::isEmailExists($newCustomer->email, true, false))
{
$referralprogram = new ReferralProgramModule();
$referralprogram->id_sponsor = (int)$sponsor->id;
$referralprogram->firstname = $newCustomer->firstname;
$referralprogram->lastname = $newCustomer->lastname;
$referralprogram->email = $newCustomer->email;
if (!$referralprogram->validateFields(false))
return false;
else
$referralprogram->save();
}
else
$referralprogram = new ReferralProgramModule((int)$id_referralprogram);
if ($referralprogram->id_sponsor == $sponsor->id)
{
$referralprogram->id_customer = (int)$newCustomer->id;
$referralprogram->save();
//var_dump($referralprogram->id, $referralprogram->id_sponsor, $referralprogram->id_customer);
}
}