예제 #1
0
 public function resetdistances()
 {
     echo '<h3>Updating and Calculating Distances</h3>';
     # Update all of the schedules
     echo '<p><strong>Updating schedules...</strong></p>';
     //$allschedules = SchedulesData::GetSchedulesNoDistance();
     $allschedules = SchedulesData::findSchedules(array());
     if (!$allschedules) {
         echo 'No schedules to update';
         $allschedules = array();
     }
     # Check 'em
     foreach ($allschedules as $sched) {
         $distance = SchedulesData::distanceBetweenPoints($sched->deplat, $sched->deplng, $sched->arrlat, $sched->arrlng);
         $distance = sprintf("%.6f", $distance);
         echo "{$sched->code}{$sched->flightnum} - {$sched->depname} to {$sched->arrname} " . "is {$distance} " . Config::Get('UNIT') . '<br />';
         SchedulesData::updateScheduleFields($sched->id, array('distance' => $distance));
     }
     # Update all of the PIREPS
     echo '<p><strong>Updating PIREPs...</strong></p>';
     $allpireps = PIREPData::findPIREPS(array());
     if (!$allpireps) {
         echo 'No PIREPs need updating!';
         $allpireps = array();
     }
     foreach ($allpireps as $pirep) {
         # Find the schedule, and the distance supplied by the schedule:
         $distance = SchedulesData::distanceBetweenPoints($pirep->deplat, $pirep->deplng, $pirep->arrlat, $pirep->arrlng);
         $distance = sprintf("%.2f", $distance);
         echo "PIREP Number {$pirep->pirepid} ({$pirep->code}{$pirep->flightnum}) " . "{$pirep->depname} to {$pirep->arrname} is {$distance} " . Config::Get('UNIT') . '<br />';
         PIREPData::editPIREPFields($pirep->pirepid, array('distance' => $distance));
     }
     echo '<p>Completed!</p><br />';
     LogData::addLog(Auth::$userinfo->pilotid, 'Reset distances');
 }
예제 #2
0
 public function testCheckFinances()
 {
     $params = array();
     $all_pireps = PIREPData::findPIREPS($params);
     foreach ($all_pireps as $pirep) {
         $gross1 = floatval($pirep->load) * floatval($pirep->price);
         $gross2 = $pirep->load * $pirep->price;
         if ($gross1 != $gross2) {
             $this->assertEqual(true, false);
         }
     }
 }
예제 #3
0
 public function viewall()
 {
     $this->post_action();
     if (!isset($this->get->start) || $this->get->start == '') {
         $this->get->start = 0;
     }
     $num_per_page = 20;
     $this->set('title', 'PIREPs List');
     $params = array();
     if ($this->get->action == 'filter') {
         $this->set('title', 'Filtered PIREPs');
         if ($this->get->type == 'code') {
             $params = array('p.code' => $this->get->query);
         } elseif ($this->get->type == 'flightnum') {
             $params = array('p.flightnum' => $this->get->query);
         } elseif ($this->get->type == 'pilotid') {
             $params = array('p.pilotid' => $this->get->query);
         } elseif ($this->get->type == 'depapt') {
             $params = array('p.depicao' => $this->get->query);
         } elseif ($this->get->type == 'arrapt') {
             $params = array('p.arricao' => $this->get->query);
         }
     }
     if (isset($this->get->accepted) && $this->get->accepted != 'all') {
         $params['p.accepted'] = $this->get->accepted;
     }
     $allreports = PIREPData::findPIREPS($params, $num_per_page, $this->get->start);
     if (count($allreports) >= $num_per_page) {
         $this->set('paginate', true);
         $this->set('admin', 'viewall');
         $this->set('start', $this->get->start + 20);
     }
     $this->set('pending', false);
     $this->set('load', 'viewall');
     $this->set('pireps', $allreports);
     $this->render('pireps_list.tpl');
 }
예제 #4
0
 /**
  * SchedulePIREPTest::testPIREPRejected()
  * 
  * @return void
  */
 public function testPIREPRejected()
 {
     $this->resetPilot();
     $sched = $this->findSchedule();
     Config::Set('PIREP_CHECK_DUPLICATE', false);
     Config::Set('EMAIL_SEND_PIREP', false);
     # Update this schedule to only pay per-hour
     SchedulesData::editScheduleFields($sched->id, array('payforflight' => 0));
     $sched = $this->findSchedule();
     $this->assertEquals(0, $sched->payforflight, 'Pay per-flight set to 0');
     $pirep_test = array('pilotid' => $this->samplePilotID, 'code' => $sched->code, 'flightnum' => $sched->flightnum, 'route' => $sched->route, 'depicao' => $sched->depicao, 'arricao' => $sched->arricao, 'aircraft' => $sched->aircraft, 'flighttime' => $sched->flighttime, 'submitdate' => 'NOW()', 'fuelused' => 6000, 'source' => 'unittest', 'comment' => 'Test Flight');
     # Update Pilot Pay to be set to zero
     PilotData::updateProfile($this->samplePilotID, array('totalpay' => 0));
     $pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals($pilot_data->totalpay, 0, 'Reset Pilot Pay to 0');
     # File the flight report
     $pirepid = PIREPData::fileReport($pirep_test);
     $this->assertGreaterThan(0, $pirepid, PIREPData::$lasterror);
     $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertGreaterThan(0, count($pirepdata), 'No PIREPs returned');
     # Work on one...
     $pirepdata = $pirepdata[0];
     # Verify the little bits of this PIREP....
     $this->assertEquals(PILOT_PAY_HOURLY, $pirepdata->paytype, 'PIREP Pay Type');
     $this->assertEquals($pilot_data->payrate, $pirepdata->pilotpay, 'PIREP Pay Amount');
     # Check the pilot pay
     $pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals(0, $pilot_data->totalpay, 'Check pilot pay after PIREP FILE');
     # Reject the PIREP and then check the pilot pay
     $status = PIREPData::changePIREPStatus($pirepdata->pirepid, PIREP_REJECTED);
     $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertEquals(PIREP_REJECTED, $pirepdata[0]->accepted, 'changePIREPStatus to ACCEPTED');
     $pirepdata = $pirepdata[0];
     # Check the schedule flown count:
     $post_accept = $this->findSchedule();
     $this->assertEquals($sched->timesflown, $post_accept->timesflown, "Schedule increment count");
     $post_pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals(0, $post_pilot_data->totalpay, 'Check pilot pay after PIREP REJECT');
     $this->assertEquals($pilot_data->totalflights, $post_pilot_data->totalflights, 'Total Flights');
     # Delete the PIREP
     PIREPData::deletePIREP($pirepid);
     # Verify delete
     $data = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertEmpty($data, 'PIREPDdata::deletePIREP()');
 }
예제 #5
0
 public static function send_all_pireps()
 {
     if (!self::central_enabled()) {
         return false;
     }
     if (self::$debug === false) {
         $within_timelimit = CronData::check_hoursdiff('update_pireps', self::$limits['update_pireps']);
         if ($within_timelimit == true) {
             return false;
         }
     }
     self::set_xml('update_pireps');
     //$allpireps = PIREPData::GetAllReports();
     $params = array('DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= p.submitdate');
     $allpireps = PIREPData::findPIREPS($params);
     if (!$allpireps) {
         return false;
     }
     // Set them all to have not been exported
     PIREPData::setAllExportStatus(false);
     self::$xml->addChild('total', count($allpireps));
     foreach ($allpireps as $pirep) {
         # Skip erronious entries
         if ($pirep->aircraft == '') {
             continue;
         }
         self::get_pirep_xml($pirep);
     }
     CronData::set_lastupdate('update_pireps');
     $resp = self::send_xml();
     // Only if we get a valid response, set the PIREPs to exported
     if ($resp === true) {
         PIREPData::setAllExportStatus(true);
         return true;
     }
 }
예제 #6
0
 public static function updateTotalHours()
 {
     $pireps = PIREPData::findPIREPS(array('p.accepted' => 1));
     if (!$pireps) {
         return;
     }
     $totaltime = 0;
     foreach ($pireps as $pirep) {
         $totaltime = Util::AddTime($totaltime, $pirep->flighttime);
     }
     SettingsData::SaveSetting('TOTAL_HOURS', $totaltime);
 }
예제 #7
0
 public static function updatePilotStats($pilotid)
 {
     $pireps = PIREPData::findPIREPS(array('p.pilotid' => $pilotid));
     $totalpireps = 0;
     $totalhours = 0;
     if (is_array($pireps)) {
         foreach ($pireps as $p) {
             if ($p->accepted != PIREP_ACCEPTED) {
                 continue;
             }
             $totalpireps++;
             $totalhours = Util::AddTime($p->flighttime, $totalhours);
         }
     }
     $params = array('totalhours' => $totalhours, 'totalflights' => $totalpireps);
     return self::updateProfile($pilotid, $params);
 }
예제 #8
0
 /**
  * CentralData::send_all_pireps()
  * 
  * @return
  */
 public static function send_all_pireps()
 {
     if (!self::central_enabled()) {
         return false;
     }
     if (self::$debug === false) {
         $within_timelimit = CronData::check_hoursdiff('update_pireps', self::$limits['update_pireps']);
         if ($within_timelimit == true) {
             return false;
         }
     }
     $allpireps = PIREPData::findPIREPS(array());
     if (!$allpireps) {
         return false;
     }
     // Set them all to have not been exported
     PIREPData::setAllExportStatus(false);
     self::startBody('update_pireps');
     self::addElement(null, 'total', count($allpireps));
     foreach ($allpireps as $pirep) {
         # Skip erronious entries
         if ($pirep->aircraft == '') {
             continue;
         }
         self::get_pirep_xml($pirep);
     }
     CronData::set_lastupdate('update_pireps');
     $resp = self::sendToCentral();
     // Only if we get a valid response, set the PIREPs to exported
     if ($resp === true) {
         PIREPData::setAllExportStatus(true);
         return true;
     }
 }
예제 #9
0
파일: Schedules.php 프로젝트: rallin/phpVMS
 public function showSchedules()
 {
     $depapts = OperationsData::GetAllAirports();
     $equip = OperationsData::GetAllAircraftSearchList(true);
     $airlines = OperationsData::GetAllAirlines();
     $this->set('airlines', $airlines);
     $this->set('depairports', $depapts);
     $this->set('equipment', $equip);
     $this->render('schedule_searchform.tpl');
     # Show the routes. Remote this to not show them.
     $schedules = SchedulesData::GetSchedules();
     # Do some filtering and whatnots, take it out of the template...
     $today = getdate();
     $week_number = intval(($today['mday'] - 1) / 7) + 1;
     $current_day == date('w');
     $var_name = 'week' . $week_number;
     # query once, save for later
     if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
         $reports = PIREPData::findPIREPS(array('p.pilotid' => Auth::$userinfo->pilotid, 'p.accepted' => PIREP_ACCEPTED), 1);
         // return only one
     }
     foreach ($schedules as $key => $s) {
         # should we skip schedules based on day of week?
         if (Config::get('CHECK_SCHEDULE_DAY_OF_WEEK') === true) {
             if (isset($s->{$var_name}) && !empty($s->{$var_name})) {
                 # check if today is in the active list for this week
                 if (@substr_count($s->{$var_name}, $current_day) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             } else {
                 if (substr_count($s->daysofweek, date('w')) == 0) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
         # remove this schedule from the list if there's a bid on it
         if (Config::get('DISABLE_SCHED_ON_BID') === true && $route->bidid != 0) {
             unset($schedules[$key]);
             continue;
         }
         /*	This means the aircraft rank level is higher than
          		what the pilot's ranklevel, so just do "continue"
         			and move onto the next route in the list  */
         if (Config::get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) {
             if ($route->aircraftlevel > Auth::$userinfo->ranklevel) {
                 unset($schedules[$key]);
                 continue;
             }
         }
         if (Config::get('SCHEDULES_ONLY_LAST_PIREP') === true && Auth::LoggedIn() == true) {
             if (count($reports) > 0) {
                 # IF the arrival airport doesn't match the departure airport
                 if ($reports[0]->arricao != $s->depicao) {
                     unset($schedules[$key]);
                     continue;
                 }
             }
         }
     }
     // end foreach schedules
     $this->set('allroutes', $schedules);
     $this->render('schedule_list.tpl');
 }
예제 #10
0
파일: vac_diag.php 프로젝트: Galihom/phpVMS
CentralData::$debug = true;
switch ($_GET['a']) {
    case 'sendstats':
        $resp = CentralData::send_vastats();
        break;
    case 'sendschedules':
        $resp = CentralData::send_schedules();
        break;
    case 'sendpilots':
        $resp = CentralData::send_pilots();
        break;
    case 'sendallpireps':
        $resp = CentralData::send_all_pireps();
        break;
    case 'sendpirep':
        $pirep = PIREPData::findPIREPS(array(), 20);
        $num = rand(0, count($pirep) - 1);
        $resp = CentralData::send_pirep($pirep[$num]->pirepid);
        break;
    case 'sendacars':
        # Send a random flight
        $flights = ACARSData::GetAllFlights();
        $total = count($flights);
        $resp = CentralData::send_acars_data($flights[rand(0, $total - 1)]);
        break;
    case 'sendallacars':
        $resp = CentralData::send_all_acars();
        break;
}
?>
<h3>Response:</h3>
예제 #11
0
//$data = array(
//	'pilotid'=>1,
//	'code'=>'vms',
//	'flightnum'=>1,
//	//'route' => 'HYLND DCT PUT J42 RBV J230 BYRDD J48 MOL DCT FLCON',
//	'depicao'=>'lfll',
//	'arricao'=>'egll',
//	'aircraft'=>'1',
//	'route' => 'BUSIL UT133 AMORO',
//	'flighttime'=>'3',
//	'submitdate'=>'NOW()',
//	'fuelused'=>6000,
//	'source'=>'unittest',
//	'comment'=>'Test Flight',
//	);
$pirepid = PIREPData::fileReport($data);
if ($ret == false) {
    echo PIREPData::$lasterror;
}
echo "PIREP ID is {$pirepid}";
$report_info = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
echo '<br />';
print_r($report_info);
echo '<strong>Deleting...</strong><br />';
#PIREPData::deletePIREP($pirepid);
//$report_info = PIREPData::findPIREPS(array('p.pirepid'=>$pirepid));
if (!$report_info) {
    echo 'PIREP deleted';
} else {
    echo 'Failed to delete PIREP!';
}
예제 #12
0
 /**
  * PIREPData::updatePIREPFeed()
  * 
  * @return
  */
 public static function updatePIREPFeed()
 {
     # Load PIREP into RSS feed
     $reports = PIREPData::findPIREPS(array(), 10);
     # Empty the rss file if there are no pireps
     if (!$reports) {
         return false;
     }
     $rss = new RSSFeed('Latest Pilot Reports', SITE_URL, 'The latest pilot reports');
     foreach ($reports as $report) {
         $rss->AddItem('Report #' . $report->pirepid . ' - ' . $report->depicao . ' to ' . $report->arricao, SITE_URL . '/admin/index.php?admin=viewpending', '', 'Filed by ' . PilotData::getPilotCode($report->code, $report->pilotid) . " ({$report->firstname} {$report->lastname})");
     }
     $rss->BuildFeed(LIB_PATH . '/rss/latestpireps.rss');
 }
예제 #13
0
파일: PIREPS.php 프로젝트: rallin/phpVMS
 public function routesmap()
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     }
     $this->title = 'My Flight Map';
     $pireps = PIREPData::findPIREPS(array('p.pilotid' => Auth::$userinfo->pilotid));
     if (!$pireps) {
         $this->set('message', 'There are no PIREPs for this pilot!!');
         $this->render('core_error.tpl');
         return;
     }
     $this->set('allschedules', $pireps);
     $this->render('flown_routes_map.tpl');
 }
예제 #14
0
 /**
  * ActivityData::pushToTwitter()
  * 
  * @param mixed $params
  * @return void
  */
 public static function pushToTwitter($params)
 {
     require_once CORE_LIB_PATH . '/twitteroauth/twitteroauth.php';
     $params = array_merge(array('pilotid' => '', 'type' => '', 'refid' => '', 'message' => ''), $params);
     $message = '';
     # These defaults will be ignored
     $lat = -120;
     $long = -120;
     if (!empty($params['pilotid'])) {
         $pilot = PilotData::getPilotData($params['pilotid']);
         $message .= PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname . ' ';
     }
     $message .= $params['message'] . ' ';
     # Show a new PIREP, also get the airport information
     if ($params['type'] == ACTIVITY_NEW_PIREP) {
         $message .= url('/pireps/view/' . $params['refid']);
         $pirep = PIREPData::findPIREPS(array('pirepid' => $params['refid']), 1);
         $pirep = $pirep[0];
         $airport = OperationsData::getAirportInfo($pirep->arricao);
         $lat = $airport->lat;
         $long = $airport->lng;
     } elseif ($params['type'] == ACTIVITY_NEW_PILOT) {
         $message .= url('/profile/view/' . $params['pilotid']);
         $airport = OperationsData::getAirportInfo($pilot->hub);
         $lat = $airport->lat;
         $long = $airport->lng;
     }
     $tweet = new TwitterOAuth(Config::get('TWITTER_CONSUMER_KEY'), Config::get('TWITTER_CONSUMER_SECRET'), Config::get('TWITTER_OAUTH_TOKEN'), Config::get('TWITTER_OAUTH_SECRET'));
     $status = $tweet->post('statuses/update', array('status' => $message, 'lat' => $lat, 'long' => $long, 'trim_user' => true));
     return $status;
 }