Jump to content
orobouros

Count only scheduled flights for finance module

Recommended Posts

Hello,

 

In the finance module, it's the total of flights by month wich is mentionned (scheduled flgihts + free flights). But i want to have just scheduled flights to have the right number. How can i do this please ?

Actually it's like this (here $month->total return all the flights.) :

<td align="center">
     <?php  
         echo $month->total;
	?>
</td>

 

i try this without success :

<td align="center">
    <?php
        $scheduledFlights="SELECT COUNT(pirepid) as totalflights FROM phpvms_pireps WHERE month(submitdate)=".$month->ym." and (code='xxx')";
        $resultScheduledFlights=DB::get_results($scheduledFlights);
        $totalScheduledFlights=$resultScheduledFlights[0]->totalflights;
        echo $totalScheduledFlights;
	?>
</td>

 

Regards

Edited by orobouros

Share this post


Link to post
Share on other sites

 

6 hours ago, orobouros said:

Hello,

 

In the finance module, it's the total of flights by month wich is mentionned (scheduled flgihts + free flights). But i want to have just scheduled flights to have the right number. How can i do this please ?

Actually it's like this (here $month->total return all the flights.) :


<td align="center">
     <?php  
         echo $month->total;
	?>
</td>

 

i try this without success :


<td align="center">
    <?php
        $scheduledFlights="SELECT COUNT(pirepid) as totalflights FROM phpvms_pireps WHERE month(submitdate)=".$month->ym." and (code='xxx')";
        $resultScheduledFlights=DB::get_results($scheduledFlights);
        $totalScheduledFlights=$resultScheduledFlights[0]->totalflights;
        echo $totalScheduledFlights;
	?>
</td>

 

Regards

 

Which ACARS are you using?

Share this post


Link to post
Share on other sites

I use a personnal ACARS, created only for my company. But I don't see the relationship between ACARS and finance. In my opinion, it's only a problem of database request and PHP.

Share this post


Link to post
Share on other sites
1 hour ago, orobouros said:

I use a personnal ACARS, created only for my company. But I don't see the relationship between ACARS and finance. In my opinion, it's only a problem of database request and PHP.

 

Here is what you can do:

First of all add a column to pireps table name it 'scheduledflight'

Ask the developer of your ACARS to insert a query which checks that the PIREP Filed by Pilot has the same data as in schedules table that has the same Flight Number, Departure ICAO and Arrival ICAO. If it exists then, it should update the 'scheduledflight' column of that pirep to '1'

Now you need to edit your Finance query like this:
 

$scheduledFlights="SELECT COUNT(pirepid) as totalflights FROM phpvms_pireps WHERE scheduledflight = '1' AND  month(submitdate)=".$month->ym." AND (code='xxx')";

That's it!

Share this post


Link to post
Share on other sites

Thanks, but in my opinion there's no need to add column. code='xxx' is already used to check scheduled flight.

When i test my request in PHPMyAdmin with values instead of $month->ym (ex: month(submitdate)=3) i have the good result. It's this code wich is wrong, and i don't know how do this

Share this post


Link to post
Share on other sites

Alternative way:

First of all add a column to pireps table name it scheduledflight 


In your PIREPData.class.php, head to line 795 if using default file, you'll see self::$pirepid = $pirepid;

Now below it, add this code
 

$checkschedflight = "SELECT * FROM " . TABLE_PREFIX . "schedules WHERE depicao = {$pirepdata['depicao']} AND arricao = {$pirepdata['arricao']} AND flightnum = {$pirepdata['flightnum']}";
        $res= DB::get_results($checkschedflight);

        if(count($res) > 0){
            $issched = "UPDATE " . TABLE_PREFIX . "pireps SET scheduledflight = '1' WHERE pirepid = '$pirepid' ";
            DB::query($issched);
        }

 

Share this post


Link to post
Share on other sites

With the solution of adding a column, i loose all stats before today. The goal is to have all the scheduled flights to have finance sheets for all months since creation of the phpvms website (2016).

Share this post


Link to post
Share on other sites

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...