Jump to content

Recommended Posts

  • Moderators
Posted

Here is another small add-on for those who want to show pilot's financial reports. It's based on pilot id, so the results are for each of you pilots.Cheers ;)

Install

1. Download the zip from repo.

2. Unzip and upload in the order of folders.

3. Access financial report for a pilot by

<?php echo url('/pfinance') ;?>

-----------------OR----------------------

Access financial report for all pilots by

<?php echo url('/pfinance/pilots') ;?>

4. Enjoy.

Download:PilotFinancialReport_V1.0

Screenshot for a pilot report:

PF1.png

Screenshot for all pilots report:

PF2.png

Change Log:

1. PilotFinance.class.php & pilots_finance.tpl have been added. Those of you who have downloaded this before should re-download.

  • Like 2
Posted

hi parkho

i have this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 12

€ 0.00


  • Your total flight fuel expenses in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 18
    € 0.00
  • Your total in flight expenses in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 24
    € 0.00
  • Your total flight revenue in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 31

  • Moderators
Posted

hi parkho

i have this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 12

€ 0.00


  • Your total flight fuel expenses in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 18
    € 0.00
  • Your total in flight expenses in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 24
    € 0.00
  • Your total flight revenue in Italiani Volanti is:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_finance.tpl on line 31

Are you using any shared server for your site? Cause I think that's where the problem lies not sure though. It's working just fine on this side. ;)

Posted

Don't forget, if you named your database to have something OTHER than "phpvms_pireps" you will get the mysql errors. Change those lines in your "PilotFinance.class.php" to indicate your database ie "nameofdata_pireps"; whatever yours is.

  • Moderators
Posted

Okay. One thing is to check your phpvms table prefix in your DB. If your DB prefix for tables is not phpvms then that's where the problem is. ;)

Posted

i would like to point out the reason some may get a sql_assoc() error is due to your pirep tables not being EXACTLY phpvms_pireps. if it is not exactly that then it will throw some errors at you. so double check your table names.

Guest lorathon
Posted

Just glancing through this.

The queries should be using the TABLE_PREFIX variable that is part of phpVMS. Then all of the MySQL DB errors regarding not finding tables would disappear. Also the queries should be using the API of phpVMS not mysql_fetch_assoc()

IMHO

Data should be returned not echoed - allows you to use it in different ways not just displaying it.

Plus the Auth::$pilotid should be in the module not the class. This allows you to use the same function to get data on another pilot. They way it is written it will ONLY return data on the pilot displaying the page.

I personally would format the data on the template not inside of the class. (FinanceData::FormatMoney)

One other item to note. The query will sum the totals of all pireps. Including rejected ones. I would include a filter in the where for only the accepted pireps.

Example

public function fuelsum($pilotid) {
$qry = 'SELECT SUM(fuelprice) AS total FROM '.TABLE_PREFIX.'pireps WHERE pilotid='.$pilotid.' AND accepted=1';
$row = DB::get_row($sql);
return $row->total;
}

  • 1 month later...
Posted

How would I show ALL reports for ALL pilots with this code edited for that??

<?php
$pilotid = Auth::$userinfo->pilotid;
$reps = PIREPData::getLastReports($pilotid, 5);
?>

<table class="balancesheet" width="50%">
<tr class="balancesheet_header">
<td colspan="5">Last 5 Flights</td>
</tr>
<tr>
<td align="center"><strong>Flight #</strong></td>
<td align="center"><strong>Duration</strong></td>
<td align="center"><strong>Pilot Pay</strong></td>
<td align="center"><strong>Revenue</strong></td>
<td align="center"><strong>Status</strong></td>
</tr>
<?php
if(!$reps)
{
?>
<tr><td align="center" colspan="4">No Flights</td></tr>
<?php
}
else
{
$i = 1;
foreach($reps as $rep)
{

?>

Guest
This topic is now closed to further replies.
×
×
  • Create New...