Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getdepapts($uselimits)
- {
- $setting = self::getsettings();
- $ranklevel = Auth::$userinfo->ranklevel;
- $weekday = date('w');
- $acldgarray = self::getaircraftslastlocations();
- $hub = Auth::$userinfo->hub;
- $pilotlocation = self::getpilotlocation(Auth::$userinfo->pilotid);
- $flighttypes = "'".str_replace(":", "', '",$setting->flighttypelimit)."'";
- $airlines = "'".str_replace(":", "', '",$setting->airlinelimit)."'";
- $sql = "SELECT s.depicao, a.name as depname FROM ".TABLE_PREFIX."schedules s
- LEFT JOIN ".TABLE_PREFIX."airports a ON a.icao = s.depicao
- LEFT JOIN ".TABLE_PREFIX."bids b ON b.routeid = s.id
- LEFT JOIN ".TABLE_PREFIX."aircraft ac ON ac.id = s.aircraft
- ";
- if($uselimits == '1')
- {
- if($setting->nolimit == 0 && ($setting->ranklimit != '0' || $setting->daylimit != '0' || $setting->pilotlocation != '0' || $setting->aircraftlocation != '0' || $setting->hublimit != '0' || $setting->schedbidlimit != '0' || $setting->flighttypelimit != '0' || $setting->flighttypelimit != '0' || $setting->airlinelimit != '0' || $setting->alreadylanded != '0'))
- {
- $sql .= "WHERE ";
- $combine = '';
- if($setting->ranklimit != '0' && $ranklevel)
- {
- $sql .= "{$combine} ac.ranklevel <= '$ranklevel' "; $combine = "AND ";
- }
- if($setting->daylimit != '0')
- {
- $sql .= "{$combine} s.daysofweek LIKE '%$weekday%' "; $combine = "AND ";
- }
- if($setting->pilotlocation != '0' && $pilotlocation)
- {
- $sql .= "{$combine} s.depicao LIKE '%$pilotlocation%' "; $combine = "AND ";
- }
- if($setting->aircraftlocation != '0')
- {
- $sql .= "{$combine}((NOT EXISTS (SELECT location FROM flightsearch_aircraftlocation WHERE aircraft = s.aircraft ORDER BY id DESC LIMIT 1)) OR (s.depicao LIKE (SELECT location FROM flightsearch_aircraftlocation WHERE aircraft = s.aircraft ORDER BY id DESC LIMIT 1)))"; $combine = "AND ";
- }
- if($setting->hublimit != '0' && $hub)
- {
- $sql .= "{$combine}(s.depicao LIKE ('%$hub%') OR s.arricao LIKE ('%$hub%')) "; $combine = "AND ";
- }
- if($setting->schedbidlimit != '0')
- {
- $sql .= "{$combine}s.id NOT IN (SELECT routeid FROM ".TABLE_PREFIX."bids GROUP BY routeid) "; $combine = "AND ";
- }
- if($setting->alreadylanded != '0')
- {
- $sql .= "{$combine}(s.code, s.flightnum) NOT IN (SELECT p.code, p.flightnum FROM ".TABLE_PREFIX."pireps p WHERE DATE(p.submitdate) = CURDATE()) "; $combine = "AND ";
- }
- $sql .= "{$combine} ac.enabled = '1' "; $combine = "AND ";
- }
- }
- $sql .= "GROUP BY s.depicao
- ORDER BY s.depicao ASC";
- return DB::get_results($sql);
- }
- public static function getdepcountries($uselimits)
- {
- $setting = self::getsettings();
- $ranklevel = Auth::$userinfo->ranklevel;
- $weekday = date('w');
- $acldgarray = self::getaircraftslastlocations();
- $hub = Auth::$userinfo->hub;
- $pilotlocation = self::getpilotlocation(Auth::$userinfo->pilotid);
- $flighttypes = "'".str_replace(":", "', '",$setting->flighttypelimit)."'";
- $airlines = "'".str_replace(":", "', '",$setting->airlinelimit)."'";
- $sql = "SELECT s.depicao, a.country FROM ".TABLE_PREFIX."schedules s
- LEFT JOIN ".TABLE_PREFIX."airports a ON a.icao = s.depicao
- LEFT JOIN ".TABLE_PREFIX."bids b ON b.routeid = s.id
- LEFT JOIN ".TABLE_PREFIX."aircraft ac ON ac.id = s.aircraft
- ";
- if($uselimits == '1')
- {
- if($setting->nolimit == 0 && ($setting->ranklimit != '0' || $setting->daylimit != '0' || $setting->pilotlocation != '0' || $setting->aircraftlocation != '0' || $setting->hublimit != '0' || $setting->schedbidlimit != '0' || $setting->flighttypelimit != '0' || $setting->flighttypelimit != '0' || $setting->airlinelimit != '0' || $setting->alreadylanded != '0'))
- {
- $sql .= "WHERE ";
- $combine = '';
- if($setting->ranklimit != '0' && $ranklevel)
- {
- $sql .= "{$combine} ac.ranklevel <= '$ranklevel' "; $combine = "AND ";
- }
- if($setting->daylimit != '0')
- {
- $sql .= "{$combine} s.daysofweek LIKE '%$weekday%' "; $combine = "AND ";
- }
- if($setting->pilotlocation != '0' && $pilotlocation)
- {
- $sql .= "{$combine} s.depicao LIKE '%$pilotlocation%' "; $combine = "AND ";
- }
- if($setting->aircraftlocation != '0')
- {
- $sql .= "{$combine}((NOT EXISTS (SELECT location FROM flightsearch_aircraftlocation WHERE aircraft = s.aircraft ORDER BY id DESC LIMIT 1)) OR (s.depicao LIKE (SELECT location FROM flightsearch_aircraftlocation WHERE aircraft = s.aircraft ORDER BY id DESC LIMIT 1)))"; $combine = "AND ";
- }
- if($setting->hublimit != '0' && $hub)
- {
- $sql .= "{$combine}(s.depicao LIKE ('%$hub%') OR s.arricao LIKE ('%$hub%')) "; $combine = "AND ";
- }
- if($setting->schedbidlimit != '0')
- {
- $sql .= "{$combine}s.id NOT IN (SELECT routeid FROM ".TABLE_PREFIX."bids GROUP BY routeid) "; $combine = "AND ";
- }
- if($setting->alreadylanded != '0')
- {
- $sql .= "{$combine}(s.code, s.flightnum) NOT IN (SELECT p.code, p.flightnum FROM ".TABLE_PREFIX."pireps p WHERE DATE(p.submitdate) = CURDATE()) "; $combine = "AND ";
- }
- $sql .= "{$combine} ac.enabled = '1' "; $combine = "AND ";
- }
- }
- $sql .= "GROUP BY a.country
- ORDER BY a.country ASC";
- return DB::get_results($sql);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement