public function post_searchvas() { $query = Input::get('query'); $vas = User::where('status', '=', 1)->where(function ($q) use($query) { $q->where('vaname', 'like', '%' . $query . '%')->orWhere('description', 'like', '%' . $query . '%')->orWhere('url', 'like', '%' . $query . '%')->orWhere('url', 'like', '%' . $query . '%'); })->orderBy('vaname', 'ASC')->get(); if (count($vas) == 0 || empty($query) || $query == " ") { echo '<h4>No Virtual Airlines Found.</h4>'; } else { $maxwidth = Setting::fetch('banner_maxwidth'); $banner_directory = rtrim(Setting::fetch('banner_directory'), '/') . '/'; $output = ''; foreach ($vas as $va) { $va->description = html_entity_decode($va->description); $va->vaname = html_entity_decode($va->vaname); $va->url = html_entity_decode($va->url); $banner = ''; if ($va->banner) { $banner = User::getBannerUrl($va->cid, $banner_directory); $output .= '<div class="bannerbg"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><img style="max-width:' . $maxwidth . ';" class="img-polaroid" src="' . $banner . '" alt="Banner" /></a></div><div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>'; } else { $output .= '<div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>'; } } echo $output; } }
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 get_va($id) { //Is someone trying to pass something other than an integer? if (!is_numeric($id)) { return Redirect::route('console'); } $va = User::findOrFail($id); //Do we have a banner? //Ugh laravel gets mad when we don't so let's just set it as empty for now. $banner = ''; if ($va->banner) { $banner = User::getBannerUrl($va->cid); } //Pull our banner directory from settings $banner_maxwidth = Setting::fetch('banner_maxwidth'); $banner_maxheight = Setting::fetch('banner_maxheight'); //Pull our audit log $audit_log = AuditLog::where('va', '=', $va->cid)->orderBy('created_at', 'DESC')->get(); //Pull our tickets created by this VA $tickets = Ticket::where('vid', '=', $id)->orderBy('updated_at', 'DESC')->get(); //Pull our hidden categories $hiddenCategories = Category::where('hidden', '=', 1)->get(); //Create an array of hidden category ids $hiddenCategoryIds = array(); foreach ($hiddenCategories as $hiddenCategory) { $hiddenCategoryIds[] = $hiddenCategory->id; } $categories = $va->categories; $categories = explode(',', $categories); //Get rid of the empty array pair array_pop($categories); $currentHiddenCategories = array(); foreach ($categories as $category) { if (in_array($category, $hiddenCategoryIds)) { $currentHiddenCategories[] = $category; } } //Get all of our non hidden categories $allcategories = Category::where('hidden', '=', 0)->get(); //Max categories $max_categories = Setting::fetch('max_categories'); //Pull our email templates $emailTemplates = EmailTemplate::where('author', '=', Auth::consoleuser()->get()->cid)->orderBy('name', 'DESC')->get(); $sharedEmailTemplates = EmailTemplate::where('author', '!=', Auth::consoleuser()->get()->cid)->where('public', '=', '1')->orderBy('name', 'DESC')->get(); return View::make('console.va')->with(array('va' => $va, 'banner' => $banner, 'audit_log' => $audit_log, 'banner_maxwidth' => $banner_maxwidth, 'banner_maxheight' => $banner_maxheight, 'tickets' => $tickets, 'emailTemplates' => $emailTemplates, 'sharedEmailTemplates' => $sharedEmailTemplates, 'hiddenCategories' => $hiddenCategories, 'currentHiddenCategories' => $currentHiddenCategories, 'categories' => $allcategories, 'currentCategories' => $categories, 'max_categories' => $max_categories)); }