Add Employee Recognition feature to notifications system
- Add Recognition notification type (ID 5) with blue color - Add employeesso field to notifications table - Create carousel display for Recognition on shopfloor dashboard - Show employee names (lookup from wjf_employees) instead of SSO - Auto-set starttime to NOW and endtime to 4AM next day - Auto-enable shopfloor display for Recognition type - Add Achievements tab to employee profile (displayprofile.asp) - Hide Recognition from calendar view - Add lookupemployee.asp AJAX endpoint for name preview - Fix datetime double-formatting bug in save/update files - Fix URL parameter loading on shopfloor dashboard init 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,10 @@
|
||||
<!--#include file="./includes/sql.asp"-->
|
||||
<!--#include file="./includes/response.asp"-->
|
||||
<%
|
||||
On Error Resume Next
|
||||
|
||||
' Get form inputs
|
||||
Dim notification, ticketnumber, starttime, endtime, isactive, isshopfloor, notificationtypeid, businessunitid, appid
|
||||
Dim notification, ticketnumber, starttime, endtime, isactive, isshopfloor, notificationtypeid, businessunitid, appid, employeesso
|
||||
notification = Trim(Request.Form("notification"))
|
||||
ticketnumber = Trim(Request.Form("ticketnumber"))
|
||||
starttime = Trim(Request.Form("starttime"))
|
||||
@@ -18,6 +20,10 @@ endtime = Trim(Request.Form("endtime"))
|
||||
notificationtypeid = Trim(Request.Form("notificationtypeid"))
|
||||
businessunitid = Trim(Request.Form("businessunitid"))
|
||||
appid = Trim(Request.Form("appid"))
|
||||
employeesso = Trim(Request.Form("employeesso"))
|
||||
|
||||
' Recognition type ID
|
||||
Const RECOGNITION_TYPE_ID = 5
|
||||
|
||||
' Checkboxes - ensure they are always integers 0 or 1
|
||||
If Request.Form("isactive") = "1" Then
|
||||
@@ -37,10 +43,55 @@ If notificationtypeid = "" Or Not IsNumeric(notificationtypeid) Then
|
||||
notificationtypeid = "1"
|
||||
End If
|
||||
|
||||
' Validate required fields (endtime is now optional)
|
||||
If Len(notification) = 0 Or Len(starttime) = 0 Then
|
||||
' Check for errors so far
|
||||
If Err.Number <> 0 Then
|
||||
objConn.Close
|
||||
ShowError "Required fields missing.", "addnotification.asp"
|
||||
ShowError "Error during initialization: " & Err.Description, "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Handle Recognition type - auto-set times and require employeesso
|
||||
Dim isRecognition
|
||||
isRecognition = (CLng(notificationtypeid) = RECOGNITION_TYPE_ID)
|
||||
|
||||
If isRecognition Then
|
||||
' Validate employeesso is provided for Recognition
|
||||
If Len(employeesso) = 0 Then
|
||||
objConn.Close
|
||||
ShowError "Employee SSO is required for Recognition notifications.", "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Auto-set starttime to NOW
|
||||
starttime = Year(Now) & "-" & Right("0" & Month(Now), 2) & "-" & Right("0" & Day(Now), 2) & " " & _
|
||||
Right("0" & Hour(Now), 2) & ":" & Right("0" & Minute(Now), 2) & ":00"
|
||||
|
||||
' Auto-set endtime to 4AM next day
|
||||
Dim nextDay
|
||||
nextDay = DateAdd("d", 1, Date)
|
||||
endtime = Year(nextDay) & "-" & Right("0" & Month(nextDay), 2) & "-" & Right("0" & Day(nextDay), 2) & " 04:00:00"
|
||||
|
||||
' Auto-enable shopfloor display for Recognition
|
||||
isshopfloor = 1
|
||||
End If
|
||||
|
||||
' Check for errors after Recognition handling
|
||||
If Err.Number <> 0 Then
|
||||
objConn.Close
|
||||
ShowError "Error during Recognition setup: " & Err.Description, "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Validate required fields (endtime is now optional, starttime not required for Recognition)
|
||||
If Len(notification) = 0 Then
|
||||
objConn.Close
|
||||
ShowError "Notification message is required.", "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
If Not isRecognition And Len(starttime) = 0 Then
|
||||
objConn.Close
|
||||
ShowError "Start time is required.", "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -50,8 +101,10 @@ If Len(notification) > 500 Or Len(ticketnumber) > 50 Then
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Convert datetime format for starttime
|
||||
starttime = Replace(starttime, "T", " ") & ":00"
|
||||
' Convert datetime format for starttime (skip if already formatted for Recognition)
|
||||
If InStr(starttime, "T") > 0 Then
|
||||
starttime = Replace(starttime, "T", " ") & ":00"
|
||||
End If
|
||||
|
||||
' Handle optional endtime - leave as NULL if blank (indefinite)
|
||||
Dim endtimeValue, businessunitValue
|
||||
@@ -59,8 +112,10 @@ If Len(endtime) = 0 Then
|
||||
' No end date - store as NULL for indefinite notifications
|
||||
endtimeValue = Null
|
||||
Else
|
||||
' End date specified - convert format
|
||||
endtime = Replace(endtime, "T", " ") & ":00"
|
||||
' End date specified - convert format (only add :00 if from datetime-local input with T)
|
||||
If InStr(endtime, "T") > 0 Then
|
||||
endtime = Replace(endtime, "T", " ") & ":00"
|
||||
End If
|
||||
endtimeValue = endtime
|
||||
End If
|
||||
|
||||
@@ -79,11 +134,25 @@ Else
|
||||
appidValue = CLng(appid)
|
||||
End If
|
||||
|
||||
' Handle optional employeesso - only for Recognition type
|
||||
Dim employeessoValue
|
||||
If Len(employeesso) = 0 Then
|
||||
employeessoValue = Null
|
||||
Else
|
||||
employeessoValue = employeesso
|
||||
End If
|
||||
|
||||
' INSERT using parameterized query
|
||||
On Error Resume Next
|
||||
Dim strSQL, cmdInsert
|
||||
strSQL = "INSERT INTO notifications (notificationtypeid, businessunitid, appid, notification, ticketnumber, starttime, endtime, isactive, isshopfloor) " & _
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
strSQL = "INSERT INTO notifications (notificationtypeid, businessunitid, appid, notification, ticketnumber, starttime, endtime, isactive, isshopfloor, employeesso) " & _
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
Set cmdInsert = Server.CreateObject("ADODB.Command")
|
||||
If Err.Number <> 0 Then
|
||||
objConn.Close
|
||||
ShowError "Error creating command: " & Err.Description, "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
cmdInsert.ActiveConnection = objConn
|
||||
cmdInsert.CommandText = strSQL
|
||||
cmdInsert.CommandType = 1
|
||||
@@ -108,8 +177,19 @@ Else
|
||||
End If
|
||||
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@isactive", 11, 1, , CBool(isactive))
|
||||
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@isshopfloor", 11, 1, , CBool(isshopfloor))
|
||||
If IsNull(employeessoValue) Then
|
||||
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@employeesso", 200, 1, 100, Null)
|
||||
Else
|
||||
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@employeesso", 200, 1, 100, employeessoValue)
|
||||
End If
|
||||
|
||||
' Check for parameter errors
|
||||
If Err.Number <> 0 Then
|
||||
objConn.Close
|
||||
ShowError "Error building parameters: " & Err.Description, "addnotification.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
On Error Resume Next
|
||||
cmdInsert.Execute
|
||||
|
||||
If Err.Number = 0 Then
|
||||
|
||||
Reference in New Issue
Block a user