object ApiDatabaseModule: TApiDatabaseModule
  OnCreate = DataModuleCreate
  Height = 491
  Width = 640
  object uqMapUnits: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  uc.ENTRYID,'
      '  uc.UNITID,'
      
        '  COALESCE(uc.UNITNAME, dua.UNITNAME, cun.CODE_DESC, dua.CARNUMB' +
        'ER::text) AS UNITNAME,'
      '  ag.AGENCYID AS AGENCY,'
      '  ag.AGENCYNAME AS AGENCY_NAME,'
      '  ag.AGENCYTYPE AS AGENCYTYPE,'
      '  uc.GPS_LATITUDE,'
      '  uc.GPS_LONGITUDE,'
      '  cdc.CODE_DESC AS CALL_TYPE,'
      '  cap.PRIORITY AS PRIORITY,'
      '  cus.CODE_DESC AS UNIT_STATUS_DESC,'
      '  uc.UPDATETIME AS UPDATE_TIME,'
      ''
      '  dua.UNITID AS DIS_UNITID,'
      ''
      '  p1.PF_LNAME AS OFFICER1_LNAME,'
      '  p1.PF_FNAME AS OFFICER1_FNAME,'
      '  p1.PF_EMPNUM AS OFFICER1_EMPNUM,'
      ''
      '  p2.PF_LNAME AS OFFICER2_LNAME,'
      '  p2.PF_FNAME AS OFFICER2_FNAME,'
      '  p2.PF_EMPNUM AS OFFICER2_EMPNUM'
      ''
      'FROM UNITS_CURRENT uc'
      'LEFT JOIN DIS_UNIT_ACTIVE dua ON dua.UNITID = uc.UNITID'
      'LEFT JOIN AGENCY ag ON ag.AGENCYID = dua.AGENCY'
      'LEFT JOIN CD_UNIT_NUMBER cun ON cun.AGENCYCODE = dua.CARNUMBER'
      'LEFT JOIN CFS_ACTIVE cfs ON uc.UNITID = cfs.UNITID'
      
        'LEFT JOIN COMPLAINT_ACTIVE cap ON cap.COMPLAINTID = cfs.COMPLAIN' +
        'TID'
      'LEFT JOIN CD_DISPATCHCODES cdc ON cdc.CODE = cap.DISPATCHCODE'
      'LEFT JOIN CD_UNITSTATUS cus ON cus.CODE = cfs.UNITSTATUS'
      'LEFT JOIN PERSONNEL p1 ON p1.PF_NAMEID = dua.OFFICER1ID'
      'LEFT JOIN PERSONNEL p2 ON p2.PF_NAMEID = dua.OFFICER2ID'
      'WHERE uc.GPS_LATITUDE IS NOT NULL'
      '  AND uc.GPS_LONGITUDE IS NOT NULL')
    ReadOnly = True
    Left = 466
    Top = 390
    object uqMapUnitsentryid: TFloatField
      FieldName = 'entryid'
      Required = True
    end
    object uqMapUnitsunitid: TFloatField
      FieldName = 'unitid'
    end
    object uqMapUnitsunitname: TMemoField
      FieldName = 'unitname'
      ReadOnly = True
      BlobType = ftMemo
    end
    object uqMapUnitsagency: TStringField
      FieldName = 'agency'
      ReadOnly = True
      Size = 6
    end
    object uqMapUnitsagency_name: TStringField
      FieldName = 'agency_name'
      ReadOnly = True
      Size = 40
    end
    object uqMapUnitsgps_latitude: TFloatField
      FieldName = 'gps_latitude'
    end
    object uqMapUnitsgps_longitude: TFloatField
      FieldName = 'gps_longitude'
    end
    object uqMapUnitscall_type: TStringField
      FieldName = 'call_type'
      ReadOnly = True
      Size = 60
    end
    object uqMapUnitspriority: TStringField
      FieldName = 'priority'
      ReadOnly = True
      Size = 6
    end
    object uqMapUnitsunit_status_desc: TStringField
      FieldName = 'unit_status_desc'
      ReadOnly = True
    end
    object uqMapUnitsupdate_time: TDateTimeField
      FieldName = 'update_time'
    end
    object uqMapUnitsdis_unitid: TFloatField
      FieldName = 'dis_unitid'
      ReadOnly = True
    end
    object uqMapUnitsofficer1_lname: TStringField
      FieldName = 'officer1_lname'
      ReadOnly = True
      Size = 15
    end
    object uqMapUnitsofficer1_fname: TStringField
      FieldName = 'officer1_fname'
      ReadOnly = True
      Size = 12
    end
    object uqMapUnitsofficer1_empnum: TStringField
      FieldName = 'officer1_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqMapUnitsofficer2_lname: TStringField
      FieldName = 'officer2_lname'
      ReadOnly = True
      Size = 15
    end
    object uqMapUnitsofficer2_fname: TStringField
      FieldName = 'officer2_fname'
      ReadOnly = True
      Size = 12
    end
    object uqMapUnitsofficer2_empnum: TStringField
      FieldName = 'officer2_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqMapUnitsagencytype: TStringField
      FieldName = 'agencytype'
      ReadOnly = True
      Size = 10
    end
  end
  object uqUnitList: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '       ag.AGENCYID AS AGENCY,'
      '       ag.AGENCYNAME AS AGENCY_NAME,'
      '       ag.AGENCYTYPE AS AGENCYTYPE,'
      '       dua.UNITID,'
      '       dua.UNITNAME,'
      '       cun.CODE_DESC AS CARNUMBER_DESC,'
      '       cd.CODE_DESC  AS DISTRICT_DESC,'
      '       cs.CODE_DESC  AS SECTOR_DESC,'
      '       p1.PF_EMPNUM  AS OFFICER1_EMPNUM,'
      '       p1.PF_LNAME   AS OFFICER1_LAST_NAME,'
      '       p1.PF_FNAME   AS OFFICER1_FIRST_NAME,'
      '       p1.PF_MI      AS OFFICER1_MI,'
      '       p2.PF_EMPNUM  AS OFFICER2_EMPNUM,'
      '       p2.PF_LNAME   AS OFFICER2_LAST_NAME,'
      '       p2.PF_FNAME   AS OFFICER2_FIRST_NAME,'
      '       p2.PF_MI      AS OFFICER2_MI,'
      '       ca.LOCATION,'
      '       ca.COMPLAINT,'
      '       ca.UNITSTATUS,'
      '       cus.CODE_DESC AS UNIT_STATUS_DESC,'
      '       cdc.CODE_DESC AS CALL_TYPE,'
      '       uc.ENTRYID,'
      '       uc.GPS_LATITUDE,'
      '       uc.GPS_LONGITUDE'
      'FROM DIS_UNIT_ACTIVE dua'
      'JOIN AGENCY ag ON ag.AGENCYID = dua.AGENCY'
      
        'LEFT JOIN CD_UNIT_NUMBER         cun ON cun.AGENCYCODE = dua.CAR' +
        'NUMBER'
      
        'LEFT JOIN CD_DISTRICT            cd  ON cd.AGENCYCODE  = dua.DIS' +
        'TRICT'
      
        'LEFT JOIN CD_SECTOR              cs  ON cs.AGENCYCODE  = dua.SEC' +
        'TOR AND cs.CODE_TYPE = cd.AGENCYCODE'
      
        'LEFT JOIN PERSONNEL              p1  ON dua.OFFICER1ID = p1.PF_N' +
        'AMEID'
      
        'LEFT JOIN PERSONNEL              p2  ON dua.OFFICER2ID = p2.PF_N' +
        'AMEID'
      
        'LEFT JOIN CFS_ACTIVE             ca  ON dua.UNITID     = ca.UNIT' +
        'ID'
      
        'LEFT JOIN CD_UNITSTATUS          cus ON ca.UNITSTATUS  = cus.COD' +
        'E'
      
        'LEFT JOIN COMPLAINT_ACTIVE       cap ON cap.COMPLAINTID = ca.COM' +
        'PLAINTID'
      
        'LEFT JOIN CD_DISPATCHCODES       cdc ON cdc.CODE        = cap.DI' +
        'SPATCHCODE'
      
        'LEFT JOIN UNITS_CURRENT          uc  ON dua.UNITID      = uc.UNI' +
        'TID'
      'WHERE ag.AGENCYTYPE = '#39'POL'#39
      'ORDER BY'
      '  CASE WHEN ag.AGENCYID = '#39'WCSO'#39' THEN 0 ELSE 1 END,'
      '  ag.AGENCYNAME,'
      '  dua.UNITNAME')
    ReadOnly = True
    Left = 78
    Top = 190
    object uqUnitListagency: TStringField
      FieldName = 'agency'
      ReadOnly = True
      Size = 6
    end
    object uqUnitListagency_name: TStringField
      FieldName = 'agency_name'
      ReadOnly = True
      Size = 40
    end
    object uqUnitListunitid: TFloatField
      FieldName = 'unitid'
    end
    object uqUnitListunitname: TStringField
      FieldName = 'unitname'
      Size = 10
    end
    object uqUnitListcarnumber_desc: TStringField
      FieldName = 'carnumber_desc'
      ReadOnly = True
      Size = 120
    end
    object uqUnitListdistrict_desc: TStringField
      FieldName = 'district_desc'
      ReadOnly = True
      Size = 120
    end
    object uqUnitListsector_desc: TStringField
      FieldName = 'sector_desc'
      ReadOnly = True
      Size = 120
    end
    object uqUnitListofficer1_empnum: TStringField
      FieldName = 'officer1_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqUnitListofficer1_last_name: TStringField
      FieldName = 'officer1_last_name'
      ReadOnly = True
      Size = 15
    end
    object uqUnitListofficer1_first_name: TStringField
      FieldName = 'officer1_first_name'
      ReadOnly = True
      Size = 12
    end
    object uqUnitListofficer1_mi: TStringField
      FieldName = 'officer1_mi'
      ReadOnly = True
      Size = 1
    end
    object uqUnitListofficer2_empnum: TStringField
      FieldName = 'officer2_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqUnitListofficer2_last_name: TStringField
      FieldName = 'officer2_last_name'
      ReadOnly = True
      Size = 15
    end
    object uqUnitListofficer2_first_name: TStringField
      FieldName = 'officer2_first_name'
      ReadOnly = True
      Size = 12
    end
    object uqUnitListofficer2_mi: TStringField
      FieldName = 'officer2_mi'
      ReadOnly = True
      Size = 1
    end
    object uqUnitListlocation: TStringField
      FieldName = 'location'
      ReadOnly = True
      Size = 100
    end
    object uqUnitListcomplaint: TStringField
      FieldName = 'complaint'
      ReadOnly = True
      Size = 10
    end
    object uqUnitListunitstatus: TFloatField
      FieldName = 'unitstatus'
      ReadOnly = True
    end
    object uqUnitListunit_status_desc: TStringField
      FieldName = 'unit_status_desc'
      ReadOnly = True
    end
    object uqUnitListcall_type: TStringField
      FieldName = 'call_type'
      ReadOnly = True
      Size = 60
    end
    object uqUnitListentryid: TFloatField
      FieldName = 'entryid'
      ReadOnly = True
      Required = True
    end
    object uqUnitListgps_latitude: TFloatField
      FieldName = 'gps_latitude'
      ReadOnly = True
    end
    object uqUnitListgps_longitude: TFloatField
      FieldName = 'gps_longitude'
      ReadOnly = True
    end
    object uqUnitListagencytype: TStringField
      FieldName = 'agencytype'
      ReadOnly = True
      Size = 10
    end
  end
  object uqComplaintUnits: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  ca.COMPLAINTID,'
      '  ca.UNITID,'
      '  ca.UNITNAME,'
      '  ca.DATEDISPATCHED,'
      '  ca.DATERESPONDED,'
      '  ca.DATEARRIVED,'
      '  ca.DATECLEARED,'
      '  ca.LOCATION'
      'FROM CFS_ACTIVE ca'
      'WHERE ca.COMPLAINTID = :COMPLAINTID'
      'ORDER BY ca.DATEDISPATCHED')
    ReadOnly = True
    Left = 466
    Top = 326
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'COMPLAINTID'
        Value = nil
      end>
    object uqComplaintUnitscomplaintid: TFloatField
      FieldName = 'complaintid'
      Required = True
    end
    object uqComplaintUnitsunitid: TFloatField
      FieldName = 'unitid'
      Required = True
    end
    object uqComplaintUnitsunitname: TStringField
      FieldName = 'unitname'
      Size = 10
    end
    object uqComplaintUnitsdatedispatched: TDateTimeField
      FieldName = 'datedispatched'
    end
    object uqComplaintUnitsdateresponded: TDateTimeField
      FieldName = 'dateresponded'
    end
    object uqComplaintUnitsdatearrived: TDateTimeField
      FieldName = 'datearrived'
    end
    object uqComplaintUnitsdatecleared: TDateTimeField
      FieldName = 'datecleared'
    end
    object uqComplaintUnitslocation: TStringField
      FieldName = 'location'
      Size = 100
    end
  end
  object uqCFSMemos: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  cm.MEMO_ID,'
      '  cm.CFSID,'
      '  cm.MEMO_TYPE,'
      '  cm.TIMESTAMP,'
      '  cm.BADGE_NUMBER,'
      '  cm.REMARKS'
      'FROM CFS_MEMOS cm'
      'WHERE cm.CFSID = :CFSID'
      'ORDER BY cm.TIMESTAMP DESC')
    ReadOnly = True
    Left = 198
    Top = 248
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'CFSID'
        Value = nil
      end>
    object uqCFSMemosmemo_id: TFloatField
      FieldName = 'memo_id'
    end
    object uqCFSMemoscfsid: TFloatField
      FieldName = 'cfsid'
    end
    object uqCFSMemosmemo_type: TFloatField
      FieldName = 'memo_type'
    end
    object uqCFSMemostimestamp: TDateTimeField
      FieldName = 'timestamp'
    end
    object uqCFSMemosbadge_number: TStringField
      FieldName = 'badge_number'
      Size = 6
    end
    object uqCFSMemosremarks: TStringField
      FieldName = 'remarks'
      Size = 4000
    end
  end
  object uqComplaintList: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  ca.COMPLAINTID,'
      '  ca.CFSID,'
      '  ca.COMPLAINT,'
      '  ca.AGENCY,'
      '  cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
      '  ca.SOURCE,'
      '  ccs.CODE_DESC AS SOURCE_DESC,'
      '  ca.PRIORITY,'
      '  ca.ADDRESSID,'
      '  ca.ADDRESS,'
      '  ca.APARTMENT,'
      '  ca.CITY,'
      '  ca.BUSINESS,'
      '  cd.CODE_DESC AS DISPATCHDISTRICT,'
      '  ca.DISPATCHSECTOR,'
      '  ca.ADDRESSDISTRICT,'
      '  ca.ADDRESSSECTOR,'
      '  ca.XCOORD,'
      '  ca.YCOORD,'
      '  ca.WARNINGS,'
      '  ca.CONTACTS,'
      '  ca.HISTORY,'
      '  ct.DATEREPORTED,'
      '  ct.DATERECEIVED,'
      '  ct.DATEDISPATCHED,'
      '  ct.DATERESPONDED,'
      '  ct.DATEARRIVED,'
      '  ct.DATECLEARED,'
      '  cp.COLOR AS PRIORITY_COLOR,'
      '  cd.CODE_DESC AS DISTRICT_DESC,'
      '  cs.CODE_DESC AS SECTOR_DESC'
      'FROM COMPLAINT_ACTIVE ca'
      'JOIN COMPLAINT_TIMES ct ON ca.COMPLAINTID = ct.COMPLAINTID'
      'LEFT JOIN CD_DISPATCHCODES cdc ON ca.DISPATCHCODE = cdc.CODE'
      'LEFT JOIN CD_CALLSOURCES   ccs ON ca.SOURCE       = ccs.CODE'
      'LEFT JOIN CD_CALLPRIORITIES cp ON cp.CODE         = ca.PRIORITY'
      
        'LEFT JOIN CD_DISTRICT cd       ON cd.AGENCYCODE   = ca.DISPATCHD' +
        'ISTRICT'
      
        'LEFT JOIN CD_SECTOR   cs       ON cs.AGENCYCODE   = ca.DISPATCHS' +
        'ECTOR AND cs.CODE_TYPE = cd.AGENCYCODE'
      'WHERE ca.COMPLAINT IS NOT NULL'
      
        'ORDER BY COALESCE(ca.AGENCY, '#39#39'), ct.DATEREPORTED DESC, ca.PRIOR' +
        'ITY DESC')
    ReadOnly = True
    OnCalcFields = uqComplaintListCalcFields
    Left = 80
    Top = 248
    object uqComplaintListcomplaintid: TFloatField
      FieldName = 'complaintid'
      Required = True
    end
    object uqComplaintListcfsid: TFloatField
      FieldName = 'cfsid'
    end
    object uqComplaintListcomplaint: TStringField
      FieldName = 'complaint'
      Size = 10
    end
    object uqComplaintListagency: TStringField
      FieldName = 'agency'
      Size = 6
    end
    object uqComplaintListdispatch_code_desc: TStringField
      FieldName = 'dispatch_code_desc'
      ReadOnly = True
      Size = 60
    end
    object uqComplaintListsource: TStringField
      FieldName = 'source'
      Size = 6
    end
    object uqComplaintListsource_desc: TStringField
      FieldName = 'source_desc'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintListpriority: TStringField
      FieldName = 'priority'
      Size = 6
    end
    object uqComplaintListaddressid: TFloatField
      FieldName = 'addressid'
    end
    object uqComplaintListaddress: TStringField
      FieldName = 'address'
      Size = 64
    end
    object uqComplaintListapartment: TStringField
      FieldName = 'apartment'
      Size = 6
    end
    object uqComplaintListcity: TStringField
      FieldName = 'city'
    end
    object uqComplaintListbusiness: TStringField
      FieldName = 'business'
      Size = 35
    end
    object uqComplaintListdispatchdistrict: TStringField
      FieldName = 'dispatchdistrict'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintListdispatchsector: TStringField
      FieldName = 'dispatchsector'
      Size = 6
    end
    object uqComplaintListaddressdistrict: TStringField
      FieldName = 'addressdistrict'
      Size = 5
    end
    object uqComplaintListaddresssector: TStringField
      FieldName = 'addresssector'
      Size = 5
    end
    object uqComplaintListxcoord: TFloatField
      FieldName = 'xcoord'
    end
    object uqComplaintListycoord: TFloatField
      FieldName = 'ycoord'
    end
    object uqComplaintListwarnings: TFloatField
      FieldName = 'warnings'
    end
    object uqComplaintListcontacts: TFloatField
      FieldName = 'contacts'
    end
    object uqComplaintListhistory: TFloatField
      FieldName = 'history'
    end
    object uqComplaintListdatereported: TDateTimeField
      FieldName = 'datereported'
      ReadOnly = True
    end
    object uqComplaintListdatereceived: TDateTimeField
      FieldName = 'datereceived'
      ReadOnly = True
    end
    object uqComplaintListdatedispatched: TDateTimeField
      FieldName = 'datedispatched'
      ReadOnly = True
    end
    object uqComplaintListdateresponded: TDateTimeField
      FieldName = 'dateresponded'
      ReadOnly = True
    end
    object uqComplaintListdatearrived: TDateTimeField
      FieldName = 'datearrived'
      ReadOnly = True
    end
    object uqComplaintListdatecleared: TDateTimeField
      FieldName = 'datecleared'
      ReadOnly = True
    end
    object uqComplaintListpriority_color: TFloatField
      FieldName = 'priority_color'
      ReadOnly = True
    end
    object uqComplaintListdistrict_desc: TStringField
      FieldName = 'district_desc'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintListsector_desc: TStringField
      FieldName = 'sector_desc'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintListcomplaintNumber: TStringField
      FieldKind = fkCalculated
      FieldName = 'complaintNumber'
      Calculated = True
    end
  end
  object uqComplaintDetails: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  ca.COMPLAINTID,'
      '  ca.CFSID,'
      '  ca.COMPLAINT,'
      '  ca.PRIORITY,'
      '  ca.DISPATCHCODE,'
      '  cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
      '  cd.CODE_DESC AS DISPATCHDISTRICT,'
      '  ca.ADDRESS,'
      '  ca.BUSINESS,'
      '  ct.DATEREPORTED,'
      '  ct.DATERECEIVED,'
      '  ct.DATEDISPATCHED,'
      '  ct.DATERESPONDED,'
      '  ct.DATEARRIVED,'
      '  ct.DATECLEARED,'
      ''
      '  -- For enabling/disabling buttons (disable when = '#39'-1'#39')'
      '  ca.HISTORY,'
      '  ca.CONTACTS,'
      '  ca.WARNINGS,'
      ''
      '  -- For Contacts + Warnings lookups'
      '  ca.ADDRESSID,'
      '  ca.AGENCY,'
      ''
      '  -- For History matching (address parts)'
      '  a.STRNUMBER,'
      '  a.STRHNUMBER,'
      '  a.STRPREFIX,'
      '  a.STRNAME,'
      '  a.STRSUFFIX,'
      '  a.CITY,'
      '  0 as status'
      'FROM COMPLAINT_ACTIVE ca'
      'JOIN COMPLAINT_TIMES ct'
      '  ON ca.COMPLAINTID = ct.COMPLAINTID'
      'LEFT JOIN CD_DISPATCHCODES cdc'
      '  ON ca.DISPATCHCODE = cdc.CODE'
      'LEFT JOIN CD_DISTRICT cd'
      '  ON cd.AGENCYCODE = ca.DISPATCHDISTRICT'
      'LEFT JOIN ADDRESS a'
      '  ON ca.ADDRESSID = a.ADDRESSID'
      'WHERE ca.COMPLAINTID = :COMPLAINTID'
      ''
      'union'
      ''
      'SELECT'
      '  ca.COMPLAINTID,'
      '  ca.CFSID,'
      '  ca.COMPLAINT,'
      '  ca.PRIORITY,'
      '  ca.DISPATCHCODE,'
      '  cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
      '  cd.CODE_DESC AS DISPATCHDISTRICT,'
      '  ca.ADDRESS,'
      '  ca.BUSINESS,'
      '  ct.DATEREPORTED,'
      '  ct.DATERECEIVED,'
      '  ct.DATEDISPATCHED,'
      '  ct.DATERESPONDED,'
      '  ct.DATEARRIVED,'
      '  ct.DATECLEARED,'
      ''
      '  -- For enabling/disabling buttons (disable when = '#39'-1'#39')'
      '  ca.HISTORY,'
      '  ca.CONTACTS,'
      '  ca.WARNINGS,'
      ''
      '  -- For Contacts + Warnings lookups'
      '  ca.ADDRESSID,'
      '  ca.AGENCY,'
      ''
      '  -- For History matching (address parts)'
      '  a.STRNUMBER,'
      '  a.STRHNUMBER,'
      '  a.STRPREFIX,'
      '  a.STRNAME,'
      '  a.STRSUFFIX,'
      '  a.CITY,'
      '  1 as status'
      'FROM COMPLAINT_ARCHIVE ca'
      'JOIN COMPLAINT_TIMES ct'
      '  ON ca.COMPLAINTID = ct.COMPLAINTID'
      'LEFT JOIN CD_DISPATCHCODES cdc'
      '  ON ca.DISPATCHCODE = cdc.CODE'
      'LEFT JOIN CD_DISTRICT cd'
      '  ON cd.AGENCYCODE = ca.DISPATCHDISTRICT'
      'LEFT JOIN ADDRESS a'
      '  ON ca.ADDRESSID = a.ADDRESSID'
      'WHERE ca.COMPLAINTID = :COMPLAINTID;'
      '')
    ReadOnly = True
    Left = 82
    Top = 302
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'COMPLAINTID'
        Value = Null
      end>
    object uqComplaintDetailscomplaintid: TFloatField
      FieldName = 'complaintid'
      ReadOnly = True
    end
    object uqComplaintDetailscfsid: TFloatField
      FieldName = 'cfsid'
      ReadOnly = True
    end
    object uqComplaintDetailscomplaint: TStringField
      FieldName = 'complaint'
      ReadOnly = True
      Size = 10
    end
    object uqComplaintDetailspriority: TStringField
      FieldName = 'priority'
      ReadOnly = True
      Size = 6
    end
    object uqComplaintDetailsdispatchcode: TStringField
      FieldName = 'dispatchcode'
      ReadOnly = True
      Size = 6
    end
    object uqComplaintDetailsdispatch_code_desc: TStringField
      FieldName = 'dispatch_code_desc'
      ReadOnly = True
      Size = 60
    end
    object uqComplaintDetailsdispatchdistrict: TStringField
      FieldName = 'dispatchdistrict'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintDetailsaddress: TStringField
      FieldName = 'address'
      ReadOnly = True
      Size = 64
    end
    object uqComplaintDetailsbusiness: TStringField
      FieldName = 'business'
      ReadOnly = True
      Size = 35
    end
    object uqComplaintDetailsdatereported: TDateTimeField
      FieldName = 'datereported'
      ReadOnly = True
    end
    object uqComplaintDetailsdatereceived: TDateTimeField
      FieldName = 'datereceived'
      ReadOnly = True
    end
    object uqComplaintDetailsdatedispatched: TDateTimeField
      FieldName = 'datedispatched'
      ReadOnly = True
    end
    object uqComplaintDetailsdateresponded: TDateTimeField
      FieldName = 'dateresponded'
      ReadOnly = True
    end
    object uqComplaintDetailsdatearrived: TDateTimeField
      FieldName = 'datearrived'
      ReadOnly = True
    end
    object uqComplaintDetailsdatecleared: TDateTimeField
      FieldName = 'datecleared'
      ReadOnly = True
    end
    object uqComplaintDetailshistory: TFloatField
      FieldName = 'history'
      ReadOnly = True
    end
    object uqComplaintDetailscontacts: TFloatField
      FieldName = 'contacts'
      ReadOnly = True
    end
    object uqComplaintDetailswarnings: TFloatField
      FieldName = 'warnings'
      ReadOnly = True
    end
    object uqComplaintDetailsaddressid: TFloatField
      FieldName = 'addressid'
      ReadOnly = True
    end
    object uqComplaintDetailsagency: TStringField
      FieldName = 'agency'
      ReadOnly = True
      Size = 6
    end
    object uqComplaintDetailsstrnumber: TFloatField
      FieldName = 'strnumber'
      ReadOnly = True
    end
    object uqComplaintDetailsstrhnumber: TStringField
      FieldName = 'strhnumber'
      ReadOnly = True
      Size = 1
    end
    object uqComplaintDetailsstrprefix: TStringField
      FieldName = 'strprefix'
      ReadOnly = True
      Size = 1
    end
    object uqComplaintDetailsstrname: TStringField
      FieldName = 'strname'
      ReadOnly = True
    end
    object uqComplaintDetailsstrsuffix: TStringField
      FieldName = 'strsuffix'
      ReadOnly = True
      Size = 2
    end
    object uqComplaintDetailscity: TStringField
      FieldName = 'city'
      ReadOnly = True
    end
    object uqComplaintDetailsstatus: TIntegerField
      FieldName = 'status'
      ReadOnly = True
    end
  end
  object ucENTCAD: TUniConnection
    ProviderName = 'PostgreSQL'
    Port = 5432
    Database = 'lems_ocso'
    SpecificOptions.Strings = (
      'PostgreSQL.Schema=lems, avl, entcad')
    Username = 'postgres'
    Server = '192.168.74.10'
    LoginPrompt = False
    Left = 54
    Top = 38
    EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
  end
  object uqMapComplaints: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  ca.COMPLAINTID,'
      '  cd.CODE_DESC AS DISPATCHDISTRICT,'
      '  ca.AGENCY AS AGENCY,'
      '  ag.AGENCYNAME AS AGENCY_NAME,'
      '  ca.PRIORITY AS PRIORITY,'
      '  ct.DATEDISPATCHED AS DATEDISPATCHED,'
      '  ct.DATEARRIVED AS DATEARRIVED,'
      '  ca.BUSINESS,'
      '  cdc.CATEGORY AS DISPATCHCODECATEGORY,'
      ''
      '  ST_X('
      '    ST_Transform('
      
        '      ST_SetSRID(ST_MakePoint(ca.XCOORD::double precision, ca.YC' +
        'OORD::double precision), 2262),'
      '      4326'
      '    )'
      '  ) AS LNG,'
      ''
      '  ST_Y('
      '    ST_Transform('
      
        '      ST_SetSRID(ST_MakePoint(ca.XCOORD::double precision, ca.YC' +
        'OORD::double precision), 2262),'
      '      4326'
      '    )'
      '  ) AS LAT,'
      ''
      '  cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
      '  ca.ADDRESS AS ADDRESS'
      'FROM COMPLAINT_ACTIVE ca'
      'JOIN COMPLAINT_TIMES ct'
      '  ON ct.COMPLAINTID = ca.COMPLAINTID'
      'LEFT JOIN CD_DISPATCHCODES cdc'
      '  ON cdc.CODE = ca.DISPATCHCODE'
      'LEFT JOIN CD_DISTRICT cd'
      '  ON cd.AGENCYCODE = ca.DISPATCHDISTRICT'
      'LEFT JOIN AGENCY ag'
      '  ON ag.AGENCYID = ca.AGENCY'
      'WHERE ca.COMPLAINT IS NOT NULL'
      '  AND ca.XCOORD IS NOT NULL'
      '  AND ca.YCOORD IS NOT NULL')
    ReadOnly = True
    OnCalcFields = uqMapComplaintsCalcFields
    Left = 468
    Top = 264
    object uqMapComplaintscomplaintid: TFloatField
      FieldName = 'complaintid'
      Required = True
    end
    object uqMapComplaintsdispatchdistrict: TStringField
      FieldName = 'dispatchdistrict'
      ReadOnly = True
      Size = 120
    end
    object uqMapComplaintspriority: TStringField
      FieldName = 'priority'
      Size = 6
    end
    object uqMapComplaintsbusiness: TStringField
      FieldName = 'business'
      Size = 35
    end
    object uqMapComplaintsdispatchcodecategory: TStringField
      FieldName = 'dispatchcodecategory'
      ReadOnly = True
      Size = 30
    end
    object uqMapComplaintslng: TFloatField
      FieldName = 'lng'
      ReadOnly = True
    end
    object uqMapComplaintslat: TFloatField
      FieldName = 'lat'
      ReadOnly = True
    end
    object uqMapComplaintsdispatch_code_desc: TStringField
      FieldName = 'dispatch_code_desc'
      ReadOnly = True
      Size = 60
    end
    object uqMapComplaintsaddress: TStringField
      FieldName = 'address'
      Size = 64
    end
    object uqMapComplaintsagency: TStringField
      FieldName = 'agency'
      Size = 6
    end
    object uqMapComplaintsagency_name: TStringField
      FieldName = 'agency_name'
      ReadOnly = True
      Size = 40
    end
    object uqMapComplaintsdatedispatched: TDateTimeField
      FieldName = 'datedispatched'
      ReadOnly = True
    end
    object uqMapComplaintsdatearrived: TDateTimeField
      FieldName = 'datearrived'
      ReadOnly = True
    end
    object uqMapComplaintspriorityBadge: TStringField
      FieldKind = fkCalculated
      FieldName = 'priorityBadge'
      Size = 80
      Calculated = True
    end
    object uqMapComplaintscomplaintStatusKey: TStringField
      FieldKind = fkCalculated
      FieldName = 'complaintStatusKey'
      Size = 80
      Calculated = True
    end
    object uqMapComplaintspngName: TStringField
      FieldKind = fkCalculated
      FieldName = 'pngName'
      Size = 80
      Calculated = True
    end
  end
  object uqBadgeCounts: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'select'
      '  (select count(*)'
      '     from COMPLAINT_ACTIVE ca'
      '     join COMPLAINT_TIMES ct on ct.COMPLAINTID = ca.COMPLAINTID'
      '    where ca.COMPLAINT is not null) as Complaints,'
      ''
      '  (select count(distinct dua.UNITID)'
      '     from DIS_UNIT_ACTIVE dua'
      '     join AGENCY ag on ag.AGENCYID = dua.AGENCY'
      '    where ag.AGENCYTYPE = '#39'POL'#39') as Units')
    ReadOnly = True
    Left = 200
    Top = 192
    object uqBadgeCountscomplaints: TLargeintField
      FieldName = 'complaints'
      ReadOnly = True
    end
    object uqBadgeCountsunits: TLargeintField
      FieldName = 'units'
      ReadOnly = True
    end
  end
  object uqMapComplaintUnitsList: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  ca.COMPLAINTID,'
      '  ca.UNITID,'
      '  ca.UNITNAME,'
      '  ca.DATEDISPATCHED,'
      '  ca.DATERESPONDED,'
      '  ca.DATEARRIVED,'
      '  ca.DATECLEARED,'
      '  ca.LOCATION'
      'FROM CFS_ACTIVE ca'
      'WHERE ca.COMPLAINTID IN ('
      '  SELECT c.COMPLAINTID'
      '  FROM COMPLAINT_ACTIVE c'
      '  WHERE c.XCOORD IS NOT NULL'
      '    AND c.YCOORD IS NOT NULL'
      ')'
      'ORDER BY ca.COMPLAINTID, ca.DATEDISPATCHED;')
    ReadOnly = True
    Left = 464
    Top = 202
    object uqMapComplaintUnitsListcomplaintid: TFloatField
      FieldName = 'complaintid'
      Required = True
    end
    object uqMapComplaintUnitsListunitid: TFloatField
      FieldName = 'unitid'
      Required = True
    end
    object uqMapComplaintUnitsListunitname: TStringField
      FieldName = 'unitname'
      Size = 10
    end
    object uqMapComplaintUnitsListdatedispatched: TDateTimeField
      FieldName = 'datedispatched'
    end
    object uqMapComplaintUnitsListdateresponded: TDateTimeField
      FieldName = 'dateresponded'
    end
    object uqMapComplaintUnitsListdatearrived: TDateTimeField
      FieldName = 'datearrived'
    end
    object uqMapComplaintUnitsListdatecleared: TDateTimeField
      FieldName = 'datecleared'
    end
    object uqMapComplaintUnitsListlocation: TStringField
      FieldName = 'location'
      Size = 100
    end
  end
  object uqComplaintHistory: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'with ctx as ('
      '  select'
      '    ca.agency,'
      '    a.strnumber,'
      '    a.strhnumber,'
      '    a.strprefix,'
      '    a.strname,'
      '    a.strsuffix,'
      '    a.city'
      '  from complaint_active ca'
      '  left join address a on ca.addressid = a.addressid'
      '  where ca.complaintid = :COMPLAINTID'
      ')'
      'select'
      '  c.complaintid,'
      '  c.complaint,'
      '  c.apartment,'
      '  c.datereported,'
      '  cp.code_desc as dpriority,'
      '  cdc.code_desc as dcalltype'
      'from complaint_archive c'
      'join ctx on 1 = 1'
      'left join cd_callpriorities cp on c.priority = cp.code'
      'left join cd_dispatchcodes cdc on c.dispatchcode = cdc.code'
      'where c.agency = ctx.agency'
      'and ('
      '  (ctx.strnumber is null and c.strnumber is null)'
      '  or (ctx.strnumber is not null and c.strnumber = ctx.strnumber)'
      ')'
      'and (ctx.strhnumber is null or c.strhnumber = ctx.strhnumber)'
      'and (ctx.strprefix is null or c.strprefix = ctx.strprefix)'
      'and (ctx.strname is null or c.strname = ctx.strname)'
      'and (ctx.strsuffix is null or c.strsuffix = ctx.strsuffix)'
      'and (ctx.city is null or c.city = ctx.city)'
      'order by c.datereported desc')
    ReadOnly = True
    Left = 330
    Top = 72
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'COMPLAINTID'
        Value = Null
      end>
    object uqComplaintHistorycomplaintid: TFloatField
      FieldName = 'complaintid'
      Required = True
    end
    object uqComplaintHistorycomplaint: TStringField
      FieldName = 'complaint'
      Size = 10
    end
    object uqComplaintHistoryapartment: TStringField
      FieldName = 'apartment'
      Size = 6
    end
    object uqComplaintHistorydatereported: TDateTimeField
      FieldName = 'datereported'
      Required = True
    end
    object uqComplaintHistorydpriority: TStringField
      FieldName = 'dpriority'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintHistorydcalltype: TStringField
      FieldName = 'dcalltype'
      ReadOnly = True
      Size = 60
    end
  end
  object uqComplaintContacts: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'with ctx as ('
      '  select ca.addressid'
      '  from complaint_active ca'
      '  where ca.complaintid = :COMPLAINTID'
      ')'
      'select'
      '  c.name,'
      '  c.phone,'
      '  ct.code_desc as dcontacttype,'
      '  c.remarks'
      'from dis_contact c'
      'join ctx on c.addressid = ctx.addressid'
      'left join cd_contacttype ct on c.contacttype = ct.code'
      'order by c.notifyorder, c.name')
    ReadOnly = True
    Left = 330
    Top = 130
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'COMPLAINTID'
        Value = nil
      end>
    object uqComplaintContactsname: TStringField
      FieldName = 'name'
      Size = 30
    end
    object uqComplaintContactsphone: TStringField
      FieldName = 'phone'
      Size = 15
    end
    object uqComplaintContactsdcontacttype: TStringField
      FieldName = 'dcontacttype'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintContactsremarks: TStringField
      FieldName = 'remarks'
      Size = 200
    end
  end
  object uqComplaintWarnings: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  wt.CODE_DESC,'
      '  a.STRNUMBER,'
      '  a.STRHNUMBER,'
      '  a.STRPREFIX,'
      '  a.STRNAME,'
      '  a.STRSUFFIX,'
      '  a.APARTMENT,'
      '  a.CITY,'
      '  w.NOTES'
      'FROM COMPLAINT_ACTIVE ca'
      'JOIN DIS_WARNING w'
      '  ON w.ADDRESSID = ca.ADDRESSID'
      'JOIN CD_WARNINGTYPE wt'
      '  ON w.CODE = wt.CODE'
      'JOIN ADDRESS a'
      '  ON w.ADDRESSID = a.ADDRESSID'
      'WHERE ca.COMPLAINTID = :COMPLAINTID'
      '  AND w.STATUS = '#39'1'#39
      'ORDER BY wt.CODE_DESC')
    ReadOnly = True
    Left = 488
    Top = 76
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'COMPLAINTID'
        Value = nil
      end>
    object uqComplaintWarningscode_desc: TStringField
      FieldName = 'code_desc'
      ReadOnly = True
      Size = 120
    end
    object uqComplaintWarningsstrnumber: TFloatField
      FieldName = 'strnumber'
      ReadOnly = True
    end
    object uqComplaintWarningsstrhnumber: TStringField
      FieldName = 'strhnumber'
      ReadOnly = True
      Size = 1
    end
    object uqComplaintWarningsstrprefix: TStringField
      FieldName = 'strprefix'
      ReadOnly = True
      Size = 1
    end
    object uqComplaintWarningsstrname: TStringField
      FieldName = 'strname'
      ReadOnly = True
    end
    object uqComplaintWarningsstrsuffix: TStringField
      FieldName = 'strsuffix'
      ReadOnly = True
      Size = 2
    end
    object uqComplaintWarningsapartment: TStringField
      FieldName = 'apartment'
      ReadOnly = True
      Size = 6
    end
    object uqComplaintWarningscity: TStringField
      FieldName = 'city'
      ReadOnly = True
    end
    object uqComplaintWarningsnotes: TStringField
      FieldName = 'notes'
      ReadOnly = True
      Size = 1000
    end
  end
  object uqUnitDetails: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'SELECT'
      '  dua.UNITID,'
      '  dua.UNITNAME,'
      '  cun.CODE_DESC AS CARNUMBER_DESC,'
      '  cd.CODE_DESC AS DISTRICT_DESC,'
      '  ca.LOCATION,'
      '  cus.CODE_DESC AS UNIT_STATUS_DESC,'
      '  p1.PF_LNAME AS OFFICER1_LNAME,'
      '  p1.PF_FNAME AS OFFICER1_FNAME,'
      '  p1.PF_EMPNUM AS OFFICER1_EMPNUM,'
      '  p2.PF_LNAME AS OFFICER2_LNAME,'
      '  p2.PF_FNAME AS OFFICER2_FNAME,'
      '  p2.PF_EMPNUM AS OFFICER2_EMPNUM,'
      '  uc.UPDATETIME AS UPDATE_TIME'
      'FROM DIS_UNIT_ACTIVE dua'
      'LEFT JOIN CD_UNIT_NUMBER cun ON cun.AGENCYCODE = dua.CARNUMBER'
      'LEFT JOIN CD_DISTRICT cd ON cd.AGENCYCODE = dua.DISTRICT'
      'LEFT JOIN CFS_ACTIVE ca ON dua.UNITID = ca.UNITID'
      'LEFT JOIN CD_UNITSTATUS cus ON ca.UNITSTATUS = cus.CODE'
      'LEFT JOIN PERSONNEL p1 ON dua.OFFICER1ID = p1.PF_NAMEID'
      'LEFT JOIN PERSONNEL p2 ON dua.OFFICER2ID = p2.PF_NAMEID'
      'LEFT JOIN avl.UNITS_CURRENT uc ON dua.UNITID = uc.UNITID'
      'WHERE dua.UNITID = :UNITID')
    ReadOnly = True
    Left = 198
    Top = 304
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'UNITID'
        Value = nil
      end>
    object uqUnitDetailsunitid: TFloatField
      FieldName = 'unitid'
    end
    object uqUnitDetailsunitname: TStringField
      FieldName = 'unitname'
      Size = 10
    end
    object uqUnitDetailscarnumber_desc: TStringField
      FieldName = 'carnumber_desc'
      ReadOnly = True
      Size = 120
    end
    object uqUnitDetailsdistrict_desc: TStringField
      FieldName = 'district_desc'
      ReadOnly = True
      Size = 120
    end
    object uqUnitDetailslocation: TStringField
      FieldName = 'location'
      ReadOnly = True
      Size = 100
    end
    object uqUnitDetailsunit_status_desc: TStringField
      FieldName = 'unit_status_desc'
      ReadOnly = True
    end
    object uqUnitDetailsofficer1_lname: TStringField
      FieldName = 'officer1_lname'
      ReadOnly = True
      Size = 15
    end
    object uqUnitDetailsofficer1_fname: TStringField
      FieldName = 'officer1_fname'
      ReadOnly = True
      Size = 12
    end
    object uqUnitDetailsofficer1_empnum: TStringField
      FieldName = 'officer1_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqUnitDetailsofficer2_lname: TStringField
      FieldName = 'officer2_lname'
      ReadOnly = True
      Size = 15
    end
    object uqUnitDetailsofficer2_fname: TStringField
      FieldName = 'officer2_fname'
      ReadOnly = True
      Size = 12
    end
    object uqUnitDetailsofficer2_empnum: TStringField
      FieldName = 'officer2_empnum'
      ReadOnly = True
      Size = 10
    end
    object uqUnitDetailsupdate_time: TDateTimeField
      FieldName = 'update_time'
      ReadOnly = True
    end
  end
  object uqUnitLogs: TUniQuery
    Connection = ucENTCAD
    SQL.Strings = (
      'select'
      '  dul.timestamp as LOG_TIME,'
      '  dul.complaint as COMPLAINT_NUM,'
      '  dul.log as LOG_TEXT'
      'from DIS_UNIT_LOG dul'
      'where dul.unitid = :UNITID'
      'order by dul.timestamp desc')
    ReadOnly = True
    Left = 198
    Top = 358
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'UNITID'
        Value = nil
      end>
    object uqUnitLogslog_time: TDateTimeField
      FieldName = 'log_time'
    end
    object uqUnitLogscomplaint_num: TStringField
      FieldName = 'complaint_num'
      Size = 10
    end
    object uqUnitLogslog_text: TStringField
      FieldName = 'log_text'
      Size = 2000
    end
  end
  object PostgreSQLUniProvider1: TPostgreSQLUniProvider
    Left = 162
    Top = 42
  end
end
