diff --git a/backend/managerRoutes.js b/backend/managerRoutes.js index 0caa596..5c85ae0 100644 --- a/backend/managerRoutes.js +++ b/backend/managerRoutes.js @@ -239,7 +239,7 @@ const dayNameFromYMD = (yyyyMmDd) => { username: r.username, full_name: r.full_name, event_type: r.event_type, - timestamp: ymdHmsInTZ(parseNaiveAsTZ(r.timestamp, TZ), TZ), + timestamp: r.timestamp, qr_code_name: r.qr_code_name, notes: r.notes })); diff --git a/backend/workerRoutes.js b/backend/workerRoutes.js index 484a31e..6d3a1a6 100644 --- a/backend/workerRoutes.js +++ b/backend/workerRoutes.js @@ -3,10 +3,6 @@ import { point, polygon, booleanPointInPolygon, pointToLineDistance } from '@tur import bcrypt from 'bcrypt'; import jwt from 'jsonwebtoken'; - -// Map IANA (no DST for KL/Jakarta) -const sessionOffset = (iana) => (iana === 'Asia/Jakarta' ? '+07:00' : '+08:00'); - async function validateDeviceForUser(userId, deviceUuid, db) { const [userRows] = await db.execute('SELECT device_uuid FROM workers WHERE id = ?', [userId]); if (userRows.length === 0) return { valid: false, message: 'User not found' }; @@ -105,10 +101,6 @@ export default function(db) { try { const { userId, eventType, qrCodeValue, latitude, longitude } = req.body; - // NEW: set session time_zone from header (defaults to KL) - const iana = req.headers['x-user-timezone'] || 'Asia/Kuala_Lumpur'; - await conn.query('SET time_zone = ?', [sessionOffset(iana)]); - // 1) Kill Switch — now evaluated in the session's local day const clockingAllowed = await isClockingEnabled(conn); // CHANGED: pass conn if (!clockingAllowed) { @@ -116,7 +108,7 @@ export default function(db) { await conn.execute( // CHANGED: use conn `INSERT INTO clock_records (worker_id, event_type, qr_code_id, latitude, longitude, notes, timestamp) - VALUES (?, "failed", ?, ?, ?, ?, CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'))`, + VALUES (?, "failed", ?, ?, ?, ?, CURRENT_TIME())`, [userId, qrCodeValue, latitude, longitude, note] ); return res.status(403).json({ message: 'error.clockingDisabled' }); @@ -131,7 +123,7 @@ export default function(db) { await conn.execute( // CHANGED `INSERT INTO clock_records (worker_id, event_type, qr_code_id, latitude, longitude, notes, timestamp) - VALUES (?, "failed", ?, ?, ?, ?, CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'))`, + VALUES (?, "failed", ?, ?, ?, ?, CURRENT_TIME())`, [userId, qrCodeValue, latitude, longitude, note] ); return res.status(403).json({ message: 'error.noActiveGeofence' }); @@ -167,7 +159,7 @@ export default function(db) { await conn.execute( // CHANGED `INSERT INTO clock_records (worker_id, event_type, qr_code_id, latitude, longitude, notes, timestamp) - VALUES (?, "failed", ?, ?, ?, ?, CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'))`, + VALUES (?, "failed", ?, ?, ?, ?, CURRENT_TIME())`, [userId, qrCodeValue, latitude, longitude, note] ); return res.status(403).json({ message: `error.outsideGeofence|${distanceString}` }); @@ -195,7 +187,7 @@ export default function(db) { await conn.execute( `INSERT INTO clock_records (worker_id, event_type, qr_code_id, latitude, longitude, timestamp) - VALUES (?, ?, ?, ?, ?, CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'))`, + VALUES (?, ?, ?, ?, ?, CURRENT_TIME())`, [userId, eventType, qrCodeValue, latitude, longitude] );