diff --git a/app/modules/quality/quality.py b/app/modules/quality/quality.py
index 7065c57..4fbe7ea 100644
--- a/app/modules/quality/quality.py
+++ b/app/modules/quality/quality.py
@@ -60,8 +60,16 @@ def save_fg_scan(operator_code, cp_code, oc1_code, oc2_code, defect_code, date,
tuple: (success: bool, approved_count: int, rejected_count: int)
"""
try:
+ from datetime import datetime
+
db = get_db()
cursor = db.cursor()
+
+ # Default to current date/time if not provided
+ if not date:
+ date = datetime.now().strftime('%Y-%m-%d')
+ if not time:
+ time = datetime.now().strftime('%H:%M:%S')
# Insert a new entry - each scan is a separate record
insert_query = """
diff --git a/app/templates/modules/quality/fg_scan.html b/app/templates/modules/quality/fg_scan.html
index 9a41ade..61043f4 100644
--- a/app/templates/modules/quality/fg_scan.html
+++ b/app/templates/modules/quality/fg_scan.html
@@ -35,6 +35,10 @@
+
+
+
+
@@ -671,11 +675,22 @@ defectCodeInput.addEventListener('input', function() {
const seconds = String(now.getSeconds()).padStart(2, '0');
const timeValue = `${hours}:${minutes}:${seconds}`;
+ // Format date as YYYY-MM-DD for database
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, '0');
+ const day = String(now.getDate()).padStart(2, '0');
+ const dateValue = `${year}-${month}-${day}`;
+
// Parse the current datetime display and update just the time part
const dateStr = timeInput.value.split(' ').slice(0, -1).join(' '); // Get date part
timeInput.value = dateStr + ' ' + timeValue;
+ // Populate hidden date/time fields for form submission
+ document.getElementById('date').value = dateValue;
+ document.getElementById('time').value = timeValue;
+
console.log('✅ Time field updated to:', timeValue);
+ console.log('✅ Date field set to:', dateValue);
// Save current scan data to localStorage for clearing after reload
localStorage.setItem('fg_scan_clear_after_submit', 'true');