Jump to content

ProAvia

Administrators
  • Posts

    1648
  • Joined

  • Last visited

  • Days Won

    72

Posts posted by ProAvia

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

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

  3. Thanks, I'll definitely look into it after I resolve my Pilot Pay issue ( https://forum.phpvms.net/topic/24313-flight-time-separator/ ) - I've been getting some excellent help from web541 in correcting that issue and am almost there. Pagination is the next thing on the list. Now to find the time to complete it all.

    I will post back when I find the magic combination. I certainly hope at least basic pagination is included with version 3.

     

  4. I don't know if this is related or not - or even if it's an issue with the processing elsewhere ... line 825 in the original PIREPData.class.php file

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

    I think that statement basically replaces the ' : ' with a ' , ' . Should the 'comma' in -  str_replace(':', ',', $pirepdata be a 'period' instead str_replace(':', '.', $pirepdata

    Seems it's replacing the colon with a comma instead of replacing the colon with a period. I did try changing it and the results I'm seeing didn't change at all.

    ____________________

    I believe my issue is that, when computing revenue, the pilotpay is getting the payrate from the pilot or ranks tables instead of pilotpay from the pireps table. And if I change the pilotpay when editing the PIREP, the new pilotpay isn't taken into account - because it's using pilotpay from $pilot->payrate. But I don't know what to change or where to change it.

  5. What version of phpVMS are you using - 2.1.x or 5.5.x? If the later, change the .tpl to .php in the core_htmlhead file name above and see if that helps.

    If that doesn't work, maybe posting the contents of your layout.php or template_start.php would help someone diagnose the issue.

  6. That corrected the SAVE issue. PayChecker results remained exactly the same. In Admin PayChecker, it's now subtracting pilotpay (based on rank $$ amount only) in PIREP Revenue. So it's subtracting pilotpay now - but the pilotpay based on rank, not the $$/hour I changed it to in EDIT.

    Database shows pilotpay = 60, revenue = 16616.6 - the revenue is based on pilotpay = 40, not pilotpay = 60.

    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, 616.60

    If I input a different Pilot Pay while editing the PIREP in admin, it doesn't take the new rate into account when recalculating.

    34800 - 18022.70 - 16536.30 = 241.00 = 4:01 @ $60/hour = 241 minutes * (60 / 60) = Actual Revenue

    34800 - 18022.70 - 16616.60 = 160.70 = 4:01 @ $40/hour = 241 minutes * (40 / 60) = PIREP Revenue

    No rush - whenever you have a chance to look it over. Always appreciate your help and insight!

     

  7. I messed with the width and was able to set it to 100% and to 80% with no change in the button display. Then I went to datatables.net and started playing around with their download options. I am using a NON-bootstrap skin - and I think that may have been part of my issue.

    I changed this: <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css"/>

    To this: <link rel="stylesheet"String type="text/css"String href="https://cdn.datatables.net/v/dt/jq-2.2.4/dt-1.10.13/b-1.2.4/datatables.min.css"String/>

    And now, while I still have the words at the bottom, they run horizontally rather than vertically.

    Here's the line right after closing script </script>:  <table id="schedules" class="table" width="80%" align="center"> ---- aligns table center @ 80% width, which looks better then aligned left @ full width on my particular template.

    I'll be playing around with the other options at datatables.net to see if I can get the buttons to show.

  8. Update:

    Adding in the last code seems to fix it once you Accept PIREP from the Edit page - except if you change the pilot's pay rate using the Edit function. This is with a PIREP submitted and accepted AFTER the file changes. Ledger table shows correct pilotpay - as it did before. Still need to check PIREPS submitted prior to file changes - if I edit and accept again.

    Additionally, using the Save PIREP option does not change revenue to correct amount. This is with a newly submitted PIREP or one submitted before the file changes.

    Same flight - only difference was initial pilotpay @ $40/hr. Prior to accepting PIREP, changed pilot pay to $60/hr. PayChecker gave following results.

     

    PIREPData => CalculatePIREPPayment

    
    241

    This amount equals the entry in the Ledger table


    PilotData => resetPilotPay

    
    1348.99

    Haven't checked this yet


    Current Pilot's Payrate (per hour)

    
    40

    This is the pay based on pilot's rank


    New Algorithm Using Decimal Form

    
    160.666666667

    This is the pay based on rank times hours.minutes


    New Algorithm Using Flight Stamp Form

    
    160.666666667

    This is pay based on rank time hours:minutes


    What you are getting now (I think)

    
    160.4

    This is what I was getting before the file changes

    Revenue For This PIREP

    
    16616.6333333

    This is the correct revenue - based on pay by rank

    4.01 = 4 hours 1 minute = 241 minutes

    __________________________________________________________________

    ($60/hr / 60) * 241 = $241

    ($40/hr / 60) * 241 = $160.666666667 

    As you can see, revenue is now taking pilotpay into account. But, if you change pilotpay via admin PIREP edit, it doesn't apply the new pilotpay to the calculation. DB shows pilotpay = 60, revenue  = 16777.3 

    Here's the Admin Paychecker, Check PIREPS, View PIREPS for the same pirep id.

    
    #ID    DepICAO ArrICAO A/C            Flighttime Date Submitted Status    Last PIREP Pay Last PIREP Real Pay
    FA1038 KMDW    KLAS    B737-800 (N138FA) 4.01     01/30/2017    Accepted  $ 241.00       $ 160.67
    
    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, 777.30
    

    Actual Revenue is correct and calculated on pilotpay $60/hr.

    PIREP Revenue is NOT taking ANY pilotpay into account.

    I think the mud is turning into quicksand! :wacko:

  9. The pic was using 'FrontSchedules'. But i checked via 'schedules' and it is full width, with the same issues mentioned.

    Thanks for the reply! I will have a closer look tomorrow and try your suggestions. Worst case, I try it on a new install with all default files and default skin.

    EDIT: In thinking about it a bit more, both FrontSchedules and schedules uses the same template file to display the search results. I wonder why schedules displays full width and FrontSchedules doesn't.

  10. I believe I am using CDN scripts - just not sure I have all the ones I need. Besides the 2 calls shown in the file contents, are there others I need? Not using a bootstrap skin. The Show and Search boxes don't line up horizontally either.

    Schedules_zps3efrw9nh.jpg

    Contents of schedule_results.php

    <?php if(!defined('IN_PHPVMS') && IN_PHPVMS !== true) { die(); } ?>
    <?php
    if(!$schedule_list)
    {
    	echo '<p align="center">No routes have been found!</p>';
    	return;
    }
    ?>
    <!-- <table id="tabledlist" class="tablesorter"> -->
    
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css"/>
     <script type="text/javascript" src="https://cdn.datatables.net/v/bs/jq-2.2.3/dt-1.10.12/datatables.min.js"></script> 
    
    <script type="text/javascript">
     $(document).ready(function() {
     $('#schedules').dataTable({
       "sPaginationType": "full_numbers",
       "lengthMenu": [ [5, 10, 20, 50, -1], [5, 10, 20, 50, "All"] ]
     });
     });
     </script>
     <table id="schedules" class="table"> 
    
    
    <thead>
    <tr>
    	<th>Flight Info</th>
    	<th>Options</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach($schedule_list as $schedule) { ?>
    <tr>
    	<td>
    		<a href="<?php echo url('/schedules/details/'.$schedule->id);?>"><?php echo $schedule->code . $schedule->flightnum?>
    			<?php echo '('.$schedule->depicao.' - '.$schedule->arricao.')'?>
    		</a>
    		<br />
    		
    		<strong>Departure: </strong><?php echo $schedule->deptime;?> &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>Arrival: </strong><?php echo $schedule->arrtime;?><br />
    		<strong>Equipment: </strong><?php echo $schedule->aircraft; ?> (<?php echo $schedule->registration;?>)  <strong>Distance: </strong><?php echo round($schedule->distance . Config::Get('UNITS'), 1);?>
    		<br />
    		<strong>Days Flown: </strong><?php echo Util::GetDaysCompact($schedule->daysofweek); ?><br />
    		<?php echo ($schedule->route=='') ? '' : '<strong>Route: </strong>'.$schedule->route.'<br />' ?>
    		<?php echo ($schedule->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($schedule->notes).'<br />' ?>
    		<?php
    		# Note: this will only show if the above code to
    		#	skip the schedule is commented out
    		if($schedule->bidid != 0) {
    			echo 'This route has been bid on';
    		}
    		?>
    	</td>
    	<td nowrap>
    		<a href="<?php echo url('/schedules/details/'.$schedule->id);?>">View Details</a><br />
    		<a href="<?php echo url('/schedules/brief/'.$schedule->id);?>">Pilot Brief</a><br />
    		
    		<?php 
    		# Don't allow overlapping bids and a bid exists
    		if(Config::Get('DISABLE_SCHED_ON_BID') == true && $schedule->bidid != 0) {
    		?>
    			<a id="<?php echo $schedule->id; ?>" class="addbid" 
    				href="<?php echo actionurl('/schedules/addbid/?id='.$schedule->id);?>">Add to Bid</a>
    		<?php
    		} else {
    			if(Auth::LoggedIn()) {
    			 ?>
    				<a id="<?php echo $schedule->id; ?>" class="addbid" 
    					href="<?php echo url('/schedules/addbid');?>">Add to Bid</a>
    			<?php			 
    			}
    		}		
    		?>
    	</td>
    </tr>
    <?php
     /* END OF ONE TABLE ROW */
    }
    ?>
    </tbody>
    </table>
    <hr>

    Thanks!

  11. That code works great! And I just started reading about all the options that are available.

    I have the code working in Schedules and View PIREPS. One issue I'm having is the placement of the First, Previous, Next, Last and page selection numbers. Right now they show in a vertical column on the lower right side of each paginated page. Is there a way to move them and possible style them into buttons?

    Thanks!

  12. On ‎1‎/‎25‎/‎2017 at 11:47 PM, web541 said:

    I did narrow the potential cause of this issue, if you file a PIREP, the edit you did to the PIREPData.class.php a few posts back would have worked, but only until you accepted the PIREP (not even rejected, just accepted), and then I narrowed it down to the PIREPData.class.php line where it recalculates the payment, but I still don't know where it's overriding the revenue.

    And leave the first edit in or put it back to original? (see first edit below)

    Quote

    Go to PIREPData.class.php line 1042 and between the if statement (the one with if($payment_type == PILOT_PAY_HOURLY) {) on it replace it's content with this

    
    $pilot = PilotData::getPilotData($data['pilotid']); # Get the pilot info for payrate in case pay field is changed later
    $flighttime = explode('.', $data['flighttime']); # split the flighttime into two parts
    $flighttime_min = ($flighttime[0] * 60) + ($flighttime[1]); # Calculate no. minutes
    $pilotpay = ($pilot->payrate / 60) * $flighttime_min; # Finalise the payment
    
    // This was the original
    // Only multiplies payrate (pay field) by the flight time without taking into account the minutes / 60 but min. / 100
    # $pilotpay = $data['pilotpay'] * $data['flighttime'];

     

  13. On ‎1‎/‎25‎/‎2017 at 8:28 PM, web541 said:
    On ‎1‎/‎25‎/‎2017 at 8:16 PM, ProAvia said:

    I'm referring to a number such as 50.40 being displayed as 50.4 - it's dropping the zero after the .4 - like Excel does in a cell if you don't have it set to use two decimal places. I guess 'float' might drop trailing zeros.

    I just tested it and you were right, entered a 5.10 value into phpmyadmin and it rejected the 0, but I'm not sure it's because it's a float value.

    I just tested this - in a DB table 'Type' column

    1. if set to FLOAT it drops any trailing zeros (floating-point)
    2. if set to DECIMAL and Length/Values is set to x,2 (where 'x' is a number of how many digits to left of '.' and '2' is how many digits to right of '.' you want to display) it will display 2 decimal places to the right of '.' (fixed-point). Note: there is a comma ( , ) between the two numbers in Lengths/Values. You can display more than two decimal places if desired.

    It's also explained in more detail in the MySQL documentation.

    This may be something that can be incorporated in version 3 to better display any DB entries that have to do with money (at least for those of us who use it that way). Guess there may be instances in some countries where a single decimal place works with their currency.

  14. 21 minutes ago, web541 said:

    16, 777.30 - 241 (pilotpay) = 16, 536.30 <= check that to see if it's correct

    Yup - correct!

    Confirm with another 3 PIREPS

    'Reset 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.30 

    So the pay isn't being subtracted "somewhere" to give the correct 'revenue' - if I understand you correctly. And 'Reset Revenue' only did the calc internally and didn't seem to change anything in the DB.

    I'm done for tonight - but tomorrow, I can easily blow the DB out and set it back to where it was before messing with PayChecker and Reset Revenue if needed. Computer is going off now - but will be on tablet to check forum. No, I won't even attempt to mess with the site files/DB from the tablet cause I'll fat finger something and mess it all up. :P:blink:

    Thanks again!

  15. It shows his Last PIREP Pay = $241.00, Last PIREP Real Pay = $241.00

    Viewing the particular PIREP in question

    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, 777.30

    Why the discrepancy between the last two entries?

  16. PayChecker Pilot Side

    PIREPData => CalculatePIREPPayment
    241
    
    PilotData => resetPilotPay
    11254.50
    
    Current Pilot's Payrate (per hour)
    60
    
    New Algorithm Using Decimal Form
    241
    
    New Algorithm Using Flight Stamp Form
    241
    
    What you are getting now (I think)
    240.6
    
    Revenue For This PIREP
    16536.3
    

    PayChecker Admin Side

    PIREPData => CalculatePIREPPayment
    241
    
    PilotData => resetPilotPay
    11254.50
    
    Current Pilot's Payrate (per hour)
    60
    
    New Algorithm Using Decimal Form
    241
    
    New Algorithm Using Flight Stamp Form
    241
    
    What you are getting now (I think)
    240.6
    
    Revenue For This PIREP
    16536.3
    

     

    1 hour ago, web541 said:

    then go to "View PIREPS for pilot..." and check the values of the Revenue Column. That will calculate it internally (real) but also calculate it again (PIREP) using values from the DB and see if it's missing anything.

    In admin, and view that particular pilot's pireps??? (.../admin/index.php/pilotadmin/viewpilots?action=viewoptions&pilotid=22) --- there is no revenue column. If I choose edit, it shows 'Total Revenue for flight' of 16777.30 . Adding 'Total Revenue for fligh't and 'Total fuel cost', it equals 'Gross Revenue'. 16777.30+18022.70=34800.00

    While the pilotpay is showing in the ledger table (as amount), it's not being subtracted from revenue.

    This is after the pirep has been accepted. I even clicked EDIT and SUBMIT again to see if that changed anything. I'm going to look in PIREPData.class.php again and make sure I have that correct.

    EDIT: I didn't try the Reset Revenue or Reset Pay + Revenue, only the Go!..... with the correct pirepid

  17. 2 hours ago, ProAvia said:

    This was a new manual PIREP - submitted and processed/accepted after the edit using same data at PIREP above (flight time, load, fuelused, fuelprice, price, pilotpay/hr)

    1. Before accepting pirep
      1. admin - revenue = -18923.90 / fuel = 18923.90 --- fuel equals revenue, no pilotpay at all (but fuel price is incorrect for 0.68/# * 26504#)
      2. viewreport - revenue = -18923.90 / fuel = 18022.70 --- fuel price is correct, no idea where the 901.20 diff comes from
    2. After accepting pirep
      1. admin DETAILS - revenue = 16777.30 / fuel = 26504# used / gross = 34800.00
      2. admin EDIT - revenue = 16777.30 / fuel = 18022.70 / gross = 16777.30 --- fuel correct --- see note about admin skin above
      3. viewreport - revenue = 16777.30 / fuel = 18022.70 / gross = 34800.00 --- fuel correct
      4. gross - fuel = revenue --- doesn't subtract pilotpay at all (difference in #2 and #3 gross is admin skin)
      5. in ledger table - amount = 241.00 --- this is pilotpay(flighttime_stamp)

    In 1.1 above - admin - the fuelprice shows as 18923.90, it should be 18022.70 based on fuelused and fuelunitcost.

    I figured out why it's showing a different fuelprice. It uses the FUEL_DEFAULT_PRICE times FUEL_SURCHARGE.

    1. FUEL_DEFAULT_PRICE (set in local.config) = fuelunitcost --- I think this is fuel price at a hub airport maybe
    2. FUEL_SURCHARGE (set in local.config) = percent surcharge added to FUEL_DEFAULT_PRICE
    3. Proof - my prices/percentage --- fuelunitprice = 0.68 / surcharge = 5% --- makes fuel price 0.741 ---- 0.741 * 26504# = 18923.856 --- rounded to 18923.9
    4. After the pirep is edited and/or accepted, it uses the 0.68 fuelunitcost. This particular flight was from a hub airport - I need time to check what happens from a non-hub airport.

    Yeah - it's not subtracting the pilotpay. And I'd like it to subtract pilotpay(flighttime_stamp) instead of the original pilotpay(flighttime).

    I'll install the updated PayChecker and report back shortly.

  18.  

     

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

    Ah ok, yeah I saw that, but I guess it's another phpVMS encounter when they call it "Gross Revenue" :)

    Nothing like trying to confuse me more.:unsure:  Gross Revenue = gross --- Net Revenue = revenue

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

    Yeah, I think that it only recalculates the revenue for PIREPS that are filed after the change as there isn't a recalculation once accepted, but my "Recalculate Revenue" script should hopefully fix the revenue on the PIREPS which were filed before this change.

    I think it will recalculate IF you choose to edit a specific pirep.

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

    As stated above, your fix will only apply to the PIREPS submitted after the edit has been made.

    But as it is now, it's not calculating and/or subtracting pilotpay at all. Shouldn't the edit account for pilotpay - hopefully pilotpay(flighttime_stamp) ??

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

    I believe this is calculating the Gross Revenue using the algorithm below (in the admin panel fix section of this post)

    load * price = gross --- how many pax times the amount per pax

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

    And on the page, it clearly states

    
    Change the load and price variables above to adjust this value.

    I think that means if you want a higher gross, then change the load and/or price to a higher number.

    On ‎1‎/‎25‎/‎2017 at 7:34 PM, web541 said:

     

    On ‎1‎/‎25‎/‎2017 at 6:30 PM, ProAvia said:

    So both pireps show the same - whether submitted before or after the edit. Both were processed/accepted after the edit. Does the single decimal place have to do with table Structure being 'float' and that item having a trailing zero? And why the differences in revenue & fuelprice in various areas?

    Not sure which 'single decimal place' or 'trailing zero' you are talking about (please confirm), but it shouldn't have anything to do with the structure being 'float' as 'float' allows the database to hold x amount of integers between a range, and they are able to be a negative number. The differences between the revenue values were hopefully explained above, but the fuelprice intrigues me as it should only be pulling the one value out of the DB. And for the revenue not subtracting the pilot pay, I'll have a look for you, but it seems to work fine on my end.

    I'm referring to a number such as 50.40 being displayed as 50.4 - it's dropping the zero after the .4 - like Excel does in a cell if you don't have it set to use two decimal places. I guess 'float' might drop trailing zeros.

    The fuelprice is an odd one. And while the ledger 'amount' for pilotpay is correct, the pireps table and/or the calculations isn't taking it into account. It's all as clear as mud!! LOL

    So, what do you want me to try next?

×
×
  • Create New...