• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Daily Time Sheet

New Here ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Hi, I have created a daily time sheet, The column with the time entered for each task is totaled at the bottom in box A (Total Hours). We are now required to pay overtime if the person works over their daily shift hours. Sometimes the shift may be 10 hours or 8 hours.

Is there a way to create a box with the daily hours (target hours). When the entered time totals less than the target, put total in box A, if the total exceeds the target hours, those hours over the target are put in box B (Overtime hours). Example would be: John's shift is 10 hours today, he enters 10 in the target box. He works through the day and at the end of his shift the total amount of hours he worked is 12 hours. Box A shows 10 Hours and Box B shows 2 hours.

Any help would be appreciated. Thanks.

TOPICS
Acrobat SDK and JavaScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 27, 2018 Feb 27, 2018

That said, a simple solution requires calculation scripts in three fields

First add a hidden total field and add a calculation to total the hours. You need that because both of the other fields rely on a total. This puts it in one place.

On the regularhours calculation.

var nTotal = this.getField("TotalHours").value;

var nShift = this.getField("ShiftHours").value;

if(nTotal > nShift)

   event.value =  nShift;

else

   event.value = nTotal;

Script for OvertimeHours calculation

var nTotal = this.getField("To

...

Votes

Translate

Translate
Community Expert ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Absolutely this is possible to do. You just need to get familiar with time and date calculations.

Here are some old articles on the topic:

https://acrobatusers.com/tutorials/date_time_part1

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-2

https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3

I've written more about it on this subscription site, which also includes a time sheet example with overtime calculations.

Date and Time Handling - Information and Scripts(Script pages at bottom)

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Thanks for your reply Thom. I don't have a lot of experience with

JavaScript, just a novice. The time that the person enters is just basic

math, the hour is divided into 4, 15 minute units so if they worked on a

project for 2 hours and 45 minutes they would enter 2.75 hours for that

project. They aren't required to enter the start and finish time. Thanks.

On Tue, Feb 27, 2018 at 11:57 AM, Thom Parker <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

That's quite easily done.

Let's say the fields are named TotalHours, NormalHours and Overtime.

As the custom calculation script of NormalHours enter this:

var v = Number(this.getField("TotalHours").valueAsString);

event.value = Math.min(10, v);

And as the custom calculation script of Overtime enter this:

var v = Number(this.getField("TotalHours").valueAsString);

event.value = Math.max(0, v-10);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Hi,

My form, as it is right now, has 16 boxes for time entry with a box at the

bottom saying Total Hours.

What I would like is a box at the top, ShiftHours, that the person working

will enter at the beginning of their shift. This could be any quantity

between 0 hours to 12 hour. 0 hours would relate to the whole day being

overtime.

I think this is what I need translated to JavaScript.

If the sum of boxes T1, T2, T3, …. T16 is less than ShiftHours then put the

sum in RegularHours.

If the sum of boxes T1, T2, T3, …. T16 is greater than ShiftHours then put

the sum, minus ShiftHours, in OvertimeHours and the quantity in ShiftHours

in RegularHours.

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

That's quite a lot of ask for in a single question. We can help you with specific scripting/form issues, but we can't provide you with a complete solution to you form, unless of course you'd like to hire us to do that.

So, please break your project down into specific, single task issues, then we'll be able to provide some help. And to do this, you will of course need to learn some scripting.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

That said, a simple solution requires calculation scripts in three fields

First add a hidden total field and add a calculation to total the hours. You need that because both of the other fields rely on a total. This puts it in one place.

On the regularhours calculation.

var nTotal = this.getField("TotalHours").value;

var nShift = this.getField("ShiftHours").value;

if(nTotal > nShift)

   event.value =  nShift;

else

   event.value = nTotal;

Script for OvertimeHours calculation

var nTotal = this.getField("TotalHours").value;

var nShift = this.getField("ShiftHours").value;

if(nTotal > nShift)

   event.value =  nTotal - nShift;

else

   event.value = 0;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

I appreciate the help, now I’ll see if I can get it to work. I do have a

work around, I can just create a second column for overtime hours, it’s not

as elegant but should work. Thanks for your help.

On Tue, Feb 27, 2018 at 2:14 PM, Thom Parker <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Works perfect, just what I wanted. Thank you very much.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2024 May 03, 2024

Copy link to clipboard

Copied

LATEST

Hello, thank you for the information.  I am not sure what I did wrong but I am very confused.  Is it possible to show what this looks like in the Text Field Properties or give me a reference where I can find this information without the line breaks?

JoLynn

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines