Exemplo n.º 1
0
 public function post_emailva($cid)
 {
     //Verify the VA CID is valid
     $va = User::findOrFail($cid);
     $email = $va->email;
     $subject = Input::get('inputSubject');
     $body = Input::get('inputBody');
     if (empty($subject) || empty($body)) {
         return Redirect::to('console/va/' . $cid . '#email')->with('message', 'Please enter a subject and body prior to sending the message.');
     }
     //Replace the email body variables
     $body = EmailTemplate::replaceContent($body, $cid);
     $data = array('va' => $va, 'email' => $email, 'subject' => $subject);
     //Alright. Time to do some email sending.
     Mail::send('email.default', array("content" => $body), function ($message) use($data) {
         $message->to($data['va']->email, $data['va']->name)->subject($data['subject']);
     });
     //Create an audit entry with the email content
     $audit_content = '<span class="email-audit-notation"><i class="fa fa-envelope fa-fw"></i> Email Sent to VA<br />Subject: </span> ' . $subject . '<br /><button class="audit-notation-body-btn btn btn-info">Show Body</button><div style="display: none;" class="well"><blockquote> ' . $body . '</blockquote></div>';
     AuditLog::createNotation($cid, $audit_content);
     //Hopefully all went well. Now just redirect back
     return Redirect::to('console/va/' . $cid . '#email')->with('message', 'Your email was sent successfully.');
 }