object ApiDatabase: TApiDatabase
  OnCreate = DataModuleCreate
  Height = 358
  Width = 519
  object ucETaskApi: TUniConnection
    AutoCommit = False
    ProviderName = 'MySQL'
    Database = 'eTask'
    LoginPrompt = False
    Left = 51
    Top = 67
  end
  object MySQLUniProvider1: TMySQLUniProvider
    Left = 56
    Top = 14
  end
  object uqUsers: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME')
    OnCalcFields = uqUsersCalcFields
    Left = 408
    Top = 20
    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 = 408
    Top = 242
    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 = 62
    Top = 138
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqTaskItemsTASK_ITEM_ID: TIntegerField
      FieldName = 'TASK_ITEM_ID'
    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 uqAddTaskRow: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'insert into task_items ('
      '  TASK_ID,'
      '  ITEM_NUM,'
      '  APPLICATION,'
      '  APP_VERSION,'
      '  TASK_DATE,'
      '  STATUS_DATE,'
      '  REPORTED_BY,'
      '  ASSIGNED_TO,'
      '  STATUS,'
      '  FIXED_VERSION,'
      '  FORM_SECTION,'
      '  ISSUE,'
      '  NOTES'
      ')'
      'values ('
      '  :TASK_ID,'
      '  :ITEM_NUM,'
      '  '#39#39','
      '  '#39#39','
      '  curdate(),'
      '  curdate(),'
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39','
      '  '#39#39
      ')')
    Left = 412
    Top = 300
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'ITEM_NUM'
        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 = 60
    Top = 242
    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 uqTaskItemUsers: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  TASK_ITEM_USER_ID,'
      '  TASK_ID,'
      '  USER_TYPE,'
      '  NAME'
      'from task_item_user'
      'where TASK_ID = :TASK_ID'
      'order by USER_TYPE, NAME')
    Left = 62
    Top = 188
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqTaskItemUsersTASK_ITEM_USER_ID: TStringField
      FieldName = 'TASK_ITEM_USER_ID'
      Required = True
      Size = 50
    end
    object uqTaskItemUsersTASK_ID: TStringField
      FieldName = 'TASK_ID'
      Required = True
      Size = 7
    end
    object uqTaskItemUsersUSER_TYPE: TStringField
      FieldName = 'USER_TYPE'
      Required = True
      Size = 8
    end
    object uqTaskItemUsersNAME: TStringField
      FieldName = 'NAME'
      Required = True
      Size = 50
    end
  end
  object uqTaskItemCodes: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'SELECT'
      '  CODE,'
      '  CODE_DESC,'
      '  CODE_TYPE'
      'FROM etask.task_item_codes'
      'WHERE CODE_TYPE = '#39'STATUS'#39
      'ORDER BY CODE')
    Left = 60
    Top = 296
    object uqTaskItemCodesCODE: TStringField
      FieldName = 'CODE'
      Required = True
      Size = 50
    end
    object uqTaskItemCodesCODE_DESC: TStringField
      FieldName = 'CODE_DESC'
      Size = 255
    end
    object uqTaskItemCodesCODE_TYPE: TStringField
      FieldName = 'CODE_TYPE'
      Size = 50
    end
  end
  object uqGetTaskRowPosition: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  TASK_ITEM_ID,'
      '  TASK_ID,'
      '  ITEM_NUM'
      'from task_items'
      'where TASK_ITEM_ID = :TASK_ITEM_ID'
      '  and TASK_ID = :TASK_ID')
    Left = 240
    Top = 16
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ITEM_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqGetTaskRowPositionTASK_ITEM_ID: TIntegerField
      AutoGenerateValue = arAutoInc
      FieldName = 'TASK_ITEM_ID'
    end
    object uqGetTaskRowPositionTASK_ID: TStringField
      FieldName = 'TASK_ID'
      Required = True
      Size = 7
    end
    object uqGetTaskRowPositionITEM_NUM: TSmallintField
      FieldName = 'ITEM_NUM'
      Required = True
    end
  end
  object uqMoveTaskRowTemp: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = :TEMP_ITEM_NUM'
      'where TASK_ITEM_ID = :TASK_ITEM_ID'
      '  and TASK_ID = :TASK_ID')
    Left = 238
    Top = 72
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TEMP_ITEM_NUM'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ITEM_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
  end
  object uqShiftTaskRowsDown: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = ITEM_NUM + 1'
      'where TASK_ID = :TASK_ID'
      '  and ITEM_NUM >= :NEW_ITEM_NUM'
      '  and ITEM_NUM < :OLD_ITEM_NUM')
    Left = 234
    Top = 132
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'NEW_ITEM_NUM'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'OLD_ITEM_NUM'
        Value = nil
      end>
  end
  object uqShiftTaskRowsUp: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = ITEM_NUM - 1'
      'where TASK_ID = :TASK_ID'
      '  and ITEM_NUM > :OLD_ITEM_NUM'
      '  and ITEM_NUM <= :NEW_ITEM_NUM')
    Left = 236
    Top = 184
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'OLD_ITEM_NUM'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'NEW_ITEM_NUM'
        Value = nil
      end>
  end
  object uqSetTaskRowFinalPosition: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = :NEW_ITEM_NUM'
      'where TASK_ITEM_ID = :TASK_ITEM_ID'
      '  and TASK_ID = :TASK_ID')
    Left = 234
    Top = 232
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'NEW_ITEM_NUM'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ITEM_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
  end
  object uqGetTaskMaxItemNum: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'select'
      '  coalesce(max(ITEM_NUM), 0) as MAX_ITEM_NUM'
      'from task_items'
      'where TASK_ID = :TASK_ID')
    Left = 236
    Top = 290
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
    object uqGetTaskMaxItemNumMAX_ITEM_NUM: TIntegerField
      FieldName = 'MAX_ITEM_NUM'
      ReadOnly = True
    end
  end
  object uqDeleteTaskRow: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'delete from task_items'
      'where TASK_ITEM_ID = :TASK_ITEM_ID'
      '  and TASK_ID = :TASK_ID')
    Left = 408
    Top = 182
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ITEM_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end>
  end
  object uqShiftTaskRowsAfterDelete: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = ITEM_NUM - 1'
      'where TASK_ID = :TASK_ID'
      '  and ITEM_NUM > :OLD_ITEM_NUM')
    Left = 408
    Top = 130
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'OLD_ITEM_NUM'
        Value = nil
      end>
  end
  object uqShiftTaskRowsForInsert: TUniQuery
    Connection = ucETaskApi
    SQL.Strings = (
      'update task_items'
      'set ITEM_NUM = ITEM_NUM + 1'
      'where TASK_ID = :TASK_ID'
      '  and ITEM_NUM > :INSERT_AFTER_ITEM_NUM')
    Left = 408
    Top = 80
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'TASK_ID'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = 'INSERT_AFTER_ITEM_NUM'
        Value = nil
      end>
  end
end
