Example #1
0
         $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');
         }
     }
     echo "1|flightplan\n{$route->depicao}\n{$route->arricao}\n{$route->arricao}\n{$route->route}\n{$maxpax}\n{$maxcargo}\nIFR\n{$route->registration}\n{$route->flightlevel}\n";
     break;
 case 'acars':
 case 'xacars':
     # Pass success by default
     $outstring = 'Success';
     $fields = array();
     $_REQUEST['DATA2'] = strtoupper($_REQUEST['DATA2']);
     if ($_REQUEST['DATA2'] == 'TEST') {
         echo '1|OK';
         return;
     } elseif ($_REQUEST['DATA2'] == 'ENDFLIGHT') {
         echo '1|OK';
Example #2
0
 /**
  * Populate the PIREP with the fianancial info needed
  * 
  * @param mixed $pirep Either a PIREP ID or the row
  * @param bool $reset_fuel Reset the fuel costs or not?
  * @return
  */
 public static function populatePIREPFinance($pirep, $reset_fuel = false)
 {
     if (!is_object($pirep) && is_numeric($pirep)) {
         $pirep = PIREPData::getReportDetails($pirep);
         if (!$pirep) {
             self::$lasterror = 'PIREP does not exist';
             return false;
         }
     }
     # Set the PIREP ID
     $pirepid = $pirep->pirepid;
     $sched = SchedulesData::getScheduleByFlight($pirep->code, $pirep->flightnum, '');
     if (!$sched) {
         self::$lasterror = 'Schedule does not exist. Please update this manually.';
         return false;
     }
     $pilot = PilotData::getPilotData($pirep->pilotid);
     # Get the load factor for this flight
     if ($pirep->load == '' || $pirep->load == 0) {
         $pirep->load = FinanceData::getLoadCount($pirep->aircraft, $sched->flighttype);
     }
     // Fix for bug #62, check the airport fuel price as 0 for live
     //$depapt = OperationsData::getAirportInfo($pirep->depicao);
     if ($pirep->fuelunitcost == '' || $pirep->fuelunitcost == 0 || $reset_fuel == true) {
         $pirep->fuelunitcost = FuelData::getFuelPrice($pirep->depicao);
     }
     # Check the fuel
     if ($pirep->fuelprice != '' || $reset_fuel == true) {
         $pirep->fuelprice = FinanceData::getFuelPrice($pirep->fuelused, $pirep->depicao);
     }
     # Get the expenses for a flight
     $total_ex = 0;
     $expense_list = '';
     /* Account for any fixed-cost percentages */
     $allexpenses = FinanceData::getFlightExpenses();
     if (is_array($allexpenses)) {
         foreach ($allexpenses as $ex) {
             $total_ex += $ex->cost;
         }
     }
     /* Account for any per-flight %age expenses */
     $all_percent_expenses = FinanceData::getFlightPercentExpenses();
     $gross = floatval($sched->price) * floatval($pirep->load);
     if (is_array($all_percent_expenses)) {
         foreach ($all_percent_expenses as $ex) {
             $cost = str_replace('%', '', $ex->cost);
             $percent = $cost / 100;
             $total = $gross * $percent;
             $total_ex += $total;
         }
     }
     /*  Set the pilotpay here - if it was a per-schedule payment,
         then set the pilot pay to that, otherwise, set it to the
         total amount paid... */
     # Handle pilot pay
     if (!empty($sched->payforflight)) {
         $pilot->payrate = $sched->payforflight;
         $payment_type = PILOT_PAY_SCHEDULE;
     } else {
         $payment_type = PILOT_PAY_HOURLY;
     }
     $data = array('price' => $sched->price, 'load' => $pirep->load, 'fuelprice' => $pirep->fuelprice, 'expenses' => $total_ex, 'pilotpay' => $pilot->payrate, 'flighttime' => $pirep->flighttime);
     $revenue = self::getPIREPRevenue($data, $payment_type);
     /* Now update the PIREP */
     $fields = array('price' => $sched->price, 'load' => $pirep->load, 'gross' => $gross, 'fuelprice' => $pirep->fuelprice, 'fuelunitcost' => $pirep->fuelunitcost, 'expenses' => $total_ex, 'pilotpay' => $pilot->payrate, 'paytype' => $payment_type, 'revenue' => $revenue);
     if (isset($data['load']) && $data['load'] != '') {
         $fields['load'] = $data['load'];
     }
     return self::editPIREPFields($pirepid, $fields);
 }