Omerr01 Posted December 8, 2013 Report Posted December 8, 2013 You can add a WHERE statement to the sql call to only pull data that matches the month you want. something like -> public function get_all_stats($month) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate) = '$month' ORDER BY landingrate DESC"; return DB::get_results($query); } $month would be the numerical representation of the month you want. Probably will want to name the year as well or you will get the data from that month for every year that is in the db. If I write another version I will include some monthly stats capability. where i put this code ??? Quote
Taran Posted December 15, 2013 Report Posted December 15, 2013 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(); ?> I did all this but how would I get the data to show the pilot's avg rate in their crew center? I want it to automatically get the pilot id. Quote
Administrators simpilot Posted December 24, 2013 Author Administrators Report Posted December 24, 2013 Any help? You have copied the necessary code into your post <?php echo 'Pilot average landing rate '.TouchdownStatsData::pilot_average('pilot#'); ?> Replace the 'pilot#' with the variable that contains the raw pilot id from the database for the page that you are on, it varies from page to page and is unavailable on some. Quote
Curshad Posted June 25, 2014 Report Posted June 25, 2014 sorry is this covered? i want to display the top 10 landing rates of the current month here http://skybahamasvirtual.net/index.php/TouchdownStats So i don't want that full table i just wanna replace all codes with what needs to be added in an taken out. I don't want to take out or add in the wrong info So i do apologies if i asked for a bit too much. This is the Template: <h2>Top 10 Landings for <?php echo date("F Y");?> NOTE* Landing Rates -600 and Below were not accepted</h2> <br> <br> <br> <?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="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>'; } ?> This is the TouchdownStatsData.class.php <?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/ class TouchdownStatsData extends CodonData { 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); } 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); } 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); } public function get_stats_by_aircraft($aircraftId) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND aircraft = $aircraftId ORDER BY landingrate DESC"; return DB::get_results($query); } 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; if(!empty($stats)) { foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } return $total / $count; } else {return '0';} } 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; } } This is the TouchdownStats.php <?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/ class TouchdownStats extends CodonModule { public function index() { $this->set('stats', TouchdownStatsData::get_all_stats()); $this->show('touchdownstats/touchdownstats_index.tpl'); } public function top_landings($howmany) { $this->set('stats', TouchdownStatsData::get_stats($howmany)); $this->show('touchdownstats/touchdownstats_index.tpl'); } } Quote
ARV187 Posted June 25, 2014 Report Posted June 25, 2014 Curshad, you want this? limit the number of row pilots? How i can limit the number of the tochdownstats 10 pilots to 5 pilot. Not sure exactly what you are looking for but the function "top_landings($howmany)" will return the top landings in order and limit it by the "$howmany" variable. Quote
Administrators simpilot Posted June 25, 2014 Author Administrators Report Posted June 25, 2014 @curshad - the code to do this is covered in the topic. http://forum.phpvms.net/topic/2989-touchdownstats-10/page__st__20#entry21408 Quote
Curshad Posted July 20, 2014 Report Posted July 20, 2014 (edited) Deleted. Edited July 20, 2014 by Curshad Quote
kkoseoglu Posted November 11, 2014 Report Posted November 11, 2014 Hii, I'm using Monthly Touch Down Rates in my homepage limited by 5. Hovewer, some pilots have really really good T/D rates. For example; Pilot A: -9,-12-15 Pilot B: -23,-26 Pilot C: -30,-34 Pilot D:-40,-41,43 Pilot E:-45,-47 The output automatically shows Pilot A:-9 Pilot A:-12 Pilot A:-15 Pilot B:-23 Pilot B:-26 Now: I would like to show Top 5 pilots top rate.Any pilot's rates should not repeated. I want to show only the best one so more pilots can enter the list . Example: Pilot A:-9 Pilot B:-23 Pilot C:-30 Pilot D:-40 Pilot E:-45 I Mean Top 5 Pilots greatest landing according to that month. How Should I Change the codes? Thanks, Kıvanç Quote
Administrators simpilot Posted November 12, 2014 Author Administrators Report Posted November 12, 2014 Maybe something like this as a new function in your data class: public static function get_unique_monthly($month, $year, $howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, MAX(landingrate) as landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate) = $month AND YEAR(submitdate) = $year GROUP BY pilotid ORDER BY landingrate DESC LIMIT $howmany"; return DB::get_results($query); } Quote
kkoseoglu Posted November 12, 2014 Report Posted November 12, 2014 Hello David, It Works. Thanks A Lot! Quote
richipilot Posted January 6, 2015 Report Posted January 6, 2015 I´m getting this; Warning: Invalid argument supplied for foreach() in httpd.www/web/core/templates/touchdownstats/touchdownstats_index.tpl on line Someone knows the solution? Quote
Moderators servetas Posted January 6, 2015 Moderators Report Posted January 6, 2015 What is your website url? The errors means that the variable which is called from the foreach does not have any data. Have your pilots sent any flights on your virtual airline using acars? Quote
richipilot Posted January 7, 2015 Report Posted January 7, 2015 What is your website url? The errors means that the variable which is called from the foreach does not have any data. Have your pilots sent any flights on your virtual airline using acars? We still making the web so no reports were sent yet. So I will post again when I hace a report Quote
Moderators servetas Posted January 7, 2015 Moderators Report Posted January 7, 2015 So that's the case. The variable that is used on the foreach does not include any data (there are not any reports on your system) and that's why it returns an error. You can add the foreach inside an if statement if you wish to remove the error. Of course, the error will disapear as soon as someone sends a flight on your system. Quote
richipilot Posted January 10, 2015 Report Posted January 10, 2015 On my website how can I show in this table the stats of the best landings of the month? <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout-wrapper layout-item-0"> <div class="art-content-layout layout-item-1"> <div class="art-content-layout-row"> <div class="art-layout-cell layout-item-2" style="width: 100%" > <div class="art-blockheader"> <h3 class="t">Mejores tomas del mes</h3> </div> <p style="color: rgb(46, 59, 62);"> Here must be the table/graph </p> </div> </div> Quote
Administrators simpilot Posted January 11, 2015 Author Administrators Report Posted January 11, 2015 On my website how can I show in this table the stats of the best landings of the month? <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout-wrapper layout-item-0"> <div class="art-content-layout layout-item-1"> <div class="art-content-layout-row"> <div class="art-layout-cell layout-item-2" style="width: 100%" > <div class="art-blockheader"> <h3 class="t">Mejores tomas del mes</h3> </div> <p style="color: rgb(46, 59, 62);"> Here must be the table/graph </p> </div> </div> The information is in the thread on the second page. Quote
richipilot Posted January 11, 2015 Report Posted January 11, 2015 The information is in the thread on the second page. Oh, thanks I will do that Quote
richipilot Posted January 12, 2015 Report Posted January 12, 2015 The result I get on my page is "array" just that... Quote
richipilot Posted January 15, 2015 Report Posted January 15, 2015 How may I solve this, thanks in advance Quote
Moderators servetas Posted January 15, 2015 Moderators Report Posted January 15, 2015 It has come up inside this thread. Search and you will find a solution. Quote
richipilot Posted January 16, 2015 Report Posted January 16, 2015 It has come up inside this thread. Search and you will find a solution. Yep I read that and I did it, but the page doesn´t work, I mean when I go to index.php/TouchDownStats there it works, but when I return to the main page on the table I showed before, it shows array, I didn´t find any solution yet, applying also the topic "solutions" Quote
kkoseoglu Posted February 19, 2015 Report Posted February 19, 2015 Maybe something like this as a new function in your data class: public static function get_unique_monthly($month, $year, $howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, MAX(landingrate) as landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate) = $month AND YEAR(submitdate) = $year GROUP BY pilotid ORDER BY landingrate DESC LIMIT $howmany"; return DB::get_results($query); } I have just noticed something related to this. When data is listed, only name and touchdown is correct. Arr icao and plane are wrong. It takes pilots first flight. For example: Pilots first flights is: Oytun B737-600 VQPR -20 ft/m 04/02 Second one is: Oytun B737-800 KJFK -12 ft/m 06/02 On the list: Oytun B737-600 VQPR -12 ft/m 04/02 The correct one must be Second one on the list but it is not. How can I solve this one? Quote
Administrators simpilot Posted February 19, 2015 Author Administrators Report Posted February 19, 2015 How are you displaying the information? I just looked at the data being returned from a live database and it seems to be returning the correct information. Quote
kkoseoglu Posted February 26, 2015 Report Posted February 26, 2015 Here is my Touchdownstatsdataclass.php : public function tdunic () { $query = "SELECT pirepid, pilotid, code, flightnum, depicao, arricao, aircraft, MAX(landingrate) as landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate)=MONTH(now()) AND YEAR(submitdate)=YEAR(now()) GROUP BY pilotid ORDER BY landingrate DESC LIMIT 5"; return DB::get_results($query); } Here is my touchdowns.php : <?php $stats = TouchdownStatsData::tdunic(); if ($stats) { ?> <table class="table table-condensed"> <tr> <th>Pilot</th> <th>Aircraft</th> <th>Arrival</th> <th>V/S</th> <th>Date</th> </tr> <?php foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); $aircraft = OperationsData::getAircraftInfo($stat->aircraft); echo '<tr>'; echo '<td>'.$pilot->firstname.'</td>'; echo '<td>'.$aircraft->name.'</td>'; echo '<td>'.$stat->arricao.'</td>'; echo '<td><font color="red">'.$stat->landingrate.' ft/m</font></td>'; echo '<td>'.date('d/m', strtotime($stat->submitdate)).'</td>'; echo '</tr>'; } }else { echo 'No ' . date('F') . ' Flights Recorded'; } ?> </table> Here is my frontpagemain.php : <?php MainController::Run('content', 'pilotlandings', '5'); ?> Quote
IrfanKhan Posted March 2, 2015 Report Posted March 2, 2015 Hello everyone just need little help if for example from touchdown table i wanted to skip any of the aircraft how should i get the final result. from all the touchdowns i wanted one or more aircraft should not show up what will be the code i can use to skip any aircraft? i used this code but still no luck <?php foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); $aircraft = OperationsData::getAircraftInfo($stat->aircraft); If($aircraft->code == “C172â€) { Continue; } else { 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>'; } } ?> Thank you Quote
kkoseoglu Posted March 23, 2015 Report Posted March 23, 2015 Should I change my touchdowns.php ? Regards Quote
yorgosGK Posted July 6, 2015 Report Posted July 6, 2015 Anyway someone can help me with a table to get each pilots average all-time landing? Quote
Administrators simpilot Posted July 7, 2015 Author Administrators Report Posted July 7, 2015 Anyway someone can help me with a table to get each pilots average all-time landing? This is already asked and answered in this thread, post #45 to be exact. Quote
Angel Air Posted August 31, 2015 Report Posted August 31, 2015 Hi all, Not sure if anyone else has had this problem but I am getting this error above the landing stats Deprecated: Non-static method TouchdownStatsData::get_stats_by_cur_month() should not be called statically, assuming $this from incompatible context in /home/angelair/public_html/test/core/modules/TouchdownStats/TouchdownStats.php on line 36 I have tried to add this to the Touchdownstats.php public static function top_landing_this_month () { but that just breaks the frontpage. any ideas for a workaround? Thanks in advance Scott 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.