Jump to content

Quick fix: Sort schedules by departure time


mischka

Recommended Posts

Hello

It has annoyed me for some time now that the schedule search results (in this add-on and the standard schedule find) is not sorted by departure time. Showing the schedules by deptime is important, because a pilot has a better overview of which flights depart in the near future.

Setting the relevant option in the local config doesnt help because the deptime field is actually a varchar, so sorting on that is a no-no. Hence I did some googling and found a neat way to convert the varchar to an actual time.

Here is the relevant pieces of code to be changed in /core/common/Frontschedulesdata.class.php, and to save you all a game of "seek the differences", the changed parts are marked bold:

public function findschedules($arricao, $depicao, $airline, $aircraft) {

$query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration, time(str_to_date(deptime,'%H:%i')) newdeptime

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.aircraft LIKE '$aircraft'

AND phpvms_aircraft.id LIKE '$aircraft'

ORDER BY newdeptime";

return DB::get_results($query);

}

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

$query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration, time(str_to_date(deptime,'%H:%i')) newdeptime

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_aircraft.id LIKE phpvms_schedules.aircraft ORDER BY newdeptime";

return DB::get_results($query);

}

Maybe this can be integrated in the product, or else somebody will find it here and my nocturnal toiling is not just for my own benefit :)

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