Jump to content

Search schedules by time


Tato123

Recommended Posts

Hello,

I'm trying to do a search for bands of time using the form Frontschedules.

In the airport search.tpl I entered this search option:

	  <tr>
	    <td>Orario</td>
	    <td>
		    <select class="search" name="deptime">
			    <option value="">All</option>
 <option value="00:01|08:00">00.01/08.00</option>
 <option value="08:01|16:00">08.01/16.00</option>
 <option value="16:01|24:00">16.01/24.00</option>
		    </select>
	    </td>
    </tr>

In the FrontSchedules.php:

    public function findflight()
{
 $arricao = DB::escape($this->post->arricao);
		    $depicao = DB::escape($this->post->depicao);
		    $airline = DB::escape($this->post->airline);
		    $aircraft = DB::escape($this->post->aircraft);
    $deptime = DB::escape ($this->post->deptime);
			  if(!$airline)
			    {
				    $airline = '%';
			    }
		    if(!$arricao)
			    {
				    $arricao = '%';
			    }
		    if(!$depicao)
			    {
				    $depicao = '%';
			    }
		    if($aircraft == !'')
		    {
			    $aircrafts = FrontSchedulesData::findaircraft($aircraft);
			    foreach($aircrafts as $aircraft)
			    {
				    $route = FrontSchedulesData::findschedules($arricao, $depicao, $airline, $aircraft->id);
				    if(!$route){$route=array();}
				    if(!$routes){$routes=array();}
				    $routes = array_merge($routes, $route);
			    }
		    }
		    else
		    {
		    $routes = FrontSchedulesData::findschedule($arricao, $depicao, $airline, $deptime);
		    }
 $this->set('allroutes', $routes);
 $this->show('schedule_results.tpl');

}

and inFrontSchedulesData Class:

 public function findschedule($arricao, $depicao, $airline, $deptime)   {
    $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration
		    FROM phpvms_schedules, phpvms_aircraft
		    WHERE phpvms_schedules.depicao LIKE '$depicao'
		    AND phpvms_schedules.arricao LIKE '$arricao'
   AND phpvms_schedules.deptime LIKE '$deptime'
		    AND phpvms_schedules.code LIKE '$airline'
		    AND phpvms_aircraft.id LIKE phpvms_schedules.aircraft";
    return DB::get_results($query);
   }

How is possible changing the query for search the time from the option value?

If i try with option valure ="8.25" i find all the flight at this time.

I won't search the range.

Thanks

Link to comment
Share on other sites

  • 4 weeks later...

in search request page:

date_default_timezone_set("UTC");

$casodletu= date("H:i:s", time());

<td>Select Departure time:</td>

<td>

<select class="search" name="deptime">

<?php

{echo '<option value="'.$casodletu.' selected">Upcoming</option>';}

{echo '<option value="">All</option>';}

?>

</select>

</td>

in FrontSchedulesData class

insert in function findschedule

public function findschedule($arricao, $depicao, $airline, $deptime) {

$query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration

FROM phpvms_schedules, phpvms_aircraft

WHERE phpvms_schedules.depicao LIKE '$depicao'

AND phpvms_schedules.arricao LIKE '$arricao'

AND phpvms_schedules.code LIKE '$airline'

AND phpvms_schedules.deptime > '$deptime'

.....

this will show for you departure after current GMT time.

Other (your modification of FrontSchedules.php is good).

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