natcret Posted January 13, 2016 Report Share Posted January 13, 2016 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 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 13, 2016 Moderators Report Share Posted January 13, 2016 You'll need to change the limit in the query results in your common file inside the function or implement pagination. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 13, 2016 Author Report Share Posted January 13, 2016 Common file....help me to understand... I have done pretty good in trying to learn without asking for too much help but I still am not totally sure where certain files are located. Which common file would you be refering to? Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 13, 2016 Moderators Report Share Posted January 13, 2016 Are you using a module for your fleet page or using the default? Quote Link to comment Share on other sites More sharing options...
natcret Posted January 13, 2016 Author Report Share Posted January 13, 2016 Using both but the length of the list seems to be coming from the default, or at least I think so. I also ran across this today. Anyway to shorten the number of pireps listed? http://flymirageva.org/phpvms/index.php/profile/view/5 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 13, 2016 Moderators Report Share Posted January 13, 2016 You need to make sure where it's getting data from. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 13, 2016 Author Report Share Posted January 13, 2016 In reference to the fleet list, coming from the default. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 15, 2016 Author Report Share Posted January 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted January 15, 2016 Moderators Report Share Posted January 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 16, 2016 Author Report Share Posted January 16, 2016 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? Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 16, 2016 Moderators Report Share Posted January 16, 2016 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 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted January 16, 2016 Moderators Report Share Posted January 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 16, 2016 Moderators Report Share Posted January 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 16, 2016 Author Report Share Posted January 16, 2016 The new code by Servetas worked perfectly! My sincere thanks to both of you for taking the time to look at this. I also learned some new stuff too! Regards, Nat Quote Link to comment Share on other sites More sharing options...
natcret Posted January 16, 2016 Author Report Share Posted January 16, 2016 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 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted January 16, 2016 Moderators Report Share Posted January 16, 2016 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); Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 16, 2016 Moderators Report Share Posted January 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
natcret Posted January 16, 2016 Author Report Share Posted January 16, 2016 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? Quote Link to comment Share on other sites More sharing options...
natcret Posted January 18, 2016 Author Report Share Posted January 18, 2016 Will test and see result Quote Link to comment Share on other sites More sharing options...
natcret Posted January 20, 2016 Author Report Share Posted January 20, 2016 Sorry it took so long to test. Everything works well. So to clarify the two updates per Servetas' code above makes updates to the profile.php and PIREPData.class.php files. Thank you both again for all of your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.