20220517000001_create_ticket_reopen_time.rb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class CreateTicketReopenTime < ActiveRecord::Migration[5.0]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. change_table :tickets do |t|
  7. t.timestamp :last_close_at, limit: 3, null: true
  8. end
  9. Ticket.reset_column_information
  10. change_table :groups do |t|
  11. t.integer :reopen_time_in_days, null: true
  12. end
  13. Group.reset_column_information
  14. UserInfo.current_user_id = 1
  15. ObjectManager::Attribute.add(
  16. force: true,
  17. object: 'Group',
  18. name: 'follow_up_possible',
  19. display: 'Follow-up possible',
  20. data_type: 'select',
  21. data_option: {
  22. default: 'yes',
  23. options: {
  24. yes: 'yes',
  25. new_ticket: 'do not reopen ticket but create new ticket',
  26. new_ticket_after_certain_time: 'do not reopen ticket after certain time but create new ticket',
  27. },
  28. null: false,
  29. note: 'Follow-up for closed ticket possible or not.',
  30. translate: true
  31. },
  32. editable: false,
  33. active: true,
  34. screens: {
  35. create: {
  36. '-all-' => {
  37. null: false,
  38. },
  39. },
  40. edit: {
  41. '-all-' => {
  42. null: false,
  43. },
  44. },
  45. },
  46. to_create: false,
  47. to_migrate: false,
  48. to_delete: false,
  49. position: 400,
  50. )
  51. ObjectManager::Attribute.add(
  52. force: true,
  53. object: 'Group',
  54. name: 'reopen_time_in_days',
  55. display: 'Reopening time in days',
  56. data_type: 'integer',
  57. data_option: {
  58. default: '',
  59. min: 1,
  60. max: 3650,
  61. null: true,
  62. note: 'Allow reopening of tickets within a certain time.',
  63. translate: true
  64. },
  65. editable: false,
  66. active: true,
  67. screens: {
  68. create: { 'admin.group': { shown: false, required: false } },
  69. edit: { 'admin.group': { shown: false, required: false } },
  70. view: { 'admin.group': { shown: false } }
  71. },
  72. to_create: false,
  73. to_migrate: false,
  74. to_delete: false,
  75. position: 410,
  76. created_by_id: 1,
  77. updated_by_id: 1,
  78. )
  79. CoreWorkflow.create_if_not_exists(
  80. name: 'base - show reopen_time_in_days',
  81. object: 'Group',
  82. condition_saved: {},
  83. condition_selected: { 'group.follow_up_possible'=>{ 'operator' => 'is', 'value' => ['new_ticket_after_certain_time'] } },
  84. perform: { 'group.reopen_time_in_days'=>{ 'operator' => %w[show set_mandatory], 'show' => 'true', 'set_mandatory' => 'true' } },
  85. preferences: { 'screen'=>%w[create edit] },
  86. changeable: false,
  87. active: true,
  88. created_by_id: 1,
  89. updated_by_id: 1,
  90. )
  91. end
  92. end