Jump to content

Search Schedules by Airlines


jamyboy

Recommended Posts

Dear folks i am willing to put search function by airlines please help

this what i have in schedule_searchform.tpl

<h3>Search Schedules</h3>
<?php
if(Auth::LoggedIn())
{?>[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]<form id="form" action="<?php echo actionurl('/schedules/view');?>" method="post">[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]<div id="tabcontainer">
<ul>
<li><a href="#depapttab"><span>By Departure Airport</span></a></li>
<li><a href="#arrapttab"><span>By Arrival Airport</span></a></li>
<li><a href="#aircrafttab"><span>By Aircraft Type</span></a></li>
<li><a href="#distance"><span>By Distance</span></a></li>
</ul>
<div id="depapttab">
<p>Select your departure airport:</p>
<select id="depicao" name="depicao">
<option value="">Select All</option>
<?php
if(!$depairports) $depairports = array();
foreach($depairports as $airport)
{
echo '<option value="'.$airport->icao.'">'.$airport->icao
 .' ('.$airport->name.')</option>';
}
?>

</select>
<input type="submit" name="submit" value="Find Flights" />
</div>
<div id="arrapttab">
<p>Select your arrival airport:</p>
<select id="arricao" name="arricao">
<option value="">Select All</option>
<?php
if(!$depairports) $depairports = array();
foreach($depairports as $airport)
{
echo '<option value="'.$airport->icao.'">'.$airport->icao
 .' ('.$airport->name.')</option>';
}
?>

</select>
<input type="submit" name="submit" value="Find Flights" />
</div>
<div id="aircrafttab">
<p>Select aircraft:</p>
<select id="equipment" name="equipment">
<option value="">Select equipment</option>
<?php

if(!$equipment) $equipment = array();
foreach($equipment as $equip)
{
echo '<option value="'.$equip->name.'">'.$equip->name.'</option>';
}

?>
</select>
<input type="submit" name="submit" value="Find Flights" />
</div>
<div id="distance">
<p>Select Distance:</p>
<select id="type" name="type">
<option value="greater">Greater Than</option>
<option value="less">Less Than</option>
</select>
<input type="text" name="distance" value="" />
<input type="submit" name="submit" value="Find Flights" />
</div>[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]<div id="airline">
				 <p>Select Airline:</p>
				 <p><b>This feature is under construction. Check back soon! AFVA Management. </b></p>
		 <select id="airline" name="airline">
				 <option value="">Select Airline</option>
		 <?php

		 $allairlines = OperationsData::GetAllAirlines(true);
foreach($allairlines as $airline)
		 {
				 echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';
		 }
		 ?>

</select>
		 <input type="submit" name="submit" value="Find Flights" />
</div>
</div>[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]<p>
<input type="hidden" name="action" value="findflight" />
</p>
</form>
<script type="text/javascript">[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]</script>
<hr>
<?php
}
?>[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]

Schedules.php

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
* Forums: http://www.phpvms.net/forum
* Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Schedules extends CodonModule
{
public function index()
{
$this->view();
}

public function view()
{
if(isset($this->post->action) && $this->post->action == 'findflight')
{
$this->FindFlight();
return;
}

$this->showSchedules();
}

public function detail($routeid='')
{
$this->details($routeid);
}

public function details($routeid = '')
{
//$routeid = $this->get->id;

if(!is_numeric($routeid))
{
preg_match('/^([A-Za-z]{3})(\d*)/', $routeid, $matches);
$code = $matches[1];
$flightnum = $matches[2];

$params = array('s.code'=>$code, 's.flightnum'=>$flightnum);
}
else
{
$params = array('s.id' => $routeid);
}

$schedule = SchedulesData::getScheduleDetailed($routeid);
$this->set('schedule', $schedule);
$this->render('schedule_details.tpl');
$this->render('route_map.tpl');
}

public function brief($routeid = '')
{
if($routeid == '')
{
$this->set('message', 'You must be logged in to access this feature!');
$this->render('core_error.tpl');
return;
}

$schedule = SchedulesData::getScheduleDetailed($routeid);
$this->set('schedule', $schedule);
$this->render('schedule_briefing.tpl');
}

public function boardingpass($routeid)
{
if($routeid == '')
{
$this->set('message', 'You must be logged in to access this feature!');
$this->render('core_error.tpl');
return;
}

$schedule = SchedulesData::getScheduleDetailed($routeid);

$this->set('schedule', $schedule);
$this->render('schedule_boarding_pass.tpl');
}

public function bids()
{
if(!Auth::LoggedIn()) return;

$this->set('bids', SchedulesData::GetBids(Auth::$userinfo->pilotid));
$this->render('schedule_bids.tpl');
}

public function addbid()
{
if(!Auth::LoggedIn()) return;

$routeid = $this->get->id;

if($routeid == '')
{
echo 'No route passed';
return;
}

// See if this is a valid route
$route = SchedulesData::findSchedules(array('s.id' => $routeid));

if(!is_array($route) && !isset($route[0]))
{
echo 'Invalid Route';
return;
}

CodonEvent::Dispatch('bid_preadd', 'Schedules', $routeid);

/* Block any other bids if they've already made a bid
*/
if(Config::Get('DISABLE_BIDS_ON_BID') == true)
{
$bids = SchedulesData::getBids(Auth::$userinfo->pilotid);

# They've got somethin goin on
if(count($bids) > 0)
{
echo 'Bid exists!';
return;
}
}

$ret = SchedulesData::AddBid(Auth::$userinfo->pilotid, $routeid);
CodonEvent::Dispatch('bid_added', 'Schedules', $routeid);

if($ret == true)
{
echo 'Bid added';
}
else
{
echo 'Already in bids!';
}
}

public function removebid()
{
if(!Auth::LoggedIn()) return;

SchedulesData::RemoveBid($this->post->id);
}[/size][/font][/color]
[color=#000000][font=Verdana, Arial, Helvetica, sans-serif][size=2]public function showSchedules()
{
$depapts = OperationsData::GetAllAirports();
$equip = OperationsData::GetAllAircraftSearchList(true);

$this->set('depairports', $depapts);
$this->set('equipment', $equip);

$this->render('schedule_searchform.tpl');

# Show the routes. Remote this to not show them.
$this->set('allroutes', SchedulesData::GetSchedules());

$this->render('schedule_list.tpl');
}

public function FindFlight()
 {

		 if($this->post->depicao != '')
		 {
				 Template::Set('allroutes', SchedulesData::GetRoutesWithDeparture($this->post->depicao));
		 }

		 if($this->post->arricao != '')
		 {
				 Template::Set('allroutes', SchedulesData::GetRoutesWithArrival($this->post->arricao));
		 }

		 if($this->post->equipment != '')
		 {
				 Template::Set('allroutes', SchedulesData::GetSchedulesByEquip($this->post->equipment));
		 }

		 if($this->post->distance != '')
		 {
				 if($this->post->type == 'greater')
						 $type = '>';
				 else
						 $type = '<';

				 Template::Set('allroutes', SchedulesData::GetSchedulesByDistance($this->post->distance, $type));
		 }

		 if($this->post->airline!= '')
{
$routes = SchedulesData::GetSchedulesWithCode($this->post->airline, true);
Template::Set('allroutes', $routes);
}

		 Template::Show('schedule_results.tpl');
 }

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);
}

protected function create_line_graph($title, $data)
{
if(!$data)
{
$data = array();
}

$titles = array();
$bar_titles = array();
foreach($data as $val)
{
$titles[] = $val->ym;
$values[] = floatval($val->total);
}

OFCharts::add_data_set($titles, $values);
echo OFCharts::create_line_graph($title);
}
}

please need solution

error Fatal error: Call to undefined method SchedulesData::GetSchedulesWithCode() in/home/james/public_html/jetblue/core/modules/Schedules/Schedules.php on line 205

Link to comment
Share on other sites

You are trying to search using a deprecated function. I have it semi working, it gives the data, but it does not give the details of the flights. There is an easier way, there is a module that does this for you. So you do not need to go through this hassle.

Link to comment
Share on other sites

You are trying to search using a deprecated function. I have it semi working, it gives the data, but it does not give the details of the flights. There is an easier way, there is a module that does this for you. So you do not need to go through this hassle.

Module which one Link please?

Link to comment
Share on other sites

  • Moderators

You're missing the function in core/common. I would do it like this:

In core/common/OperationsData.class.php write the following before the last bracket closes:

public function GetSchedulesWithCode($code)
{
$sql = "SELECT * FROM phpvms_schedules WHERE code='$code'";
return DB::get_results($sql);
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...