Jump to content

Recommended Posts

Posted

Hello!

I am just wondering if somebody could tell me the code for the following options on the flight search (simpilot):

  • Flight times so show flights between 5 and 7 hours
  • Show flights on a particular day.

Thanks!

Jacob

Posted

I have tried getting schedules with a min/max flight time but the problem is that you'll need to edit the getSchedules function. Instead I recommend you create a new one. It's best to make a new class for it, create a new file in core/common and call it something along the lines of ScheduleSearch.class.php. This way, when you update, it won't get overwritten.

Anyway, you could do this for the flight time:

public function getSchedulesByDuration($min, $max){
$sql = "SELECT * FROM ".TABLE_PREFIX."_schedules"; WHERE flighttime >= '".$min."' AND flighttime <= '".$max."';
return DB::get_results($sql);
}

Obviously you'll need to pass the min and max values in when you use it. As for the day of week:

public function getSchedulesByDayofWeek($dayofweek){
$sql = "SELECT * FROM ".TABLE_PREFIX."_schedules"; WHERE daysofweek LIKE '".$dayofweek."';
return DB::get_results($sql);
}

Remember that the value passed into that one must be a number, you could use a CASE or IF statement to assign each number to a day for the user to enter.

Posted

$flights = ScheduleSearch::getSchedulesByDuration(5, 7);

foreach($flights as $flight){
do stuff here...
}

This is only if you want to specify the min/max. If you want the user to specify it, assign them to the field names in the form.

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