Jump to content

Fleet View Page Question


natcret

Recommended Posts

Can't seem to find the answer for this one.

On the Fleet Page (fleet_list.php) when you select an aircraft it then takes you to the Fleet View page (fleet_view.php). So when I view the particular aircraft, everything is fine, except that the number of rows under Schedule Flights is getting very long for specific aircraft. So, my question is: How do you limit the number of "Scheduled Flights" that are displayed on the Fleet View page?

Currently, I have pages that are getting very long, so I have basically commented out the code in fleet_view.php file (about line 73) until I can figure this out. It is probably something easy to fix, but I can't find any reference in the forums.

http://flymirageva.org/phpvms/index.php/fleet/view/9

Regards

Link to comment
Share on other sites

I apologize, I think I may have misunderstood and caused even more confusion. I went back and checked.

I have both Advanced Fleet and vFleetTracker installed but my initial question is related to the Advanced Fleet module and how do you limit the amount of scheduled aircraft shown: http://flymirageva.org/phpvms/index.php/fleet/view/9

My other question is related to the default public pilot profile and how to shorten the number of pireps listed on a page. Example link below: http://flymirageva.org/phpvms/index.php/profile/view/5

Again, I am sorry for the confusion.

Link to comment
Share on other sites

  • Moderators

For the schedules limit of your aircraft page open your core/common/FleetData.class.php file, find this:

$sql = 'SELECT * FROM '.TABLE_PREFIX.'schedules WHERE aircraft='.$id.'';

and replace it with this:

$sql = 'SELECT * FROM '.TABLE_PREFIX.'schedules WHERE aircraft='.$id.' LIMIT 10';

You can replace number '10' with the number of schedules you wish to show. As for the pireps, open your Profile.php file and find this:

$this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));

replace it with this:

$this->set('pireps', PIREPData::getLastReports($pilotid, 10));

Again, you can replace number '10' with the number of PIREPs you wish to show on your pilot's page. I hope they'll work for you.

Link to comment
Share on other sites

Thank you so very much! The schedules limit code change worked as advertised. Unfortunately, I am still having problems with the pirep item. Under the Profile.php, I find this statement:

$this->set('allfields', PilotData::getFieldData($pilotid, false));
	 $pirep_list = PIREPData::getAllReportsForPilot($pilotid);
	 $this->set('pireps', $pirep_list);
	 $this->set('pirep_list', $pirep_list);

So when I replaced:

$pirep_list = PIREPData::getAllReportsForPilot($pilotid);

With what you had above:

$this->set('pireps', PIREPData::getLastReports($pilotid, 10));

I get "no reports to be found". I know that can't be correct because this particular pilot flies at least 3-5 small flights a day. I then changed the code back to the original line.

Below is the original code for that section and I am using the phpvms 5.5.2:

public function view($pilotid='')
{
	 #replacement for OFC charts - Google Charts API - simpilot
	 $this->set('chart_url', ChartsData::build_pireptable($pilotid, 30));
	 #end
	 $pilotid = PilotData::parsePilotID($pilotid);
	 $pilot = PilotData::getPilotData($pilotid);
	 $this->title = 'Profile of '.$pilot->firstname.' '.$pilot->lastname;
	 $this->set('userinfo', $pilot);
	 $this->set('pilot', $pilot);
	 $this->set('allfields', PilotData::getFieldData($pilotid, false));
	 $pirep_list = PIREPData::getAllReportsForPilot($pilotid);
	 $this->set('pireps', $pirep_list);
	 $this->set('pirep_list', $pirep_list);
$this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10'));
	 $this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
	 $this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
	 $this->render('pilot_public_profile.php');
	 $this->render('pireps_viewall.php');
}

Thoughts?

Link to comment
Share on other sites

  • Moderators

The reason is that the function you're using to get 10 items is not actually fetching data since it's not set to do so. Open PIREPData.class.php in common folder and look for the following:

public static function getAllReportsForPilot($pilotid) {
    return self::findPIREPS(array('p.pilotid' => $pilotid));
   }

And change it to:

public static function getAllReportsForPilot($pilotid) {
    return self::findPIREPS(array('p.pilotid' => $pilotid), 10);
   }

I haven't tested this so I wouldn't know if it's working.

Cheers

Link to comment
Share on other sites

  • Moderators

As soon as you send me the whole view function, you can replace it with this part of code:

public function view($pilotid='')
{
			 #replacement for OFC charts - Google Charts API - simpilot
			 $this->set('chart_url', ChartsData::build_pireptable($pilotid, 30));
			 #end
			 $pilotid = PilotData::parsePilotID($pilotid);
			 $pilot = PilotData::getPilotData($pilotid);
			 $this->title = 'Profile of '.$pilot->firstname.' '.$pilot->lastname;
			 $this->set('userinfo', $pilot);
			 $this->set('pilot', $pilot);
			 $this->set('allfields', PilotData::getFieldData($pilotid, false));
			 $this->set('pirep_list', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10'));
			 $this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
			 $this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
			 $this->render('pilot_public_profile.php');
			 $this->render('pireps_viewall.php');
}

You can replace number '10' with the number you wish. @parkho, the reason why I did not suggest the update of the "getAllReportsForPilot" function on the PIREPSData.class.php file is because this function is used on the pilot's profiles in the admin center. If he do this, he will not be able to view all the pilot's PIREPs through each ones profile in the admin center. "GetLastReports" function already exists in the PIREPData.class.php file and I have never seen it used in any part of the phpVMS.

Link to comment
Share on other sites

  • Moderators

As soon as you send me the whole view function, you can replace it with this part of code:

public function view($pilotid='')
{
			 #replacement for OFC charts - Google Charts API - simpilot
			 $this->set('chart_url', ChartsData::build_pireptable($pilotid, 30));
			 #end
			 $pilotid = PilotData::parsePilotID($pilotid);
			 $pilot = PilotData::getPilotData($pilotid);
			 $this->title = 'Profile of '.$pilot->firstname.' '.$pilot->lastname;
			 $this->set('userinfo', $pilot);
			 $this->set('pilot', $pilot);
			 $this->set('allfields', PilotData::getFieldData($pilotid, false));
			 $this->set('pirep_list', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10'));
			 $this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
			 $this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
			 $this->render('pilot_public_profile.php');
			 $this->render('pireps_viewall.php');
}

You can replace number '10' with the number you wish. @parkho, the reason why I did not suggest the update of the "getAllReportsForPilot" function on the PIREPSData.class.php file is because this function is used on the pilot's profiles in the admin center. If he do this, he will not be able to view all the pilot's PIREPs through each ones profile in the admin center. "GetLastReports" function already exists in the PIREPData.class.php file and I have never seen it used in any part of the phpVMS.

That's right and thanks for pointing that out. In fact, I wouldn't suggest modifying any default functions since they are used in different sections. Instead, I would suggest creating a class with a specific function to fetch what's needed. ;)

Link to comment
Share on other sites

  • Moderators

Open your core/common/PIREPData.class.php file and replace this:

public static function getLastReports($pilotid, $count = 1, $status='')
{
 $sql = 'SELECT * FROM '.TABLE_PREFIX.'pireps AS p
 WHERE pilotid='.intval($pilotid);

with this:

public static function getLastReports($pilotid, $count = 1, $status='')
{
 $sql = 'SELECT p.*, UNIX_TIMESTAMP(p.submitdate) as submitdate,
 a.id AS aircraftid, a.name as aircraft, a.registration FROM '.TABLE_PREFIX.'pireps AS p
 LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft
 WHERE p.pilotid='.intval($pilotid);

Link to comment
Share on other sites

  • Moderators

I spoke to soon, Another Issue:

TOR114 CYYT KCVG 9 () 04.29 12/31/1969

Notice the 9 () and the date. The 9() is replacing all aircraft under the Aircraft field and the Submitted for all aircraft is showing the 12/31/1969. Something in the new code?

Regards,

Nat

Is this corrected when you roll back to what it was? If yes then the new code causes the issue if not look at you DB table and see what data you have there.

Link to comment
Share on other sites

Is this corrected when you roll back to what it was? If yes then the new code causes the issue if not look at you DB table and see what data you have there.

When I roll back to the original code prior to Servetas' fix, all is ok. So to make sure I understand, do you want me to put his code back in along with your update, or just your update with original code?

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