Jump to content

Recommended Posts

Posted

G'day,

How do I make searching schedules by airlines work?

What code do I need?

I know basic PHP and do not know much about advanced PHP. I will add it to schedule_searchform.tpl

Thanks,

Mitchell Williamson

Australian Frontier VA

Posted

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

Posted

Hi Mitchell;

I guess our problem is not that important. I tried to program it but like you I really do not know enough about PHP to get it to work.

Not sure where to go from here. If you get it working could you let me know and I if I can figure it out I will do the same.    :-

Bruce

Posted

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

  • Administrators
Posted

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.

Posted

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

  • Administrators
Posted

if(!$airline) $airline = array();
    foreach($allairlines as $airline)

Use:

$allairlines = OperationsData::GetAllAirlines(true);
    foreach($allairlines as $airline)

Posted

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.

  • Administrators
Posted

Try

$routes = SchedulesData::GetSchedulesWithCode($this->post->airline, true);

Also putting a DB::debug(); after it will show you what the query was. Try that too and post it here. Maybe there's an error

  • Administrators
Posted

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

Posted

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

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