Esempio n. 1
0
 /**
  * Schedules::showSchedules()
  * 
  * @return
  */
 public function showSchedules()
 {
     $depapts = OperationsData::GetAllAirports();
     $equip = OperationsData::GetAllAircraftSearchList(true);
     $airlines = OperationsData::GetAllAirlines();
     $this->set('airlines', $airlines);
     #deprecated
     $this->set('airline_list', $airlines);
     $this->set('depairports', $depapts);
     $this->set('equipment', $equip);
     # deprecated
     $this->set('aircraft_list', $equip);
     $this->render('schedule_searchform.tpl');
     # Show the routes. Remote this to not show them.
     $schedules = SchedulesData::getSchedules();
     # Do some filtering and whatnots, take it out of the template...
     $today = getdate();
     $week_number = intval(($today['mday'] - 1) / 7) + 1;
     $current_day == date('w');
     $var_name = 'week' . $week_number;
     # query once, save for later
     if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
         $pirep_list = PIREPData::findPIREPS(array('p.pilotid' => Auth::$pilot->pilotid, 'p.accepted' => PIREP_ACCEPTED), 1);
         // return only one
     }
     foreach ($schedules as $key => $s) {
         # should we skip schedules based on day of week?
         if (Config::get('CHECK_SCHEDULE_DAY_OF_WEEK') === true) {
             if (isset($s->{$var_name}) && !empty($s->{$var_name})) {
                 # check if today is in the active list for this week
                 if (@substr_count($s->{$var_name}, $current_day) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             } else {
                 if (substr_count($s->daysofweek, date('w')) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
         # remove this schedule from the list if there's a bid on it
         if (Config::get('DISABLE_SCHED_ON_BID') === true && $route->bidid != 0) {
             unset($schedules[$key]);
             continue;
         }
         /*	This means the aircraft rank level is higher than
          		what the pilot's ranklevel, so just do "continue"
         			and move onto the next route in the list  */
         if (Config::get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) {
             if ($route->aircraftlevel > Auth::$pilot->ranklevel) {
                 unset($schedules[$key]);
                 continue;
             }
         }
         if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
             if (count($pirep_list) > 0) {
                 # IF the arrival airport doesn't match the departure airport
                 if ($pirep_list[0]->arricao != $s->depicao) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
     }
     // end foreach schedules
     $this->set('allroutes', $schedules);
     $this->set('schedule_list', $schedules);
     $this->render('schedule_list.tpl');
 }