Moderators Parkho Posted September 16, 2012 Moderators Report Share Posted September 16, 2012 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: Screenshot for all pilots report: Change Log: 1. PilotFinance.class.php & pilots_finance.tpl have been added. Those of you who have downloaded this before should re-download. 2 Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 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 Link to comment Share on other sites More sharing options...
Moderators servetas Posted September 16, 2012 Moderators Report Share Posted September 16, 2012 Screenshot? Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 attach photos Link to comment Share on other sites More sharing options...
Moderators servetas Posted September 16, 2012 Moderators Report Share Posted September 16, 2012 I was talking about the general screen shot of the module in order to preview it... Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Report Share Posted September 16, 2012 Great Work, Parkho I made some adjustments Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Report Share Posted September 16, 2012 Mattia you touched on some of the files line by disponibilziados Parkho? Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 16, 2012 Author Moderators Report Share Posted September 16, 2012 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. Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Report Share Posted September 16, 2012 Parkho, seems to be a permission problem, what do you think? Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 16, 2012 Author Moderators Report Share Posted September 16, 2012 I was talking about the general screen shot of the module in order to preview it... Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 i copy the file in my site but dont work Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 16, 2012 Author Moderators Report Share Posted September 16, 2012 i copy the file in my site but dont work Strange! did you copy the .tpl in templates or your skin folder? Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 yes, pilot_finance.tpl in templates folder and Pfinance folder in modules folder Link to comment Share on other sites More sharing options...
SparrowBD Posted September 17, 2012 Report Share Posted September 17, 2012 im getting that mysql error as well. one thing you should be able to do maybe in a future update is allow admins to view all the pilots profitability. Link to comment Share on other sites More sharing options...
Fly Star Alliance Posted September 17, 2012 Report Share Posted September 17, 2012 Same here, MySql error 1 Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 17, 2012 Author Moderators Report Share Posted September 17, 2012 I think it's fixed 1 Link to comment Share on other sites More sharing options...
Fly Star Alliance Posted September 17, 2012 Report Share Posted September 17, 2012 Better now, thanks Parkho, although I still have a couple of little problems to solve.... Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 17, 2012 Author Moderators Report Share Posted September 17, 2012 I edited the .tpl as well, have you replaced that too? Link to comment Share on other sites More sharing options...
CPC900 Posted September 17, 2012 Report Share Posted September 17, 2012 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. Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 17, 2012 Author Moderators Report Share Posted September 17, 2012 Good point. Thanks Link to comment Share on other sites More sharing options...
Stealthbird97 Posted September 17, 2012 Report Share Posted September 17, 2012 Well Its pointless saying that you've fixed it when you don't tell us what we need to change to fix the sql problem. Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 17, 2012 Author Moderators Report Share Posted September 17, 2012 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. Link to comment Share on other sites More sharing options...
mattia Posted September 17, 2012 Report Share Posted September 17, 2012 now work for me thanks Link to comment Share on other sites More sharing options...
SparrowBD Posted September 17, 2012 Report Share Posted September 17, 2012 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. Link to comment Share on other sites More sharing options...
Guest lorathon Posted September 17, 2012 Report Share Posted September 17, 2012 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; } Link to comment Share on other sites More sharing options...
Fly Star Alliance Posted September 18, 2012 Report Share Posted September 18, 2012 God I wish I had Jeff's programming knowledge.... When something doesn't work I'm simply lost without help. Anyway, table wise, mines are default phpvms and therefore not the problem. Hope to get some more suggestions...... Link to comment Share on other sites More sharing options...
CPC900 Posted October 20, 2012 Report Share Posted October 20, 2012 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) { ?> Link to comment Share on other sites More sharing options...
CPC900 Posted October 22, 2012 Report Share Posted October 22, 2012 BUMP Link to comment Share on other sites More sharing options...
Kalo Posted October 24, 2012 Report Share Posted October 24, 2012 I would love to see CPC900's suggestion also. Is there a way to show every pilots stats along with their earnings? When you click "Pilots" it only shows how many flights and how many hours...it would be great to beable to categorize the list by people with the most hours. I would also like that page to show pilot finances. Look at my page for an example: http://www.msflights.net/pilots/phpvms/index.php/pilots Link to comment Share on other sites More sharing options...
CPC900 Posted October 25, 2012 Report Share Posted October 25, 2012 I wanted code so I could see what flights were losing money for all pilots, not just my own flights. Link to comment Share on other sites More sharing options...
Recommended Posts