-- HR modules converted to Module Builder definitions

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Attendance', '{"title":"Attendance","body":[{"type":"table","options":{"tableName":"attendance","searchInputTypes":{"employee":"text","date":"date","timeIn":"time","timeOut":"time","timeInLat":"number","timeInLng":"number","timeOutLat":"number","timeOutLng":"number"},"columnsToShow":["employee","date","timeIn","timeOut","hoursWorked","overtime"]}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Attendance');

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Attendance Dashboard', '{"title":"Attendance Dashboard","body":[{"type":"html","id":"attendanceDash","html":"<div class=\"grid grid-cols-2 gap-4\"><div class=\"bg-base-100 rounded-lg shadow p-4 text-center\"><h3 class=\"text-sm font-medium\">Clocked In</h3><p id=\"adClockIn\" class=\"text-2xl font-bold\">0</p></div><div class=\"bg-base-100 rounded-lg shadow p-4 text-center\"><h3 class=\"text-sm font-medium\">Clocked Out</h3><p id=\"adClockOut\" class=\"text-2xl font-bold\">0</p></div></div>"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Attendance Dashboard');

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Time Clocks', '{"title":"Time Clocks","mapLibraries":{"provider":"google"},"body":[{"type":"table","options":{"tableName":"time_clocks","searchInputTypes":{"user_id":"number","clock_type":{"type":"select","options":["in","out"]},"lat":"number","lng":"number","location_id":"number","supervisor_id":"number","supervisor_type":"text","work_id":"number","security_type":"text","clocked_at":"datetime-local"},"columnsToShow":["user_id","clock_type","location_id","stationApproved","supervisor_id","supervisor_type","work_id","security_type","clocked_at"]}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Time Clocks');

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Time Clock Locations', '{"title":"Time Clock Locations","mapLibraries":{"provider":"google","libraries":"drawing"},"body":[{"type":"table","options":{"tableName":"time_clock_locations","searchInputTypes":{"name":"text","shape":"text","radius_m":"number","assigned_to_type":"text"},"columnsToShow":["name","shape","radius_m","assigned_to_type"]}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Time Clock Locations');

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Timesheet Approval', '{"title":"Timesheet Approval","body":[{"type":"table","options":{"tableName":"pending_timesheets","tableUrl":"../api/timesheets/pending","columnsToShow":["id","user_id","date","standard_hours","overtime_hours","break_hours"],"apiRowActions":[{"buttonText":"Approve","apiUrl":"../api/timesheets/approve/{id}"}]}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Timesheet Approval');

