Skip to content

Commit df1c9dc

Browse files
authored
script.js
1 parent 599f55e commit df1c9dc

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

  • Client-Side Components/Client Scripts/Reinstate Error status
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function onSubmit() {
2+
// Cutoff time for submission in CST.
3+
var cutoffTime = "20:00:00";
4+
5+
// Get the current date and time in CST
6+
var currentDate = new Date();
7+
var currentCSTDate = new Date(
8+
currentDate.toLocaleString("en-US", {
9+
timeZone: "America/Chicago"
10+
})
11+
);
12+
13+
// Get time from current CST date
14+
var currentCSTTime = currentCSTDate.toTimeString().substring(0, 8);
15+
16+
// Get last day of the month
17+
var dayOfMonth = currentCSTDate.getDate();
18+
var lastDayOfMonth = new Date(
19+
currentCSTDate.getFullYear(),
20+
currentCSTDate.getMonth() + 1,
21+
0
22+
).getDate();
23+
24+
if ((dayOfMonth === 16 || dayOfMonth === lastDayOfMonth) && currentCSTTime > cutoffTime) {
25+
var workDate = g_form.getValue("work_date");
26+
27+
if (workDate) {
28+
var formattedWorkDate = new Date(workDate + "T00:00:00");
29+
// If work_date is on or before current date, block submission
30+
if (formattedWorkDate <= currentCSTDate) {
31+
g_form.addErrorMessage(
32+
"The time period closed for time submission at 8:00 PM CST. Time must be billed in the next time period." + ": " + lastDayOfMonth
33+
);
34+
return false;
35+
}
36+
}
37+
}
38+
return true;
39+
}

0 commit comments

Comments
 (0)