Jump to content

Multi-Input Schedule Search


AFVA | Mitchell

Recommended Posts

I am currently working on a passenger flight booking feature.

How can I make a search which has a function to search by both departure and arrival airports, and not just one like the one in schedule search.

Pages(under construction):

Search: http://www.vhmrw.site90.com/index.php/booking

Results of Search: http://www.vhmrw.site90.com/index.php/booking/results

Confirmation: http://www.vhmrw.site90.com/index.php/booking/confirm

Also I need to know how to send values (like the amount of adults/children) a user added to the confirm and results page.

Thanks,

Mitchell Williamson

Link to comment
Share on other sites

  • Administrators

For the adult/children, that can be passed to the next page, and you can do some random logic with the price.

For the day of arrival/departure, you have to determine what day of week it is, and search by that, and then arrival/departure.

But thanks for reminding me, I was starting to write a multi-search function, which would search on whatever parameters you pass to it:

<?php
// Returns KJFK flights on sundays
$data = array('arricao'=>'KJFK', 'dayofweek'=>0);
$results = SchedulesData::getMultiSearch($data);

// return VMS flights from KJFK, departing during 18:00-59 hours (% is SQL wildcard)
$data = array('depicao'=>'KJFK', 'code'=>'VMS', 'deptime'=>'18:%');
$results = SchedulesData::getMultiSearch($data);

This would facilitate any custom searches or modules which want to return specific data, and you can pass in any column to search on which is in that table.

I added a ticket for it:

http://bugs.phpvms.net/ticket/110

I will probably write a similar function for PIREPS.

Link to comment
Share on other sites

How can I exactly implement the code?

booking_form.tpl(yes thats 175 lines):

<h1>Book a Flight</h1>
<form name="booking_search" id="booking_search" action="<?php echo SITE_URL?>/index.php/booking/search">
<br>
<table>
<thead>
<th><p><b>Departing From: </b></p></th><th><p><b>Arriving At:</b></p></th>
<thead>
<tbody>
<td>
<select id="depicao" name="depicao">
<option value="">--ORIGIN</option>
<?php
if(!$depairports) $depairports = array();
foreach($depairports as $airport)
{
echo '<option value="'.$airport->icao.'">'.$airport->icao
.' ('.$airport->name.')</option>';
}
?>
</select>
</td>
<td>
	<select id="arricao" name="arricao">
		<option value="">--DESTINATION</option>
	<?php
	if(!$depairports) $depairports = array();
		foreach($depairports as $airport)
		{
			echo '<option value="'.$airport->icao.'">'.$airport->icao
					.' ('.$airport->name.')</option>';
		}
	?>

	</select>
	</td>
	</thead>
	</table>
	<hr>
	<table border="1">
	<thead>
	<th><b>Adults (13+)</b></th><th><b>Children (2-12)</b></th><th><b><b><a href="#" onclick="showhide('policy'); return(false);">Under 2 Policy</a></b></th>
	</thead>
	<tbody>
	<td>
	<center>
	<select id="adults" name="adults">
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	<option value="5">5</option>
	<option value="6">6</option>
	<option value="7">7</option>
	<option value="8">8</option>
	</select>
	</center>
	</td>
	<td>
	<center>
	<select name="children" id="children">
    <option value="0">0</option>
	<option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    </select>
    </center>
    </td>
    <td>
    <div style="display: none;" id="policy">
    <p>When flying on our airline with a baby under the age of two, we ask you bring a Baby Car Seat.<br>
	Please Contact Booking Staff at admin@vhmrw.site90.com for Further Information.
	</p>
    </div>
    </td>
    </tbody>
    </table>
	<hr>
	<table>
	<thead>
	<th><p><b>Departure Date:</b></p></th><th><p><b>Arrival Date(Only If Return Flight):</b></p></th>
	</thead>
	<tbody>
	<td>
	<select id="depmonth" name="depmonth">
	<option value="dec09">December 2009</option>
	<option value="jan10">January 2010</option>
	<option value="feb10">Febuary 2010</option>
	<option value="mar10">March 2010</option>
	</select>
	<select id="depday" name="depday">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
  </select>
  		</td>
			<td>
	<select id="arrmonth" name="arrmonth">
	<option value="dec09">December 2009</option>
	<option value="jan10">January 2010</option>
	<option value="feb10">Febuary 2010</option>
	<option value="mar10">March 2010</option>
	</select>
	<select id="arrday" name="arrday">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
  </select>
  </td>
	</tbody>
	</table>
	<hr>
	<input type="submit" name="submit" value="GO!">

	</form>

Booking.php:

<?php

class Booking extends CodonModule

{

	public function index()
	{
	$depapts = OperationsData::GetAllAirports();

	Template::Set('depairports', $depapts);
	Template::Show('booking_form.tpl');

	}
	public function search()
	{

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

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


	Template::Set('allresults', $schedules);
	Template::Show('booking_results.tpl');

	}
	public function results()
	{
	                       
	Template::Set('allresults', $schedules);
	Template::Show('booking_results.tpl');

	}
	public function confirm()
	{

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

	}

}

?>

When I search it gives me this error:

Warning: Invalid argument supplied for foreach() in /home/a5059087/public_html/core/templates/booking_results.tpl on line 13

Can anyone help me?

Link to comment
Share on other sites

  • Administrators

Hey

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

Should be:

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

No need to assign them to arrays. And putting variables in single quotes doesn't parse the variable, it will literally put $value

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