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 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 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(); }
/** * 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'); }
<br /> <strong>Guests Online: </strong><?php echo count(StatsData::GuestsOnline()); ?> </td> <td valign="top" width="33%" nowrap="nowrap" > <strong>Total Pilots: </strong><?php echo StatsData::PilotCount(); ?> <br /> <strong>Total Flights: </strong><?php echo StatsData::TotalFlights(); ?> <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>
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 */
<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>