Administrators simpilot Posted May 30, 2010 Administrators Report Posted May 30, 2010 TouchdownStats 1.0 Module to extract and display landing rates from your PIREPS table ---------------------------------------------- A visible link to http://www.simpilotgroup.com must be provided on any webpage utilizing this script for the license to be valid. ---------------------------------------------- Developed by: simpilot - David Clark www.simpilotgroup.com www.david-clark.net Developed on: phpVMS 2.1.935 php 5.2.11 mysql 5.0.51 apache 2.2.11 Install: -Download the attached package. -unzip the package and place the files as structured in your root phpVMS install. To show all the landing stats currently in the datbase create a link to www.yoursite.com/index.php/TouchdownStats To show a limited number of stats from your database create a link to www.yoursite.com/index.php/TouchdownStats/top_landings/10 The "10" can be changed to however many you would like to see The most useful method of the data class would be to use TouchdownStatsData::get_all_stats() and TouchdownStatsData::get_stats('10') You can use these inside of one of your templates to bring back the data you want and display it as you wish. An example to fill a variable with data for use in your template you can use $this->set->('stats', TouchdownStatsData::get_stats('10')); in your module to pass the data to the template within the $stats variable. Then in your template use the $stats variable to do what you wish with the display. TouchDownStats Released under the following license: Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License Code hosted on Github - Link In Signature. 7 Quote
Gabriel Fernandez Posted May 30, 2010 Report Posted May 30, 2010 Aamaaaaziing!! Thaks for post that!! Quote
savagegrave Posted May 30, 2010 Report Posted May 30, 2010 Aamaaaaziing!! Thaks for post that!! agreed thanks alot for this... cant wait to put it in action cheers dude! Quote
CPC900 Posted May 30, 2010 Report Posted May 30, 2010 Yes, awesome! Is it difficult to get the pilots average landings score as well, as a top ten? Quote
Moderators Kyle Posted May 31, 2010 Moderators Report Posted May 31, 2010 Yes, awesome! Is it difficult to get the pilots average landings score as well, as a top ten? Hey, how can i dispaly the landing stats table like on a different page? i want to dispaly the top 10. Quote
MrAmsterdam Posted June 16, 2010 Report Posted June 16, 2010 Hey, how can i dispaly the landing stats table like on a different page? i want to dispaly the top 10. Yeah, i have the top 20 selected on my site. I really want the average pilot landing rate as well. is this easy to create? Thanks all! Lucas Quote
selwynorren Posted June 17, 2010 Report Posted June 17, 2010 Hi All, I love this add-on, great work! Its been a while since I have worked with phpvms and php in general. I cant seem to get this module to show on my front page I would like to show the best 5 landing rates on the left sidebar of my site I call it using: <?php echo TouchdownStatsData::get_stats('5'); ?> But the result just shows the word Array Would you mind pointing me in the right direction Quote
Administrators simpilot Posted June 18, 2010 Author Administrators Report Posted June 18, 2010 The function does not return anything to echo, it returns a variable filled with the info you requested. An example to use it would be to set the variable, preferably in your module: $this->set('myvariable', TouchdownStatsData::get_stats('5')); Then in your template use a foreach command to show what data you want to display: foreach($myvariable as $variable) { Do Stuff } To see what is available to echo do a: print_r($myvariable); in your template. If you want to call the data within the template just do: $myvariable = TouchdownStatsData::get_stats('5'); in your template before you need the info. Quote
selwynorren Posted June 18, 2010 Report Posted June 18, 2010 Wow, Ok actually easy enough I suppose, It worked like a charm If you want to call the data within the template just do:$myvariable = TouchdownStatsData::get_stats('5'); in your template before you need the info. Is what I somehow missed... I think. Thanks so much. Quote
Jeff Posted June 25, 2010 Report Posted June 25, 2010 so how do you pull the "Average Touchdown Rate" for the month or to date? Quote
MrAmsterdam Posted June 25, 2010 Report Posted June 25, 2010 Yeah i would like to know that as well.. i can't find it anywhere... :-( Quote
Administrators simpilot Posted June 28, 2010 Author Administrators Report Posted June 28, 2010 What are you looking for? The VA's average or a pilot's average? Monthly, alltime? Quote
Jeff Posted June 28, 2010 Report Posted June 28, 2010 The average for both the pilot and also the monthly average if you could. Quote
MrAmsterdam Posted June 28, 2010 Report Posted June 28, 2010 Yeah, that would be great! Could you make a selection between all time, year and month? (month is the least important for me though) :-) Thanks in advance! Lucas Quote
CPC900 Posted June 28, 2010 Report Posted June 28, 2010 I was looking for the top 10 pilots average for all time, but the more stats the better. Almost like the TopPilot module, but associated as landing stats. Maybe combine them both?! A second table listed below the top pilot data for best monthly touchdown rate, and then a best average as well. SO, below the top pilot data, it could be: Best Landing Rate (for month) | Best Landing Rate Average (for month) | Smoothest Pilot (for month) I don't know, maybe the smoothest pilot could be based on combination of best landing rate + average somehow, possibly with a minimum of 5 flights or something?! Quote
MrAmsterdam Posted June 28, 2010 Report Posted June 28, 2010 Yeah that's a good idea... and yeah, the more stats the better of course :-p Regards Lucas Quote
Airport Posted June 29, 2010 Report Posted June 29, 2010 Hello, it works very fine but there is an error also at my page: Warning: Invalid argument supplied for foreach() in /mnt/weba/40/03/52426403/htdocs/core/templates/touchdownstats/touchdownstats_index.tpl on line 21 Im using: Version 2.1.934 Martin Quote
Administrators simpilot Posted June 29, 2010 Author Administrators Report Posted June 29, 2010 Hello, it works very fine but there is an error also at my page: Warning: Invalid argument supplied for foreach() in /mnt/weba/40/03/52426403/htdocs/core/templates/touchdownstats/touchdownstats_index.tpl on line 21 Im using: Version 2.1.934 Martin Looks like there is no data coming back from the database. Do you have any PIREPs filed with landing rates? Quote
Airport Posted June 29, 2010 Report Posted June 29, 2010 Hello, right, my mistake, I had deleted the database because of the problems with the Flight Bids ... Martin Quote
maiochine Posted June 30, 2010 Report Posted June 30, 2010 Looks like there is no data coming back from the database. Do you have any PIREPs filed with landing rates? I have the same problem, i usually send manual pireps and I confirm to have landing rates as field .... any help ? Quote
Administrators simpilot Posted June 30, 2010 Author Administrators Report Posted June 30, 2010 I have the same problem, i usually send manual pireps and I confirm to have landing rates as field .... any help ? Manual PIREPS do not have a landing rate included to put in the database, generally that is only going to come from an ACARS system PIREP. Check your database to see if there is actually any data in the landing rate column. If there is no data at all in the column you will get the error as there is nothing to make the foreach command work. Quote
maiochine Posted July 1, 2010 Report Posted July 1, 2010 Manual PIREPS do not have a landing rate included to put in the database, generally that is only going to come from an ACARS system PIREP. Check your database to see if there is actually any data in the landing rate column. If there is no data at all in the column you will get the error as there is nothing to make the foreach command work. Hey I have entered manualy 3 landing rate data in the rate field but all the other fields for the remaining flights have the landing rate still 0 but since I'm using FsCaptain I have its own landing rate fields and table in my phpvms that it might be interesting if I link your add-on to it instead of the phpvms_pireps table. If you could please help me do this because I'm not a programmer and I understand few of coding... Here's the structure of my FsCaptain table witch is called "flights" CREATE TABLE IF NOT EXISTS `flights` ( `id` int(16) unsigned NOT NULL auto_increment, `datestamp` datetime NOT NULL default '0000-00-00 00:00:00', `UserName` varchar(22) NOT NULL default '', `CompanyName` varchar(35) NOT NULL default '', `PilotName` varchar(35) NOT NULL default '', `FlightId` varchar(10) NOT NULL default '', `OnlineNetworkNbr` tinyint(4) NOT NULL default '0', `FlightDate` date NOT NULL default '0000-00-00', `AircraftName` varchar(50) NOT NULL default '', `AircraftType` varchar(5) NOT NULL default '', `NbrPassengers` smallint(2) NOT NULL default '0', `CargoWeight` varchar(15) NOT NULL default '', `Mtow` varchar(15) NOT NULL default '', `StartAircraftWeight` varchar(15) NOT NULL default '', `EndAircraftWeight` varchar(15) NOT NULL default '', `StartFuelQuantity` varchar(15) NOT NULL default '', `EndFuelQuantity` varchar(15) NOT NULL default '', `DepartureIcaoName` varchar(50) NOT NULL default '', `ArrivalIcaoName` varchar(50) NOT NULL default '', `DepartureLocalHour` time NOT NULL default '00:00:00', `ArrivalLocalHour` time NOT NULL default '00:00:00', `DepartureGmtHour` time NOT NULL default '00:00:00', `ArrivalGmtHour` time NOT NULL default '00:00:00', `TotalBlockTime` time NOT NULL default '00:00:00', `TotalBlockTimeNight` time NOT NULL default '00:00:00', `TotalAirbornTime` time NOT NULL default '00:00:00', `TotalTimeOnGround` time NOT NULL default '00:00:00', `TotalDistance` varchar(18) NOT NULL default '', `MaxAltitude` varchar(15) NOT NULL default '', `CruiseSpeed` varchar(15) NOT NULL default '', `CruiseMachSpeed` varchar(15) NOT NULL default '', `CruiseTimeStartSec` time NOT NULL default '00:00:00', `CruiseTimeStopSec` time NOT NULL default '00:00:00', `CruiseFuelStart` varchar(15) NOT NULL default '', `CruiseFuelStop` varchar(15) NOT NULL default '', `LandingSpeed` varchar(15) NOT NULL default '', `LandingPitch` varchar(15) NOT NULL default '', `TouchDownVertSpeedFt` float NOT NULL default '0', `CaptainSentMayday` tinyint(3) NOT NULL default '0', `CrashFlag` tinyint(3) NOT NULL default '0', `FlightResult` varchar(15) NOT NULL default '', `PassengersOpinion` tinyint(4) NOT NULL default '0', `PassengersOpinionText` text NOT NULL, `FailureText` text NOT NULL, `CasualtiesText` text NOT NULL, `PilotBonusText` text NOT NULL, `BonusPoints` int(10) NOT NULL default '0', `PilotPenalityText` text NOT NULL, `PenalityPoints` int(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `datestamp` (`datestamp`), KEY `UserName` (`UserName`), KEY `CompanyName` (`CompanyName`), KEY `PilotName` (`PilotName`), KEY `AircraftName` (`AircraftName`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=70 ; STEPS TO FOLLOW: 1- the first thing to do is to modify both entries ".TABLE_PREFIX." in the file TouchdownStatsData.class.php of your add-on found in the folder "common" to ".flights." is that correct ? 2- to show only the best five I have to open the file TouchdownStats.php and modify the entry at line 15 $this->set('stats', TouchdownStatsData::get_all_stats()); to $this->set->('stats', TouchdownStatsData::get_stats('5')); so the whole code would look like this : <?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_stats('5')); $this->show('touchdownstats/touchdownstats_index.tpl'); } public function top_landings($howmany) { $this->set('stats', TouchdownStatsData::get_stats($howmany)); $this->show('touchdownstats/touchdownstats_index.tpl'); } } 3- Please show me how to change the entries in touchdownstats_index.tpl so it communicates with the "flights" table. <?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>'; } ?> Quote
Moderators mark1million Posted July 1, 2010 Moderators Report Posted July 1, 2010 Is there a quick way to limit this to the month? as you have done with the Toppilot release. Quote
Administrators simpilot Posted July 1, 2010 Author Administrators Report Posted July 1, 2010 @maiochine You will have to make some changes to the data class to start (TouchdownData.class.php) this -> 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); } would change to something like -> public function get_all_stats() { $query = "SELECT * FROM flights WHERE TouchDownVertSpeedFt < '0' ORDER BY TouchDownVertSpeedFt DESC"; return DB::get_results($query); } You can leave touchdownstats.php as it is and make changes to your tpl file to reflect the new db column names. For example in touchdownstats_index.tpl this-> echo '<td>'.$stat->landingrate.'</td>'; would change to -> echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; All the other variable names will need to be changed to match the db table as well. Quote
Administrators simpilot Posted July 1, 2010 Author Administrators Report Posted July 1, 2010 Is there a quick way to limit this to the month? as you have done with the Toppilot release. 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. Quote
maiochine Posted July 1, 2010 Report Posted July 1, 2010 @simpilot I have tried the modification you told me about but still have a small issue, please take a look at this result : http://www.cargoitaliavirtual.com/index.php/TouchdownStats/ As you can see there's no pilot name nor aircraft name.... my touchdownstats_index.tpl look like this now <?php foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->PilotName); $aircraft = OperationsData::getAircraftInfo($stat->AircraftName); echo '<tr>'; echo '<td>'.PilotData::getPilotCode($pilot->UserName, $pilot->PilotName).' - '.$pilot->PilotName.'</td>'; echo '<td>'.$aircraft->AircraftName.'</td>'; echo '<td>'.$stat->ArrivalIcaoName.'</td>'; echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; echo '<td>'.$stat->datestamp.'</td>'; echo '</tr>'; } ?> </table> could you please help me for this one too ? thanks again Quote
Administrators simpilot Posted July 1, 2010 Author Administrators Report Posted July 1, 2010 Your PIREP system does not record pilotid or the aircraft id so you are not going to be able to use the native phpVMS functions for callsigns and getting aircraft data from the db. Without having a db in front of me to work with it looks like the best you may do is something like this -> <?php foreach($stats as $stat) { echo '<tr>'; echo '<td>'.$stat->PilotName.'</td>'; echo '<td>'.$stat->AircraftName.'</td>'; echo '<td>'.$stat->ArrivalIcaoName.'</td>'; echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; echo '<td>'.$stat->datestamp.'</td>'; echo '</tr>'; } ?> also, how do you get a landing rate of +63 ft/min thats taking off isnt it? lol Quote
maiochine Posted July 1, 2010 Report Posted July 1, 2010 Your PIREP system does not record pilotid or the aircraft id so you are not going to be able to use the native phpVMS functions for callsigns and getting aircraft data from the db. Without having a db in front of me to work with it looks like the best you may do is something like this -> <?php foreach($stats as $stat) { echo '<tr>'; echo '<td>'.$stat->PilotName.'</td>'; echo '<td>'.$stat->AircraftName.'</td>'; echo '<td>'.$stat->ArrivalIcaoName.'</td>'; echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; echo '<td>'.$stat->datestamp.'</td>'; echo '</tr>'; } ?> also, how do you get a landing rate of +63 ft/min thats taking off isnt it? lol Im gonna try this out and see what I can get ! I dont know how the landing rate works !!! it shouldn't be -120 ft/m it should be 120ft/m but eh +69 I have no idea how that was since I was not flying that flight Quote
Jeff Posted July 1, 2010 Report Posted July 1, 2010 also, how do you get a landing rate of +63 ft/min thats taking off isnt it? lol Maybe he landed upside down. This is how I have mine setup you can look into it. <?php foreach($stats as $stat) { $pilot = PilotData::getPilotData($stat->pilotid); $aircraft = OperationsData::getAircraftInfo($stat->aircraft); echo '<tr align="center" valign="middle" bgcolor="#DFF4FF">'; 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></div> 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.