diff --git a/addnotification.asp b/addnotification.asp
index 0750005..40f2a0e 100644
--- a/addnotification.asp
+++ b/addnotification.asp
@@ -112,14 +112,24 @@
Link this notification to a specific application (e.g., for software updates)
-
+
Optional ServiceNow ticket number
-
+
+
+
+ Enter one or more SSOs separated by commas
+
+
+
+
+
+
@@ -246,7 +256,76 @@
startInput.value = formatDateTime(now);
// Leave endInput blank by default for indefinite notifications
+
+ // Handle notification type change
+ var typeSelect = document.getElementById('notificationtypeid');
+ typeSelect.addEventListener('change', handleTypeChange);
+ handleTypeChange(); // Initial check
});
+
+ // Recognition type ID (from database)
+ var RECOGNITION_TYPE_ID = '5';
+
+ function handleTypeChange() {
+ var typeSelect = document.getElementById('notificationtypeid');
+ var selectedText = typeSelect.options[typeSelect.selectedIndex].text;
+ var isRecognition = selectedText.toLowerCase().indexOf('recognition') !== -1;
+
+ // Show/hide SSO field
+ document.getElementById('employeessoGroup').style.display = isRecognition ? 'block' : 'none';
+ document.getElementById('employeesso').required = isRecognition;
+
+ // Show/hide time fields and ticket number for Recognition
+ document.getElementById('timeFieldsRow').style.display = isRecognition ? 'none' : 'flex';
+ document.getElementById('ticketnumberGroup').style.display = isRecognition ? 'none' : 'block';
+
+ // For Recognition, remove required from starttime
+ document.getElementById('starttime').required = !isRecognition;
+
+ // Auto-check shopfloor dashboard for Recognition
+ if (isRecognition) {
+ document.getElementById('isshopfloor').checked = true;
+ }
+ }
+
+ // Lookup employee names by SSO
+ var lookupTimeout = null;
+ document.addEventListener('DOMContentLoaded', function() {
+ var ssoInput = document.getElementById('employeesso');
+ ssoInput.addEventListener('input', function() {
+ clearTimeout(lookupTimeout);
+ lookupTimeout = setTimeout(lookupEmployees, 500);
+ });
+ });
+
+ function lookupEmployees() {
+ var ssoInput = document.getElementById('employeesso');
+ var ssos = ssoInput.value.trim();
+ var previewDiv = document.getElementById('employeePreview');
+ var namesSpan = document.getElementById('employeeNames');
+
+ if (!ssos) {
+ previewDiv.style.display = 'none';
+ return;
+ }
+
+ // Call AJAX endpoint to lookup names
+ fetch('./lookupemployee.asp?sso=' + encodeURIComponent(ssos))
+ .then(function(response) { return response.json(); })
+ .then(function(data) {
+ if (data.success && data.names) {
+ namesSpan.textContent = data.names;
+ previewDiv.style.display = 'block';
+ } else {
+ namesSpan.textContent = data.error || 'Employee not found';
+ namesSpan.className = 'badge badge-warning';
+ previewDiv.style.display = 'block';
+ }
+ })
+ .catch(function(err) {
+ previewDiv.style.display = 'none';
+ });
+ }