Example #1
0
 public function testDeletePIREP()
 {
     # Delete it
     PIREPData::DeleteFlightReport($this->pirep_id);
     # Verify delete
     $data = PIREPData::GetReportDetails($this->pirep_id);
     $this->assertFalse($data);
     echo '<br />';
 }
 public static function getLocation($pilot)
 {
     $query = "SELECT * FROM fltbook_location WHERE pilot_id='{$pilot}'";
     $real_location = DB::get_row($query);
     $pirep_location = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, '');
     if ($real_location->last_update > $pirep_location->submitdate) {
         return $real_location;
     } else {
         return $pirep_location;
     }
 }
Example #3
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);
         }
     }
 }
Example #4
0
 /**
  * Profile::view()
  * 
  * @param string $pilotid
  * @return
  */
 public function view($pilotid = '')
 {
     $pilotid = PilotData::parsePilotID($pilotid);
     $pilot = PilotData::getPilotData($pilotid);
     $this->title = 'Profile of ' . $pilot->firstname . ' ' . $pilot->lastname;
     $this->set('userinfo', $pilot);
     $this->set('pilot', $pilot);
     $this->set('allfields', PilotData::getFieldData($pilotid, false));
     $pirep_list = PIREPData::getAllReportsForPilot($pilotid);
     $this->set('pireps', $pirep_list);
     $this->set('pirep_list', $pirep_list);
     $this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
     $this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
     $this->render('pilot_public_profile.tpl');
     $this->render('pireps_viewall.tpl');
 }
Example #5
0
 /**
  * This is the public profile for the pilot
  */
 public function view($pilotid = '')
 {
     if (!is_numeric($pilotid)) {
         preg_match('/^([A-Za-z]*)(\\d*)/', $pilotid, $matches);
         $code = $matches[1];
         $pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');
     }
     $userinfo = PilotData::getPilotData($pilotid);
     $this->title = 'Profile of ' . $userinfo->firstname . ' ' . $userinfo->lastname;
     $this->set('userinfo', $userinfo);
     $this->set('allfields', PilotData::GetFieldData($pilotid, false));
     $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
     $this->set('pilotcode', PilotData::GetPilotCode($userinfo->code, $userinfo->pilotid));
     $this->set('allawards', AwardsData::GetPilotAwards($userinfo->pilotid));
     $this->render('pilot_public_profile.tpl');
     $this->render('pireps_viewall.tpl');
 }
Example #6
0
 public function pirepcounts()
 {
     # Create the chart
     //$reportcounts = '';
     $data = PIREPData::getIntervalDataByDays(array(), 30);
     if (!$data) {
         $data = array();
         // so it doesn't error out
     }
     $bar_values = array();
     $bar_titles = array();
     foreach ($data as $val) {
         $bar_titles[] = $val->ym;
         $bar_values[] = floatval($val->total);
     }
     OFCharts::add_data_set($bar_titles, $bar_values);
     echo OFCharts::create_line_graph('Past 30 days PIREPS');
 }
Example #7
0
 /**
  * Profile::view()
  *
  * @param string $pilotid
  * @return
  */
 public function view($pilotid = '')
 {
     #replacement for OFC charts - Google Charts API - simpilot
     $this->set('chart_url', ChartsData::build_pireptable($pilotid, 30));
     #end
     $pilotid = PilotData::parsePilotID($pilotid);
     $pilot = PilotData::getPilotData($pilotid);
     $this->title = 'Profile of ' . $pilot->firstname . ' ' . $pilot->lastname;
     $this->set('userinfo', $pilot);
     $this->set('pilot', $pilot);
     $this->set('allfields', PilotData::getFieldData($pilotid, false));
     $pirep_list = PIREPData::getAllReportsForPilot($pilotid);
     $this->set('pireps', $pirep_list);
     $this->set('pirep_list', $pirep_list);
     $this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
     $this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
     $this->render('pilot_public_profile.tpl');
     $this->render('pireps_viewall.tpl');
 }
Example #8
0
 public function sendqueuedpireps()
 {
     echo '<h3>vaCentral PIREP Export</h3>';
     $pireps = PIREPData::getReportsByExportStatus(false);
     if (!$pireps) {
         echo 'You have no PIREPs waiting to be exported!';
         return;
     }
     echo '<p>';
     foreach ($pireps as $pirep) {
         $resp = CentralData::send_pirep($pirep->pirepid);
         if ((int) CentralData::$response->responsecode == 200) {
             echo "Exported PIREP #{$pirep->pirepid}<br />";
         } else {
             echo "FAILED exporting PIREP #{$pirep->pirepid} - " . CentralData::$last_error . '<br />';
         }
     }
     echo "Completed</p>";
     LogData::addLog(Auth::$userinfo->pilotid, 'vaCentral - queued PIREPs sent');
 }
Example #9
0
 public function viewmap()
 {
     if ($this->get->type === 'pirep') {
         $data = PIREPData::getReportDetails($this->get->id);
     } elseif ($this->get->type === 'schedule') {
         $data = SchedulesData::getScheduleDetailed($this->get->id);
     } elseif ($this->get->type === 'preview') {
         $data = new stdClass();
         $depicao = OperationsData::getAirportInfo($this->get->depicao);
         $arricao = OperationsData::getAirportInfo($this->get->arricao);
         $data->deplat = $depicao->lat;
         $data->deplng = $depicao->lng;
         $data->depname = $depicao->name;
         $data->arrlat = $arricao->lat;
         $data->arrlng = $arricao->lng;
         $data->arrname = $arricao->name;
         $data->route = $this->get->route;
         unset($depicao);
         unset($arricao);
         $data->route_details = NavData::parseRoute($data);
     }
     $this->set('mapdata', $data);
     $this->render('route_map.tpl');
 }
 public static function send_pirep($pirep_id)
 {
     if (!self::central_enabled()) {
         return false;
     }
     if ($pirep_id == '') {
         return;
     }
     self::set_xml('add_pirep');
     $pirep = PIREPData::getReportDetails($pirep_id);
     PIREPData::setExportedStatus($pirep_id, false);
     if (!$pirep) {
         return false;
     }
     self::get_pirep_xml($pirep);
     CronData::set_lastupdate('add_pirep');
     $resp = self::send_xml();
     if ($resp === true) {
         PIREPData::setExportedStatus($pirep_id, true);
         return true;
     }
 }
Example #11
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()');
 }
Example #12
0
 public static function build_pireptable($pilotid, $days = '30', $color = '000000', $background = 'EFEFEF', $width = '950', $height = '260')
 {
     #make sure $days is even - if not add 1
     if ($days & 1) {
         $days++;
     }
     $output = array();
     #set current date
     $month = date("m");
     $day = date("d");
     $year = date("Y");
     #set todays date
     $output[] = date('m-d', mktime(0, 0, 0, $month, $day, $year));
     #loop through days
     for ($i = 1; $i <= $days - 1; $i++) {
         $output[] = date('m-d', mktime(0, 0, 0, $month, $day - $i, $year));
     }
     #reverse the days for chart
     $output = array_reverse($output);
     #set baseline values
     $labels = array();
     $points = array();
     $xTotal = 0;
     $yTotal = 0;
     $dataPoint = array();
     $data = PIREPData::getIntervalDataByDays(array('p.pilotid' => $pilotid), $days);
     if ($data) {
         foreach ($data as $dat) {
             $points[] = $dat->total;
             #get highest y-axis value for chart
             if ($dat->total > $total) {
                 $yTotal = $dat->total;
             }
             $date = '';
             $date = explode('-', $dat->ym);
             $labels[] = $date[1] . '-' . $date[2];
             $xTotal++;
             $z = new stdClass();
             $z->label = $date[1] . '-' . $date[2];
             $z->point = $dat->total;
             $dataPoint[] = $z;
         }
     }
     $fLabels = array();
     $fPoints = array();
     $arraySpot = '0';
     foreach ($output as $num => $point) {
         #display every x-axis label on charts 10 days or less
         if ($days < 11) {
             if (in_array($point, $labels)) {
                 $fLabels[] = $dataPoint[$arraySpot]->label;
                 $fPoints[] = $dataPoint[$arraySpot]->point;
                 $arraySpot++;
             } else {
                 $fLabels[] = $point;
                 $fPoints[] = '0';
             }
         } else {
             if (in_array($point, $labels)) {
                 if ($num & 1) {
                     $fLabels[] = $dataPoint[$arraySpot]->label;
                 } else {
                     $fLabels[] = '';
                 }
                 $fPoints[] = $dataPoint[$arraySpot]->point;
                 $arraySpot++;
             } else {
                 if ($num & 1) {
                     $fLabels[] = $point;
                 } else {
                     $fLabels[] = '';
                 }
                 $fPoints[] = '0';
             }
         }
     }
     #build chart params
     $lineChart = new gLineChart($width, $height);
     $lineChart->addDataSet($fPoints);
     $lineChart->setColors(array($color));
     $lineChart->setVisibleAxes(array('x', 'y'));
     $lineChart->setDataRange(0, $yTotal + 1);
     $lineChart->addAxisRange(0, 1, $days, 1);
     $lineChart->addAxisRange(1, 0, $yTotal + 1, 1);
     $lineChart->setlineMarkers('6');
     $lineChart->setlineWidth('1');
     $lineChart->setaxisStyle('0', $color, '10');
     $lineChart->addAxisLabel(0, $fLabels);
     $lineChart->setGridLines(100 / 29, 100 / ($yTotal + 1), 4, 2, 0, 0);
     $lineChart->setTitle("Last " . $days . " Days PIREPS");
     $lineChart->setTitleOptions($color, '18');
     $lineChart->setChartMargins(array(20, 20, 20, 20));
     $lineChart->addBackgroundFill('bg', $background);
     return $lineChart->getUrl();
 }
Example #13
0
     #
     # We have more coming to the log
     #
     $report = PIREPData::GetLastReports($pilotid, 1);
     /* Check for any other data which might be in the other
     			chunks sent by fsacars, because it's stupid and doesn't
     			just do POST */
     $log = explode('*', $_GET['log']);
     /* Find the landing rate */
     $pos = find_in_fsacars_log('TouchDown:Rate', $log);
     $landingrate = str_replace('TouchDown:Rate', '', $log[$pos]);
     $count = preg_match('/([0-9]*:[0-9]*).*([-+]\\d*).*/i', $landingrate, $matches);
     if ($count > 0) {
         PIREPData::editPIREPFields($report->pirepid, array('landingrate' => $matches[2]));
     }
     PIREPData::AppendToLog($report->pirepid, $_GET['log']);
     echo 'OK';
     return;
 }
 # Full PIREP, run with it
 preg_match('/^([A-Za-z]*)(\\d*)/', $_GET['pilot'], $matches);
 $code = $matches[1];
 $log = explode('*', $_GET['log']);
 # Find where flight IATA is
 # And extract the code and flight number
 $pos = find_in_fsacars_log('Flight IATA', $log);
 $flightnum = str_replace('Flight IATA:', '', $log[$pos]);
 //preg_match('/^([A-Za-z]*)(\d*)/', $flightnum, $matches);
 $flightinfo = SchedulesData::getProperFlightNum($flightnum);
 $code = $flightinfo['code'];
 $flightnum = $flightinfo['flightnum'];
Example #14
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);
 }
Example #15
0
 /**
  * Show the graph of the past week's reports. Outputs the
  *	image unless $ret == true
  * 
  * @deprecated
  */
 public static function showReportCounts($ret = false)
 {
     // Recent PIREP #'s
     $max = 0;
     $data = array();
     # Get the past 7 days
     $time_start = strtotime('-7 days');
     $time_end = date('Ymd');
     do {
         $count = PIREPData::getReportCount($time_start);
         $data[date('m/d', $time_start)] = $count;
         $time_start += SECONDS_PER_DAY;
         $check = date('Ymd', $time_start);
     } while ($check <= $time_end);
     return $data;
 }
Example #16
0
<?php 
// List all of the custom PIREP fields
if (!$pirepfields) {
    echo '<p>There are no custom fields to edit for PIREPs!</p>';
    return;
}
foreach ($pirepfields as $field) {
    ?>
	<dt><?php 
    echo $field->title;
    ?>
</dt>
	<dd>
	<?php 
    // Determine field by the type
    $value = PIREPData::GetFieldValue($field->fieldid, $pirep->pirepid);
    if ($field->type == '' || $field->type == 'text') {
        ?>
		<input type="text" name="<?php 
        echo $field->name;
        ?>
" value="<?php 
        echo $value;
        ?>
" />
	<?php 
    } elseif ($field->type == 'textarea') {
        echo '<textarea name="' . $field->name . '">' . $value . '</textarea>';
    } elseif ($field->type == 'dropdown') {
        $values = explode(',', $field->options);
        echo '<select name="' . $field->name . '">';
Example #17
0
 public function statsdaysdata($routeid)
 {
     $routeinfo = SchedulesData::findSchedules(array('s.id' => $routeid));
     $routeinfo = $routeinfo[0];
     // Last 30 days stats
     $data = PIREPData::getIntervalDataByDays(array('p.code' => $routeinfo->code, 'p.flightnum' => $routeinfo->flightnum), 30);
     $this->create_line_graph('Schedule Flown Counts', $data);
 }
Example #18
0
 /**
  * Pilots::statsmonthsdata()
  * 
  * @param mixed $pilotid
  * @return
  */
 public function statsmonthsdata($pilotid)
 {
     $data = PIREPData::getIntervalDataByMonth(array('p.pilotid' => $pilotid), 3);
     $this->create_line_graph('Monthly Flight Stats', $data);
 }
Example #19
0
 /**
  * Reset the pilot pay from all of the PIREPs, do it from
  * scratch
  * 
  * @param mixed $pilotid
  * @return
  */
 public static function resetLedgerforPilot($pilotid)
 {
     DB::query("DELETE FROM `" . TABLE_PREFIX . "ledger` WHERE `pirepid` > 0 AND `pilotid`=" . $pilotid);
     $sql = 'SELECT `pirepid` FROM `' . TABLE_PREFIX . 'pireps`
             WHERE `pilotid`=' . $pilotid . ' AND `accepted`=' . PIREP_ACCEPTED;
     $results = DB::get_results($sql);
     if (!$results) {
         return false;
     }
     foreach ($results as $pirep) {
         PIREPData::calculatePIREPPayment($pirep->pirepid);
     }
     return self::resetPilotPay($pilotid);
 }
Example #20
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);
 }
Example #21
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!';
}
Example #22
0
    /**
     * Maintenance::resetpireproute()
     * 
     * @return
     */
    public function resetpireproute()
    {
        CodonModule::checkPermission(MAINTENANCE);
        echo '<h3>Reset cached PIREP routes</h3> 
				Resetting... <br />';
        PIREPData::deleteAllRouteDetails();
        echo 'Completed!';
        LogData::addLog(Auth::$userinfo->pilotid, 'Reset cached pirep route details');
    }
Example #23
0
 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;
 }
Example #24
0
    public function resetpireproute()
    {
        echo '<h3>Reset cached PIREP routes</h3> 
				Resetting... <br />';
        PIREPData::deleteAllRouteDetails();
        echo 'Completed!';
        LogData::addLog(Auth::$userinfo->pilotid, 'Reset cached pirep route details');
    }
Example #25
0
 /**
  * File a PIREP from an ACARS program
  *
  * @param mixed $pilotid The pilot ID of the pilot filing the PIREP
  * @param mixed $data This is the data structure with the PIREP info
  * @return bool true/false
  *
  */
 public static function FilePIREP($pilotid, $data)
 {
     if (!is_array($data)) {
         self::$lasterror = 'PIREP data must be array';
         return false;
     }
     # Call the pre-file event
     #
     if (CodonEvent::Dispatch('pirep_prefile', 'PIREPS', $_POST) == false) {
         return false;
     }
     # File the PIREP report
     #
     $ret = PIREPData::FileReport($data);
     # Set them as non-retired
     PilotData::setPilotRetired($pilotid, 0);
     if (!$ret) {
         return false;
     }
     self::$pirepid = DB::$insert_id;
     # Call the event
     #
     CodonEvent::Dispatch('pirep_filed', 'PIREPS', $_POST);
     # Close out a bid if it exists
     #
     $bidid = SchedulesData::GetBidWithRoute($pilotid, $data['code'], $data['flightnum']);
     if ($bidid) {
         SchedulesData::RemoveBid($bidid->bidid);
     }
     return true;
 }
Example #26
0
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>
Example #27
0
 protected function PIREP_DeleteField()
 {
     $id = DB::escape($this->post->id);
     $ret = PIREPData::DeleteField($id);
     if (DB::errno() != 0) {
         $this->set('message', 'There was an error deleting the field: ' . DB::$err);
         $this->render('core_error.tpl');
     } else {
         LogData::addLog(Auth::$userinfo->pilotid, 'Deleted PIREP field');
         $this->set('message', 'The field was deleted');
         $this->render('core_success.tpl');
     }
 }
Example #28
0
<?php

include dirname(__FILE__) . '/bootstrap.inc.php';
echo '<pre>';
Config::set('TWITTER_AIRLINE_ACCOUNT', 'nabeels');
Config::set('TWITTER_ENABLE_PUSH', false);
ActivityData::readTwitter();
// Push a test message to Twitter
Config::set('TWITTER_ENABLE_PUSH', true);
$pirep = PIREPData::getRecentReportsByCount(20);
$idx = rand(0, count($pirep) - 1);
$pirep = $pirep[$idx];
$message = Lang::get('activity.new.pirep');
foreach ($pirep as $key => $value) {
    $message = str_replace('$' . $key, $value, $message);
}
# Push a new PIREP
$ret = ActivityData::pushToTwitter(array('pilotid' => $pirep->pilotid, 'type' => ACTIVITY_NEW_PIREP, 'refid' => $pirep->pirepid, 'message' => $message));
var_dump($ret);
Example #29
0
 /**
  * Show the graph of the past week's reports. Outputs the
  *	image unless $ret == true
  * 
  * @deprecated
  */
 public static function showReportCounts()
 {
     // Recent PIREP #'s
     $max = 0;
     $data = array();
     $time_start = strtotime('-7 days');
     $time_end = time();
     // This is for the past 7 days
     do {
         $count = PIREPData::getReportCount($time_start);
         $data[] = $count;
         if ($count > $max) {
             $max = $count;
         }
         $time_start += SECONDS_PER_DAY;
     } while ($time_start < $time_end);
     return $data;
 }
Example #30
0
 /**
  * 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;
 }