public function post_guestsubmitticket() { //Get our data $content = Input::get('content'); //Ticked ID $ticketid = Input::get('ticketid'); //Hash $hash = Input::get('hash'); //We never trust the client. Let's make sure our trust is not broken :P $ticket = Ticket::where('id', '=', $ticketid)->where('hash', '=', $hash)->first(); if (!empty($ticket)) { //Phew alright, we trust the client now, (maybe) :) $reply = new TicketReply(); $reply->tid = $ticketid; //Make it clear that this is not from a VA account $reply->author = '-1'; $reply->content = $content; $reply->staff = 0; //Save our reply $reply->save(); //Check to see if there is an auditor assigned to this ticket. If there is then let's send them an email notification advising them that there is a ticket update. if (!empty($ticket->assigned)) { $auditor = ConsoleUser::where('cid', '=', $ticket->assigned)->first(); if (!empty($auditor->email)) { $data = array('email' => $auditor->email, 'name' => $auditor->name, 'subject' => 'VASOPS Ticket #' . $ticket->id . ": " . $ticket->subject); $body = "Hello " . $auditor->name . ",<br /><br />There has been an update to your assigned ticket " . $ticket->subject . " by " . $ticket->name . ". <br /><br />" . $content . "<br /><br /><br /> <strong>Do not reply to this email. If you wish to reply to this ticket, please do so through the auditor console.</strong>"; Mail::send('email.default', array("content" => $body), function ($message) use($data) { $message->to($data['email'], $data['name'])->subject($data['subject']); }); } } //Return the new content to append to the existing div $response = '<div style="margin-top: 15px; margin-bottom: 15px;"><hr style="border-bottom: 0;" /></div><div class="well"><div style="margin-top: 20px; margin-bottom: 40px;" class="row-fluid"><div class="span2"><strong>' . $ticket->name . '</strong><br /><small>' . $reply->created_at . '</small></div><div style="padding-top: 3px; padding-left: 3px; margin-left: 0px; border-left: 1px solid #e5e5e5;" class="span8">' . $reply->content . '</div></div></div>'; echo $response; } }
public function post_helpdeskreply($id) { //Find the ticket to reply to or fail $ticket = Ticket::findOrFail($id); //Update the timestamps for the ticket $ticket->touch(); //We have client side verification here so if they modified the JS and submitted an empty reply screw them and just abort. $content = Input::get('inputReplyContent'); if (empty($content)) { App::abort('404', 'Page not found. Reply content not sent.'); } //Create a new instance of TicketReply $reply = new TicketReply(); $reply->tid = $id; $reply->author = Auth::consoleuser()->get()->cid; $reply->staff = 1; $reply->content = $content; $reply->save(); //Figure out what button was clicked, be it reply, reply and open, or reply and close if (Input::get('replyAndOpenSubmit')) { $ticket->status = 1; $ticket->save(); //Declare the success message $message = "Your ticket reply was successfully submitted and the ticket was reopened."; } else { if (Input::get('replyAndCloseSubmit')) { $ticket->status = 0; $ticket->save(); //Declare the success message $message = "Your ticket reply was successfully submitted and the ticket was closed."; } else { //Declare the success message $message = "Your ticket reply was successfully submitted."; } } //Email the VA advising them that there is a new response if ($ticket->vid == -1) { $data = array(); $data['subject'] = "VATSIM VA New Ticket Update"; $data['email'] = $ticket->email; $data['name'] = $ticket->name; if (!empty($data['email'])) { $body = "Hello " . $data['name'] . ",<br /><br />There has been an update to your " . $ticket->subject . " ticket by Auditor " . ConsoleUser::getName(Auth::consoleuser()->get()->cid) . ". <br /><br />" . $content . "<br /><br /><br /> <strong>Do not reply to this email. If you wish to reply to this ticket, please do so through your account online.</strong>"; Mail::send('email.default', array("content" => $body), function ($message) use($data) { $message->to($data['email'], $data['name'])->subject($data['subject']); }); } } else { $va = User::where('cid', '=', $ticket->vid)->first(); $data = array(); $data['va'] = $va; $data['subject'] = "VATSIM VA New Ticket Update"; if (!empty($va->email)) { $body = "Hello " . User::getFirstName($ticket->vid) . ",<br /><br />There has been an update to your " . $ticket->subject . " ticket by Auditor " . ConsoleUser::getName(Auth::consoleuser()->get()->cid) . ". <br /><br />" . $content . "<br /><br /><br /> <strong>Do not reply to this email. If you wish to reply to this ticket, please do so through your account online.</strong>"; Mail::send('email.default', array("content" => $body), function ($message) use($data) { $message->to($data['va']->email, $data['va']->name)->subject($data['subject']); }); } } //All set now just redirect back to the ticket page with the message return Redirect::to('console/helpdesk/view/' . $id)->with(array('scrollTo' => '#ticketReply' . $reply->id, 'message' => $message)); }