Exemplo n.º 1
0
 /**
  * @param ISummitRegistrationPromoCode $promo_code
  * @return $this
  */
 public function registerPromoCode(ISummitRegistrationPromoCode $promo_code)
 {
     $promo_code->assignOwner($this->owner);
     return $this;
 }
 /**
  * @param int $summit_id
  * @param array $data
  * @param ISummitRegistrationPromoCode $promocode
  * @return ISummitRegistrationPromoCode
  */
 public function populatePromoCode($summit_id, array $data, $promocode)
 {
     $code_type = $data['code_type'];
     switch ($code_type) {
         case 'ACCEPTED':
         case 'ALTERNATE':
             if (isset($data['speaker_id']) && $data['speaker_id']) {
                 $speaker = PresentationSpeaker::get_by_id('PresentationSpeaker', trim($data['speaker_id']));
                 if ($speaker->Exists()) {
                     $promocode->assignSpeaker($speaker);
                 }
             }
             break;
         case 'VIP':
         case 'ATC':
         case 'MEDIA ANALYST':
             if (isset($data['member_id']) && $data['member_id']) {
                 $owner = Member::get_by_id('Member', trim($data['member_id']));
                 if ($owner->Exists()) {
                     $promocode->assignOwner($owner);
                 }
             }
             if (isset($data['first_name'])) {
                 $promocode->setFirstName(trim($data['first_name']));
             }
             if (isset($data['last_name'])) {
                 $promocode->setLastName(trim($data['last_name']));
             }
             if (isset($data['email'])) {
                 $promocode->setEmail(trim($data['email']));
             }
             break;
         case 'SPONSOR':
             if (isset($data['member_id']) && $data['member_id']) {
                 $owner = Member::get_by_id('Member', trim($data['member_id']));
                 if ($owner->Exists()) {
                     $promocode->assignOwner($owner);
                 }
             }
             if (isset($data['company_id']) && $data['company_id']) {
                 $sponsor = Company::get_by_id('Company', trim($data['company_id']));
                 if ($sponsor->Exists()) {
                     $promocode->assignSponsor($sponsor);
                 }
             }
             if (isset($data['first_name'])) {
                 $promocode->setFirstName(trim($data['first_name']));
             }
             if (isset($data['last_name'])) {
                 $promocode->setLastName(trim($data['last_name']));
             }
             if (isset($data['email'])) {
                 $promocode->setEmail(trim($data['email']));
             }
             break;
     }
     $email_sent = isset($data['email_sent']) ? 1 : 0;
     $redeemed = isset($data['redeemed']) ? 1 : 0;
     $promocode->setCode(trim($data['code']));
     $promocode->setEmailSent($email_sent);
     $promocode->setRedeemed($redeemed);
     $promocode->setSummit(trim($summit_id));
     $promocode->setSource('ADMIN');
     $promocode->setType($code_type);
     $promocode->setCreator(Member::currentUser());
     return $promocode;
 }