Nighthawk Posted April 11, 2012 Report Share Posted April 11, 2012 Hi made a little Snippet in /core/templates/schedule_results.tpl It shows like this : Here is the code (Line 14-78 in my code) <tbody> <?php foreach($schedule_list as $schedule) { ?> <tr> <td> <a href="<?php echo url('/schedules/details/'.$schedule->id);?>"><?php echo $schedule->code . $schedule->flightnum?> <?php echo '('.$schedule->depicao.' - '.$schedule->arricao.')'?> </a> <br /> <strong>Departure: </strong><?php echo $schedule->deptime;?> <strong>Arrival: </strong><?php echo $schedule->arrtime;?><br /> <strong>Equipment: </strong><?php echo $schedule->aircraft; ?> (<?php echo $schedule->registration;?>) <strong>Distance: </strong><?php echo $schedule->distance . Config::Get('UNITS');?> <br /> <strong>Days Flown: </strong><?php echo Util::GetDaysCompact($schedule->daysofweek); ?><br /> <?php echo ($schedule->route=='') ? '' : '<strong>Route: </strong>'.$schedule->route.'<br />' ?> <?php echo ($schedule->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($schedule->notes).'<br />' ?> <?php # Note: this will only show if the above code to # skip the schedule is commented out if($schedule->bidid != 0) { echo 'This route has been bid on'; } ?> </br> <?php //Routes Flown $Tesla2=("$schedule->flightnum"); $result2 = mysql_query("SELECT COUNT(*) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows2 = mysql_result($result2,0); ?> Route flown:<?php print "$num_rows2" ?></br> <?php //Average Fuel used $Tesla2=("$schedule->flightnum"); $result3 = mysql_query("SELECT sum(fuelused) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows3 = mysql_result($result3,0); ?> Real Average Fuel used:<?php echo"$num_rows3"/"$num_rows2"?> <?php echo Config::Get('CARGO_UNITS');?></br> <?php //Average Time $result4 = mysql_query("SELECT SUM(flighttime) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows4 = mysql_result($result4,0); $array=explode(".", $num_rows4); $hours2=$array[0]; $min2=$array[1]; $min2calc=(("$hours2"*60)+"$min2"); $min3calc=$min2calc/"$num_rows2"; $hourcalc=$min3calc/60; $hours3=("$hours2"/"$num_rows2"); $hours4=floor($hours3); $Difmin=$min3calc-(("$hours2"/"$num_rows2")*60); $totaltime2=$hours4+("$Difmin"/100); ?> Real Average Flight duration: <?php print $totaltime2;?> hrs </td> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted April 13, 2012 Moderators Report Share Posted April 13, 2012 Doesn't work for me im afraid. Quote Link to comment Share on other sites More sharing options...
mattia Posted April 13, 2012 Report Share Posted April 13, 2012 delete Quote Link to comment Share on other sites More sharing options...
tutmeister Posted April 13, 2012 Report Share Posted April 13, 2012 I got it working for me, but I changed a couple of things. The main reason it didn't work for me was the API hook wasn't schedule->, but route->. This is what I have: //Routes Flown $Tesla2=("$route->flightnum"); $result2 = mysql_query("SELECT COUNT(*) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows2 = mysql_result($result2,0); ?> <b>Route flown:</b><br /><?php echo "$num_rows2" ?> times</br> <?php //Average Fuel used $Tesla2=("$route->flightnum"); $result3 = mysql_query("SELECT sum(fuelused) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows3 = mysql_result($result3,0); ?> <b>Average Fuel consumption:</b><br /> <?php echo round($num_rows3, 0, PHP_ROUND_HALF_UP); ?> <?php echo Config::Get('CARGO_UNITS');?></br> <?php //Average Time $result4 = mysql_query("SELECT SUM(flighttime) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows4 = mysql_result($result4,0); $array=explode(".", $num_rows4); $hours2=$array[0]; $min2=$array[1]; $min2calc=(("$hours2"*60)+"$min2"); $min3calc=$min2calc/"$num_rows2"; $hourcalc=$min3calc/60; $hours3=("$hours2"/"$num_rows2"); $hours4=floor($hours3); $Difmin=$min3calc-(("$hours2"/"$num_rows2")*60); $totaltime2=$hours4+("$Difmin"/100); ?> <b>Average Flight duration:</b><br /> <?php echo round($totaltime2, 2); ?> hrs Used echo round on the results to round results to 2 decimals for duration and to round up to the next whole number for fuel. Quote Link to comment Share on other sites More sharing options...
flyalaska Posted April 14, 2012 Report Share Posted April 14, 2012 I get no errors, but every single schedule shows the same info on routes flown, fuel. duration. Any ideas? Quote Link to comment Share on other sites More sharing options...
mattia Posted April 14, 2012 Report Share Posted April 14, 2012 i have the same error Quote Link to comment Share on other sites More sharing options...
tutmeister Posted April 15, 2012 Report Share Posted April 15, 2012 Have you tried it with my changes above? The default as posted doesn't work for me either, the one I edited does. Quote Link to comment Share on other sites More sharing options...
flyalaska Posted April 15, 2012 Report Share Posted April 15, 2012 Tried that first, got loads of errors. Quote Link to comment Share on other sites More sharing options...
tutmeister Posted April 20, 2012 Report Share Posted April 20, 2012 Tried that first, got loads of errors. For the division by zero errors, add an @ symbol before the calculation to suppress the error as it will go away once the route has been flown once. Like so: $min3calc=@($min2calc/"$num_rows2"); For the round errors, you can either remove the round, like this: <li><b>Average Fuel used:</b> <?php echo round($num_rows3, 0, PHP_ROUND_HALF_UP); ?> <?php echo Config::Get('CARGO_UNITS');?></li> becomes <li><b>Average Fuel used:</b> <?php echo ($num_rows3); ?> <?php echo Config::Get('CARGO_UNITS');?></li> and <li><b>Average Flight time:</b> <?php echo round($totaltime2, 2); ?> hrs</li> becomes <li><b>Average Flight time:</b> <?php echo ($totaltime2); ?> hrs</li> 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.