orobouros Posted August 10, 2019 Report Posted August 10, 2019 (edited) 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 August 10, 2019 by orobouros Quote
Yash Posted August 11, 2019 Report Posted August 11, 2019 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? Quote
orobouros Posted August 11, 2019 Author Report Posted August 11, 2019 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. Quote
Yash Posted August 11, 2019 Report Posted August 11, 2019 (edited) See my reply in next post. This was by mistake.. Edited August 11, 2019 by Yash Quote
Yash Posted August 11, 2019 Report Posted August 11, 2019 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! Quote
orobouros Posted August 11, 2019 Author Report Posted August 11, 2019 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 Quote
Yash Posted August 11, 2019 Report Posted August 11, 2019 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); } Quote
orobouros Posted August 11, 2019 Author Report Posted August 11, 2019 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). Quote
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.