TennShadow Posted September 1, 2015 Report Share Posted September 1, 2015 I'm having a weird issue with pilot pay. It's not adding up correctly on the PIREPs. For example, my rank pays $100.00/hr and I flew a 5 hour flight I only got paid $100.00. It doesn't matter if I'm using Smartcars, KACARS custom, or file a manual PIREP. I've recalculated the ranks and have ran the maintenance script but that didn't make any difference. I'm running version 2.1.936. Has anyone seen anything like this and know how to fix it? Quote Link to comment Share on other sites More sharing options...
TennShadow Posted September 2, 2015 Author Report Share Posted September 2, 2015 Any ideas on where to start looking? Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted September 4, 2015 Administrators Report Share Posted September 4, 2015 I am not sure if this file is exactly like what you are running but I am looking at this file from Nabeel's version here -> https://github.com/nshahzad/phpVMS/blob/master/core/common/PIREPData.class.php It looks like the update PIREP function that starts on line 991 never actually calculates the pilot pay, only the pay rate. At line 1012 it gets the pilot data including the pay rate, then on line 1082 it is injected back into the pirep data and is never calculated so it becomes just the base pay rate of the pilot. This is just a quick glance and it is possible it is being calculated somewhere else. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted September 5, 2015 Author Report Share Posted September 5, 2015 I am not sure if this file is exactly like what you are running but I am looking at this file from Nabeel's version here -> https://github.com/n...PData.class.php It looks like the update PIREP function that starts on line 991 never actually calculates the pilot pay, only the pay rate. At line 1012 it gets the pilot data including the pay rate, then on line 1082 it is injected back into the pirep data and is never calculated so it becomes just the base pay rate of the pilot. This is just a quick glance and it is possible it is being calculated somewhere else. Interesting - Thanks for that Simpilot. Since we don't really use vCash I've never noticed if it actually worked or not. Do you know if the beta version or your version has this corrected? Quote Link to comment Share on other sites More sharing options...
TennShadow Posted October 27, 2015 Author Report Share Posted October 27, 2015 Is there a version of PHPVMS that this is fixed in? Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 27, 2015 Moderators Report Share Posted October 27, 2015 You can create a function to get the pay rate from PIREPS and multiply it by the hours of the PREP and update the pilot pay in pilots table then call the function in pilot profile giving it the pilot ID. I think this is much faster solution than actually fixing the bug. I can write the code for it if you want. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted October 27, 2015 Author Report Share Posted October 27, 2015 You can create a function to get the pay rate from PIREPS and multiply it by the hours of the PREP and update the pilot pay in pilots table then call the function in pilot profile giving it the pilot ID. I think this is much faster solution than actually fixing the bug. I can write the code for it if you want. Thank you for the offer. I would love to have this working as I have plans for the vCash in the future. How much do you want to create this function? Thanks, Keith Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 28, 2015 Moderators Report Share Posted October 28, 2015 Thank you for the offer. I would love to have this working as I have plans for the vCash in the future. How much do you want to create this function? Thanks, Keith Absolutely nothing! 1 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 28, 2015 Moderators Report Share Posted October 28, 2015 Put this in any class file like OperationsData at the end: public static function pilot_pay($pilotid) { #Get the flight time from last submitted pirep by the pilot $ft = "SELECT flighttime FROM phpvms_pireps WHERE pilotid = '$pilotid' ORDER BY submitdate DESC"; $flttme = DB::get_row($ft); #Extract the hour from it $hr = intval($flttme->flighttime); #Now the minutes $mn = ($flttme->flighttime - $hr) * 100; #Put everything together as minutes $min = ($hr * 60) + $mn; #How much the pilotpay is $fr = "SELECT pilotpay FROM phpvms_pireps WHERE pilotid = '$pilotid' ORDER BY submitdate DESC"; $payrate = DB::get_row($fr); #pilot pay per minute $pay = $payrate->pilotpay / 60; #We need total money for the pilot $pp = "SELECT totalpay FROM phpvms_pilots WHERE pilotid = '$pilotid'"; $ppay = DB::get_row($pp); $pipay = $payrate->totalpay; #Multiply it by the minutes $ftupdt = $min * $pay; #Add it to pilot money $ttalpay = $ftupdt + $pipay; $totalpay = ROUND($ttalpay, 2); #Update the table $updt = "UPDATE phpvms_pilots SET totalpay = '$totalpay' + totalpay WHERE pilotid = '$pilotid'"; DB::query($updt); } Then call it like this: OperationsData::pilot_pay(Auth::$userinfo->pilotid); Remember if you call the function inside pilot profile, pilotpay column will get updated with the last pirep submitted on each page load, so I suggest u call it inside filereport function and as soon as you hit the accept button it will update the profile. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted October 29, 2015 Author Report Share Posted October 29, 2015 Thanks for this. I tried it out and it works. The only issue I'm having is it doesn't add up correctly. For example, my current rank pay is $100.00 per hour. I submitted a 1 hours flight and I was paid $200.00. I tried to look at the math in the function but wasn't able to get it to add up correctly when I tried. I opened up PIREPAdmin.php and added that function into the below functions. public function approveall protected function approve_pirep_post I've attached it to this post. Could you look it over to see if everything looks good where I added it? Everything seems to be working fine other than the doubling of money. Thanks again for this! PIREPAdmin.php Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 29, 2015 Moderators Report Share Posted October 29, 2015 I see that you've added the call inside the foreach loop with a counter. Try calling it out side the loop. I have tested the function and it worked correctly on my side. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted October 30, 2015 Author Report Share Posted October 30, 2015 I see that you've added the call inside the foreach loop with a counter. Try calling it out side the loop. I have tested the function and it worked correctly on my side. Thanks - that did it. I appreciate all your help in this. Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 31, 2015 Moderators Report Share Posted October 31, 2015 Absolutely. Glad I could help. Cheers Quote Link to comment Share on other sites More sharing options...
KenG Posted October 20, 2016 Report Share Posted October 20, 2016 I hate to narcopost, but can you tell me which lines you ended up putting this into. I tried this myself as I am having the same problem in phpvms 5.5.2 and would like to get this to properly pay crew by the hour. Quote Link to comment Share on other sites More sharing options...
web541 Posted October 20, 2016 Report Share Posted October 20, 2016 (edited) Try admin/modules/PIREPAdmin/PIREPAdmin.php And add it On line 39 after the } On line 301 after the # Update Pilot Stats # Add correct pay for the pilot OperationsData::pilot_pay(Auth::$userinfo->pilotid); And make sure you add the code above from parkho into your core/common/OperationsData.class.php Edited October 22, 2016 by web541 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted October 22, 2016 Moderators Report Share Posted October 22, 2016 Bare in mind that this works on phpVMS 2.1 (nabeels version). phpVMS 5.5 (simpilots version) uses LedgerData.class.php to keep track of all the payments of the system. If the payment does not get added into the ledger database table of the system, it will be lost on the next recalculation. Quote Link to comment Share on other sites More sharing options...
KenG Posted October 22, 2016 Report Share Posted October 22, 2016 OK, thank you. I am using 5.5.2 so that must be the reason I am unable to get it to work correctly and the line numbers that Web541 gave do not seem to match up. -Ken Quote Link to comment Share on other sites More sharing options...
web541 Posted October 22, 2016 Report Share Posted October 22, 2016 OK, thank you. I am using 5.5.2 so that must be the reason I am unable to get it to work correctly and the line numbers that Web541 gave do not seem to match up. -Ken lol, managed to give you the line numbers from the version above without thinking. Try admin/modules/PIREPAdmin/PIREPAdmin.php And add it On line 151 after the } On line 318 after the StatsData::UpdateTotalHours(); # Add correct pay for the pilot OperationsData::pilot_pay(Auth::$userinfo->pilotid); Be mindful though (as stated above by servetas) that you will have to include reference in the code to add the data to the Ledger table in your database. If the above doesn't work however, you may want to try this (just having a quick look) Go to core/common/PIREPData.class.php On line 998 after the $payment_type = PILOT_PAY_HOURLY; Add this $p = PilotData::getPilotData($pirep->pilotid); $peices = explode(':', $pirep->flighttime_stamp); $minutes = ($peices[0] * 60) + $peices[1]; $pilot->payrate = $minutes * ($p->payrate / 60); If that doesn't work, move it below this on line 1010 $revenue = self::getPIREPRevenue($data, $payment_type); That should theoretically recalculate the pay to what it should be. Prior to this, it would have only been setting the pay to the pilot's payrate. Though the calculation for pilot pay is in numerous different places so you may have to update a few more things, but as far as I'm aware, this is the main change. 1 Quote Link to comment Share on other sites More sharing options...
KenG Posted October 24, 2016 Report Share Posted October 24, 2016 Thank you, that seems to have worked. Quote Link to comment Share on other sites More sharing options...
Moderators shakamonkey88 Posted January 3, 2018 Moderators Report Share Posted January 3, 2018 Gah, I have this issue and am stuggling to add it to the correct line. Anyone shed any light? My admin/modules/PIREPAdmin/PIREPAdmin.php seems to not line up with the above answers. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 3, 2018 Report Share Posted January 3, 2018 18 minutes ago, shakamonkey88 said: Gah, I have this issue and am stuggling to add it to the correct line. Anyone shed any light? My admin/modules/PIREPAdmin/PIREPAdmin.php seems to not line up with the above answers. Are you using 5.5.x? If so, check here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/PIREPAdmin/PIREPAdmin.php#L136 and here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/PIREPAdmin/PIREPAdmin.php#L304 that should do it Quote Link to comment Share on other sites More sharing options...
Moderators shakamonkey88 Posted January 3, 2018 Moderators Report Share Posted January 3, 2018 2 minutes ago, web541 said: Are you using 5.5.x? If so, check here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/PIREPAdmin/PIREPAdmin.php#L136 and here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/PIREPAdmin/PIREPAdmin.php#L304 that should do it Thanks buddy. Do I just need to add this? # Add correct pay for the pilot OperationsData::pilot_pay(Auth::$userinfo->pilotid); Quote Link to comment Share on other sites More sharing options...
web541 Posted January 3, 2018 Report Share Posted January 3, 2018 1 minute ago, shakamonkey88 said: Thanks buddy. Do I just need to add this? # Add correct pay for the pilot OperationsData::pilot_pay(Auth::$userinfo->pilotid); Yep, have you added the pilot_pay function to the OperationsData.class.php file? Quote Link to comment Share on other sites More sharing options...
Moderators shakamonkey88 Posted January 3, 2018 Moderators Report Share Posted January 3, 2018 1 hour ago, web541 said: Yep, have you added the pilot_pay function to the OperationsData.class.php file? Yes, I've added it right at the bottom. edit: It is writing to the phpvms_ledger tables correctly. But none of that seems to be used/shown on the site edit2: Unless I just call the pilot pay for the PIREP directly from the ledger table? Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 4, 2018 Moderators Report Share Posted January 4, 2018 7 hours ago, shakamonkey88 said: Yes, I've added it right at the bottom. edit: It is writing to the phpvms_ledger tables correctly. But none of that seems to be used/shown on the site edit2: Unless I just call the pilot pay for the PIREP directly from the ledger table? I would trigger the function on page load to see if it's working properly. Quote Link to comment Share on other sites More sharing options...
FDC001 Posted August 15, 2019 Report Share Posted August 15, 2019 Can you be more specific on how to do this on the ledger? I have 5.5.2 and the adminpirep and operations from above not making it work. Thanks, Tim Quote Link to comment Share on other sites More sharing options...
FDC001 Posted August 17, 2019 Report Share Posted August 17, 2019 Nevermind. It works with scheduled flights but i'm assuming it does not with charter (non-scheduled) flights. Quote Link to comment Share on other sites More sharing options...
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.