public function testTimesAdded() { $sql = 'SELECT `flighttime` FROM ' . TABLE_PREFIX . 'pireps WHERE `accepted`=' . PIREP_ACCEPTED; $results = DB::get_results($sql); if (!$results) { $this->markTestSkipped('No PIREPs to test against'); } $this->added_time = 0; foreach ($results as $row) { $this->added_time = Util::AddTime($this->added_time, $row->flighttime); } $this->assertNotEqual(0, $this->added_time); // Now calculate by PIREP $allpilots = PilotData::GetAllPilots(); $total = 0; foreach ($allpilots as $pilot) { $p_hours = PilotData::getPilotHours($pilot->pilotid); $total = Util::AddTime($total, $p_hours); } $this->assertNotEqual(0, $total); $this->assertEqual($total, $this->added_time); StatsData::UpdateTotalHours(); $this->assertEqual($total, StatsData::TotalHours()); }
public function testTimesAdded() { echo '<h3>Checking Times</h3>'; $sql = 'SELECT `flighttime` FROM ' . TABLE_PREFIX . 'pireps WHERE `accepted`=' . PIREP_ACCEPTED; $results = DB::get_results($sql); $this->added_time = 0; foreach ($results as $row) { $this->added_time = Util::AddTime($this->added_time, $row->flighttime); } heading('Time added, all PIREPS at once'); $this->assertNotEqual(0, $this->added_time); heading('Time added, pilot by pilot'); // Now calculate by PIREP $allpilots = PilotData::GetAllPilots(); $total = 0; foreach ($allpilots as $pilot) { $p_hours = PilotData::getPilotHours($pilot->pilotid); $total = Util::AddTime($total, $p_hours); } $this->assertNotEqual(0, $total); heading('Comparing pilot to pilot vs all PIREPS'); $this->assertEqual($total, $this->added_time); heading('Compare to STAT total hours'); StatsData::UpdateTotalHours(); $this->assertEqual($total, StatsData::TotalHours()); echo '<br />'; }
public function savepro() { if ($this->post->firstname == '' || $this->post->lastname == '') { $this->set('message', 'The first or lastname cannot be blank!'); $this->render('core_error.tpl'); return; } $params = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'hub' => $this->post->hub, 'retired' => $this->post->retired, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'transferhours' => $this->post->transferhours); PilotData::updateProfile($this->post->pilotid, $params); PilotData::SaveFields($this->post->pilotid, $_POST); /* Don't calculate a pilot's rank if this is set */ if (Config::Get('RANKS_AUTOCALCULATE') == false) { PilotData::changePilotRank($this->post->pilotid, $this->post->rank); } else { RanksData::calculateUpdatePilotRank($this->post->pilotid); } StatsData::UpdateTotalHours(); $this->set('message', 'Profile updated successfully'); $this->render('core_success.tpl'); $this->set('pilots', PilotData::getAllPilots()); $this->render('/pm/pilot_manager.php'); if ($this->post->resend_email == 'true') { $this->post->id = $this->post->pilotid; $this->resendemail(false); } $pilot = PilotData::getPilotData($this->post->pilotid); LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname); return; break; }
public function statsaircraftdata($pilotid) { $data = StatsData::PilotAircraftFlownCounts($pilotid); if (!$data) { $data = array(); } include CORE_LIB_PATH . '/php-ofc-library/open-flash-chart.php'; $d = array(); foreach ($data as $ac) { OFCharts::add_data_set($ac->aircraft, floatval($ac->hours)); } echo OFCharts::create_pie_graph('Aircraft Flown'); }
/** * 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($this_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; }
public function aircraft() { $acstats = StatsData::AircraftUsage(); $this->set('acstats', $acstats); $this->render('reports_aircraft.php'); }
/** * CentralData::send_vastats() * * @return */ public static function send_vastats() { if (!self::central_enabled()) { return false; } if (self::$debug === false) { $within_timelimit = CronData::check_hoursdiff('update_vainfo', self::$limits['update_vainfo']); if ($within_timelimit == true) { return false; } } self::startBody('update_vainfo'); self::addElement(null, 'pilotcount', StatsData::PilotCount()); self::addElement(null, 'totalhours', StatsData::TotalHours()); self::addElement(null, 'totalflights', StatsData::TotalFlights()); self::addElement(null, 'totalschedules', StatsData::TotalSchedules()); $all_news = SiteData::getAllNews(); if (count($all_news) > 0) { $news_parent = self::addElement(null, 'newsitems'); foreach ($all_news as $news) { $body = str_ireplace('<br>', "\n", $news->body); $body = str_ireplace('<br />', "\n", $body); $body = htmlentities(strip_tags($body)); $news_xml = self::addElement($news_parent, 'news', null, array('id' => $news->id, 'subject' => $news->subject, 'body' => $body, 'postdate' => $news->postdate, 'postedby' => $news->postedby)); } } # Some of the settings self::addElement(null, 'livefuel', Config::Get('FUEL_GET_LIVE_PRICE')); # Package and send CronData::set_lastupdate('update_vainfo'); return self::sendToCentral(); }
/** * Maintenance::resethours() * * @return */ public function resethours() { CodonModule::checkPermission(MAINTENANCE); echo '<h3>Updating Total Hours Count</h3>'; $total = 0; echo '<p>Calculating hours for all pilots: <br />'; $allpilots = PilotData::GetAllPilots(); foreach ($allpilots as $pilot) { $hours = PilotData::UpdateFlightHours($pilot->pilotid); $total = Util::AddTime($total, $hours); echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid) . " - found {$hours} flight hours for number <br />"; } echo "Pilots have a total of <strong>{$total} hours</strong><br /><br />"; echo "<strong>Now counting from PIREPS</strong><br />"; StatsData::UpdateTotalHours(); echo 'Found ' . StatsData::TotalHours() . ' total hours, updated<br /></p>'; LogData::addLog(Auth::$userinfo->pilotid, 'Reset hours'); }
<h4>Stats for <?php echo $airline->name; ?> </h4> <div class="outlined"> <strong>Total Pilots: </strong><?php echo StatsData::PilotCount($airline->code); ?> <br /> <strong>Total Flights: </strong><?php echo StatsData::TotalFlights($airline->code); ?> <br /> <strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours($airline->code); ?> <br /> </div> <?php } if (is_array($acstats)) { ?> <h4>Aircraft Usage<span> Aircraft Hours and Usage</span></h4> <table id="tabledlist" class="tablesorter"> <thead> <tr> <th>Aircraft</th> <th>Hours</th> <th>Miles</th>
/** * Re-populates all expenses, deleteing all the old ones * * @return mixed This is the return value description * */ public static function populateAllExpenses() { $times = StatsData::GetMonthsSinceStart(); foreach ($times as $timestamp) { self::setExpensesforMonth($timestamp); } }
<br /> <strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?> </td> <td valign="top" width="33%" nowrap="nowrap" > <strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?> <br /> <strong>Total Schedules: </strong><?php echo StatsData::TotalSchedules(); ?> <br /> <strong>Flights Today: </strong><?php echo StatsData::TotalFlightsToday(); ?> </td> </tr> </table> <?php MainController::Run('Dashboard', 'CheckInstallFolder'); echo $updateinfo; ?> <h3>Pilot Reports for the Past Week</h3> <div align="center" style="width=98%"> <div id="reportcounts" align="center" width="400px" > <img src="<?php echo fileurl('/lib/images/loading.gif'); ?> " /><br /><br />
public function viewpilots() { /* This function is called for *ANYTHING* in that popup box Preset all of the template items in this function and call them in the subsequent templates Confusing at first, but easier than loading each tab independently via AJAX. Though may be an option later on, but can certainly be done by a plugin (Add another tab through AJAX). The hook is available for whoever wants to use it */ switch ($this->post->action) { case 'changepassword': $this->ChangePassword(); return; break; case 'deletepilot': $pilotid = $this->post->pilotid; $pilotinfo = PilotData::getPilotData($pilotid); PilotData::DeletePilot($pilotid); CodonEvent::Dispatch('pilot_deleted', 'PilotAdmin', $pilot); $this->set('message', Lang::gs('pilot.deleted')); $this->render('core_success.tpl'); LogData::addLog(Auth::$userinfo->pilotid, 'Deleted pilot ' . PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid) . ' ' . $pilotinfo->firstname . ' ' . $pilotinfo->lastname); break; /* These are reloaded into the #pilotgroups ID so the entire groups list is refreshed */ /* These are reloaded into the #pilotgroups ID so the entire groups list is refreshed */ case 'addgroup': $this->AddPilotToGroup(); $this->SetGroupsData($this->post->pilotid); $this->render('pilots_groups.tpl'); return; break; case 'removegroup': $this->RemovePilotGroup(); $this->SetGroupsData($this->post->pilotid); $this->render('pilots_groups.tpl'); return; break; case 'saveprofile': if ($this->post->firstname == '' || $this->post->lastname == '') { $this->set('message', 'The first or lastname cannot be blank!'); $this->render('core_error.tpl'); return; } if (intval($this->post->retired) == 1) { $retired = true; } else { $retired = false; } $params = array('code' => $this->post->code, 'firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'location' => $this->post->location, 'hub' => $this->post->hub, 'retired' => $retired, 'totalhours' => $this->post->totalhours, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'payadjust' => floatval($this->post->payadjust), 'transferhours' => $this->post->transferhours, 'comment' => $this->post->comment); PilotData::updateProfile($this->post->pilotid, $params); PilotData::SaveFields($this->post->pilotid, $_POST); /* Don't calculate a pilot's rank if this is set */ if (Config::Get('RANKS_AUTOCALCULATE') == false) { PilotData::changePilotRank($this->post->pilotid, $this->post->rank); } else { RanksData::calculateUpdatePilotRank($this->post->pilotid); } StatsData::UpdateTotalHours(); $this->set('message', 'Profile updated successfully'); $this->render('core_success.tpl'); $pilot = PilotData::getPilotData($this->post->pilotid); LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname); return; break; } if ($this->get->action == 'viewoptions') { $this->ViewPilotDetails(); return; } $this->ShowPilotsList(); }
FROM ' . TABLE_PREFIX . "settings\n\t\t\t\t\tWHERE name='TOTAL_HOURS'"; $res = DB::get_row($sql); if (!$res) { $sql = "INSERT INTO `phpvms_settings` (`friendlyname`, `name`, `value`,`descrip`,`core`)\n\t\t\tVALUES ('Total Hours', 'TOTAL_HOURS', '', 'These are the total hours your VA has flown', '0')"; DB::query($sql); } echo '<strong>Updating hours</strong><br />'; $allpilots = PilotData::GetAllPilots(); foreach ($allpilots as $pilot) { $hours = PilotData::UpdateFlightHours($pilot->pilotid); $total = Util::AddTime($total, $hours); } echo "Pilots have a total of <strong>{$total} hours</strong><br /><br />"; echo "<strong>Updating PIREPS Hours</strong><br />"; StatsData::UpdateTotalHours(); echo 'Found ' . StatsData::TotalHours() . ' total hours, updated<br />'; } if ($version < 20854) { Installer::add_to_config('USERS_ONLINE_TIME', 20, 'The StatsData::UserOnline() function - how many minutes to check'); Installer::sql_file_update(SITE_ROOT . '/install/update_854.sql'); } Installer::sql_file_update(SITE_ROOT . '/install/update.sql'); OperationsData::updateAircraftRankLevels(); /* Add them to the default group */ $allpilots = PilotData::GetAllPilots(); foreach ($allpilots as $pilot) { PilotGroups::AddUsertoGroup($pilot->pilotid, DEFAULT_GROUP); } /* Update expenses */ //FinanceData::updateAllExpenses(); /* Manually specify a revenue value for all PIREPs */
/** * Change the status of a PIREP. For the status, use the constants: * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS * * Also handle paying the pilot, and handle PIREP rejection, etc * * @deprecated Use editPIREPFields instead */ public static function changePIREPStatus($pirepid, $status) { # Look up the status of the PIREP of previous $pirep_details = PIREPData::getReportDetails($pirepid); if (!$pirep_details) { return false; } if ($pirep_details->accepted == $status) { return true; } $ret = self::editPIREPFields($pirepid, array('accepted' => $status)); # Do something if the PIREP was previously marked as pending if ($pirep_details->accepted == PIREP_PENDING) { if ($status == PIREP_ACCEPTED) { # Pay per-schedule if (!empty($pirep_details->payforflight)) { $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n \t\t\t\tSET totalpay=totalpay+{$pirep_details->payforflight} \n \t\t\t\tWHERE pilotid={$pirep_details->pilotid}"; DB::query($sql); } else { # Pay by hour PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, true); } SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1'); } elseif ($status == PIREP_REJECTED) { // Do nothing, since nothing in the PIREP was actually counted } } elseif ($pirep_details->accepted == PIREP_ACCEPTED) { # If already accepted if ($status == PIREP_REJECTED) { # Subtract their pay for the rejected flight if (!empty($pirep_details->payforflight)) { $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n \t\t\t\tSET totalpay=totalpay-{$pirep_details->payforflight} \n \t\t\t\tWHERE pilotid={$pirep_details->pilotid}"; DB::query($sql); } else { PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, false); } SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1'); } } PilotData::updatePilotStats($pirep_details->pilotid); RanksData::calculateUpdatePilotRank($pirep_details->pilotid); PilotData::generateSignature($pirep_details->pilotid); StatsData::updateTotalHours(); return $ret; }
public function index() { $this->set('usersonline', StatsData::UsersOnline()); $this->set('guestsonline', StatsData::GuestsOnline()); $this->render('frontpage_main.tpl'); }
public function testTotalTime() { StatsData::updateTotalHours(); }
public static function send_vastats() { if (!self::central_enabled()) { return false; } if (self::$debug === false) { $within_timelimit = CronData::check_hoursdiff('update_vainfo', self::$limits['update_vainfo']); if ($within_timelimit == true) { return false; } } self::set_xml('update_vainfo'); self::$xml->addChild('pilotcount', StatsData::PilotCount()); self::$xml->addChild('totalhours', StatsData::TotalHours()); self::$xml->addChild('totalflights', StatsData::TotalFlights()); self::$xml->addChild('totalschedules', StatsData::TotalSchedules()); # Expenses stuff /*$exp_data = FinanceData::getExpensesForMonth(time()); self::$xml->addChild('expenses', $exp_data->total); self::$xml->addChild('expensescost', $exp_data->cost);*/ # Some of the settings self::$xml->addChild('livefuel', Config::Get('FUEL_GET_LIVE_PRICE')); # Package and send CronData::set_lastupdate('update_vainfo'); return self::send_xml(); }
/** * Return summary/detailed information about all aircraft * * @return array Array of objects with the flight data * */ public static function getAircraftDetails() { return StatsData::AircraftUsage(); }
<?php if (!defined('IN_PHPVMS') && IN_PHPVMS !== true) { die; } ?> <br /><div style="float: right;"> <form action="<?php echo url('/finances/viewreport'); ?> " method="get"> <strong>Select Report: </strong> <?php $years = StatsData::GetYearsSinceStart(); $months = StatsData::GetMonthsSinceStart(); $months = array_reverse($months, true); ?> <select name="type"> <option value="" <?php echo $_GET['type'] == '' ? 'selected="selected"' : ''; ?> >View Summary</option> <?php /* * Get the years since the VA started */ foreach ($years as $yearname => $timestamp) { # Get the one that's currently selected if ($_GET['type'] == 'y' . $timestamp) { $selected = 'selected="selected"'; } else {
/** * Change the status of a PIREP. For the status, use the constants: * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS * * Also handle paying the pilot, and handle PIREP rejection, etc * * @param int $pirepid The PIREP ID of status to change * @param int $status Use consts: PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS * @return bool */ public static function changePIREPStatus($pirepid, $status) { # Look up the status of the PIREP of previous $pirep_details = PIREPData::getReportDetails($pirepid); if (!$pirep_details) { return false; } if ($pirep_details->accepted == $status) { return true; } $ret = self::editPIREPFields($pirepid, array('accepted' => $status)); # Do something if the PIREP was previously marked as pending if ($pirep_details->accepted == PIREP_PENDING) { if ($status == PIREP_ACCEPTED) { self::calculatePIREPPayment($pirepid); SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1'); } elseif ($status == PIREP_REJECTED) { // Do nothing, since nothing in the PIREP was actually counted } } elseif ($pirep_details->accepted == PIREP_ACCEPTED) { # If already accepted if ($status == PIREP_REJECTED) { LedgerData::deletePaymentByPIREP($pirep_details->pirepid); PilotData::resetPilotPay($pirep_details->pilotpay); SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1'); } } PilotData::updatePilotStats($pirep_details->pilotid); RanksData::calculateUpdatePilotRank($pirep_details->pilotid); PilotData::generateSignature($pirep_details->pilotid); StatsData::updateTotalHours(); return $ret; }
protected function edit_pirep_post() { 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!'); $this->render('core_error.tpl'); return false; } $pirepInfo = PIREPData::getReportDetails($this->post_action->pirepid); if (!$pirepInfo) { $this->set('message', 'Invalid PIREP!'); $this->render('core_error.tpl'); return false; } $this->post->fuelused = str_replace(' ', '', $this->post->fuelused); $this->post->fuelused = str_replace(',', '', $this->post->fuelused); $fuelcost = $this->post->fuelused * $this->post->fuelunitcost; # form the fields to submit $data = array('pirepid' => $this->post->pirepid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'leg' => $this->post->leg, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'load' => $this->post->load, 'price' => $this->post->price, 'pilotpay' => $this->post->pilotpay, 'fuelused' => $this->post->fuelused, 'fuelunitcost' => $this->post->fuelunitcost, 'fuelprice' => $fuelcost, 'expenses' => $this->post->expenses); if (!PIREPData::UpdateFlightReport($this->post->pirepid, $data)) { $this->set('message', 'There was an error editing your PIREP'); $this->render('core_error.tpl'); return false; } PIREPData::SaveFields($this->post->pirepid, $_POST); //Accept or reject? $this->post->id = $this->post->pirepid; $submit = strtolower($this->post->submit_pirep); // Add a comment if (trim($this->post->comment) != '' && $submit != 'reject pirep') { PIREPData::AddComment($this->post->pirepid, Auth::$userinfo->pilotid, $this->post->comment); } if ($submit == 'accept pirep') { $this->approve_pirep_post(); } elseif ($submit == 'reject pirep') { $this->reject_pirep_post(); } StatsData::UpdateTotalHours(); # Update a pilot's stats PilotData::updatePilotStats($pirepInfo->pilotid); LogData::addLog(Auth::$userinfo->pilotid, 'Edited PIREP #' . $this->post->id); return true; }
<form method="post" action="<?php echo adminurl('/massmailer/sendmail'); ?> "> <p> <strong>Subject: </strong> <input type="text" name="subject" value="" /> </p> <p> <strong>Message:</strong> </p> <p> <textarea name="message" id="editor" style="width: 600px; height: 250px;">To: {PILOT_FNAME} {PILOT_LNAME}, </textarea> </p> <p>Select groups to send to:<br /> <?php $total = StatsData::PilotCount(); ?> <input type="checkbox" name="groups[]" value="all" />All Pilots (<?php echo $total; ?> pilots)<br /> <?php foreach ($allgroups as $group) { $total = count(PilotGroups::getUsersInGroup($group->groupid)); echo "<input type=\"checkbox\" name=\"groups[]\" value=\"{$group->groupid}\" />{$group->name} - ({$total} pilots)<br />"; } ?> </p> <p> <input type="submit" name="submit" value="Send Email" />