object ApiDatabase: TApiDatabase
  OnCreate = DataModuleCreate
  Height = 358
  Width = 519
  object ucETaskApi: TUniConnection
    AutoCommit = False
    ProviderName = 'MySQL'
    Database = 'eTask'
    Username = 'root'
    Server = '192.168.102.129'
    LoginPrompt = False
    Left = 71
    Top = 65
    EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
  end
  object MySQLUniProvider1: TMySQLUniProvider
    Left = 178
    Top = 66
  end
  object uqUsers: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME')
    OnCalcFields = uqUsersCalcFields
    Left = 304
    Top = 70
    object uqUsersUSER_ID: TIntegerField
      FieldName = 'USER_ID'
      Required = True
    end
    object uqUsersNAME: TStringField
      FieldName = 'NAME'
      Size = 40
    end
    object uqUsersSTATUS: TStringField
      FieldName = 'STATUS'
      Size = 7
    end
    object uqUsersREPRESENTATIVE: TStringField
      FieldKind = fkCalculated
      FieldName = 'REPRESENTATIVE'
      Calculated = True
    end
  end
  object uqSaveTaskRow: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'UPDATE task_items'
      'SET'
      '  APPLICATION   = :APPLICATION,'
      '  APP_VERSION   = :APP_VERSION,'
      '  TASK_DATE     = :TASK_DATE,'
      '  REPORTED_BY   = :REPORTED_BY,'
      '  ASSIGNED_TO   = :ASSIGNED_TO,'
      '  STATUS        = :STATUS,'
      '  STATUS_DATE   = :STATUS_DATE,'
      '  FIXED_VERSION = :FIXED_VERSION,'
      '  FORM_SECTION  = :FORM_SECTION,'
      '  ISSUE         = :ISSUE,'
      '  NOTES         = :NOTES'
      'WHERE TASK_ITEM_ID = :TASK_ITEM_ID')
    Left = 306
    Top = 198
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'APPLICATION'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'APP_VERSION'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_DATE'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'REPORTED_BY'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'ASSIGNED_TO'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'STATUS'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'STATUS_DATE'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'FIXED_VERSION'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'FORM_SECTION'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'ISSUE'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'NOTES'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ITEM_ID'
        Value = nil
      end>
  end
  object uqTaskItems: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  TASK_ITEM_ID,'
      '  TASK_ID,'
      '  ITEM_NUM,'
      '  APPLICATION,'
      '  APP_VERSION,'
      '  TASK_DATE,'
      '  STATUS_DATE,'
      '  REPORTED_BY,'
      '  ASSIGNED_TO,'
      '  STATUS,'
      '  FIXED_VERSION,'
      '  FORM_SECTION,'
      '  ISSUE,'
      '  NOTES'
      'from task_items'
      'where TASK_ID = :TASK_ID'
      'order by ITEM_NUM')
    Left = 306
    Top = 134
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqTaskItemsTASK_ITEM_ID: TStringField
      FieldName = 'TASK_ITEM_ID'
      Required = True
      Size = 7
    end
    object uqTaskItemsTASK_ID: TStringField
      FieldName = 'TASK_ID'
      Required = True
      Size = 7
    end
    object uqTaskItemsITEM_NUM: TShortintField
      FieldName = 'ITEM_NUM'
      Required = True
    end
    object uqTaskItemsAPPLICATION: TStringField
      FieldName = 'APPLICATION'
      Required = True
      Size = 255
    end
    object uqTaskItemsAPP_VERSION: TStringField
      FieldName = 'APP_VERSION'
      Required = True
      Size = 50
    end
    object uqTaskItemsTASK_DATE: TDateField
      FieldName = 'TASK_DATE'
      Required = True
    end
    object uqTaskItemsSTATUS_DATE: TDateField
      FieldName = 'STATUS_DATE'
      Required = True
    end
    object uqTaskItemsREPORTED_BY: TStringField
      FieldName = 'REPORTED_BY'
      Required = True
      Size = 50
    end
    object uqTaskItemsASSIGNED_TO: TStringField
      FieldName = 'ASSIGNED_TO'
      Required = True
      Size = 50
    end
    object uqTaskItemsSTATUS: TStringField
      FieldName = 'STATUS'
      Required = True
      Size = 100
    end
    object uqTaskItemsFIXED_VERSION: TStringField
      FieldName = 'FIXED_VERSION'
      Required = True
      Size = 50
    end
    object uqTaskItemsFORM_SECTION: TStringField
      FieldName = 'FORM_SECTION'
      Required = True
      Size = 255
    end
    object uqTaskItemsISSUE: TStringField
      FieldName = 'ISSUE'
      Required = True
      Size = 1000
    end
    object uqTaskItemsNOTES: TStringField
      FieldName = 'NOTES'
      Required = True
      Size = 1000
    end
  end
  object uqEnsureBlankRow: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'insert ignore into task_items ('
      '  TASK_ITEM_ID,'
      '  TASK_ID,'
      '  ITEM_NUM,'
      '  PROJECT_ID,'
      '  APPLICATION,'
      '  APP_VERSION,'
      '  TASK_DATE,'
      '  STATUS_DATE,'
      '  REPORTED_BY,'
      '  ASSIGNED_TO,'
      '  STATUS,'
      '  FIXED_VERSION,'
      '  FORM_SECTION,'
      '  ISSUE,'
      '  NOTES'
      ')'
      'values ('
      '  :TASK_ID,'
      '  :TASK_ID,'
      
        '  coalesce((select PROJECT_ID from tasks where TASK_ID = :TASK_I' +
        'D), '#39#39'),'
      '  '#39#39','
      '  '#39#39','
      '  curdate(),'
      '  curdate(),'
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39
      ')')
    Left = 306
    Top = 254
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
  end
  object uqTaskHeader: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  t.TASK_ID,'
      '  t.PARENT_ID,'
      '  t.TASK_NUM_1,'
      '  t.TASK_NUM_2,'
      '  t.TASK_NUM_3,'
      '  t.TASK_NUM_4,'
      '  t.TASK_NUM_5,'
      '  t.TASK_NUM_6,'
      '  t.PROJECT_ID,'
      '  t.SUBJECT,'
      '  p.NAME as PROJECT_NAME'
      'from tasks t'
      'left join project p'
      '  on p.PROJECT_ID = t.PROJECT_ID'
      'where t.TASK_ID = :TASK_ID')
    Left = 164
    Top = 248
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqTaskHeaderTASK_ID: TStringField
      FieldName = 'TASK_ID'
      Required = True
      Size = 7
    end
    object uqTaskHeaderPARENT_ID: TStringField
      FieldName = 'PARENT_ID'
      Size = 7
    end
    object uqTaskHeaderTASK_NUM_1: TIntegerField
      FieldName = 'TASK_NUM_1'
    end
    object uqTaskHeaderTASK_NUM_2: TIntegerField
      FieldName = 'TASK_NUM_2'
    end
    object uqTaskHeaderTASK_NUM_3: TIntegerField
      FieldName = 'TASK_NUM_3'
    end
    object uqTaskHeaderTASK_NUM_4: TIntegerField
      FieldName = 'TASK_NUM_4'
    end
    object uqTaskHeaderTASK_NUM_5: TIntegerField
      FieldName = 'TASK_NUM_5'
    end
    object uqTaskHeaderTASK_NUM_6: TIntegerField
      FieldName = 'TASK_NUM_6'
    end
    object uqTaskHeaderPROJECT_ID: TStringField
      FieldName = 'PROJECT_ID'
      Size = 7
    end
    object uqTaskHeaderSUBJECT: TStringField
      FieldName = 'SUBJECT'
      Size = 80
    end
    object uqTaskHeaderPROJECT_NAME: TStringField
      FieldName = 'PROJECT_NAME'
      ReadOnly = True
      Size = 30
    end
  end
  object uqTaskItemsForParent: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  ti.TASK_ITEM_ID,'
      '  ti.TASK_ID,'
      '  ti.ITEM_NUM,'
      '  ti.APPLICATION,'
      '  ti.APP_VERSION,'
      '  ti.TASK_DATE,'
      '  ti.STATUS_DATE,'
      '  ti.REPORTED_BY,'
      '  ti.ASSIGNED_TO,'
      '  ti.STATUS,'
      '  ti.FIXED_VERSION,'
      '  ti.FORM_SECTION,'
      '  ti.ISSUE,'
      '  ti.NOTES'
      'from task_items ti'
      'join tasks t'
      '  on t.TASK_ID = ti.TASK_ID'
      'where ti.TASK_ID = :TASK_ID'
      '   or t.PARENT_ID = :TASK_ID'
      'order by'
      '  case when ti.TASK_ID = :TASK_ID then 0 else 1 end,'
      '  t.TASK_NUM_1,'
      '  t.TASK_NUM_2,'
      '  t.TASK_NUM_3,'
      '  t.TASK_NUM_4,'
      '  t.TASK_NUM_5,'
      '  t.TASK_NUM_6,'
      '  ti.ITEM_NUM')
    Left = 164
    Top = 182
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqTaskItemsForParentTASK_ITEM_ID: TStringField
      FieldName = 'TASK_ITEM_ID'
      Required = True
      Size = 7
    end
    object uqTaskItemsForParentTASK_ID: TStringField
      FieldName = 'TASK_ID'
      Required = True
      Size = 7
    end
    object uqTaskItemsForParentITEM_NUM: TSmallintField
      FieldName = 'ITEM_NUM'
      Required = True
    end
    object uqTaskItemsForParentAPPLICATION: TStringField
      FieldName = 'APPLICATION'
      Required = True
      Size = 255
    end
    object uqTaskItemsForParentAPP_VERSION: TStringField
      FieldName = 'APP_VERSION'
      Required = True
      Size = 50
    end
    object uqTaskItemsForParentTASK_DATE: TDateField
      FieldName = 'TASK_DATE'
      Required = True
    end
    object uqTaskItemsForParentSTATUS_DATE: TDateField
      FieldName = 'STATUS_DATE'
      Required = True
    end
    object uqTaskItemsForParentREPORTED_BY: TStringField
      FieldName = 'REPORTED_BY'
      Required = True
      Size = 50
    end
    object uqTaskItemsForParentASSIGNED_TO: TStringField
      FieldName = 'ASSIGNED_TO'
      Required = True
      Size = 50
    end
    object uqTaskItemsForParentSTATUS: TStringField
      FieldName = 'STATUS'
      Required = True
      Size = 100
    end
    object uqTaskItemsForParentFIXED_VERSION: TStringField
      FieldName = 'FIXED_VERSION'
      Required = True
      Size = 50
    end
    object uqTaskItemsForParentFORM_SECTION: TStringField
      FieldName = 'FORM_SECTION'
      Required = True
      Size = 255
    end
    object uqTaskItemsForParentISSUE: TStringField
      FieldName = 'ISSUE'
      Required = True
      Size = 1000
    end
    object uqTaskItemsForParentNOTES: TStringField
      FieldName = 'NOTES'
      Required = True
      Size = 1000
    end
  end
end
