overtime and break time added to timesheet script

I am working on a fillable Timesheet for use on IOS or PC and I am hoping that one of you experts might be able to help as I am having difficulties finishing this script here is a link to the file I am working on if you want to look at it https://www.dropbox.com/s/0sxdlmfjvax...

So far the RegTime.1(decimal number) field is calculating time ok but I need to incorporate the following

1) I Have a variable field called RegHours that defaults to 8. if this field has 8 then anything over will go to another field OverTime.1

2) I also have a decimal number field called BreakTime.1 that needs to be deducted from the total

3) one other thing is that if I go past midnight my total goes to negative number. I'm just wondering if a simple solution to this would be to add 24 if the result is less than 0

//RegTime.1 Field Calculation Script

var cIn = "StartTime.1", cOut = "StopTime.1";

event.value = TimeDiff("HH:MM", cIn, cOut);

// convert zero entry to null

if(event.value == 0) event.value = "";

//OverTime.1 Field Calculation Script

not written yet

Any help you can give will be greatly appreciated

Greg


Greg Nygren


4 Answers

Voted Best Answer

I did take a quick look at your PDF file.

I assume you don't want RegHours to default to 8 hours, it should be the result of the calculation if that result is 8 hours or below, and it should be 8 hours if it is above 8 hours. The overtime field should in that case be the difference between the calculated time and 8 hours.

As far as the breaktime goes, you can just subtract it from the calculated number of hours.

The reason you are ending up with negative numbers is that you are using minute values - so if somebody works over midnight, you are subtracting a large number from a small number. Because your form does not allow somebody to work across two midnights, you can just add 24 to the result if you end up with a negative value.

I made a few more changes to your form, so that you can use the same calculation script for every result field (it determines which row it is in automatically). Take a look at http://www.khkonsulting.com/files/TimesheetFillable.pdf for more details.

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


By Karl Heinz Kremer   

Thanks Karl. that is exactly what i have been trying to do for several days. you are awesome. very much appreciated


Greg Nygren   

Hi Karl. what you wrote is amazing I cant believe how quick you did that. The RegHours is a single field at the top of the timesheet that I would like the user to be able to change becasuse sometimes they work 4 10 hour days so the 8 RegHours would chang to 10 in the RegHours field or sometimes they just get paid straight time for all hours. I tried to modify the script to make it work so I wouldnt have to bother you but was unable to get the sytax correct.

another question for you regading copying fields. it was very clever how you setup the script to recognize the lines.that was a big bonus. what is the best way to copy fields to populate the sheet. I usually do the multiple copy option or control drag, then go back and rename the fields and fix the scripts as needed.

thanks againg for your help it is definately appreciated


Greg Nygren   

Can you tell me how you got your RegTime.1 to calculate to a decimal number?

Thanks in advance


Gail Musolino   


Please specify a reason: