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; } }
/** * sharedTemplates() * Returns a query object of all the shared templates by default excluding the shared templates authored by the current user. * @param bool $showall * @return mixed */ public static function sharedTemplates($showall = FALSE) { if ($showall) { $query = EmailTemplate::where('public', '=', '1')->orderBy('name', 'ASC')->get(); } else { $query = EmailTemplate::where('public', '=', '1')->where('author', '!=', Auth::consoleuser()->get()->cid)->orderBy('name', 'ASC')->get(); } return $query; }
public function post_emailtemplatedelete() { //Get our id $id = Input::get('id'); //Verify that the id is valid and the template is owned by the member trying to delete it or they are level 1 access if (Auth::consoleuser()->get()->access > 0) { $query = EmailTemplate::where('id', '=', $id)->count(); } else { $query = EmailTemplate::where('id', '=', $id)->where('author', '=', Auth::consoleuser()->get()->cid)->count(); } if ($query > 0) { //Count is greater than 0 let's delete the record; EmailTemplate::where('id', '=', $id)->delete(); } }