Moderators Kyle Posted March 7, 2011 Moderators Report Share Posted March 7, 2011 Your Welcome!!! Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted March 7, 2011 Moderators Report Share Posted March 7, 2011 Top Man !!!! Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 I think it would be real sweet if we could show hub finance stats as well such as how much money the hub has made and how much was spent on fuel. I am not so sure we will ever be able to do that though. But on another note, thank you all very much for working on this and helping so many of us out with it. I really appreciate it! I have been wanting to add hub pages for quite some time now. This is the icing on the cake for me. Thanks! Ray Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 8, 2011 Moderators Report Share Posted March 8, 2011 No Problem Guys! Glad you like it. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 I think it would be real sweet if we could show hub finance stats as well such as how much money the hub has made and how much was spent on fuel. I am not so sure we will ever be able to do that though. But on another note, thank you all very much for working on this and helping so many of us out with it. I really appreciate it! I have been wanting to add hub pages for quite some time now. This is the icing on the cake for me. Thanks! Ray TAV, Did you look at the function that I posted in this thread? It has the items you are looking for. Look up a few posts. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 TAV, Did you look at the function that I posted in this thread? It has the items you are looking for. Look up a few posts. I must have read it wrong. I will go back and look. Thanks for pointing that out to me. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 I think that you could have combined a lot of these to get better results. Here is a hubstats function that I use. public static function getHubStats($hubicao) { $key = 'HubStats_Stats_'.$hubicao; $ret = CodonCache::read($key); if($ret === false) { $params = array( 'u.hub' => $hubicao, 'p.accepted' => PIREP_ACCEPTED ); $sql = 'SELECT COUNT(p.pirepid) as total, SUM(p.landingrate)/COUNT(*) as landAvg, SUM(p.gross) as gross, SUM(p.expenses) as expenses, SUM(p.pilotpay) as pilotpay, SUM(p.revenue) as revenue, SUM(p.load) as pax, SUM(p.fuelused) as fuelused, SUM(p.fuelprice) as fuelprice, SUM(p.fuelused)/SUM(p.fuelprice) as fuelAvg, SUM((TIME_TO_SEC(flighttime_stamp)/60)) as time, SUM(p.distance) as distance, COUNT(DISTINCT(p.pilotid)) as pilots, COUNT(DISTINCT(p.depicao)) as departures, COUNT(DISTINCT(p.arricao)) as arrivals, COUNT(DISTINCT(a.icao)) as airframes FROM '.TABLE_PREFIX.'pireps p LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft '; $sql .= DB::build_where($params); $ret = DB::get_row($sql); CodonCache::write($key, $ret, 'long'); } return $ret; } This uses the cache function of phpVMS and also returns the following data. $ret->total = Total number of accepted pireps $ret->landAvg = Landing Average of all accepted pireps $ret->gross = Total Gross revenue of accepted pireps $ret->expenses = Total expenses of all accepted pireps $ret->pilotpay = Total pilotpay of all accepted pireps $ret->revenue = Total revenue of all accepted pireps $ret->pax = Total load count (this one is tricky if you run pax and cargo then this wont work correctly it just adds all of the load fields) $ret->fuelused = Total fuel used of all accepted pireps $ret->fuelprice = Total cost of all fuel of all accepted pireps $ret->fuelAvg = Average fuel per unit price of all accepted pireps $ret->time = Total flightime of all accepted pireps (returned as minutes use a different function to convert to hours:minutes) $ret->distance = Total distance flown of all accepted pireps $ret->pilots = Total pilots who have actually filed an accepted pirep $ret->departures = Total number of airport departures (counts an airport only once) $ret->arrivals = Same as above except arrival airports $ret->airframes = Total number of airframes flown (uses aircraft icao to count) Where does this little ditty of code go? I am looking at it but not sure where to place it and when I do how to call it on a tpl file to show info. This is very interesting to say the least. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 You can put it directly into Tom's HubStats Class. It can then be called as such..... <?php $hub = "KLAX"; $stats = HubStats::getHubStats($hub); ?> The $stats array will then be filled with the info I have shown in $ret. $stats->total.... etc.... Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 Ahh very nice. I'll give that a go and see how she goes for me. Thanks! Ray Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 I can't seem to get it to work. I placed that info in the hubstats and then placed the call in the tpl file and nothing is coming up. I am 100% sure it is not the code....It is the end user as usual. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 Here is how to debug. It might be that I have left something in that is not standard for phpVMS. I have added quite a bit to my copy that I always seem to forget what was original and what was modified. Any way replace the above with the following until you can get the bugs worked out. This will stop it from loading the cached version (very necessary for debugging) and also display any MySql errors that are generated. (Like I said I may have left something in there ) public static function getHubStats($hubicao) { //$key = 'HubStats_Stats_'.$hubicao; //$ret = CodonCache::read($key); //if($ret === false) //{ $params = array( 'u.hub' => $hubicao, 'p.accepted' => PIREP_ACCEPTED ); $sql = 'SELECT COUNT(p.pirepid) as total, SUM(p.landingrate)/COUNT(*) as landAvg, SUM(p.gross) as gross, SUM(p.expenses) as expenses, SUM(p.pilotpay) as pilotpay, SUM(p.revenue) as revenue, SUM(p.load) as pax, SUM(p.fuelused) as fuelused, SUM(p.fuelprice) as fuelprice, SUM(p.fuelused)/SUM(p.fuelprice) as fuelAvg, SUM((TIME_TO_SEC(flighttime_stamp)/60)) as time, SUM(p.distance) as distance, COUNT(DISTINCT(p.pilotid)) as pilots, COUNT(DISTINCT(p.depicao)) as departures, COUNT(DISTINCT(p.arricao)) as arrivals, COUNT(DISTINCT(a.icao)) as airframes FROM '.TABLE_PREFIX.'pireps p LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft '; $sql .= DB::build_where($params); $ret = DB::get_row($sql); echo DB::$error; CodonCache::write($key, $ret, 'long'); //} return $ret; } Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 On the template add the following print_r(HubStats::getHubStats($hubicao)); This will print to the screen all data that is returned (if any) Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 On the template add the following print_r(HubStats::getHubStats($hubicao)); This will print to the screen all data that is returned (if any) Tried the code you just gave and it was a no go. I then added the print function and came up with this. stdClass Object ( [total] => 0 [landAvg] => [gross] => [expenses] => [pilotpay] => [revenue] => [pax] => [fuelused] => [fuelprice] => [fuelAvg] => [time] => [distance] => [pilots] => 0 [departures] => 0 [arrivals] => 0 [airframes] => 0 ) Quote Link to comment Share on other sites More sharing options...
Cor Posted March 8, 2011 Report Share Posted March 8, 2011 Tried the code you just gave and it was a no go. I then added the print function and came up with this. stdClass Object ( [total] => 0 [landAvg] => [gross] => [expenses] => [pilotpay] => [revenue] => [pax] => [fuelused] => [fuelprice] => [fuelAvg] => [time] => [distance] => [pilots] => 0 [departures] => 0 [arrivals] => 0 [airframes] => 0 ) Same here, Regards, Cor Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 Did you actually use a hubicao? Or just stick the code in? Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 TAV - Try this in the template. (This should pull the stats for hub St Louis) <?php print_r(HubStats::getHubStats('KSTL')); ?> COR - Try this in the template. (this should pull the stats for hub San Fransisco) <?php print_r(HubStats::getHubStats('KSFO')); ?> Quote Link to comment Share on other sites More sharing options...
Cor Posted March 8, 2011 Report Share Posted March 8, 2011 got it now. Tnx, Regards, Cor Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 8, 2011 Report Share Posted March 8, 2011 I actually put an the hub code. I just think I did the code wrong. I tried it again and came up with stdClass Object ( [total] => 6 [landAvg] => -211.833333333333 [gross] => 75608 [expenses] => 100 [pilotpay] => 168 [revenue] => 51073.9459228516 [pax] => 392 [fuelused] => 25123.200012207 [fuelprice] => 24203.2344360352 [fuelAvg] => 1.03801002624683 [time] => 533.0000 [distance] => 3045 [pilots] => 1 [departures] => 3 [arrivals] => 4 [airframes] => 3 ) That time it worked. Thanks Lor. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 8, 2011 Report Share Posted March 8, 2011 NP Quote Link to comment Share on other sites More sharing options...
Allan Posted March 9, 2011 Report Share Posted March 9, 2011 Im looking to do this but I am a noob and no coding knowledge........We operate FBO's which has 3 airports for each region, So what I am looking to do is insert 3 airports for each stat ,I am willing to pay for some one to do this.... West Coast Region Central Region East Coast Region thanks in advance Regards, Allan Quote Link to comment Share on other sites More sharing options...
lorlandi Posted March 21, 2011 Report Share Posted March 21, 2011 Any chance to code something like schedules search, i mean search a hub consulting all airports and to show only the selected airport by ICAO. Regards Quote Link to comment Share on other sites More sharing options...
flyalaska Posted December 3, 2011 Report Share Posted December 3, 2011 Is it possible to show some stats per month, Hours and flights? Quote Link to comment Share on other sites More sharing options...
Tom Posted December 6, 2011 Author Report Share Posted December 6, 2011 Is it possible to show some stats per month, Hours and flights? You can quite easily add more functions as each have their own queries, yes Quote Link to comment Share on other sites More sharing options...
Strider Posted February 4, 2012 Report Share Posted February 4, 2012 I am trying to put this into an externalt page, I have writtne a basic module to call a tpl file, but it says it is trying to call to an undefine method HubStats::gethubstats. But I have it in the hubstats class file, and it is properly cased. I have changed the hubicao to just icao. Anyone know how to fix this? [url="http://malaysiava.org/index.php/hubstats#"]Fatal[/url] error: [url="http://malaysiava.org/index.php/hubstats#"]Call[/url] to undefined method HubStats::gethubstats() in /home/globalai/public_html/malaysiava.org/lib/skins/cityportal/hubstats.tpl on line 4 Quote Link to comment Share on other sites More sharing options...
Thomas Posted March 2, 2012 Report Share Posted March 2, 2012 Hi Tom, Don't suppose you still have the full php code do you please? I can't download it from the original post and really need it for my site as we were running it before. Thanks, Thomas. Quote Link to comment Share on other sites More sharing options...
Tom Posted March 3, 2012 Author Report Share Posted March 3, 2012 I most certainly do. I'll github it in the morning. (at a slightly more reasonable hour. it's 3:36 right now) Quote Link to comment Share on other sites More sharing options...
Tom Posted March 3, 2012 Author Report Share Posted March 3, 2012 Nevermind, I'll do it now. Here you go: https://github.com/tomsterritt/HubStats Quote Link to comment Share on other sites More sharing options...
Thomas Posted March 3, 2012 Report Share Posted March 3, 2012 Cheers mate Quote Link to comment Share on other sites More sharing options...
flyalaska Posted April 12, 2012 Report Share Posted April 12, 2012 How do I have the stats to show whle nmbers for the hours? Fairbanks Pilots:55 Fairbanks Flights: 1194 Fairbanks Hours: 1846.019999999998 Quote Link to comment Share on other sites More sharing options...
Tom Posted April 12, 2012 Author Report Share Posted April 12, 2012 How do I have the stats to show whle nmbers for the hours? Fairbanks Pilots:55 Fairbanks Flights: 1194 Fairbanks Hours: 1846.019999999998 You can use round() to round it to however many places you'd like 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.