Home      KBase      Ask a Question      My Stuff      Help   
  
SUPPORT: SCRIPTING: Majority of shift
CRC

To change the shift times, just change the variables of $shift1Start, $shift2Start, $shift3Start to the corresponding times.
This script also requires 3 hidden numeric prompts for tracking total shift time.

// SplitScript
if(istimes){
$inDateString = cstr(cdate(indt));
$outDateString = cstr(cdate(outdt));
$shift1Start = " 07:00:00";
$shift2Start = " 15:00:00";
$shift3Start = " 23:00:00";
$shift1StartIn = cdatetime($inDateString + $shift1Start);
$shift2StartIn = cdatetime($inDateString + $shift2Start);
$shift3StartIn = cdatetime($inDateString + $shift3Start);
$shift1StartOut = cdatetime($outDateString + $shift1Start);
$shift2StartOut = cdatetime($outDateString + $shift2Start);
$shift3StartOut = cdatetime($outDateString + $shift3Start);
if(outtime < ctime($shift1StartOut)){
$shift3StartOut = $shift3StartIn;
}

if(indt >= $shift1StartIn and indt < $shift2StartIn && outdt <= $shift2StartOut and outdt > $shift1StartOut){
shift1 = hours;
} else if(indt >= $shift2StartIn and indt < $shift3StartIn && outdt <= $shift3StartOut and outdt > $shift2StartOut){
shift2 = hours;
} else if((indt >= $shift3StartIn or indt < $shift1StartIn) && (outdt <= $shift1StartOut or outdt > $shift3StartOut)){
shift3 = hours;
} else if(indt < $shift1StartIn && outdt <= $shift2StartOut){
shift1 = val(outdt - $shift1StartOut) * 24;
shift3 = val($shift1StartIn - indt) * 24;
} else if(indt < $shift2StartIn and indt >= $shift1StartIn && outdt <= $shift3StartOut){
shift1 = val($shift2StartIn - indt) * 24;
shift2 = val(outdt - $shift2StartOut) * 24;
} else if(indt < $shift3StartIn and indt >= $shift2StartIn && (outdt <= $shift1StartOut or outdt >= $shift3StartOut)){
shift2 = val($shift3StartIn - indt) * 24;
shift3 = val(outdt - $shift3StartIn) * 24;
} else if(indt < $shift1StartIn && outdt <= $shift3StartOut){
shift1 = 8;
shift2 = val(outdt - $shift2StartOut) * 24;
shift3 = val($shift1StartIn - indt) * 24;
} else if(indt < $shift2StartIn && (outdt <= $shift1StartOut or outdt > $shift3StartOut)){
shift1 = val($shift2StartIn - indt) * 24;
shift2 = 8;
shift3 = val(outdt - $shift3StartIn);
} else if(indt < $shift3StartIn && outdt <= $shift2StartOut and outtime < intime){
shift1 = val(outdt - $shift1StartOut);
shift2 = val($shift3StartIn - indt) * 24;
shift3 = 8;
}
}
shift1 = round(val(shift1), 2);
shift2 = round(val(shift2), 2);
shift3 = round(val(shift3), 2);

// PayRateScript
if(istimes and otcategory <> ""){
$totalShift1Hrs = reportingdate.totalday("shift1");
$totalShift2Hrs = reportingdate.totalday("shift2");
$totalShift3Hrs = reportingdate.totalday("shift3");
if($totalShift1Hrs >= $totalShift2Hrs && $totalShift1Hrs >= $totalShift3Hrs){
category = "1st Shift";
} else if($totalShift2Hrs >= $totalShift1Hrs && $totalShift2Hrs >= $totalShift3Hrs){
category = "2nd Shift";
} else{
category = "3rd Shift";
}
}
ID
1887
Category
>Support
  Scripting
Date Created
7/31/2017 9:07:21 AM
Date Updated
8/25/2017 11:26:23 AM
Was this information helpful?
 
Back to Search Results