Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. public static function getdepapts($uselimits)
  2. {
  3. $setting = self::getsettings();
  4. $ranklevel = Auth::$userinfo->ranklevel;
  5. $weekday = date('w');
  6. $acldgarray = self::getaircraftslastlocations();
  7. $hub = Auth::$userinfo->hub;
  8. $pilotlocation = self::getpilotlocation(Auth::$userinfo->pilotid);
  9. $flighttypes = "'".str_replace(":", "', '",$setting->flighttypelimit)."'";
  10. $airlines = "'".str_replace(":", "', '",$setting->airlinelimit)."'";
  11.  
  12. $sql = "SELECT s.depicao, a.name as depname FROM ".TABLE_PREFIX."schedules s
  13. LEFT JOIN ".TABLE_PREFIX."airports a ON a.icao = s.depicao
  14. LEFT JOIN ".TABLE_PREFIX."bids b ON b.routeid = s.id
  15. LEFT JOIN ".TABLE_PREFIX."aircraft ac ON ac.id = s.aircraft
  16. ";
  17.  
  18. if($uselimits == '1')
  19. {
  20. 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'))
  21. {
  22.  
  23. $sql .= "WHERE ";
  24.  
  25.  
  26. $combine = '';
  27. if($setting->ranklimit != '0' && $ranklevel)
  28. {
  29. $sql .= "{$combine} ac.ranklevel <= '$ranklevel' "; $combine = "AND ";
  30. }
  31. if($setting->daylimit != '0')
  32. {
  33. $sql .= "{$combine} s.daysofweek LIKE '%$weekday%' "; $combine = "AND ";
  34. }
  35. if($setting->pilotlocation != '0' && $pilotlocation)
  36. {
  37. $sql .= "{$combine} s.depicao LIKE '%$pilotlocation%' "; $combine = "AND ";
  38. }
  39. if($setting->aircraftlocation != '0')
  40. {
  41. $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 ";
  42. }
  43. if($setting->hublimit != '0' && $hub)
  44. {
  45. $sql .= "{$combine}(s.depicao LIKE ('%$hub%') OR s.arricao LIKE ('%$hub%')) "; $combine = "AND ";
  46. }
  47. if($setting->schedbidlimit != '0')
  48. {
  49. $sql .= "{$combine}s.id NOT IN (SELECT routeid FROM ".TABLE_PREFIX."bids GROUP BY routeid) "; $combine = "AND ";
  50. }
  51.  
  52. if($setting->alreadylanded != '0')
  53. {
  54. $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 ";
  55. }
  56.  
  57. $sql .= "{$combine} ac.enabled = '1' "; $combine = "AND ";
  58. }
  59.  
  60. }
  61. $sql .= "GROUP BY s.depicao
  62. ORDER BY s.depicao ASC";
  63.  
  64. return DB::get_results($sql);
  65.  
  66.  
  67. }
  68.  
  69.  
  70. public static function getdepcountries($uselimits)
  71. {
  72. $setting = self::getsettings();
  73. $ranklevel = Auth::$userinfo->ranklevel;
  74. $weekday = date('w');
  75. $acldgarray = self::getaircraftslastlocations();
  76. $hub = Auth::$userinfo->hub;
  77. $pilotlocation = self::getpilotlocation(Auth::$userinfo->pilotid);
  78. $flighttypes = "'".str_replace(":", "', '",$setting->flighttypelimit)."'";
  79. $airlines = "'".str_replace(":", "', '",$setting->airlinelimit)."'";
  80.  
  81.  
  82. $sql = "SELECT s.depicao, a.country FROM ".TABLE_PREFIX."schedules s
  83. LEFT JOIN ".TABLE_PREFIX."airports a ON a.icao = s.depicao
  84. LEFT JOIN ".TABLE_PREFIX."bids b ON b.routeid = s.id
  85. LEFT JOIN ".TABLE_PREFIX."aircraft ac ON ac.id = s.aircraft
  86. ";
  87.  
  88. if($uselimits == '1')
  89. {
  90. 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'))
  91. {
  92.  
  93. $sql .= "WHERE ";
  94.  
  95. $combine = '';
  96. if($setting->ranklimit != '0' && $ranklevel)
  97. {
  98. $sql .= "{$combine} ac.ranklevel <= '$ranklevel' "; $combine = "AND ";
  99. }
  100. if($setting->daylimit != '0')
  101. {
  102. $sql .= "{$combine} s.daysofweek LIKE '%$weekday%' "; $combine = "AND ";
  103. }
  104. if($setting->pilotlocation != '0' && $pilotlocation)
  105. {
  106. $sql .= "{$combine} s.depicao LIKE '%$pilotlocation%' "; $combine = "AND ";
  107. }
  108. if($setting->aircraftlocation != '0')
  109. {
  110. $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 ";
  111. }
  112. if($setting->hublimit != '0' && $hub)
  113. {
  114. $sql .= "{$combine}(s.depicao LIKE ('%$hub%') OR s.arricao LIKE ('%$hub%')) "; $combine = "AND ";
  115. }
  116. if($setting->schedbidlimit != '0')
  117. {
  118. $sql .= "{$combine}s.id NOT IN (SELECT routeid FROM ".TABLE_PREFIX."bids GROUP BY routeid) "; $combine = "AND ";
  119. }
  120.  
  121. if($setting->alreadylanded != '0')
  122. {
  123. $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 ";
  124. }
  125. $sql .= "{$combine} ac.enabled = '1' "; $combine = "AND ";
  126.  
  127. }
  128. }
  129. $sql .= "GROUP BY a.country
  130. ORDER BY a.country ASC";
  131.  
  132. return DB::get_results($sql);
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement