I'm creating a fillable PDF, to be used as a timesheet. This document will allow employees to document their hours worked daily (or vacation time taken, comp time taken, etc.). I have several columns, but the three most important ones for this are "Hours worked, Regular OT, and Comp OT".
In our department, employees don't hit overtime until they've worked 43 hours. Once they hit 43 hours, and time over that can be taken as Regular OT (paid to them at 1.5 time), or Comp OT (added to their compensatory time bank at a rate of 1.5).
Here's what I want the form to do, if possible. As an employee is entering their daily hours, I want the form to calculate the hours from the previous days, and include the current day. If their hours are over 43, I want the form to prompt the user, asking them if they'd like the overage of hours to go into the Regular OT column or the Comp OT column.
Thanks in advance!
So you didn't mention the most difficult part of this process, which is what happens after the user decides where the OT hours go. Is the excess automatically pushed off into the selected column?
Creating the solution as you've discribed requires some advanced scripting skills. A much easier solution is to put radio buttons over each column (Regular OT and Comp OT). The user then selects where the extra hours go.
Thank you for the reply! Yes, the excess amount would be put into the column that the user decides.
I assumed it was probably a fairly intricate script but, was hoping maybe someone had done something similar and might have the script they used on hand.
So, if I were to use the radio buttons, would that then force any amount over 43 (in the regular time column) into the other selected column? I'm trying to "dummy proof" this thing! lol
The answer is, it's whatever you design the form and script to do. You have a wide range of possibilities. If there are multiple lines, then you could have radio button on each line, or they could be at the top of the colum and used for every line. I don't know how the fields are named on this form, but say they are
For the hours fields on the first Row: "Row1.HoursRegOT" and "Row1.HoursCompOT"
and the radio button is named: "Row1.OTSelect" with export values of "Reg" and "Comp"
Then the calculation on the "HoursWorked" field would include this code at the end of the calculation script:
if(event.value > 43)
var overHours = 43 - event.value;
if(this.getField("Row1.OTSelect").value == "Comp")
this.getField("Row1.HoursCompOT").value = overHours;
this.getField("Row1.HoursRegOT").value = overHours;
Also, if there are multiple lines, I would make the calculation a document level function, and generate the field names so it would work for every line.
You can find out everything you ever wanted to know about PDF form calculations here:
Thanks!! I'll try that and see what I can accomplish.
Yeah, I have checked out the pdfscripting website but, $149 is a little steep for a guy that will most likely rarely use JS for anything else. I have been using codeademy to try and learn some coding though!
I have limited coding experience but, I pick up on stuff fairly fast by looking at examples.
Get the O'Reilly book