fsx Posted June 17, 2011 Report Posted June 17, 2011 Hi, This problem is because you don't have flights. Kind Regards. i have flight with pirep accept, but the situation not change maybe the table will only work with the new flights in pending ? I feel Quote
Administrators simpilot Posted June 19, 2011 Author Administrators Report Posted June 19, 2011 @fsx, does the db table have anything in the landing rate column? Quote
fsx Posted June 20, 2011 Report Posted June 20, 2011 @fsx, does the db table have anything in the landing rate column? Hello Simpilot, I am the person who commissioned the work redesign (tcaf) As you can see I have canceled flights and pirep, but if you need a flight and I can show you the result Quote
Angel Air Posted August 1, 2011 Report Posted August 1, 2011 Hi all, Keep getting this error all uploaded to correct files not sure what to do any help will be appreciated I am using kACARS so I know the landing rate is there. here is the error Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\lib\skins\detachable\frontpage_main.tpl on line 33 I can link to the landing rates when I use http://www.angelairva.co.uk/index.php/Touchdownstats But I just can not get it to show on the Frontpage. here is the code I am putting on my Frontpage.TPL <?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 (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ ?> <table width="100%" border="1px"> <tr> <td>Pilot</td> <td>Aircraft</td> <td>Arrival Field</td> <td>Landing Rate</td> <td>Date Posted</td> </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>'.$aircraft->fullname.'</td>'; echo '<td>'.$stat->arricao.'</td>'; echo '<td>'.$stat->landingrate.'</td>'; echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>'; echo '</tr>'; } ?> </table></p> Thanks in advance Scott Quote
Administrators simpilot Posted August 1, 2011 Author Administrators Report Posted August 1, 2011 How are you including it on your frontpage? something like <?php MainController::run('touchdownstats', 'index'); ?> should be all you need if the data is there. Quote
Angel Air Posted August 1, 2011 Report Posted August 1, 2011 How are you including it on your frontpage? something like <?php MainController::run('touchdownstats', 'index'); ?> should be all you need if the data is there. Damn that was quick Dave!!! Will give it a try Thanks again Scott Quote
Angel Air Posted August 2, 2011 Report Posted August 2, 2011 That did work dave but I was hoping to have it in a table and only show the 5 most recent see 3 posts up Thanks Scott Quote
Administrators simpilot Posted August 2, 2011 Author Administrators Report Posted August 2, 2011 <?php MainController::run('touchdownstats', 'top_landings', '5'); ?> Quote
Angel Air Posted August 2, 2011 Report Posted August 2, 2011 <?php MainController::run('touchdownstats', 'top_landings', '5'); ?> Excellent worked like a charm Thanks Scott Quote
Jakes Posted August 12, 2011 Report Posted August 12, 2011 Hi there, I have Helicopters, as well as Aircraft in my fleet, and the fixed wing pilots are sarting to omplain that the Heli guys is unfair with landing rates. Is there a way I can seperate the landing rate stats for each aircraft, OR maybe each Airline at least? Thanks very much! Jakes Quote
Administrators simpilot Posted August 12, 2011 Author Administrators Report Posted August 12, 2011 The easiest thing to to do would be seperate them by airline if you have that in place already. You could add a function to the model like: public function get_airline_stats($airline) { $query = "SELECT * FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND code = '$airline' ORDER BY landingrate DESC"; return DB::get_results($query); } Quote
Jakes Posted August 12, 2011 Report Posted August 12, 2011 Thank you for the reply I am not too familiar with this system, so can you please indicate what file/s to be modified? Thanks, Jakes Quote
Jakes Posted August 12, 2011 Report Posted August 12, 2011 Ok, I have added the code you provided to /core/common/TouchdownStatsData.class.php, and then, I get the following error: Warning: Invalid argument supplied for foreach() in /home/jdsarcco/public_html/uvsaaf/core/templates/touchdownstats/touchdownstats_index.tpl on line 21 What do I miss? When I enter a statistic value for example 10, it work perfect, but with an airline code, I also get this error. Link to first 10 stats: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10'>http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10 Link to error: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/ I guess this should work when placing the airline code instead? here are some of the airlines (Squadrons) we operate: CEF Central Flying School Langebaaan CFS 85 Combat Flying School FFS 44 Squadron FTS 15 Squadron HFS 87 Helicopter Flying School Thank you, Jakes Quote
Administrators simpilot Posted August 14, 2011 Author Administrators Report Posted August 14, 2011 Can you post your controller and data class to paste bucket so I can see what it is trying to do. I think you are just not assigning the variable in the controller function, not sure though. Quote
Moderators Parkho Posted August 23, 2011 Moderators Report Posted August 23, 2011 You could add a couple new functions to the module and data class Maybe something like this in your module file public function worst_landings($howmany) { $this->set('stats', TouchdownStatsData::get_worst_stats($howmany)); $this->show('touchdownstats/touchdownstats_index.tpl'); } And something like this in your data class public function get_worst_stats($howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate ASC LIMIT $howmany"; return DB::get_results($query); } Hi Simpilot Is it possible to change the code to find the lowest or highest between the landing rates and show them as the best and the worst on daily PIREPS? Thanks Quote
Administrators simpilot Posted August 23, 2011 Author Administrators Report Posted August 23, 2011 You can use the above referenced function and just ask for 1 return, that would give you the worst, then add a WHERE DAY(submitdate) = DAY(NOW()) or something like that into the function to granb the worst from that day. You will have to code for the reality of no data at all being found as well to avoid a foreach loop error. Quote
kbohme Posted August 28, 2011 Report Posted August 28, 2011 Simpilot, I saw that i made a mistake.. evetything runs now! Thanks for the help!! Lucas I have the same issue. What was your mistake ? Quote
kbohme Posted August 28, 2011 Report Posted August 28, 2011 I keep getting the error: Invalid argument supplied for foreach() in C:\xampp\htdocs\vms\core\common\TouchdownStatsData.class.php on line 44 When I try to call the average landing rate of the pilot. 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; } is the code I have in the TouchdownStatsData.class and <?php echo 'Pilot average landing rate '.round(TouchdownStatsData::pilot_average('$pilotid'), 2); ?> I am using in the template. I can get the average ailine rate fine....just not the pilot rate. I am stumped. (line 44 is the second foreach call Quote
Administrators simpilot Posted August 29, 2011 Author Administrators Report Posted August 29, 2011 Can you post the entire file to pastebin so I can look at it, I dont see a second foreach call that would be line 44. Quote
Moderators Parkho Posted August 29, 2011 Moderators Report Posted August 29, 2011 You can use the above referenced function and just ask for 1 return, that would give you the worst, then add a WHERE DAY(submitdate) = DAY(NOW()) or something like that into the function to granb the worst from that day. You will have to code for the reality of no data at all being found as well to avoid a foreach loop error. Hello Simpilot Just wanted to thank you for this and let you know that I managed the coding and it's now working like a charm. Here is my site for reference : www.alvandair.com Thanks again Cheers Quote
kbohme Posted August 29, 2011 Report Posted August 29, 2011 its in pastebin... I appreciate the help http://pastebin.com/8RK9QCYv Quote
Administrators simpilot Posted September 1, 2011 Author Administrators Report Posted September 1, 2011 It seems to work on my test install. Do you have any records for the pilot with a landing rate? Quote
Moderators mark1million Posted September 8, 2011 Moderators Report Posted September 8, 2011 Dave sorry if this has been covered already i got to page 7 and it was nearly there but not quite. What im after is to display the top xx pilots in average landing rate order, so Pilot name, Average landing rate, limited to 10. I have all their averages listed on my pilots list ok but just want a table with the top 10 pilots sorted with the best average landing rate. Cheers. Quote
Administrators simpilot Posted September 9, 2011 Author Administrators Report Posted September 9, 2011 How about something like this Mark; Add to TouchdownstataData.class.php function get_averages($howmany) { $avg = array(); $pilots = PilotData::findPilots(array('retired' => '0')); foreach($pilots as $pilot) { $query = "SELECT AVG(landingrate) as average, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'"; $result = DB::get_row($query); if($result->pilotid != '') {$avg[] = $result;} } rsort($avg); return array_slice($avg, '0', $howmany); } Add to TouchdownStats.php function averages($howmany) { $this->set('stats', TouchdownStatsData::get_averages($howmany)); $this->show('touchdownstats/touchdownstats_averages.tpl'); } Add a new template in core/templates/touchdownstats called touchdownstats_averages.tpl <h3>Best Average Landing Rate</h3> <?php if($stats) { echo '<table>'; echo '<tr>'; echo '<th>Landing Rate</th>'; echo '<th>Pilot</th>'; echo '</tr>'; foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); echo '<tr>'; echo '<td>'.round($stat->average, 1).'</td>'; echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>'; echo '</tr>'; } echo '</table>'; } else { echo 'No Stats Available'; } ?> Then call it by url and pass how many records you want as the last element http://www.yoursite.com/index.php/touchdownstats/averages/10 or within another template <?php MainController::run('touchdownstats', 'averages', '10'); ?> Quote
Moderators mark1million Posted September 9, 2011 Moderators Report Posted September 9, 2011 Thanks Dave, im just on my way out to work now but its returning a an empty page with just the header and footer only being displayed. Will have another look when i get home tonight. Quote
Moderators mark1million Posted September 9, 2011 Moderators Report Posted September 9, 2011 My error, I put the template in the wrong folder All i want to do now is count and display the number of flights for each pilot and im there I have tried the usual $userinfo but cant get it to display anything, would i need to update the query? Quote
Administrators simpilot Posted September 13, 2011 Author Administrators Report Posted September 13, 2011 Try changing the query to; $query = "SELECT AVG(landingrate) as average, SUM(*) as flights, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'"; And you should get the number of flights back with the array; $stat->flights Quote
Moderators mark1million Posted September 13, 2011 Moderators Report Posted September 13, 2011 Thank you Dave, one change i had to make was the SUM to COUNT and that brought back the data for me. Thanks again. Quote
Administrators simpilot Posted September 13, 2011 Author Administrators Report Posted September 13, 2011 Sorry about that Mark, it was off the cuff, and you know what you get with that. Quote
Moderators mark1million Posted September 13, 2011 Moderators Report Posted September 13, 2011 Hey don't apologise, great full as always for all your help Thanks... Quote
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.