$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');*/ $pilotid = PilotData::parsePilotID($_REQUEST['DATA4']); $route = SchedulesData::GetLatestBid($pilotid); if (!$route) { echo '0|No bids found!'; return; } } else { if (is_numeric($flight)) { echo '0|No airline code entered!'; return; } $flightinfo = SchedulesData::getProperFlightNum($flight); $code = $flightinfo['code']; $flight_num = $flightinfo['flightnum']; $route = SchedulesData::GetScheduleByFlight($code, $flight_num); Debug::log(print_r($route, true), 'xacars'); if (!$route) { echo '0|Flight not found, make sure you include the flight code!'; return; } } /* Ok to proceed */ if ($route->flighttype == 'H') { $maxpax = $route->maxpax; } else { if ($route->flighttype == 'C') { $maxcargo = FinanceData::getLoadCount($route->aircraftid, 'C'); } else { $maxpax = FinanceData::getLoadCount($route->aircraftid, 'P'); }
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; }