Hours This Month

HI

I want Add Total Hours This Month and Total Flight This Month in profile_main ( Pilot Center) !

I added some code in StatsData , but doesn’t work!! 

I have problem with date filter …

Finlay I used this code directly in profile_main

$dateFilter = date("Y-m-d", mktime(0,0,0,date("m"),date("d")-30,date("Y")));
$toDay = date("Y-m-d");
$datecondition = "where FlightDate BETWEEN '".$dateFilter."' AND '".$toDay."'";

For total hours in a month, you can do:

$hours = PIREPData::getIntervalDataByMonth(array(), 1);
echo $hours->total;

For total flights:

$flights = PIREPData::findFlights(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));

$total = count($flights);
1 Like

Thank you Nabeel .

Those codes doesn’t work for me .

can anybody help me!

What happens? Need some more info

$flights = PIREPData::findFlights(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));

$total = count($flights);

changed to

$flights = PIREPData::findPIREPS(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));
$total = count($flights);

and

<?php
$hours = PIREPData::getIntervalDataByMonth(array(), 1);
echo $hours->total;
?>

I added those code in Pilot center , but doesn’t work . and no value show in pilot center .

If you add a DB::debug() after them, like:

DB::debug();

What does that show?

1 Like

HI

<?php
$flights = PIREPData::findPIREPS(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));
$total = count($flights);
echo $total;
?>

that code for Flight This Month work , now show all pireps, but i want show Flight This Month for accepted pireps .

and for Hours This Month :

<?php
$hours = PIREPData::getIntervalDataByMonth(array(), 1);
echo $hours->total;
DB::debug();
?>

doesn’t work .

and how can I use those codes in Pilot center and pilot public profile ?

HI

<?php $flights = PIREPData::findPIREPS(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate')); $total = count($flights); echo $total; ?>

This code for Flight This Month work , But i want show Flight This Month for accepted pireps , now show all pireps .

and for Hours This Month :

<?php $hours = PIREPData::getIntervalDataByMonth(array(), 1); echo $hours->total; DB::debug(); ?>

doesn’t work .

It’ll show some debug output on the screen. What is that?

for second code nothing show on screen , but first code fully work .

can anybody help me!

Hours This Month doesn’t work .

how can i use those codes in pilot center and pilot public profile .

After

$flights = PIREPData::findPIREPS(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));
DB::debug();

Add that DB::debug(); What does the output say?

$hours = PIREPData::getIntervalDataByMonth(array(), 1);
echo $hours->total;
DB::debug();
?>

that code is correct ?

if correct , Not shown anything .

Flight Hours this Month:

Hours This Month:

ezDB (v3.00) Debug..

Query [10] – [sELECT DATE_FORMAT(p.submitdate, ‘%Y-%m’) AS ym, UNIX_TIMESTAMP(p.submitdate) AS timestamp, COUNT(p.pirepid) AS total, SUM(p.revenue) as revenue, SUM(p.gross) as gross, SUM(p.fuelprice) as fuelprice, SUM(p.price) as price, SUM(p.expenses) as expenses, (SUM(p.pilotpay) * SUM(p.flighttime)) as pilotpay FROM phpvms_pireps p WHERE DATE_SUB(NOW(), INTERVAL 1 MONTH) <= p.submitdate GROUP BY ym ORDER BY timestamp ASC]

Query Result..

(row) string 0

ym int 0

timestamp int 0

total real 0

revenue real 0

gross real 0

fuelprice real 0

price real 0

expenses real 0

pilotpay

No Results

So that says there were no PIREPs since it returns empty

Flight Hours This Month:

<?php
$hours = PIREPData::getIntervalDataByMonth(array(), 1);
echo $hours->total;
DB::debug();
?>

ezDB (v3.00) Debug..

Query [12] -- [sELECT * FROM phpvms_expenselog WHERE `dateadded`=201003]

Query Result..

   (row)	int 0
   dateadded	string 0
   name	string 0
   type	real 0
   cost
   No Results

I have 6 PIREPs for this Month .

Flight This Month: 6

I’ll look

Hi Nabeel

Did you find any solution for Flight Hours This Month ?

please check this code .

$pireps = PIREPData::findPIREPS(array('DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= p.submitdate'));

	$thismonth = 0;
	foreach($pireps as $pirep)
	{
		$thismonth = $pirep->flighttime;
	}

	echo $thismonth;