chilemugriento Posted July 28, 2014 Report Posted July 28, 2014 Wrote a script to get VA total flights current month This for StatsData.class /** * Return the number of flights current month * * @return int Total number of flights * */ public static function Totalflightscurrentmonth($airline_code='') { $key = 'total_flights_month'; if($airline_code != '') { $key .= '_'.$airline_code; } $total = CodonCache::read($key); if($total === false) { $sql = 'SELECT COUNT(*) AS `total` FROM '.TABLE_PREFIX.'pireps p WHERE month(p.submitdate) = month(now()) AND year(p.submitdate) = year(now())'; $result = DB::get_row($sql); if(!$result) { $total = 0; } else { $total = $result->total; } CodonCache::write($key, $total, '15minute'); } return $total; } and this for Index.tpl from vStatsCenter <?php echo StatsData::Totalflightscurrentmonth(); ?> And working fine :) but want to show Total Flights This Month for each pilot, in pilots_list.tpl <?php echo StatsData::Totalflightscurrentmonth()($pilot->pilotid) ?> but had an error Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/surair/public_html/phpvms/core/templates/pilots_list.tpl on line 72 Any help would be appreciated Best regards. Quote
Members Vangelis Posted July 28, 2014 Members Report Posted July 28, 2014 You have an excess character or you havent closed the line with ; in line 72 of your pilots_list.tpl and also the proper way to use a function is FunctionClass::FunctionName(any nececary info like pilot id); in your case it should be <?php echo StatsData::Totalflightscurrentmonth($pilot->pilotid); ?> every line in php except some spesial cases HAVE to end with ; Quote
chilemugriento Posted July 28, 2014 Author Report Posted July 28, 2014 Hi Vangelis, Thanks for reply. Error in line 72 gone, but still not working, because displays VA Total Flights this month, not per pilot. Take a look from General Statistics and Pilot´s Stats : http://www.surair.co...p/vStatsCenter/ (first table, last column) http://www.surair.co...ndex.php/pilots (last column) (had same value as above) Quote
Members Vangelis Posted July 28, 2014 Members Report Posted July 28, 2014 with the query that you have provided you ask for statistics per months to be honest i dont undertand what exacly are you trying to achieve if you can please describe it Quote
chilemugriento Posted July 28, 2014 Author Report Posted July 28, 2014 We offer awards if pilots reach 15 flights per month in 3 consecutive months http://www.surair.com.mx/pilotos/salon If we can acces to that info, issue wil be simple. Thanks. Quote
Strider Posted July 28, 2014 Report Posted July 28, 2014 You need to add the pilot id into the sql, otherwise it is doing nothing with the pilot id. The where clause has to be ammended. I am working on it, not found the code that works yet. 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.