Home      Ask a Question      My Stuff      Help   
  
TimeWorks Plus: Scripting Overtime Alert
Question
ID
848
Category
<Unassigned>
Date Created
2/19/2013 3:35:11 PM
Date Updated
12/18/2014 10:23:28 AM
Is there a way for me to see what time an employee will hit overtime?
Answer
Yes, there is a script that you can put in the PayRateScript Rule under processing rules that will show an alert on the time card for what time the employee will hit overtime.

The following script checks to see if they hit 30 hours, then calculates the time they will hit overtime:

$OThours = 30; //Enter hours in a week for OT

if(istimes){
    if(reportingdate.hourstodateot >= val($OThours) and reportingdate.hourstodateot < 40 and outismissing){
        $difference = 40 - reportingdate.hourstodateot;
        $newtime = cstr(dateadd("h", $difference, intime));
        if(len($newtime) > 5){
                $newtime = left($newtime,5);
        }
        $hour = left($newtime,2);
        
        if(right($hour,1) != ":"){
            if(cint($hour) >= 13 and cint($hour) < 24){
                $hour = cint($hour) - 12;
                $newtime = right($newtime,3);
                $newtime = cstr($hour) + left($newtime,3) + " pm";
            }
            else if(cint($hour) >= 24){
                if(cint($hour) = 24){
                    $hour = cint($hour) - 12;
                }
                else
                    $hour = cint($hour) - 24;
                $newtime = right($newtime,3);
                $newtime = cstr($hour) + left($newtime,3) + " am";
            }
            else if(cint($hour) <= 12){
                $newtime = left($newtime,5);
                if(cint($hour) < 12){
                    $newtime = $newtime + " am";
                }
                else{
                    $newtime = $newtime + " pm";
                }
            }
        }
        else{
            $newtime = left($newtime,4);
            if(left($newtime,1) = "0"){
                $newtime = cstr(12) + right($newtime,3) + " am";
            }
            else{
                $newtime = $newtime + " am";
            }
        }
        addalert("Employee will hit overtime at " + $newtime);
    }
}

Here is what it looks like on the time card:


Back to Search Results