Jump to content

Recommended Posts

Posted

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?

  • Administrators
Posted

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.

Posted

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?

  • 1 month later...
  • Moderators
Posted

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

Posted

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

  • Moderators
Posted

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! ;)

  • Like 1
  • Moderators
Posted

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.

Posted

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

  • Moderators
Posted

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.

Posted

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.

  • 11 months later...
Posted

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.

Posted (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 by web541
  • Moderators
Posted

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.

Posted

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

Posted

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.

  • Like 1
  • 1 year later...
Posted
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

  • Moderators
Posted
2 minutes ago, web541 said:

Thanks buddy. Do I just need to add this?

# Add correct pay for the pilot
OperationsData::pilot_pay(Auth::$userinfo->pilotid);

 

Posted

 

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?

  • Moderators
Posted
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?

  • Moderators
Posted
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.

  • 1 year later...

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