Exemple #1
0
 public function insertPoolingSchedule($contact_id, $member_id, $template_id)
 {
     $contactTarget = Contact::find($contact_id);
     $memberTarget = User::find($member_id);
     $templateTarget = EmailTemplate::where('sequence', $template_id)->first();
     // return $templateTarget->id;
     if (!$contactTarget || !$memberTarget || !$templateTarget) {
         return null;
     }
     $stag = new EmailSchedullerPool();
     $stag->contact_id = $contact_id;
     $stag->member_id = $member_id;
     $stag->template_id = $template_id;
     // $configurationMember = MemberConfiguration::where('member_id',$member_id)->where('param_code',MemberConfiguration::FOLLOW_UP_SEQUENCE)->first();
     // if(!$configurationMember){
     //       	return null ;
     // }
     // $followUpSequence = $configurationMember->param_value;
     $followUpSequence = Sysparam::getValue('conf_follow_up_date');
     $stag->execution_date = date('Y-m-d H:i:s', strtotime("+" . $followUpSequence . " day"));
     $emailSchedullerPool = EmailSchedullerPool::where('member_id', $member_id)->where('contact_id', $contact_id)->where('template_id', $template_id)->first();
     if ($emailSchedullerPool) {
         //save history
         $this->saveHistory("canceled", $emailSchedullerPool->member_id, $emailSchedullerPool->template_id);
         //delete pool
         $emailSchedullerPool->delete();
     }
     //add entry
     if ($contactTarget->active && $memberTarget->active) {
         $stag->save();
         return $stag->toJson();
     } else {
         return null;
     }
 }
 public function getTargetEmails()
 {
     $polls = EmailSchedullerPool::where(DB::raw('DAY(execution_date)'), '=', date('d'))->get();
     return $polls;
 }