function post_module_load() { /* Misc tasks which need to get done */ /* If the setting to auto-retired pilots is on, then do that and only check every 24 hours */ if (Config::Get('USE_CRON') == false) { if (Config::Get('PILOT_AUTO_RETIRE') == true) { $within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24'); if ($within_timelimit === false) { PilotData::findRetiredPilots(); CronData::set_lastupdate('find_retired_pilots'); } } if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) { $within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24'); if ($within_timelimit === false) { SchedulesData::deleteExpiredBids(); CronData::set_lastupdate('check_expired_bids'); } } /* Expenses, make sure they're all populated */ $within_timelimit = CronData::check_hoursdiff('populate_expenses', 18); if ($within_timelimit === false) { FinanceData::updateAllExpenses(); CronData::set_lastupdate('populate_expenses'); } /* And finally, clear expired sessions */ Auth::clearExpiredSessions(); } if (Config::Get('TWITTER_AIRLINE_ACCOUNT') != '') { $within_timelimit = CronData::check_hoursdiff('twitter_update', '3'); if ($within_timelimit === false) { ActivityData::readTwitter(); CronData::set_lastupdate('twitter_update'); } } // @TODO: Clean ACARS records older than one month if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) { Template::Show('maintenance.tpl'); die; } return true; }
function post_module_load() { /* Misc tasks which need to get done */ /* If the setting to auto-retired pilots is on, then do that and only check every 24 hours */ if (Config::Get('USE_CRON') === true) { if (Config::Get('PILOT_AUTO_RETIRE') == true) { $within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24'); if ($within_timelimit == false) { PilotData::findRetiredPilots(); CronData::set_lastupdate('find_retired_pilots'); } } if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) { $within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24'); if ($within_timelimit == false) { SchedulesData::deleteExpiredBids(); CronData::set_lastupdate('check_expired_bids'); } } /* Expenses, make sure they're all populated */ $within_timelimit = CronData::check_hoursdiff('populate_expenses', '18'); if ($within_timelimit == false) { FinanceData::updateAllExpenses(); CronData::set_lastupdate('populate_expenses'); } /* And finally, clear expired sessions */ Auth::clearExpiredSessions(); } // @TODO: Clean ACARS records older than one month if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) { echo '<html><head><title>Down for maintenance - ' . SITE_NAME . '</title></head><body>'; Debug::showCritical(Config::Get('MAINTENANCE_MESSAGE'), 'Down for maintenance'); echo '</body></html>'; die; } return true; }
* * @author Nabeel Shahzad * @copyright Copyright (c) 2008, Nabeel Shahzad * @link http://www.phpvms.net * @license http://creativecommons.org/licenses/by-nc-sa/3.0/ */ /* This is the maintenance cron file, which can run nightly. You should either point to this file directly in your web-host's control panel Or add an entry into the crontab file. I recommend running this maybe 2-3am, */ define('ADMIN_PANEL', true); include dirname(dirname(__FILE__)) . '/core/codon.config.php'; Auth::$userinfo->pilotid = 0; error_reporting(E_ALL); ini_set('display_errors', 'on'); /* Clear expired sessions */ Auth::clearExpiredSessions(); /* Update any expenses */ FinanceData::updateAllExpenses(); if (Config::Get('PILOT_AUTO_RETIRE') == true) { /* Find any retired pilots and set them to retired */ PilotData::findRetiredPilots(); CronData::set_lastupdate('find_retired_pilots'); } if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) { SchedulesData::deleteExpiredBids(); CronData::set_lastupdate('check_expired_bids'); } MaintenanceData::optimizeTables(); MainController::Run('Maintenance', 'resetpirepcount'); MainController::Run('Maintenance', 'resethours');
/** * Edit a certain expense */ public static function editExpense($id, $name, $cost, $type) { if ($name == '' || $cost == '') { self::$lasterror = 'Name and cost must be entered'; return false; } $name = DB::escape($name); $cost = DB::escape($cost); $type = strtoupper($type); if ($type == '') { $type = 'M'; } // Default as monthly $sql = 'UPDATE ' . TABLE_PREFIX . "expenses\n\t\t\t\t\tSET `name`='{$name}', `cost`='{$cost}', `type`='{$type}'\n\t\t\t\t\tWHERE `id`={$id}"; DB::query($sql); if (DB::errno() != 0) { return false; } return true; }
# see if they are a valid pilot: preg_match('/^([A-Za-z]*)(\d*)/', $_GET['pilot'], $matches); $code = $matches[1]; $pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET'); }*/ $pilotid = PilotData::parsePilotID($_GET['pilot']); $route = SchedulesData::getLatestBid($pilotid); $date = date('Y:m:d'); # Get load counts 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'); } } //$starttime = echo "OK\n{$route->depicao}\n{$route->arricao}\n\n{$route->flightlevel}\n{$route->aircraft}\n\n\n{$route->code}{$route->flightnum}\n{$route->registration}\n{$route->code}\n{$route->route}\n\n\n{$maxpax}\n{$maxcargo}"; break; # # Position Update # # # Position Update # case 'status': Debug::log('STATUS UPDATE', 'fsacars'); Debug::log(print_r($_GET, true), 'fsacars'); if ($_GET['detailph'] == '') {
public function processExpense() { if ($this->post->name == '' || $this->post->cost == '') { $this->set('message', 'Name and cost must be entered'); $this->render('core_error.tpl'); return; } if (!is_numeric($this->post->cost)) { $this->set('message', 'Cost must be a numeric amount, no symbols'); $this->render('core_error.tpl'); return; } if ($this->post->action == 'addexpense') { # Make sure it doesn't exist if (FinanceData::GetExpenseByName($this->post->name)) { $this->set('message', 'Expense already exists!'); $this->render('core_error.tpl'); return; } $ret = FinanceData::AddExpense($this->post->name, $this->post->cost, $this->post->type); $this->set('message', 'The expense "' . $this->post->name . '" has been added'); FinanceData::setExpensesforMonth(time()); LogData::addLog(Auth::$userinfo->pilotid, 'Added expense "' . $this->post->name . '"'); } elseif ($this->post->action == 'editexpense') { $ret = FinanceData::EditExpense($this->post->id, $this->post->name, $this->post->cost, $this->post->type); $this->set('message', 'The expense "' . $this->post->name . '" has been edited'); FinanceData::setExpensesforMonth(time()); LogData::addLog(Auth::$userinfo->pilotid, 'Edited expense "' . $this->post->name . '"'); } if (!$ret) { $this->set('message', 'Error: ' . DB::error()); $this->render('core_error.tpl'); return; } $this->render('core_success.tpl'); }
echo str_replace('$', Config::Get('MONEY_UNIT'), FinanceData::FormatMoney(-1 * $month_data->expenses_total)); ?> </td> </tr> <tr class="balancesheet_header"> <td align="" colspan="2">Totals</td> </tr> <tr class="balancesheet_header" style="border-bottom: 1px dotted"> <td align="" colspan="2" style="padding: 1px;"></td> </tr> <tr> <td align="right"><strong>Total:</strong></td> <td align="right"> <?php echo str_replace('$', Config::Get('MONEY_UNIT'), FinanceData::FormatMoney($month_data->revenue)); ?> </td> </tr> </table> <h3>Breakdown</h3> <div align="center"> <?php /* Added in 2.0! */ $chart_width = '800'; $chart_height = '500'; /* Don't need to change anything below this here */ ?>
<td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->load * $pirep->price); ?> </td> </tr> <tr> <td align="right">Fuel Cost: <br /> (<?php echo $pirep->fuelused; ?> fuel used @ <?php echo $pirep->fuelunitcost; ?> / unit)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->fuelused * $pirep->fuelunitcost); ?> </td> </tr> </table> </td> </tr> </table> <?php if ($fields) { ?> <h3>Flight Details</h3> <ul> <?php foreach ($fields as $field) {
?> <li><strong>Total Flights: </strong><?php echo $pilot->totalflights; ?> </li> <li><strong>Total Hours: </strong><?php echo $pilot->totalhours; ?> </li> <li><strong>Total Transfer Hours: </strong><?php echo $pilot->transferhours; ?> </li> <li><strong>Total Money: </strong><?php echo FinanceData::formatMoney(floatval($pilot->totalpay) + floatval($pilot->payadjust)); ?> </li> <?php if ($nextrank) { ?> <p>You have <?php echo $nextrank->minhours - $pilot_hours; ?> hours left until your promotion to <?php echo $nextrank->rank; ?> </p> <?php
/** * Loop through month by month, and pull any data for that month. * If there's nothing for that month, then blank it */ protected function getyearly($year) { //$params = $this->formfilter(); $all_finances = array(); $months = StatsData::GetMonthsInRange('January ' . $year, 'December ' . $year); foreach ($months as $month) { $date_filter = array("DATE_FORMAT(p.submitdate, '%Y%m') = '" . date('Ym', $month) . "'"); //$this_filter = array_merge($date_filter, $params); $data = PIREPData::getIntervalData($date_filter); if (!$data) { $data = new stdClass(); $data->ym = date('Y-m', $month); $data->timestamp = $month; $data->total = 0; $data->revenue = 0; $data->gross = 0; $data->fuelprice = 0; $data->price = 0; $data->expenses = 0; $data->pilotpay = 0; } else { $data = FinanceData::calculateFinances($data[0]); } $all_finances[] = $data; } return $all_finances; }
/** * 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); }
?> " title="Available airports to search from your current location"> </td> <td align="center" > <input type="hidden" name="action" value="findflight" /> <input type="submit" name="submit" value="Search Flight" /> </td> </tr> </table> </form> </div> <h3>Pilot Transfer</h3> <ul> <li>Your Bank limit is : <font color="#66FF00"><?php echo FinanceData::FormatMoney(Auth::$userinfo->totalpay); ?> </font></li> </ul> <br /> <form action="<?php echo url('/FBSV11/jumpseat'); ?> " method="get"> <table> <tr> <td>select airport to transfer : </td> <td > <select name="depicao" onchange="listSel(this,'cost')"> <option value="">--Select--</option>
$total += $month->revenue; echo FinanceData::FormatMoney($month->revenue); ?> </td> </tr> <?php } ?> <tr class="balancesheet_header" style="border-bottom: 1px dotted"> <td align="" colspan="8" style="padding: 1px;"></td> </tr> <tr> <td align="right" colspan="6"><strong>Total:</strong></td> <td align="right" colspan="2"><strong><?php echo FinanceData::FormatMoney($total); ?> </strong></td> </tr> </table> <h3>Breakdown</h3> <div align="center"> <?php /* Added in 2.0! */ $chart_width = '800'; $chart_height = '500'; /* Don't need to change anything below this here */
?> </td> <td><strong>Pilot Pay: </strong><?php echo FinanceData::formatMoney($pirep->pilotpay); ?> </td> <td><strong>Fuel Used: </strong><?php echo $pirep->fuelused != '' ? $pirep->fuelused . Config::Get('LIQUID_UNIT_NAMES', Config::Get('LiquidUnit')) : '-'; ?> </td> <td><strong>Revenue: </strong><?php echo FinanceData::formatMoney($pirep->revenue); ?> </td> <td><strong>Gross: </strong><?php echo FinanceData::formatMoney($pirep->gross); ?> </td> </tr> <?php // Get the additional fields // I know, badish place to put it, but it's pulled per-PIREP $fields = PIREPData::GetFieldData($pirep->pirepid); if (!$fields) { echo 'No additional data found'; } else { $i = 1; echo '<tr>'; foreach ($fields as $field) { if ($i == 1) {
?> " /> <p>Additional expenses for this flight (catering, cleaning, etc)</p></td> </tr> <tr> <td style="font-weight: bold;">Pilot Pay</td> <td><input type="text" name="pilotpay" value="<?php echo $pirep->pilotpay; ?> " /> <p>This is the amount this pilot has been paid for this flight</p></td> </tr> <tr> <td style="font-weight: bold;">Total Revenue for flight:</td> <td><?php echo FinanceData::FormatMoney($pirep->revenue); ?> <p></p></td> </tr> <tr><td colspan="2" style="border: none;"><h4>Comments</h4></td></tr> <tr> <td>Comments</td> <td> <?php if (!$comments) { echo '<p>No comments</p>'; $comments = array(); } foreach ($comments as $comment) {