-- Update Case Hour Entry modal with filters and table view
UPDATE ui_modals
SET config = '{"title":"Case Hour Entry","header":[{"type":"button","label":"Add Hour","formId":38},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"approved","data_column":"approved"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"user_id","data_column":"user_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"case_id","data_column":"case_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"client_id","data_column":"client_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"updatedAt","data_column":"updatedAt_start"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"updatedAt","data_column":"updatedAt_end"}}],"body":[{"type":"table","options":{"tableName":"case_hours","tableUrl":"../api/case_hours","showGlobalSearch":false,"addButton":false,"editFormId":38,"filterField":"approved"}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}'
WHERE name = 'Case Hour Entry';

INSERT INTO ui_modals (name, config, tenant_id, branch_id)
SELECT 'Case Hour Entry', '{"title":"Case Hour Entry","header":[{"type":"button","label":"Add Hour","formId":38},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"approved","data_column":"approved"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"user_id","data_column":"user_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"case_id","data_column":"case_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"client_id","data_column":"client_id"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"updatedAt","data_column":"updatedAt_start"}},{"type":"filter-select","options":{"source_table":"case_hours","source_column":"updatedAt","data_column":"updatedAt_end"}}],"body":[{"type":"table","options":{"tableName":"case_hours","tableUrl":"../api/case_hours","showGlobalSearch":false,"addButton":false,"editFormId":38,"filterField":"approved"}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Case Hour Entry');

