{
  "template_pack": "FlowCRM_Additional_Industry_Templates_v1",
  "schema": {
    "template": {
      "category": "For Industries",
      "name": "string",
      "slug": "string",
      "stages": [{ "order": 1, "name": "string", "slug": "string" }],
      "template_fields": [{ "key": "string", "label": "string", "type": "string", "required_global": false, "options": [] }],
      "form_schema": { "sections": [{ "title": "string", "fields": ["field_key_1", "field_key_2"] }] },
      "stage_gate_rules": [{ "to_stage_slug": "string", "required_fields": ["field_key_1"], "message": "string" }]
    }
  },
  "templates": [
    {
      "category": "For Industries",
      "name": "Healthcare Clinic Appointments",
      "slug": "healthcare-clinic-appointments",
      "stages": [
        { "order": 1, "name": "Enquiry / Request", "slug": "enquiry-request" },
        { "order": 2, "name": "Registration", "slug": "registration" },
        { "order": 3, "name": "Appointment Scheduled", "slug": "appointment-scheduled" },
        { "order": 4, "name": "Pre-Visit Checklist", "slug": "pre-visit-checklist" },
        { "order": 5, "name": "Visit Completed", "slug": "visit-completed" },
        { "order": 6, "name": "Billing & Payment", "slug": "billing-payment" },
        { "order": 7, "name": "Follow-up Scheduled", "slug": "follow-up-scheduled" },
        { "order": 8, "name": "Closed", "slug": "closed" }
      ],
      "template_fields": [
        { "key": "patient_name", "label": "Patient Name", "type": "text", "required_global": true },
        { "key": "patient_phone", "label": "Patient Phone", "type": "phone", "required_global": true },
        { "key": "appointment_reason", "label": "Reason for Visit", "type": "select", "required_global": false, "options": ["Consultation", "Follow-up", "Emergency", "Therapy", "Other"] },
        { "key": "preferred_date", "label": "Preferred Date", "type": "date", "required_global": false },
        { "key": "doctor_assigned", "label": "Doctor Assigned", "type": "user_lookup", "required_global": false },
        { "key": "scheduled_at", "label": "Scheduled Date/Time", "type": "datetime", "required_global": false },
        { "key": "insurance_provider", "label": "Insurance Provider", "type": "text", "required_global": false },
        { "key": "payment_status", "label": "Payment Status", "type": "select", "required_global": false, "options": ["Pending", "Paid", "Partially Paid", "Not Required"] },
        { "key": "followup_date", "label": "Follow-up Date", "type": "date", "required_global": false },
        { "key": "visit_notes", "label": "Visit Notes", "type": "textarea", "required_global": false }
      ],
      "form_schema": {
        "sections": [
          { "title": "Patient", "fields": ["patient_name", "patient_phone", "contact_id", "company_id"] },
          { "title": "Appointment", "fields": ["appointment_reason", "preferred_date", "doctor_assigned", "scheduled_at"] },
          { "title": "Billing", "fields": ["insurance_provider", "payment_status"] },
          { "title": "Outcome", "fields": ["visit_notes", "followup_date", "attachments", "tags"] }
        ]
      },
      "stage_gate_rules": [
        { "to_stage_slug": "registration", "required_fields": ["patient_name", "patient_phone"], "message": "Patient name and phone are required before Registration." },
        { "to_stage_slug": "appointment-scheduled", "required_fields": ["doctor_assigned", "scheduled_at"], "message": "Doctor and Scheduled Date/Time are required before Appointment Scheduled." },
        { "to_stage_slug": "visit-completed", "required_fields": ["visit_notes"], "message": "Visit Notes are required before Visit Completed." },
        { "to_stage_slug": "billing-payment", "required_fields": ["payment_status"], "message": "Payment status is required before Billing & Payment." },
        { "to_stage_slug": "follow-up-scheduled", "required_fields": ["followup_date"], "message": "Follow-up date is required before Follow-up Scheduled." }
      ]
    },
    {
      "category": "For Industries",
      "name": "Manufacturing Sales (B2B)",
      "slug": "manufacturing-sales-b2b",
      "stages": [
        { "order": 1, "name": "New Enquiry", "slug": "new-enquiry" },
        { "order": 2, "name": "Qualified", "slug": "qualified" },
        { "order": 3, "name": "Technical Discussion", "slug": "technical-discussion" },
        { "order": 4, "name": "Quotation Sent", "slug": "quotation-sent" },
        { "order": 5, "name": "Sampling / Prototype", "slug": "sampling-prototype" },
        { "order": 6, "name": "Negotiation", "slug": "negotiation" },
        { "order": 7, "name": "PO Received", "slug": "po-received" },
        { "order": 8, "name": "Production", "slug": "production" },
        { "order": 9, "name": "Dispatch", "slug": "dispatch" },
        { "order": 10, "name": "Closed Won", "slug": "closed-won" },
        { "order": 11, "name": "Closed Lost", "slug": "closed-lost" }
      ],
      "template_fields": [
        { "key": "product_category", "label": "Product Category", "type": "text", "required_global": false },
        { "key": "quantity", "label": "Quantity", "type": "number", "required_global": false },
        { "key": "specification_doc", "label": "Specification Doc Link", "type": "url", "required_global": false },
        { "key": "quotation_value", "label": "Quotation Value", "type": "money", "required_global": false },
        { "key": "delivery_timeline", "label": "Delivery Timeline", "type": "text", "required_global": false },
        { "key": "sample_required", "label": "Sample Required?", "type": "boolean", "required_global": false },
        { "key": "po_number", "label": "PO Number", "type": "text", "required_global": false },
        { "key": "dispatch_tracking", "label": "Dispatch Tracking", "type": "text", "required_global": false },
        { "key": "lost_reason", "label": "Lost Reason", "type": "select", "required_global": false, "options": ["Price", "Timeline", "Competitor", "Not Qualified", "Other"] }
      ],
      "form_schema": {
        "sections": [
          { "title": "Customer", "fields": ["title", "owner_user_id", "contact_id", "company_id", "tags", "source"] },
          { "title": "Requirement", "fields": ["product_category", "quantity", "specification_doc", "attachments"] },
          { "title": "Commercials", "fields": ["quotation_value", "delivery_timeline", "sample_required"] },
          { "title": "Order & Dispatch", "fields": ["po_number", "dispatch_tracking"] },
          { "title": "Notes", "fields": ["description", "lost_reason"] }
        ]
      },
      "stage_gate_rules": [
        { "to_stage_slug": "qualified", "required_fields": ["company_id"], "message": "Company is required before Qualified." },
        { "to_stage_slug": "quotation-sent", "required_fields": ["quotation_value", "delivery_timeline"], "message": "Quotation value and delivery timeline are required before Quotation Sent." },
        { "to_stage_slug": "sampling-prototype", "required_fields": ["specification_doc"], "message": "Specification doc link is required before Sampling / Prototype." },
        { "to_stage_slug": "po-received", "required_fields": ["po_number"], "message": "PO number is required before PO Received." },
        { "to_stage_slug": "dispatch", "required_fields": ["dispatch_tracking"], "message": "Dispatch tracking is required before Dispatch." },
        { "to_stage_slug": "closed-lost", "required_fields": ["lost_reason"], "message": "Lost reason is required before Closed Lost." }
      ]
    },
    {
      "category": "For Industries",
      "name": "Construction / Contractor Projects",
      "slug": "construction-contractor-projects",
      "stages": [
        { "order": 1, "name": "New Enquiry", "slug": "new-enquiry" },
        { "order": 2, "name": "Site Visit Scheduled", "slug": "site-visit-scheduled" },
        { "order": 3, "name": "Site Visit Completed", "slug": "site-visit-completed" },
        { "order": 4, "name": "Estimate Prepared", "slug": "estimate-prepared" },
        { "order": 5, "name": "Estimate Sent", "slug": "estimate-sent" },
        { "order": 6, "name": "Negotiation", "slug": "negotiation" },
        { "order": 7, "name": "Contract Signed", "slug": "contract-signed" },
        { "order": 8, "name": "Execution", "slug": "execution" },
        { "order": 9, "name": "Quality Check", "slug": "quality-check" },
        { "order": 10, "name": "Handover", "slug": "handover" },
        { "order": 11, "name": "Payment Complete", "slug": "payment-complete" },
        { "order": 12, "name": "Closed", "slug": "closed" }
      ],
      "template_fields": [
        { "key": "project_address", "label": "Project Address", "type": "textarea", "required_global": false },
        { "key": "site_visit_at", "label": "Site Visit Date/Time", "type": "datetime", "required_global": false },
        { "key": "project_type", "label": "Project Type", "type": "select", "required_global": false, "options": ["New Build", "Renovation", "Interior", "Repair", "Other"] },
        { "key": "estimated_cost", "label": "Estimated Cost", "type": "money", "required_global": false },
        { "key": "estimate_doc", "label": "Estimate Doc Link", "type": "url", "required_global": false },
        { "key": "contract_doc", "label": "Contract Doc Link", "type": "url", "required_global": false },
        { "key": "start_date", "label": "Start Date", "type": "date", "required_global": false },
        { "key": "target_completion_date", "label": "Target Completion Date", "type": "date", "required_global": false },
        { "key": "qc_checklist", "label": "QC Checklist", "type": "multiline_checklist", "required_global": false },
        { "key": "payment_status", "label": "Payment Status", "type": "select", "required_global": false, "options": ["Pending", "Partially Paid", "Paid"] }
      ],
      "form_schema": {
        "sections": [
          { "title": "Client & Site", "fields": ["title", "contact_id", "company_id", "owner_user_id", "project_address", "project_type"] },
          { "title": "Site Visit", "fields": ["site_visit_at", "attachments"] },
          { "title": "Estimate", "fields": ["estimated_cost", "estimate_doc"] },
          { "title": "Contract & Timeline", "fields": ["contract_doc", "start_date", "target_completion_date"] },
          { "title": "QC & Payment", "fields": ["qc_checklist", "payment_status"] },
          { "title": "Notes", "fields": ["description", "tags"] }
        ]
      },
      "stage_gate_rules": [
        { "to_stage_slug": "site-visit-scheduled", "required_fields": ["project_address", "site_visit_at"], "message": "Project address and site visit time are required before scheduling." },
        { "to_stage_slug": "estimate-prepared", "required_fields": ["project_type"], "message": "Project type is required before Estimate Prepared." },
        { "to_stage_slug": "estimate-sent", "required_fields": ["estimated_cost", "estimate_doc"], "message": "Estimated cost and estimate doc link are required before Estimate Sent." },
        { "to_stage_slug": "contract-signed", "required_fields": ["contract_doc"], "message": "Contract doc link is required before Contract Signed." },
        { "to_stage_slug": "execution", "required_fields": ["start_date", "target_completion_date"], "message": "Start date and target completion date are required before Execution." },
        { "to_stage_slug": "quality-check", "required_fields": ["qc_checklist"], "message": "QC checklist is required before Quality Check." },
        { "to_stage_slug": "payment-complete", "required_fields": ["payment_status"], "message": "Payment status must be set before Payment Complete." }
      ]
    }
  ]
}
