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_pilots() { if (!self::central_enabled()) { return false; } if (self::$debug === false) { $within_timelimit = CronData::check_hoursdiff('update_pilots', self::$limits['update_pilots']); if ($within_timelimit == true) { return false; } } self::set_xml('update_pilots'); $allpilots = PilotData::GetAllPilots(); self::$xml->addChild('total', count($allpilots)); foreach ($allpilots as $pilot) { $pilot_xml = self::$xml->addChild('pilot'); $pilot_xml->addChild('pilotid', PilotData::GetPilotCode($pilot->code, $pilot->pilotid)); $pilot_xml->addChild('pilotname', $pilot->firstname . ' ' . $pilot->lastname); $pilot_xml->addChild('location', $pilot->location); } CronData::set_lastupdate('update_pilots'); return self::send_xml(); }
/** * 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'); }
protected function edit_admin_setting() { $pilot_id = DB::escape($this->post->pilot_id); $admin_level = DB::escape($this->post->admin_level); $cur_level = DB::escape($this->post->cur_level); if ($cur_level == $admin_level) { $this->set('pilots', PilotData::GetAllPilots()); $this->show('exams/exam_assign_admin'); } elseif ($cur_level == '0') { ExamsData::add_admin($pilot_id, $admin_level); $this->set('message', '<div id="success">Pilot Administrator Status Changed.</div>'); $this->set('pilots', PilotData::GetAllPilots()); $this->show('exams/exam_assign_admin'); } elseif ($admin_level == '0') { ExamsData::delete_admin($pilot_id); $this->set('message', '<div id="success">Pilot Administrator Status Changed.</div>'); $this->set('pilots', PilotData::GetAllPilots()); $this->show('exams/exam_assign_admin'); } else { ExamsData::edit_admin($pilot_id, $admin_level); $this->set('message', '<div id="success">Pilot Administrator Status Changed.</div>'); $this->set('pilots', PilotData::GetAllPilots()); $this->show('exams/exam_assign_admin'); } }
$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 */ /*$allpireps = PIREPData::findPIREPS(array()); if(is_array($allpireps)) { foreach($allpireps as $pirep) { $data = array( 'price' => $pirep->price, 'load' => $pirep->load, 'fuelprice' => $pirep->fuelprice,