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_assignauditors() { //Pull our categories //Potential parents are nonchild categories. $potentialparents = Category::where('parentid', '=', '')->get(); $children = Category::where('parentid', '!=', '')->get(); $parentsarray = array(); foreach ($children as $child) { if (!in_array($child->parentid, $parentsarray)) { //If the parent is not already in the array add it. $parentsarray[$child->id] = $child->parentid; } } //Get all of our parents and find the amount of VAs associated with each $categories = Category::all(); $vaInCategories = array(); foreach ($categories as $category) { $vaInCategories[$category->id] = User::where('categories', 'like', '%' . $category->id . ',%')->where('status', '>', -1)->count(); } //Fetch a list of active auditors $auditors = ConsoleUser::where('access', '>', '-1')->get(); //Calculate how many assignments each auditor currently has $assignmentsPerAuditor = array(); foreach ($auditors as $auditor) { $assignments = Assignment::where('auditors', 'like', '%' . $auditor->cid . ',%')->get(); $assignmentsPerAuditor[$auditor->cid] = 0; foreach ($assignments as $assignment) { $vas = explode(',', $assignment->vas); $vascount = count($vas) - 1; //Remove the last value of the array (if it is empty) if (empty($vas[$vascount])) { unset($vas[$vascount]); } $count = count($vas); $assignmentsPerAuditor[$auditor->cid] += $count; } } return View::make('console.assignauditors')->with(array('potentialparents' => $potentialparents, 'children' => $children, 'parentsarray' => $parentsarray, 'vaInCategories' => $vaInCategories, 'auditors' => $auditors, 'assignmentsPerAuditor' => $assignmentsPerAuditor)); }