Jump to content

How to... (schedules)


skymx

Recommended Posts

How can I limit the amount of flight plans (schedules) listed when searching for flight plans?

before I added schedules to my site that was NOT a problem, had only a few of them... BUT!

Now I have added more than 1,300 schedules and the list is just Too BIG!!!

I would like to list in chuncks of 25 for example, or 12, maybe 15 in a page format at a time, not all of them.

Is it posible in phpvms to do this, and where is the config file to do it?

local.config or app.config? have been searching them,

but can´t find any reference to accomplish this.

Link to comment
Share on other sites

Guest lorathon

Hi Nabeel,

I looked in the core/modules/schedules/schedules.php file and I didn't see anything that jumped out at me. Could you provide any clues what to look for? cool.gif

If you look in the SchedulesData.class.php you will see the call to find schedules. you can limit there

public static function findSchedules($params, $count = '', $start = '')
{
	$sql = 'SELECT s.*, 
				a.id as aircraftid, a.name as aircraft, a.registration,
				a.minrank as aircraft_minrank, a.ranklevel as aircraftlevel,
				dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
				arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng
			FROM '.TABLE_PREFIX.'schedules AS s
			LEFT JOIN '.TABLE_PREFIX.'airports AS dep ON dep.icao = s.depicao
			LEFT JOIN '.TABLE_PREFIX.'airports AS arr ON arr.icao = s.arricao
			LEFT JOIN '.TABLE_PREFIX.'aircraft AS a ON a.id = s.aircraft ';

Sample

               $params['s.enabled'] = 1;
               $count = 1000;
	$start = 0;
	$schedules = SchedulesData::findSchedules($params, $count, $start);

The above will return the first 1000 enabled schedules starting at schedule 0 into the the array $schedules.

If you look in the SchedulesData.class.php you can find the other params you can stick in there to limit or choose even further.


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

The above will take the post data from a form and depicao (Departing ICAO airport) and limit the selection by schedules that depart from the above ICAO that are enabled.

Link to comment
Share on other sites

Guest lorathon

I should have added this.

If you change the $start you can use it for pagnation. (I have never tried this but it should work)

               $params['s.enabled'] = 1;
               $count = 25;
               $start = 0;
               $schedules = SchedulesData::findSchedules($params, $count, $start);

The above should give you enabled schedules 0-24

               $params['s.enabled'] = 1;
               $count = 25;
               $start = 25;
               $schedules = SchedulesData::findSchedules($params, $count, $start);

The above should give you enabled schedules 25-49

So if you code it right you should be able to use the above for you own customized pagnation. You can do this with the PIREPS also.

This is from the PIREPData.class.php

public static function findPIREPS($params,  $count = '', $start = '')
{
	$sql = 'SELECT p.*, UNIX_TIMESTAMP(p.submitdate) as submitdate, 
				u.pilotid, u.firstname, u.lastname, u.email, u.rank,
				a.id AS aircraftid, a.name as aircraft, a.registration,
				dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
				arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng						
			FROM '.TABLE_PREFIX.'pireps p
			LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft
			LEFT JOIN '.TABLE_PREFIX.'airports AS dep ON dep.icao = p.depicao
			LEFT JOIN '.TABLE_PREFIX.'airports AS arr ON arr.icao = p.arricao 
			LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid ';

As you can see it has the same variables available. $count (Number of PIREPS to return) $start (Start point of the return)

Link to comment
Share on other sites

I will also be looking into adding the admin-style pagination for PIREPS in several places (the other pagination thread)

Edit NVM, I see you posted there already :)

Thanks a lot, I will check that,

it would be a nice addition to phpvms to have pagination for all those large lists!

Link to comment
Share on other sites

  • 5 months later...

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