phpvms / phpvms_v2

Virtual Airline Management (not maintained)
http://www.phpvms.net
BSD 3-Clause "New" or "Revised" License
41 stars 46 forks source link

Error With Total Time Stat for Aircraft #48

Closed twincessna340a closed 13 years ago

twincessna340a commented 13 years ago

<?php foreach ($fleet as $aircraft) { ?> <?php echo $aircraft->totaltime; ?>

Ex. 58.54 returns 34:48

nabeelio commented 13 years ago

Where is this and from what function?

twincessna340a commented 13 years ago

Totally forgot this was an addon....I'll move it back to the forums.

nabeelio commented 13 years ago

Well it could be getting data from a StatsData function, so could be an API issue, I will check it out too

twincessna340a commented 13 years ago

Ok, it is from AFVA | Mitchell's Fleet Table Addon. I have the latest version (v2.0)

nabeelio commented 13 years ago

Do you know which function he is calling to set the $fleet variable? I don't have his code

twincessna340a commented 13 years ago

$fleet = self::FleetInfo()

public static function FleetInfo() { $sql = 'SELECT a._, a.name AS aircraft, COUNT(p.pirepid) AS routesflown, SUM(p.distance) AS distance, SEC_TO_TIME(SUM(p.flighttime_60*60)) AS totaltime, AVG(p.distance) AS averagedistance, AVG(p.flighttime) as averagetime FROM '.TABLE_PREFIX.'aircraft a LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id) GROUP BY a.registration';

        return DB::get_results($sql);
        DB::debug();
        return $ret;

    }
twincessna340a commented 13 years ago

Changed "SEC_TO_TIME(SUM(p.flighttime_60_60))" to "SEC_TO_TIME(SUM(TIME_TO_SEC(p.flighttime_stamp)))" as currently coded in StatsData (beta 152) and it works 100%.