-- Restore Workplace Registration form and modal

-- Workplace Registration form
INSERT INTO forms (id, name, description, mapped_table, elements, tenant_id, branch_id)
VALUES (
  98,
  'Workplace Registration',
  'Record new workplaces',
  'workplace_registrations',
  $json$
 [
  {
    "label": "Name of owner(s) of business",
    "type_id": 16,
    "field_name": "name_of_owners_of_business",
    "order_index": 0,
    "placeholder": "Name of owner(s) of business:"
  },
  {
    "label": "Trading name",
    "type_id": 1,
    "field_name": "trading_name",
    "order_index": 1,
    "placeholder": "Trading name"
  },
  {
    "label": "Address of workplace",
    "type_id": 1,
    "field_name": "address_of_workplace",
    "order_index": 2,
    "placeholder": "Address of workplace"
  },
  {
    "label": "Postal address",
    "type_id": 1,
    "field_name": "postal_address",
    "order_index": 3,
    "placeholder": "Postal address"
  },
  {
    "label": "Date of business commenced operations at these premises",
    "type_id": 3,
    "field_name": "date_of_business_commenced_operations_at_these_premises",
    "order_index": 4,
    "placeholder": "Date of business commenced operations at these premises"
  },
  {
    "label": "Details of ownership of premises",
    "type_id": 7,
    "field_name": "details_of_ownership_of_premises",
    "order_index": 5,
    "placeholder": "Details of ownership of premises"
  },
  {
    "label": "Name & address of Owner of the Building:",
    "type_id": 1,
    "field_name": "name_and_address_of_owner_of_the_building",
    "order_index": 6,
    "placeholder": "Name & address of Owner of the Building"
  },
  {
    "label": "Details of business activity: (Refer to First Schedule)",
    "type_id": 7,
    "field_name": "details_of_business_activiy",
    "order_index": 7,
    "placeholder": "Details of business activity"
  },
  {
    "label": "Main Activity Conducted by Business",
    "type_id": 1,
    "field_name": "main_activity_conducted_by_business",
    "order_index": 8,
    "placeholder": "Main Activity Conducted by Business"
  },
  {
    "label": "Principal Articles to be manufactured repaired or sold",
    "type_id": 1,
    "field_name": "principal_articles_to_be_manufactured_repaired_or_sold",
    "order_index": 9,
    "placeholder": "Principal Articles to be manufactured repaired or sold"
  },
  {
    "label": "Are goods sold at this location:",
    "type_id": 5,
    "field_name": "goods_sold",
    "order_index": 10,
    "placeholder": ""
  },
  {
    "label": "Sales Type",
    "options": [
      {
        "value": "wholesale",
        "display_text": "Wholesale"
      },
      {
        "value": "retail",
        "display_text": "Retail"
      },
      {
        "value": "both",
        "display_text": "Both"
      }
    ],
    "type_id": 4,
    "field_name": "sales_type",
    "order_index": 11,
    "condition_field": "goods_sold",
    "condition_value": "1"
  },
  {
    "label": "Has Site Previously been used as a workplace",
    "type_id": 1,
    "field_name": "has_site_previously_been_used_as_a_workplace",
    "order_index": 12,
    "placeholder": "Has Site Previously been used as a workplace"
  },
  {
    "label": "Name of previous Occupier",
    "type_id": 1,
    "field_name": "name_of_previous_occupier",
    "order_index": 13,
    "placeholder": "Name of previous Occupier"
  },
  {
    "label": "Contact telephone number",
    "type_id": 2,
    "field_name": "contact_telephone_number",
    "order_index": 14,
    "placeholder": "Contact telephone number"
  }
  ]$json$::jsonb,
  NULL,
  NULL
) ON CONFLICT (id) DO NOTHING;

-- Workplace Registration modal
INSERT INTO ui_modals (name, config, tenant_id, branch_id, icon, aria_label, description) VALUES ('Workplace Registration','{"title":"Workplace Registration","header":[{"type":"button","label":"New Registration","formName":"Workplace Registration"}],"body":[{"type":"table","options":{"tableName":"workplace_registrations","rowClick":"selectRecord","rowActions":[{"label":"Detail","onClick":"openSelectedDetail"},{"label":"Invoice","onClick":"openWorkplaceInvoiceForm"}],"inlineEdit":true,"editFormId":98}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}',NULL,NULL,'fa-building','Workplace Registration','Workplace Registration');
