Administrators simpilot Posted October 22, 2010 Author Administrators Report Share Posted October 22, 2010 I have noticed this addon isn't pulling the stats any longer...Any ideas...The landing stats aren't updating. Things seem to be working on my site, is it not showing any, or just the latest? Quote Link to comment Share on other sites More sharing options...
Fly Star Alliance Posted November 6, 2010 Report Share Posted November 6, 2010 Nevermind !! Forgive me.. I'm such an idiot..... Quote Link to comment Share on other sites More sharing options...
RogerB Posted November 12, 2010 Report Share Posted November 12, 2010 I had a super great landing in one of my aircraft don't remember which now and the system didn't update it. UPdate: Ok I found it. I had a landing in my B103 of-23 and it doesn't appear in the stats at all for that aircraft. and of course its the top landing for it. THE ONLY DIFFERENCE IS I USED "FSX" FOR THE FIRST TIME Quote Link to comment Share on other sites More sharing options...
Daniel Posted November 20, 2010 Report Share Posted November 20, 2010 mine is not working for some reason? Any ideas? thanks http://www.pashairvirtual.co.uk/index.php/TouchdownStats/top_landings/20 any then look at this Pirep http://www.pashairvirtual.co.uk/index.php/pireps/viewreport/27 It has been accepted and i don't know why it is not appearing? thank you very much in advance Daniel Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted November 20, 2010 Moderators Report Share Posted November 20, 2010 Some how you have landed with a + rate not a - rate, this happens sometimes,if you look at the pirep its at 15fpm not -15fpm if you get what i mean, just go in to the database and edit that field to a -15 and it should show up Quote Link to comment Share on other sites More sharing options...
Daniel Posted November 23, 2010 Report Share Posted November 23, 2010 ahh ok thanks mark Quote Link to comment Share on other sites More sharing options...
Mysterious Pilot Posted December 9, 2010 Report Share Posted December 9, 2010 @SimPilot: I was getting an error in your default installation that said it was the wrong argument in foreach, exactly the line where you iterate through statistical records returned by the data layer. I have no PIREPs filed in my system as I want to iron out all system quirks before doing PR. I found a slight oversight in your code that could be fixed by changing that PHP code in touchdownstats_index.tpl as follows: <?php if ($stats === NULL) { echo '<tr><td colspan="5">No PIREPS match search criteria</td></tr>'; } else { foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); $aircraft = OperationsData::getAircraftInfo($stat->aircraft); echo '<tr>'; echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>'; echo '<td>'.$aircraft->fullname.'</td>'; echo '<td>'.$stat->arricao.'</td>'; echo '<td>'.$stat->landingrate.'</td>'; echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>'; echo '</tr>'; } } ?> It is always good to check for NULLs ;-) Also decided to add this to the table code above that script as follows: <table ....> <caption>Touchdown Statistics</caption> : </table> Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted December 9, 2010 Author Administrators Report Share Posted December 9, 2010 How can you iron out kinks in a statistical function when there are no stats (or pireps in this case) to examine? The module was not designed to work on a vs site with no pireps. As far as adding a caption, I try to leave template files as bland and generic as possible at this point to make it as easy as I can for members to integrate the module into their own skin. Quote Link to comment Share on other sites More sharing options...
flyalaska Posted December 14, 2010 Report Share Posted December 14, 2010 Is there a way to display the pilots top 25 greased landings? Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted December 15, 2010 Author Administrators Report Share Posted December 15, 2010 Is there a way to display the pilots top 25 greased landings? I created a data call for vACA for individual pilot stats in my touchdownstatsData.php file like this -> public function get_pilot_landingstats($pilot, $howmany) { $query = "SELECT * FROM phpvms_pireps WHERE landingrate <'0' AND pilotid = '$pilot' ORDER BY landingrate DESC LIMIT $howmany;"; return DB::get_results($query); } Then in your module you can set the variable using something like -> $this->set('stats' = TouchdownstatsData::get_pilot_landingstats($pilotid, 5); You will just need to load the $pilotid ahead of it to call the pilot you are looking for, and the '5' is how many records you want returned in the array. Quote Link to comment Share on other sites More sharing options...
MrAmsterdam Posted January 5, 2011 Report Share Posted January 5, 2011 Add this to TouchdownstatsData -> public function pilot_stats($pilotid) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC"; return DB::get_results($query); } public function pilot_average($pilotid) { $stats = self::pilot_stats($pilotid); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } public function airline_average() { $stats = self::get_all_stats(); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } Then where you want to show a pilots average do -> <?php echo 'Pilot average landing rate '.TouchdownStatsData::pilot_average('pilot#'); ?> and replace pilot# with the database id for the pilot you want to show the stat for - ie in pilot_public_profile it would be $userinfo->pilotid or for the VA's average -> <?php echo 'VA average landing rate '.TouchdownStatsData::airline_average(); ?> Hey Simpilot, I was wondering if it's possible to show the average landingrate for the year 2010 and for this year, 2011 ? All the best wishes by the way!! Regards Lucas Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted January 7, 2011 Author Administrators Report Share Posted January 7, 2011 Hey Simpilot, I was wondering if it's possible to show the average landingrate for the year 2010 and for this year, 2011 ? All the best wishes by the way!! Regards Lucas You can follow the structure you quoted above and just change the call to the database to collect only records from the year you want and the loop thorugh and average them. The native cache function probably should be used if the va has a substantial number of pireps, if not it will slow things down everytime someone views that page for the server to recalculate the stat. WHERE YEAR(submitdate) = '2010' Quote Link to comment Share on other sites More sharing options...
MrAmsterdam Posted January 11, 2011 Report Share Posted January 11, 2011 You can follow the structure you quoted above and just change the call to the database to collect only records from the year you want and the loop thorugh and average them. The native cache function probably should be used if the va has a substantial number of pireps, if not it will slow things down everytime someone views that page for the server to recalculate the stat. WHERE YEAR(submitdate) = '2010' Aren't you getting tired of being right all the time ;-) hahahaha Thanks! Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted January 30, 2011 Moderators Report Share Posted January 30, 2011 Im being really lazy here but could someone tell me how to get the variable $pilotid loaded, ps im in the profile main tpl. <li><strong><?php echo 'Your Average Landing Rate: '.round(TouchdownStatsData::pilot_average($pilotid), 2); ?></strong></li> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted January 30, 2011 Moderators Report Share Posted January 30, 2011 No worries i have the variable <li><strong><?php echo 'Your Average Landing Rate: '.round(TouchdownStatsData::pilot_average($userinfo->pilotid), 2); ?></strong></li> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted February 3, 2011 Moderators Report Share Posted February 3, 2011 Dave, I have been trying to get this to display on the top pilot page for hours now, i just cant seem to get it. <h3>Top 10 Landings for <?php echo date("F Y");?></h3> <table width="700" border="1" cellspacing="1" cellpadding="1"> <tr> <th>Pilot</th> <th>Aircraft</th> <th>Arrival Field</th> <th>Landing Rate</th> <th>Date Flown</th> </tr> <?php foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); $aircraft = OperationsData::getAircraftInfo($stat->aircraft); echo '<tr>'; echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>'; echo '<td align="center">'.$aircraft->fullname.'</td>'; echo '<td align="center">'.$stat->arricao.'</td>'; echo '<td align="center">'.$stat->landingrate.'</td>'; echo '<td align="center">'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>'; echo '</tr>'; } ?> </table> I have added a new call to the module TouchdownStats.php, } public function top_landing_this_month () { $this->set('stats', TouchdownStatsData::get_stats_by_cur_month()); $this->show('touchdownstats/touchdownstats_index.tpl'); And also a new sql query to the TouchdownStatsData.class.php //added By Mark Grant 03-02-2011 public function get_stats_by_cur_month () { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate)=MONTH(now()) AND YEAR(submitdate)=YEAR(now()) ORDER BY landingrate DESC LIMIT 10"; return DB::get_results($query); } Everything works fine when i use the url to call, http://www.easyjetva.com/index.php/TouchdownStats/top_landing_this_month but when i add that code to the tp_index.php i keep getting Invalid argument supplied for foreach(), i have tried renaming the variables but i cant seem to get it, any help would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted February 4, 2011 Author Administrators Report Share Posted February 4, 2011 Mark There are a couple of ways, the easiest may be to put this in your tp_index.tpl page where you want the table to display; <?php MainController::Run('TopPilot', 'top_landing_this_month '); ?> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted February 4, 2011 Moderators Report Share Posted February 4, 2011 Dave, Its not showing and im not getting any errors in the logs either Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted February 4, 2011 Author Administrators Report Share Posted February 4, 2011 doh! try changing TopPilot to TouchdownStats........ Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted February 4, 2011 Moderators Report Share Posted February 4, 2011 Dont worry i got it Your light shon the way. Thanks, <?php MainController::Run('TouchdownStats', 'top_landing_this_month'); ?> Quote Link to comment Share on other sites More sharing options...
md82 Posted February 12, 2011 Report Share Posted February 12, 2011 Hey guys, I'm trying to install the average landing function, it works for pilots who have flights logged, but for pilots with no flights yet it shows this: Warning: Invalid argument supplied for foreach() in /home/flynryan/public_html/allegiantvirtual.com/core/common/TouchdownStatsData.class.php on line 30Warning: Division by zero in /home/flynryan/public_html/allegiantvirtual.com/core/common/TouchdownStatsData.class.php on line 35 Your Average Landing Rate: 0 my touchdown stats data class <?php//simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright © 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ class TouchdownStatsData extends CodonData { public function pilot_stats($pilotid) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC"; return DB::get_results($query); } public function pilot_average($pilotid) { $stats = self::pilot_stats($pilotid); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } public function airline_average() { $stats = self::get_all_stats(); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } public function get_all_stats() { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC"; return DB::get_results($query); } public function get_stats($howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC LIMIT $howmany"; return DB::get_results($query); } } any help appreciated Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted February 12, 2011 Moderators Report Share Posted February 12, 2011 Hi thats normal, just put this at the top of that tpl <?php error_reporting(0); ?> What the error saying is correct devision by zero as it has nothing to devide to make an average Quote Link to comment Share on other sites More sharing options...
md82 Posted February 12, 2011 Report Share Posted February 12, 2011 That done did it ! Thanks a lot ! Quote Link to comment Share on other sites More sharing options...
CPC900 Posted February 14, 2011 Report Share Posted February 14, 2011 Sorry, but how do I round to 2 decimal places again for: <?php echo 'VA average landing rate '.TouchdownStatsData::airline_average(); ?> Quote Link to comment Share on other sites More sharing options...
CPC900 Posted February 14, 2011 Report Share Posted February 14, 2011 <li><strong><?php echo 'Your Average Landing Rate: '.round(TouchdownStatsData::pilot_average($userinfo->pilotid), 2); ?></strong></li> That works fine, but I want the other to do the same!? <?php echo 'VA average landing rate '.TouchdownStatsData::airline_average(); ?> <li><strong><?php echo 'VA average landing rate: '.round(TouchdownStatsData::airline_average(), 2); ?></strong></li> That doesn't seem to work?! Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted February 15, 2011 Author Administrators Report Share Posted February 15, 2011 Your syntax looks correct Bruce. Is there any error showing at all? Quote Link to comment Share on other sites More sharing options...
CPC900 Posted February 15, 2011 Report Share Posted February 15, 2011 On second attempt it worked?! I don't know, must have missed something before Quote Link to comment Share on other sites More sharing options...
dimitris Posted March 1, 2011 Report Share Posted March 1, 2011 Hello all! I 'm making the new pilot_public_profile.tpl for my va and i would like to get the last 5 landings per pilot. So if i m looking at pilot 25 i would like to see the last 5 landings for this pilot. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted March 1, 2011 Moderators Report Share Posted March 1, 2011 Hello all! I 'm making the new pilot_public_profile.tpl for my va and i would like to get the last 5 landings per pilot. So if i m looking at pilot 25 i would like to see the last 5 landings for this pilot. Take a look here http://forum.phpvms.net/topic/2989-touchdownstats-10/page__view__findpost__p__29230 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted March 1, 2011 Report Share Posted March 1, 2011 Love this! Been looking for something like this for awhile. Just now ran into it. 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.