Jump to content

Searching Schedules via Airline


AFVA | Mitchell

Recommended Posts

I'm in the same situation as Mitchell. On my website I offer my pilots several different airlines to choose from and have nearly a thousand flight plans between the different airlines they can choose from.

I would also like to know how to program into the "Search Schedules" feature another search option where my pilots can search specifically on the Airline. This would be a great help to my pilots and less time consuming.

You're help in this matter with the code to be added would be greatly appreciated.

Website:  http://westpalmairva.thewestieplace.com/

Thanks in advance.....

Link to comment
Share on other sites

The code I am working on at the moment:

	  <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

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

Trying to get all the airlines to display as an option.

Anyone know how to get all the airlines to display as an option??

Link to comment
Share on other sites

  • Administrators

To add a search, basically you modify this:

/core/modules/Schedules/Schedules.php, around line 166 is:

public function FindFlight()

There's a bunch of if statements looking at that search form.

So let's assume the field you added was name'd "airline", you'd add:

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

Basically you need the Template::Set('allroutes', ...); portion so the template has routes to display. The GetSchedulesWithCode will work with the latest beta.

But that's basically how you would build up that search.

You can add additional fields/search parameters that way too. The only thing would be is you might need to write some SQL.

Link to comment
Share on other sites

Got a small problem though:

The drop-down menu won't display the airlines.

The code in schedule_searchform.tpl

		
<div id="airline">
		<p>Select Airline:</p>
		<select id="airline" name="airline">
		<option value="">Select Airline</option>
	<?php

	if(!$airline) $airline = array();
    foreach($allairlines as $airline)
	{
		echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';
	}
	?>

    </select>
	<input type="submit" name="submit" value="Find Flights" />
  </div>

Schedules.php:

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);
    Template::Set('allroutes', $routes);
    }

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

I want to search using the airlines so that all the airlines appear in the drop down menu.

Thanks in advance,

Mitch

Link to comment
Share on other sites

schedules.php: FindFlight section

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);
   Template::Set('allroutes', $routes);
    }

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

schedule_searchform.tpl : Airline Search

<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>

Sorry for the long reply, internet has been down the last couple of days.

Link to comment
Share on other sites

  • Administrators

Ahh, there's an error with that query. I fixed it, but it'll be in the next commit.

Open core/common/scheduledata.class.php

search for this line:

WHERE s.code''.$code.'' '.$enabled;

I think it's around line 242 though, it should be

WHERE s.code=''.$code.'' '.$enabled;

It's missing the = sign

Link to comment
Share on other sites

Hi

Tried to implement this. Foolwed all the code in this thread but got this error.

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

Any help appreciated

TJ

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...