Jump to content

Get Latest Pilots by Join Date (not ID)


Vidofnir

Recommended Posts

The latest pilots to join thing on the index is nice and dandy if you keep consecutive Pilot IDs. If you change the Pilot IDs on registration (say, for hub purposes) there is an unfortunate problem where it only shows the highest Pilot ID, which may not necessarily be the newest pilot. I whipped up a work-around that should benefit airlines that do this.

This simple change can be condensed even more, but I figured I would create a new Method just to keep things clean (and give me something to fall back on later).

Open core/common/PilotData.class.php

Add this snippet somewhere (perhaps after the getLatestPilots method, Line ~227)

public static function getLatestPilotsByJoinDate($count=10)
{
$sql = 'SELECT * FROM '.TABLE_PREFIX.'pilots
	ORDER BY `joindate` DESC
	LIMIT '.$count;

return DB::get_results($sql);
}

Save, Now open core/modules/Pilots/Pilots.php

Change:

$this->set('pilots', PilotData::GetLatestPilots($count));

To:

$this->set('pilots', PilotData::GetLatestPilotsByJoinDate($count));

Save, upload, be happy.

Alternatively, you can just change the existing SQL query under getLatestPilots to order by 'joindate' and leave it at that, but I preferred to make my own method just to not break things. Or something.

Link to comment
Share on other sites

Our airline changes your pilot code once you join, so the big pilot codes (I.E 1300+) are not used. Each hub has a specific set of numbers associated with it. If no one has a pending application, then the person with the highest code is always the "newest pilot" regardless of his actual join date.

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