-- =============================================================================
-- larcare_inactive_unused_forms.sql - the LarCare website uses two Aggie forms: the Free Care Consultation Request
-- (form key "consultation": Contact page, Consultation page and the location pages) and the Private Care Inquiry form
-- ("private-care-inquiry": linked from the staff portal and feeds the private-pay workflow). Every other LarCare web
-- form (careers, contact, SMS consent, patient survey, the caregiver / client / nurse / HR portal forms) is not shown
-- on the website any more - caregiver forms open in Zoho Forms - so it is made inactive. Nothing is deleted: the form
-- and its earlier submissions stay in Aggie and a form can be switched on again in Website > Forms. Only the LarCare
-- site is touched. Safe to run again.
-- (The Sensi AI information form ("sensi-ai-information", on the /sensi-ai page) is also kept on.)
-- (An earlier run of this file also switched the private care inquiry off by mistake; this version turns it back on.)
-- =============================================================================
SET @site_id := (SELECT id FROM dim_web_sites WHERE public_site_key = 'pSlfeq9OCm5MvZyoFguIK7jy0uz2aKShJkxZxTSWXwzPOpYJ' AND is_deleted = 0 LIMIT 1);

UPDATE dim_web_forms SET is_active = 0
WHERE @site_id IS NOT NULL AND site_id = @site_id AND is_deleted = 0 AND is_active = 1
  AND form_key NOT IN ('consultation', 'private-care-inquiry', 'sensi-ai-information');

UPDATE dim_web_forms SET is_active = 1
WHERE @site_id IS NOT NULL AND site_id = @site_id AND is_deleted = 0 AND is_active = 0
  AND form_key IN ('private-care-inquiry', 'sensi-ai-information');
