Jump to content

HubStats Class


Tom

Recommended Posts

Would this be it? I highly doubt it, but it's worth a shot?

public static function TotalCargoBetweenDates($icao, $startdate, $enddate) { //Count total cargo
$query = "SELECT SUM(cargo) 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->cargo;
}

Link to comment
Share on other sites

Would this be it? I highly doubt it, but it's worth a shot?

public static function TotalCargoBetweenDates($icao, $startdate, $enddate) { //Count total cargo
$query = "SELECT SUM(cargo) 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->cargo;
}

I believe the 'load' column is used for both pax and cargo, so you'll need to use the 'flightType' to differentiate between them.

Link to comment
Share on other sites

public static function TotalCargoBetweenDates($icao, $startdate, $enddate) { //Count total cargo
$query = "SELECT SUM(cargo) as cargo FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND flighttype = 'C' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) <= '$enddate'";
$result = DB::get_row($query);
return $result->cargo;
}

Link to comment
Share on other sites

I hate to ask for more, but is there a way to get the data from only ACCEPTED PIREPs and have it ignore the data from rejected PIREPs? right now we have completely delete the rejected pireps for the data to stay correct.

public static function TotalCargoBetweenDates($icao, $startdate, $enddate) { //Count total cargo
$query = "SELECT SUM(cargo) as cargo FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND flighttype = 'C' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) <= '$enddate' AND accepted = '1'";
$result = DB::get_row($query);
return $result->cargo;
}

Link to comment
Share on other sites

  • 2 weeks later...

Ok, it appears that it's not calculating correctly at all by month. It just reduced the numbers but I can't tell exactly what it's calculating. At the start of February UTC time it should have reset to 0 for all, but did not. Any ideas?

What's your code?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

AM I missing something? I have

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;
}

in my HubStats.class

and this on my frontpage_main.php

<?php echo HubStats::TotalHoursBetweenDates('PANC', date("Y-m-01"), date("Y-m-t"));?>

Still getting a blank return.

crew.png

Any help would be appreciated!

Link to comment
Share on other sites

Only thing I can suggest is that you don't have phpvms_ as your table prefix. Other than that, you could always do

$startdate = date("Y-m-01");
$enddate = date("Y-m-t");
HubStats::TotalHoursBetweenDates('PANC', date("Y-m-01"), date("Y-m-t"));

Shouldn't make a difference but give it shot.

EDIT: You might have to set your timezone:

date_default_timezone_set('Europe/London');

Change as necessary of course.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...