Jump to content

Flight Time Separator [SOLVED]


ProAvia

Recommended Posts

  • Administrators

Your last isn't passing the pilotpay to the ledger table as I believe it needs $amount instead of $pilotpay at start of this line

$pilotpay = ($pirep->pilotpay / 60) * $flighttime_min; # Finalise the payment

I changed $pilotpay to $amount without success.

___________________________________________________

Just cause I had nothing better to do :huh: ...., I decided to review the original PIREPData.class.php file again. I ran a new PIREP through using that file, went to admin Edit and Save and as expected the revenue number was incorrect.  Then I changed the comma in line 825 to a period.

From this

$pirepdata['flighttime'] = str_replace(':', ',', $pirepdata['flighttime']);

To this

$pirepdata['flighttime'] = str_replace(':', '.', $pirepdata['flighttime']);

Ran another new PIREP through using the edited file (comma to period was only edit), went to admin Edit and Save, checked PayChecker and it seems the results in ledger->amount are correct --- and pirep->revenue (PIREP Revenue in PayChecker) is within $0.40 of Actual Revenue in PayChecker.

I went back and edited the PENDING pirep to change the pilotpay and Save -- ledger->amount and pirep->pilotpay updated accordingly, and revenue changed to reflect new amounts. Then went back and edited an older APPROVED pirep - same results.

Only discrepancy is Last PIREP Pay and Last PIREP Real Pay. But I think PayChecker is taking the pilotpay rate based on rank (????) for Last PIREP RealPay.

Last PIREP Pay   Last PIREP Real Pay   Status
0.00             160.67                New Pirep PENDING - no Edit - pilotpay @ $40/hour
241.00           160.67                New Pirep PENDING - Edit and Save - pilotpay @ $60/hour
241.00           160.67                Old Pirep APPROVED - Edit and Save - pilotpay @ $60/hour

Revenue
PIREP Gross:      34800
Actual Gross:     34800
Expenses:             0
Fuel Price:     $ 18, 022.70
Pilot Pay:      $ 241.00
Actual Revenue: $ 16, 536.30
PIREP Revenue:  $ 16, 536.70

The overall function where the edit is located is public static function updateFlightReport ... , starting on line 807.

Still need to do more testing - maybe tomorrow to see if the above holds true.

Edited by ProAvia
Link to comment
Share on other sites

Uh, yeah. PayChecker was taking the pilot's payrate out of it, check the github link again and there should be another indication on the paychecker page called the "Final Revenue" calculated using the PIREP table's pilotpay instead of the pilot's payrate (or in some cases, the value from the ledger table).

Also, what other issues are there currently, has the internal ones been fixed and it's only the PayChecker? It's getting confusing with so many posts lol.

Btw, the Paychecker only calculates it on the page, so trust the PIREP Revenue for the moment. If everything else is good, then let us know.

 

Edited by web541
Link to comment
Share on other sites

4 hours ago, ProAvia said:

 

Your last isn't passing the pilotpay to the ledger table as I believe it needs $amount instead of $pilotpay at start of this line


$pilotpay = ($pirep->pilotpay / 60) * $flighttime_min; # Finalise the payment

I changed $pilotpay to $amount without success.

 

It should be pulling the data from the pireps table as this is the table you are using when you edit the payrate in the "Edit PIREP" section, or am I mistaken? I haven't touched anything to do with the Ledger table, I don't think.

Edited by web541
Link to comment
Share on other sites

  • Administrators
18 hours ago, web541 said:

It's getting confusing with so many posts lol.

OK, Captain Obvious! LOL - You should be looking at it from my side. I had re-read the entire thread just before doing your last edit, cause I was so confused.

I'm still crunching some numbers and will report back with details soon. Basically in the original (default) PIREPData.class.php file that comes with version 5.5.2 - I did this as the only edit

Line 825 in default PIREPData.class.php - the one you suggested I leave alone....

From this

$pirepdata['flighttime'] = str_replace(':', ',', $pirepdata['flighttime']);

To this

$pirepdata['flighttime'] = str_replace(':', '.', $pirepdata['flighttime']);

That pretty much fixed the major issue I was seeing. It's in the 'updateFlightReport' section. As to why it helped, I haven't a clue.

The only thing I'm seeing now is the flighttime (not flighttime_stamp - or flighttime converted to hours:minutes) is still being used when computing pilotpay that is used in the revenue calculation. I need to track if it's only after initial pirp submittal or if it's after an admin uses Edit and Save.The ledger table isn't even populated until an admin takes an action on the submitted PIREP (Accept or Save, I think).

As to not passing pilotpay to the ledger table as 'amount' - I think that occurred in your last edit. But it's a non-issue now as I think most of the issue was the comma vs period in link 825 of the original file. As I said, I need to do more testing and document exactly what I'm seeing before we go further - at least I think that might be best for now.

Thanks! - I'll post here after I test and document the findings.

Link to comment
Share on other sites

  • Administrators

I think I may have figured it out.

Attached is my current PIREPData.class.php file and the original file as supplied with phpVMS 5.5.2 (PIREPData.class.php.ORIG) for your reference. All line references are to my current file.

  1. updateFlightReport - starts line 805, see lines 829-834
    1. formats $flighttime_stamp and $pirepdata['flighttime'] correctly - regardless if initial flighttime contains a period or colon. In a manual PIREP submittal, the hours and minutes can be separated by a colon, a period, no separator, etc. - based on user input.
    2. used your initial edit (maybe on page one of this thread)
      1. commented out $pilot = PilotData::getPilotData($data['pilotid']); - as I don't think it's needed. And, if I edit a PIREP after a pilot's rank/pay changes, I don't know whether this line would change the pilotpay to the new rate.
      2. change 'explode' and calculate lines from $flighttime to $peices. I had changed this earlier in my latest testing to see if it changed anything, which it did not. But left it as $peices anyway.
    3. changed $pilot->payrate to $data['pilotpay'] to reflect $data array. Just a lucky guess, as I was trying all kinds other stuff here too.
  2. getPIREPRevenue - starts line 1040, see lines 1051-1063
    1. uses $data array and $payment_type - so I tried using $data['flighttime'] and $data['pilotpay'] for the pay calculation. This was after many failed attempts using other parameters - which resulted in the pay being passed as 0 to the $revenue calculation on line 1069 (I think).
  3. calculatePIREPayment - starts line 1260
    1. calculates $amount and passed to pireps table
    2. left this as original - as it seems to pass the correct data to the ledger table.
  4. A few things I changed/added for my specific operation
    1. changed .tpl to .php - lines 349, 360, 374, 383 - in the FSFlightKeeper section.
    2. added line 633 to display route string in upper case.
    3. changed/added 'Send an email to the admin...' after line 758 for my specific needs. I believe both options can be active at one time, but I want Admins to actually review PIREPs instead of just clicking to approve - at least for now.
    4. added notes so I remember what stuff does and what I did.

In testing, both manual and ACARS PIREPs have been submitted. PIREPs have been viewed, edited, saved and accepted via the admin panel - in various combinations. After a PIREP has been accepted, it's been edited to change the Pilot Pay, saved and/or (re-)accepted. I think I've tried all possible combinations. The revenue and pilotpay appears to compute correctly. The correct $ amount now shows in the pireps table (after save and/or accept).

____________________

PayChecker

  1. Final Revenue (per PIREP Pilotpay) is showing $revenue based on $pirep->pilotpay. The $pirep->pilotpay is the hourly pay (or per schedule pay) from the pireps table, not the actual pay based on $pirep->pilotpay times the flight time (in hours and minutes, not tenths). That section can probably be deleted.
    1. admin/templates/view_pilot_pireps.php - lines 73 and 74.
    2. admin/modules/PayChecker.php - lines 264-286.
  2. Everything else in the PayChecker works as advertised - and was a GREAT help in getting the end result we were after.

____________________

I think I figured out the FUEL_DEFAULT_PRICE and FUEL_SURCHARGE stuff too - but will leave that for another time.

Disclaimer: I really don't have a good handle on php - but I'm learning slowly. A lot of what I tried on my own was trial and error - along with many hours of staring at the computer screen looking for that "something" that would stand out and editing stuff, not knowing what the results would be. Glad I have a working live site and a test site to mess with.

After 60+ posts and a LOT of confusion on my part, I believe it's finally working as it should. If you have the time, please check my work to see if you are getting the same results. After I hear back from you, I'll mark the thread as SOLVED - as least I hope I will.

If all this pans out, maybe it will help with the version 3 development too.

Thank you once again for all your time and effort! I really do appreciate all the advice and hand-holding!

 

PIREPData.class.php.ORIG

PIREPData.class.php

Edited by ProAvia
Link to comment
Share on other sites

Sorry about the delay, been caught up in stuff.

Yeah, I took a look and it seems to work for me (mostly, got to work out my ledger values) so I'd consider this solved for now.

As for v3 development, I don't think it will be this difficult to calculate as everything should be streamlined to the one spot.

As for the help in this topic, not a problem :P

Link to comment
Share on other sites

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