2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2016-02-11 01:57:27 +00:00
|
|
|
|
|
|
|
class FirstStepsController < ApplicationController
|
2017-02-15 12:29:25 +00:00
|
|
|
prepend_before_action :authentication_check
|
2016-02-11 01:57:27 +00:00
|
|
|
|
2020-03-19 09:39:51 +00:00
|
|
|
before_action -> { render json: [] }, if: -> { !authorized? }
|
2016-02-11 01:57:27 +00:00
|
|
|
|
2020-03-19 09:39:51 +00:00
|
|
|
def index
|
2016-02-11 01:57:27 +00:00
|
|
|
invite_agents = false
|
2021-07-16 13:44:10 +00:00
|
|
|
# if User.of_role('Agent').count > 2
|
2016-02-11 01:57:27 +00:00
|
|
|
# invite_agents = true
|
2021-07-16 13:44:10 +00:00
|
|
|
# end
|
2016-02-11 01:57:27 +00:00
|
|
|
invite_customers = false
|
2021-07-16 13:44:10 +00:00
|
|
|
# if User.of_role('Customer').count > 2
|
2016-02-11 01:57:27 +00:00
|
|
|
# invite_customers = true
|
2021-07-16 13:44:10 +00:00
|
|
|
# end
|
2016-02-11 01:57:27 +00:00
|
|
|
|
|
|
|
chat_active = false
|
|
|
|
if Setting.get('chat')
|
|
|
|
chat_active = true
|
|
|
|
end
|
2019-08-14 08:15:36 +00:00
|
|
|
form_active = false
|
2016-02-11 01:57:27 +00:00
|
|
|
if Setting.get('form_ticket_create')
|
2019-08-14 08:15:36 +00:00
|
|
|
form_active = true
|
2016-02-11 01:57:27 +00:00
|
|
|
end
|
|
|
|
twitter_active = false
|
2016-10-24 21:59:18 +00:00
|
|
|
if Channel.where(area: 'Twitter::Account').count.positive?
|
2016-02-11 01:57:27 +00:00
|
|
|
twitter_active = true
|
|
|
|
end
|
|
|
|
facebook_active = false
|
2016-10-24 21:59:18 +00:00
|
|
|
if Channel.where(area: 'Facebook::Account').count.positive?
|
2016-02-11 01:57:27 +00:00
|
|
|
facebook_active = true
|
|
|
|
end
|
|
|
|
email_active = false
|
2016-10-24 21:59:18 +00:00
|
|
|
if Channel.where(area: 'Email::Account').count.positive?
|
2016-02-11 01:57:27 +00:00
|
|
|
email_active = true
|
|
|
|
end
|
|
|
|
text_module_active = false
|
2016-10-24 21:59:18 +00:00
|
|
|
if TextModule.count.positive?
|
2016-02-11 01:57:27 +00:00
|
|
|
text_module_active = true
|
|
|
|
end
|
|
|
|
macro_active = false
|
|
|
|
if Macro.count > 1
|
|
|
|
macro_active = true
|
|
|
|
end
|
|
|
|
|
2016-08-12 16:39:09 +00:00
|
|
|
if current_user.permissions?('admin')
|
2016-02-11 01:57:27 +00:00
|
|
|
|
|
|
|
result = [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Configuration',
|
2016-02-11 01:57:27 +00:00
|
|
|
items: [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Branding',
|
|
|
|
checked: true,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#settings/branding',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Your Email Configuration',
|
|
|
|
checked: email_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#channels/email',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Invite agents/colleagues to help working on tickets',
|
|
|
|
checked: invite_agents,
|
2016-02-17 18:36:33 +00:00
|
|
|
location: '#',
|
2018-12-19 17:31:51 +00:00
|
|
|
class: 'js-inviteAgent',
|
2016-02-11 01:57:27 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Invite customers to create issues in Zammad',
|
|
|
|
checked: invite_customers,
|
2016-02-17 18:36:33 +00:00
|
|
|
location: '#',
|
2018-12-19 17:31:51 +00:00
|
|
|
class: 'js-inviteCustomer',
|
2016-02-11 01:57:27 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'How to use it',
|
2016-02-11 01:57:27 +00:00
|
|
|
items: [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Intro',
|
|
|
|
checked: true,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#clues',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Create a Test Ticket',
|
|
|
|
checked: false,
|
2016-02-29 23:52:51 +00:00
|
|
|
location: '#',
|
2018-12-19 17:31:51 +00:00
|
|
|
class: 'js-testTicket',
|
2016-02-11 01:57:27 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Create Text Modules',
|
|
|
|
checked: text_module_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#manage/text_modules',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Create Macros',
|
|
|
|
checked: macro_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#manage/macros',
|
|
|
|
},
|
2021-07-16 13:44:10 +00:00
|
|
|
# {
|
2016-03-04 11:01:26 +00:00
|
|
|
# name: 'Create Overviews',
|
|
|
|
# checked: false,
|
|
|
|
# location: '#manage/overviews',
|
2021-07-16 13:44:10 +00:00
|
|
|
# },
|
2016-02-11 01:57:27 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Additional Channels',
|
2016-02-11 01:57:27 +00:00
|
|
|
items: [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Twitter',
|
|
|
|
checked: twitter_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#channels/twitter',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Facebook',
|
|
|
|
checked: facebook_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#channels/facebook',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Chat',
|
|
|
|
checked: chat_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#channels/chat',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Online Forms',
|
2019-08-14 08:15:36 +00:00
|
|
|
checked: form_active,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#channels/form',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2016-02-29 23:52:51 +00:00
|
|
|
check_availability(result)
|
|
|
|
|
2016-02-11 01:57:27 +00:00
|
|
|
render json: result
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
result = [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'How to use it',
|
2016-02-11 01:57:27 +00:00
|
|
|
items: [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Intro',
|
|
|
|
checked: true,
|
2016-02-11 01:57:27 +00:00
|
|
|
location: '#clues',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Create a Test Ticket',
|
|
|
|
checked: false,
|
2016-02-29 23:52:51 +00:00
|
|
|
location: '#',
|
2018-12-19 17:31:51 +00:00
|
|
|
class: 'js-testTicket',
|
2016-02-11 01:57:27 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Invite customers to create issues in Zammad',
|
|
|
|
checked: invite_customers,
|
2016-02-17 18:36:33 +00:00
|
|
|
location: '#',
|
2018-12-19 17:31:51 +00:00
|
|
|
class: 'js-inviteCustomer',
|
2016-02-11 01:57:27 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2016-02-29 23:52:51 +00:00
|
|
|
check_availability(result)
|
|
|
|
|
2016-02-11 01:57:27 +00:00
|
|
|
render json: result
|
|
|
|
end
|
|
|
|
|
2016-02-29 23:52:51 +00:00
|
|
|
def test_ticket
|
|
|
|
agent = current_user
|
|
|
|
customer = test_customer
|
|
|
|
from = "#{customer.fullname} <#{customer.email}>"
|
|
|
|
original_user_id = UserInfo.current_user_id
|
2016-04-13 23:40:37 +00:00
|
|
|
result = NotificationFactory::Mailer.template(
|
2016-02-29 23:52:51 +00:00
|
|
|
template: 'test_ticket',
|
2020-01-27 09:28:17 +00:00
|
|
|
locale: agent.locale,
|
2016-02-29 23:52:51 +00:00
|
|
|
objects: {
|
2018-12-19 17:31:51 +00:00
|
|
|
agent: agent,
|
2016-02-29 23:52:51 +00:00
|
|
|
customer: customer,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
raw: true,
|
2016-02-29 23:52:51 +00:00
|
|
|
)
|
|
|
|
UserInfo.current_user_id = customer.id
|
2017-06-16 23:02:13 +00:00
|
|
|
ticket = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
group_id: Group.find_by(active: true, name: 'Users').id,
|
2016-02-29 23:52:51 +00:00
|
|
|
customer_id: customer.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
title: result[:subject],
|
2016-02-29 23:52:51 +00:00
|
|
|
)
|
2017-06-16 23:02:13 +00:00
|
|
|
article = Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.find_by(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
|
|
|
|
from: from,
|
|
|
|
body: result[:body],
|
2016-02-29 23:52:51 +00:00
|
|
|
content_type: 'text/html',
|
2018-12-19 17:31:51 +00:00
|
|
|
internal: false,
|
2016-02-29 23:52:51 +00:00
|
|
|
)
|
|
|
|
UserInfo.current_user_id = original_user_id
|
|
|
|
overview = test_overview
|
|
|
|
assets = ticket.assets({})
|
|
|
|
assets = article.assets(assets)
|
|
|
|
assets = overview.assets(assets)
|
|
|
|
render json: {
|
|
|
|
overview_id: overview.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
assets: assets,
|
2016-02-29 23:52:51 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def test_overview
|
|
|
|
Overview.find_by(name: 'Unassigned & Open')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_customer
|
|
|
|
User.find_by(login: 'nicole.braun@zammad.org')
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_availability(result)
|
2020-11-12 11:42:44 +00:00
|
|
|
return result if test_ticket_active?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-10-01 12:25:52 +00:00
|
|
|
result.each do |item|
|
2016-02-29 23:52:51 +00:00
|
|
|
items = []
|
2017-10-01 12:25:52 +00:00
|
|
|
item[:items].each do |local_item|
|
2016-02-29 23:52:51 +00:00
|
|
|
next if local_item[:name] == 'Create a Test Ticket'
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-02-29 23:52:51 +00:00
|
|
|
items.push local_item
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-02-29 23:52:51 +00:00
|
|
|
item[:items] = items
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-02-29 23:52:51 +00:00
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2020-11-12 11:42:44 +00:00
|
|
|
def test_ticket_active?
|
|
|
|
overview = test_overview
|
|
|
|
|
|
|
|
return false if !overview
|
|
|
|
return false if overview.updated_by_id != 1
|
|
|
|
return false if !test_customer
|
|
|
|
return false if Group.where(active: true, name: 'Users').count.zero?
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
2016-02-11 01:57:27 +00:00
|
|
|
end
|