Esempio n. 1
0
 protected function SubmitPIREP()
 {
     $pilotid = Auth::$userinfo->pilotid;
     if ($pilotid == '' || Auth::LoggedIn() == false) {
         $this->set('message', 'You must be logged in to access this feature!!');
         //$this->render('core_error.tpl');
         return false;
     }
     if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->depicao == '' || $this->post->arricao == '' || $this->post->aircraft == '' || $this->post->flighttime == '') {
         $this->set('message', 'You must fill out all of the required fields!');
         return false;
     }
     # Only allow for valid routes to be filed
     $sched_data = SchedulesData::GetScheduleByFlight($this->post->code, $this->post->flightnum);
     if (!$sched_data) {
         $this->set('message', 'The flight code and number you entered is not a valid route!');
         return false;
     }
     # See if they entered more than 59 in the minutes part of the flight time
     $this->post->flighttime = str_replace(':', '.', $this->post->flighttime);
     $parts = explode('.', $this->post->flighttime);
     if ($parts[1] > 59) {
         $this->set('message', 'You entered more than 60 minutes in the minutes');
         return false;
     }
     /* Check the schedule and see if it's been bidded on */
     if (Config::Get('DISABLE_SCHED_ON_BID') == true) {
         $biddata = SchedulesData::GetBid($sched_data->bidid);
         if ($biddata) {
             if ($biddata->pilotid != $pilotid) {
                 $this->set('message', 'You are not the bidding pilot');
                 //$this->render('core_error.tpl');
                 return false;
             }
         }
     }
     /* Removed this check since maybe it's a training flight or something, who knows
        if($this->post->depicao == $this->post->arricao)
        {
        $this->set('message', 'The departure airport is the same as the arrival airport!');
        $this->render('core_error.tpl');
        return false;
        }*/
     $this->post->flighttime = str_replace(':', '.', $this->post->flighttime);
     if (!is_numeric($this->post->flighttime)) {
         $this->set('message', 'The flight time has to be a number!');
         return false;
     }
     # form the fields to submit
     $this->pirepdata = array('pilotid' => $pilotid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'route' => $this->post->route, 'submitdate' => 'NOW()', 'fuelused' => $this->post->fuelused, 'source' => 'manual', 'comment' => $this->post->comment);
     CodonEvent::Dispatch('pirep_prefile', 'PIREPS');
     if (CodonEvent::hasStop('pirepfile')) {
         return false;
     }
     if (!PIREPData::FileReport($this->pirepdata)) {
         $this->set('message', 'There was an error adding your PIREP : ' . PIREPData::$lasterror);
         return false;
     }
     $pirepid = DB::$insert_id;
     PIREPData::SaveFields($pirepid, $_POST);
     # Remove the bid
     $bidid = SchedulesData::GetBidWithRoute($pilotid, $this->post->code, $this->post->flightnum);
     if ($bidid) {
         SchedulesData::RemoveBid($bidid->bidid);
     }
     # Call the event
     CodonEvent::Dispatch('pirep_filed', 'PIREPS');
     # Set them as non-retired
     PilotData::setPilotRetired($pilotid, 0);
     # Delete the bid, if the value for it is set
     if ($this->post->bid != '') {
         SchedulesData::RemoveBid($this->post->bid);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * PIREPS::FilePIREPForm()
  * 
  * @param string $bidid
  * @return
  */
 protected function FilePIREPForm($bidid = '')
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     }
     $this->set('pilot', Auth::$pilot->firstname . ' ' . Auth::$pilot->lastname);
     $this->set('pilotcode', PilotData::GetPilotCode(Auth::$pilot->code, Auth::$pilot->pilotid));
     $this->set('pirepfields', PIREPData::GetAllFields());
     if ($bidid != '') {
         $this->set('bid', SchedulesData::GetBid($bidid));
         // get the bid info
     }
     $airport_list = OperationsData::getAllAirports();
     $this->set('allairports', $airport_list);
     #deprecated
     $this->set('airport_list', $airport_list);
     $airline_list = OperationsData::getAllAirlines(true);
     $this->set('allairlines', $airline_list);
     #deprecated
     $this->set('airline_list', $airline_list);
     $aircraft_list = OperationsData::getAllAircraft(true);
     /*	Skip any aircraft which have aircraft that the pilot
     			is not rated to fly (according to RANK)
                 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) {
         foreach ($aircraft_list as $index => $aircraft) {
             if ($aircraft->ranklevel > Auth::$pilot->ranklevel) {
                 unset($aircraft_list[$index]);
                 continue;
             }
         }
     }
     $this->set('allaircraft', $aircraft_list);
     #deprecated
     $this->set('aircraft_list', $aircraft_list);
     $this->render('pirep_new.tpl');
 }