Jump to content

Multiple Airlines > Search by carrier


cloudsurferuk

Recommended Posts

Have been exploring adding search by Carrier option to the search form but struggling a bit to get it to work. Any got any suggestions for the code to add to the search form in order to search by airline code? i.e. pull out all flights for a specific airline (we have 14).

I know this may be getting ignored as a similair question came up and the anser was the realschedules module. However, all I want to do is add a list by carrier (code) option to the schedule search page so a drop down box shows all airline codes, and selcted will list all flights by that airline. Nabeel, you must have a quick solution for this surely? :lol::rolleyes:

Link to comment
Share on other sites

  • Administrators

Hey,

No quick solution, if you know PHP it's pretty quick. But if I have the time I willl add it for the next build

I'm thinking of replacing this with the way the schedules are handled in the admin side.

Link to comment
Share on other sites

Hey,

No quick solution, if you know PHP it's pretty quick. But if I have the time I willl add it for the next build

I'm thinking of replacing this with the way the schedules are handled in the admin side.

Yeah am ok in it, have been using this

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

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

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

No list of airline codes appears in drop down though, anything obvious?

Link to comment
Share on other sites

Guest lorathon

Try this

<div id="airlinetab">
               <p>Select by Airline:</p>
               <select id="code" name="code">
                       <option value="">Select Airline</option>
               <?php
               $airline = OperationsData::GetAllAirlines(true);  // This will get the list of enabled airlines
               if(!$airline) $airline = array();
               foreach($airline as $code)
               {
                       echo '<option value="'.$code->code.'">'.$code->name.'</option>';  // This will send the airline code from the form to whatever the form is sending the data to as $this->post->code
               }

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

What ever this form is being sent to you will need to add a check airline param for the schedule search such as below

$params['s.code'] = $this->post->code;

You can then pull the schedules with the following

$schedules = SchedulesData::findSchedules($params);

The above code will pull the schedules attached to the selected airline. It will pull all schedules even disabled. To remove disabled add the following with the first param.

$params['s.enabled'] = 1;

Tha params can be combined into the following

$params = array(
   's.code'    => $this->post->code,
   's.enabled' => '1'
   );

Look at the beginning of the SchedulesData.class.php and you will see all of the other params that can be shoved in to filter the schedule returns.

Link to comment
Share on other sites

Guest lorathon

Here is a better code.

I wrote this her without testing. But it should work. You will need to create a module or stick the module code into some other module and then change the form post address.

Seach Form

<form name="airlineSearch" id="airlineSearch" action="<?php echo SITE_URL?>/index.php/airlineSearch/search" method="post">
    <p>Select by Airline:</p>
         <select id="code" name="code">
             <option value="">Select Airline</option>
             <?php
               $airline = OperationsData::GetAllAirlines(true);  // This will get the list of enabled airlines
               if(!$airline) $airline = array();
               foreach($airline as $code)
               {
                       echo '<option value="'.$code->code.'">'.$code->name.'</option>';  // This will send the airline code from the form to whatever the form is sending the data to as $this->post->code
               }

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

AirlineSearch Module Code - Either a new module named airlineSearch or you can stick this function into another module but be sure to change the post action address

class airlineSearch extends CodonModule
{
public function search()

	{

		$params = array(
                           's.code'    => $this->post->code,
                           's.enabled' => '1'
                            );

		$schedules = SchedulesData::findSchedules($params);			

		Template::Set('results', $schedules);
		Template::Show('airlineSearchResults.tpl');			
	} 
}

airlineSeachResults.tpl - this template will be called and should be filled with a table displaying the schedules attached to the selected airline. Template should go into your skins folder.

<table>
 <tr>
   <th>Airline</th>
   <th>Flight #</th>    
   <th>Departure</th>
   <th>Arrival</th>
   <th>Duration</th>
   <th>Price</th>
   <th>Options</th>
 </tr>

<?php


if (!$results)
     { ?> 
	<tr><td>No Routes Found!</td></tr>
<?php }
else
   { ?>
	<?php foreach($results as $result) 
	{ 
	?>

<tr>
   <td><?php echo $result->code;?></td>        
          <td><?php echo $result->code.$result->flightnum;?></td>
          <td><?php echo $result->depicao;?></td>
          <td><?php echo $result->arricao;?></td>
     	   <td><?php echo $result->flighttime;?></td>
     	   <td><?php echo $result->price; ?><</td>
   <td><a id="<?php echo $result->id; ?>" class="addbid" href="<?php echo SITE_URL?>.php/Schedules/addbid/">Add to Bid</a></td>  		
      </tr>
<?php           }
   } ?>

</table>      

If you get errors post them and I will help you out

Link to comment
Share on other sites

Works like a charm, top man! Have made changes to airlineSearchResults.tpl though which make it display better, and more like standard search results.

<table>
 <tr>
   <th>Airline</th>
   <th>Flight #</th>    
   <th>Departure</th>
   <th>Departure Time</th>
   <th>Arrival</th>
   <th>Arrival Time</th>
   <th>Distance</th>
   <th>Aircraft</th>
   <th>Options</th>
 </tr>

<?php


if (!$results)
     { ?> 
               <tr><td>No Routes Found!</td></tr>
<?php }
else
   { ?>
               <?php foreach($results as $result) 
               { 
               ?>

       <tr>
          <td><?php echo $result->code;?></td>        
          <td><?php echo $result->code.$result->flightnum;?></td>
          <td><?php echo $result->depicao;?></td>
          <td><?php echo $result->deptime;?></td>
          <td><?php echo $result->arricao;?></td>
          <td><?php echo $result->arrtime;?></td>
          <td><?php echo $result->distance;?></td>
          <td><?php echo $result->aircraft;?> (<?php echo $result->registration;?>)</td>
          <td><a id="<?php echo $result->id; ?>" class="addbid" href="<?php echo SITE_URL?>.php/Schedules/addbid/">Add to Bid</a></td>                 
      </tr>
<?php           }
   } ?>

</table>  

Link to comment
Share on other sites

  • 8 months later...

Just a quick question:

Where do I place the airlineSearch Module? I have made a new folder /core/modules/airlinesearch and placed the airlineSearch.php inside the folder, but still getting this message:

An Error Was Encountered

The module "AIRLINESEARCH" doesn't exist!

Any help is appreciated

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