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 get_va() { //Pull our users VA data $record = User::where('cid', '=', Auth::user()->get()->cid)->first(); // //Figure out what the last 4 months are and append -1 for the first day of the month // $month = date('Y-m'); // $month .= '-1'; // $month1before = date('Y-m', strtotime('-1 month')); // $month1before .= '-1'; // $month2before = date('Y-m', strtotime('-2 month')); // $month2before .= '-1'; // $month3before = date('Y-m', strtotime('-3 month')); // $month3before .= '-1'; // //Convert to unix time stamps to compare with the DB // $month = strtotime($month); // $month1before = strtotime($month1before); // $month2before = strtotime($month2before); // $month3before = strtotime($month3before); // // //Now let's store our month names in an array // $clicks = array(); // $clicks['month_name'] = date("F", $month); // $clicks['month1before_name'] = date("F", $month1before); // $clicks['month2before_name'] = date("F", $month2before); // $clicks['month3before_name'] = date("F", $month3before); // // // //Count the data in the DB // //Where data is greater than the first of this month and is associated with our logged in user. // $month = Click::where('created_at', '>=', $month)->where('vid', '=', Auth::user()->get()->cid)->count(); // //Where data is greater than the first of last month, but less than the first of this month and is associated with our logged in user. // $month1before = Click::where('created_at', '>=', $month1before)->where('created_at', '<', $month)->where('vid', '=', Auth::user()->get()->cid)->count(); // //You get the point :) // $month2before = Click::where('created_at', '>=', $month2before)->where('created_at', '<', $month1before)->where('vid', '=', Auth::user()->get()->cid)->count(); // $month3before = Click::where('created_at', '>=', $month3before)->where('created_at', '<', $month2before)->where('vid', '=', Auth::user()->get()->cid)->count(); // //Add to our clicks array. // $clicks['month'] = $month; // $clicks['month1before'] = $month1before; // $clicks['month2before'] = $month2before; // $clicks['month3before'] = $month3before; //Let's just keep it simple for now and get the total number of clicks $clicks = Click::where('vid', '=', Auth::user()->get()->cid)->count(); //Pull our ticket information $opentickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->orderBy('created_at', 'DESC')->get(); $openticketscount = count($opentickets); $closedtickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '0')->orderBy('created_at', 'DESC')->get(); $closedticketscount = count($closedtickets); //Create our array $tickets = array(); $tickets['opentickets'] = $opentickets; $tickets['opentickets_count'] = $openticketscount; $tickets['closedtickets'] = $closedtickets; $tickets['closedtickets_count'] = $closedticketscount; //Pull our replies $tickets_request = Ticket::where('vid', '=', Auth::user()->get()->cid)->get(); $tids = array(); foreach ($tickets_request as $ticket_request) { $tid = $ticket_request->id; $tids[$tid] = $tid; } if (!empty($tids)) { $replies = TicketReply::whereIn('tid', $tids)->orderBy('created_at', 'ASC')->get(); } else { $replies = ''; } $tickets['replies'] = $replies; //Pull our Category data $categories = Category::where('hidden', '!=', 1)->get(); //Check to see if there is a banner if so provide the source for it if ($record->banner) { $banner = User::getBannerUrl(Auth::user()->get()->cid); } else { //No banner we will set this as false so the views no not to try and display it. $banner = FALSE; } //Get our news $news = News::orderBy("updated_at", "DESC")->get(); //Create our view with the VA, clicks, categories and tickets data. return View::make('va')->with(array('news' => $news, 'record' => $record, 'clicks' => $clicks, 'tickets' => $tickets, 'categories' => $categories, 'banner' => $banner)); }
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)); }