flyalaska Posted April 12, 2012 Report Share Posted April 12, 2012 Thank you! Quote Link to comment Share on other sites More sharing options...
ATAvCEO Posted September 9, 2012 Report Share Posted September 9, 2012 Hi all, I have been reading this thread over and over trying to figure out how to get this working. I would like to have a single custom page for each main hub we fly to/from (KIND & KMDW) and pull the data out of the hubstats.class file. However I am at a total loss. I have placed the hubstats.class file in the core/common folder on the site, a couple things I am not understanding are, 1) Do I need to create a module for both Hubs and placed in the core/modules folder for this? 2) What code needs to go into the module? Thanks for your time and help and sorry for my ignorance on how to set this up. Still learning Quote Link to comment Share on other sites More sharing options...
Tom Posted September 9, 2012 Author Report Share Posted September 9, 2012 Hi all, I have been reading this thread over and over trying to figure out how to get this working. I would like to have a single custom page for each main hub we fly to/from (KIND & KMDW) and pull the data out of the hubstats.class file. However I am at a total loss. I have placed the hubstats.class file in the core/common folder on the site, a couple things I am not understanding are, 1) Do I need to create a module for both Hubs and placed in the core/modules folder for this? 2) What code needs to go into the module? Thanks for your time and help and sorry for my ignorance on how to set this up. Still learning I made a module in core/modules - Folder called Hub and then in Hub.php do something like: <?php class Hub extends CodonModule { public function index() { // Do nothing? Show a list of all hubs perhaps? } public function view($hub) { if(!$hub){ $this->set('message', 'No hub code specified!'); $this->render('core_error.tpl'); return; } $this->set('pilots', PilotData::findPilots(array('p.hub'=>$hub))); $this->set('hub', OperationsData::retrieveAirportInfo($hub)); $this->render('hub.tpl'); } } ?> And then make a template in your skin folder called hub.tpl which you put the codes for HubStats in and so on. Then you link to site.com/index.php/hub/view/KIND etc Quote Link to comment Share on other sites More sharing options...
ATAvCEO Posted September 10, 2012 Report Share Posted September 10, 2012 Hi Tom, Thanks for the info and so far I got the module made and placed in folder per your specs. Now my trouble begins with the hub.tpl file. I have tried a couple of different coding ways each giving me different results. Below is the code I have in hub.tpl file. If you look you can see what I am trying to see. Here is the page that is being called too - http://www.ata-virtu...p/hub/view/KMDW, the /../../KIND page looks the same no matter what. <b>Using ..CountPilots (KMDW) in place of ($icao)etc</b><br> Pilots: <?php echo HubStats::Pilots(KMDW); ?><br> Number of Pilots: <?php echo HubStats::CountPilots (KMDW); ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom(KMDW); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo($KMDW); ?><br> Number of Flights: <?php echo HubStats::CountFlights(KMDW); ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails(KMDW, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles(KMDW); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo(KMDW); ?><br><br> <b>Using ..CountPilots (KIND) in place of ($icao)etc</b><br> Pilots: <?php echo HubStats::Pilots(KIND); ?><br> Number of Pilots: <?php echo HubStats::CountPilots (KIND); ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom(KIND); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo(KIND); ?><br> Number of Flights: <?php echo HubStats::CountFlights(KIND); ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails(KIND, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles(KIND); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo(KIND); ?><br><br> <b>Using ..CountPilots($icao)etc</b><br> Pilots: <?php echo HubStats::Pilots($icao); ?><br> Number of Pilots: <?php echo HubStats::CountPilots ($icao); ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom($icao); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo($icao); ?><br> Number of Flights: <?php echo HubStats::CountFlights($icao); ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails($icao, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles($icao); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo($icao); ?><br><br> I know it looks screwy. but just trying to see how to work this. Again thanks for your help, it is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Tom Posted September 10, 2012 Author Report Share Posted September 10, 2012 Within the template you'll want to use $hub->ICAO - and for pilots it returns an array of all the pilots so you'll want to do something like: $pilots = HubStats::Pilots($hub->ICAO); foreach($pilots as $pilot){ // Do a table row or something? } Quote Link to comment Share on other sites More sharing options...
ATAvCEO Posted September 10, 2012 Report Share Posted September 10, 2012 Hi Tom, Thanks for your help and your patience with me on this but still not doing anything here. Here is the code: If you notice Section 1 is using the $hub->KMDW, Section 2 is using just plain (KIND) as before and Section 3 is using $hub->ICAO. Section 2 is only pulling info out of the database but not everything that it should get, whereas Sections 1 & 3 aren't pulling anything. I know about creating a table/row for the pilot info I just put the code in there as stated above just as a place holder. <b>Using ..CountPilots ($hub->KMDW) in place of($icao) etc</b><br> <table> <tr>$pilots = HubStats::Pilots($hub->KMDW); foreach($pilots as $pilot){ // Do a table row or something?</tr></table> }<br> Number of Pilots: <?php echo HubStats::CountPilots ($hub->KMDW) ; ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom ($hub->KMDW); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo ($hub->KMDW); ?><br> Number of Flights: <?php echo HubStats::CountFlights ($hub->KMDW) ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails($hub->KMDW, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles($hub->KMDW); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo($hub->KMDW); ?><br><br> <b>Using ..CountPilots (KIND) in place of ($icao)etc</b><br> $pilots = HubStats::Pilots($hub->KIND); foreach($pilots as $pilot){ // Do a table row or something? }<br> Number of Pilots: <?php echo HubStats::CountPilots (KIND); ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom(KIND); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo(KIND); ?><br> Number of Flights: <?php echo HubStats::CountFlights(KIND); ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails(KIND, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles(KIND); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo(KIND); ?><br><br> <b>Using ..CountPilots($hub->ICAO) etc</b><br> Pilots: <?php echo HubStats::Pilots($hub->ICAO); ?><br> Number of Pilots: <?php echo HubStats::CountPilots ($hub->ICAO); ?><br> Number of Flights From: <?php echo HubStats::CountFlightsFrom($hub->ICAO); ?><br> Number of Flights to: <?php echo HubStats::CountFlightsTo($hub->ICAO); ?><br> Number of Flights: <?php echo HubStats::CountFlights($hub->ICAO); ?><br> Last 10 Pireps: <?php echo HubStats::FlightsDetails($hub->ICAO, $limit=10); ?><br> Number of Miles: <?php echo HubStats::TotalMiles($hub->ICAO); ?><br> Number of Routes To: <?php echo HubStats::CountRoutesTo($hub->ICAO); ?><br><br> Again thank you for your help and your patience on this, very much appreciated. Quote Link to comment Share on other sites More sharing options...
Stealthbird97 Posted November 6, 2012 Report Share Posted November 6, 2012 How do I even get this to show data? I've tried <?php print_r(HubStats::getHubStats('KSFO')); ?> in a .tpl file i;ve created and i just get an error Fatal error: Call to undefined method HubStats::getHubStats() How would i fix this. Do i have to tell it to read the HubStats.class.php or something? Also how would you do such a thing? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 14, 2013 Report Share Posted December 14, 2013 What is the specific code to get hours for the current month? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 15, 2013 Report Share Posted December 15, 2013 anyone? Quote Link to comment Share on other sites More sharing options...
Tom Posted December 15, 2013 Author Report Share Posted December 15, 2013 Taran, you can modify the SQL for the TotalHours function to create another to specify a date range: public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."' AND '".$startdate."' < submitdate < '".$enddate."'"; $result = DB::get_row($query); return $result->hours; } (Not tested) Quote Link to comment Share on other sites More sharing options...
Taran Posted December 15, 2013 Report Share Posted December 15, 2013 where would i add that and what would the code be to get the data? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 18, 2013 Report Share Posted December 18, 2013 Any help? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 18, 2013 Report Share Posted December 18, 2013 I figured out that i would put that in the HubStats.class.php file, but how would the code be to put that into my frontpage_main.tpl ? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 22, 2013 Report Share Posted December 22, 2013 Taran, you can modify the SQL for the TotalHours function to create another to specify a date range: public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."' AND '".$startdate."' < submitdate < '".$enddate."'"; $result = DB::get_row($query); return $result->hours; } (Not tested) I figured out to put that in HubStats.class.php but what is the exact code to pull that data on my website? Quote Link to comment Share on other sites More sharing options...
Taran Posted December 30, 2013 Report Share Posted December 30, 2013 anyone? Quote Link to comment Share on other sites More sharing options...
freshJet Posted December 30, 2013 Report Share Posted December 30, 2013 <?php echo HubStats::TotalHoursBetweenDates($icao, $startdate, $enddate);?> Make sure you have values for the three parameters... Quote Link to comment Share on other sites More sharing options...
Taran Posted December 30, 2013 Report Share Posted December 30, 2013 Let's say i want the start date to be Jan. 1, 2014, and end date to be Feb. 1,2014. Please show me that code? I can take it from there Quote Link to comment Share on other sites More sharing options...
freshJet Posted December 31, 2013 Report Share Posted December 31, 2013 From my PM to Taran, for those interested: Using manual dates: $start = strtotime("2014-1-1"); $end= strtotime("2014-2-1"); If you are doing these dynamically, you need to use: $start = date("Y-m-01"); $end = date("Y-m-t"); Quote Link to comment Share on other sites More sharing options...
Taran Posted December 31, 2013 Report Share Posted December 31, 2013 We got it working! Thanks! 1 Quote Link to comment Share on other sites More sharing options...
Taran Posted January 1, 2014 Report Share Posted January 1, 2014 Taran, you can modify the SQL for the TotalHours function to create another to specify a date range: public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."' AND '".$startdate."' < submitdate < '".$enddate."'"; $result = DB::get_row($query); return $result->hours; } (Not tested) For the folks back home who are wanting this as well, here's the corrected code that will be placed in the HubStats.class.php: public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."' AND submitdate >= '".$startdate."' AND submitdate =< '".$enddate."'"; $result = DB::get_row($query); return $result->hours; } Quote Link to comment Share on other sites More sharing options...
Taran Posted January 1, 2014 Report Share Posted January 1, 2014 Would you mind posting the code to make all the functions by month? I believe there would be a lot of VA's that could find a use for it Quote Link to comment Share on other sites More sharing options...
Tom Posted January 1, 2014 Author Report Share Posted January 1, 2014 Would you mind posting the code to make all the functions by month? I believe there would be a lot of VA's that could find a use for it Just modify the others using what you've changed with the last one? Quote Link to comment Share on other sites More sharing options...
Taran Posted January 1, 2014 Report Share Posted January 1, 2014 Ok, wow i feel stupid Quote Link to comment Share on other sites More sharing options...
flyalaska Posted January 1, 2014 Report Share Posted January 1, 2014 I am getting a blank return. <?php echo HubStats::TotalHoursBetweenDates(CYQH, date("Y-m-01"), date("Y-m-t"));?> I added the class to my hubstats class Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 1, 2014 Report Share Posted January 1, 2014 ICAO is a string, it should be: <?php echo HubStats::TotalHoursBetweenDates('CYQH', date("Y-m-01"), date("Y-m-t"));?> Quote Link to comment Share on other sites More sharing options...
Taran Posted January 1, 2014 Report Share Posted January 1, 2014 Well, it didn't do the trick... It went to blank once the new month started, but i did a flight to test it, and it's not working. any other tricks up your sleeve? Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 2, 2014 Report Share Posted January 2, 2014 The SQL DATE function is needed. public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) =< '$enddate'"; $result = DB::get_row($query); return $result->hours; } That should be it now Quote Link to comment Share on other sites More sharing options...
Taran Posted January 2, 2014 Report Share Posted January 2, 2014 Still not working on my end :/ If i'm supposed to put something else somewhere please help! Here's what i have: This code is in the HubStats.class.php public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) =< '$enddate'"; $result = DB::get_row($query); return $result->hours; } This is the code i'm using to get the data displayed <?php echo HubStats::TotalHoursBetweenDates('KATL', date("Y-m-01"), date("Y-m-t"));?> Quote Link to comment Share on other sites More sharing options...
Taran Posted January 4, 2014 Report Share Posted January 4, 2014 Still nothing? Anyone? Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 4, 2014 Report Share Posted January 4, 2014 Oops, it was something very minor public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) <= '$enddate'"; $result = DB::get_row($query); return $result->hours; } 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.