|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Agent\helpdesk; |
|
4
|
|
|
|
|
5
|
|
|
// controllers |
|
6
|
|
|
use App\Http\Controllers\Controller; |
|
7
|
|
|
// models |
|
8
|
|
|
use App\Model\helpdesk\Agent\Department; |
|
9
|
|
|
use App\Model\helpdesk\Agent\Teams; |
|
10
|
|
|
use App\Model\helpdesk\Email\Emails; |
|
11
|
|
|
use App\Model\helpdesk\Manage\Help_topic; |
|
12
|
|
|
use App\Model\helpdesk\Manage\Sla_plan; |
|
13
|
|
|
use App\Model\helpdesk\Ticket\Ticket_Priority; |
|
14
|
|
|
use App\Model\helpdesk\Ticket\Ticket_Status; |
|
15
|
|
|
use App\Model\helpdesk\Workflow\WorkflowAction; |
|
16
|
|
|
use App\Model\helpdesk\Workflow\WorkflowName; |
|
17
|
|
|
use App\Model\helpdesk\Workflow\WorkflowRules; |
|
18
|
|
|
use App\User; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* TicketWorkflowController. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Ladybird <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class TicketWorkflowController extends Controller |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* constructor |
|
29
|
|
|
* Create a new controller instance. |
|
30
|
|
|
* |
|
31
|
|
|
* @param type TicketController $TicketController |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(TicketController $TicketController) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->TicketController = $TicketController; |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* This is the core function from where the workflow is applied. |
|
40
|
|
|
* |
|
41
|
|
|
* @return type response |
|
42
|
|
|
*/ |
|
43
|
|
|
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response) |
|
44
|
|
|
{ |
|
45
|
|
|
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'subject' => $subject, 'message' => $body]; |
|
46
|
|
|
$ticket_settings_details = ['help_topic' => $helptopic, 'sla' => $sla, 'priority' => $priority, 'source' => $source, 'dept' => $dept, 'assign' => $assign, 'team' => $team_assign, 'status' => $ticket_status, 'reject' => false]; |
|
47
|
|
|
// get all the workflow common to the entire system which includes any type of ticket creation where the execution order of the workflow should be starting with ascending order |
|
48
|
|
|
$workflows = WorkflowName::where('target', '=', 'A-0')->where('status', '=', '1')->orderBy('order', 'asc')->get(); |
|
49
|
|
|
foreach ($workflows as $workflow) { |
|
50
|
|
|
// checking if any workflow defined in the system |
|
51
|
|
|
if ($workflow) { |
|
52
|
|
|
// get all the rules of workflow which has a foreign key of those workflow which are applied to creating any ticket from any source |
|
53
|
|
|
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get(); |
|
54
|
|
|
foreach ($worklfow_rules as $worklfow_rule) { |
|
55
|
|
|
// checking for the workflow rules to which workflow rule type it is |
|
56
|
|
|
if ($worklfow_rule->matching_scenario == 'email') { |
|
57
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
58
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'email_name') { |
|
61
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
62
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'subject') { |
|
65
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
66
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'message') { |
|
69
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
70
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details); |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
if ($source == 1) { |
|
77
|
|
|
// get all the workflow which are applied to ticket generated via webforms and in ascending order |
|
78
|
|
|
$workflows_webs = WorkflowName::where('target', '=', 'A-1')->where('status', '=', '1')->orderBy('order', 'asc')->get(); |
|
79
|
|
|
foreach ($workflows_webs as $workflows_web) { |
|
80
|
|
|
if ($workflows_web) { |
|
81
|
|
|
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get(); |
|
82
|
|
|
foreach ($worklfow_rules as $worklfow_rule) { |
|
83
|
|
|
if ($worklfow_rule) { |
|
84
|
|
|
// checking for the workflow rules to which workflow rule type it is |
|
85
|
|
|
if ($worklfow_rule->matching_scenario == 'email') { |
|
86
|
|
|
if ($this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
87
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'email_name') { |
|
90
|
|
|
if ($this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
91
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details); |
|
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'subject') { |
|
94
|
|
|
if ($this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
95
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'message') { |
|
98
|
|
|
if ($this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
99
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details); |
|
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
View Code Duplication |
if ($source == 2) { |
|
|
|
|
|
|
108
|
|
|
// get all the workflow which are applied to ticket generated via emails and in ascending order |
|
109
|
|
|
$workflows_emails = WorkflowName::where('target', '=', 'A-2')->where('status', '=', '1')->orderBy('order', 'asc')->get(); |
|
110
|
|
|
foreach ($workflows_emails as $workflows_email) { |
|
111
|
|
|
if ($workflows_email) { |
|
112
|
|
|
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get(); |
|
113
|
|
|
foreach ($worklfow_rules as $worklfow_rule) { |
|
114
|
|
|
if ($worklfow_rule) { |
|
115
|
|
|
// checking for the workflow rules to which workflow rule type it is |
|
116
|
|
|
if ($worklfow_rule->matching_scenario == 'email') { |
|
117
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
118
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details); |
|
|
|
|
|
|
119
|
|
|
} |
|
120
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'email_name') { |
|
121
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
122
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'subject') { |
|
125
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
126
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details); |
|
|
|
|
|
|
127
|
|
|
} |
|
128
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'message') { |
|
129
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
130
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details); |
|
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
View Code Duplication |
if ($source == 4) { |
|
|
|
|
|
|
139
|
|
|
// get all the workflow which are applied to ticket generated via API and in ascending order |
|
140
|
|
|
$workflows_apis = WorkflowName::where('target', '=', 'A-4')->where('status', '=', '1')->orderBy('order', 'asc')->get(); |
|
141
|
|
|
foreach ($workflows_apis as $workflows_api) { |
|
142
|
|
|
if ($workflows_api) { |
|
143
|
|
|
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get(); |
|
144
|
|
|
foreach ($worklfow_rules as $worklfow_rule) { |
|
145
|
|
|
if ($worklfow_rule) { |
|
146
|
|
|
// checking for the workflow rules to which workflow rule type it is |
|
147
|
|
|
if ($worklfow_rule->matching_scenario == 'email') { |
|
148
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
149
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details); |
|
|
|
|
|
|
150
|
|
|
} |
|
151
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'email_name') { |
|
152
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
153
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details); |
|
|
|
|
|
|
154
|
|
|
} |
|
155
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'subject') { |
|
156
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
157
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details); |
|
|
|
|
|
|
158
|
|
|
} |
|
159
|
|
|
} elseif ($worklfow_rule->matching_scenario == 'message') { |
|
160
|
|
|
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) { |
|
|
|
|
|
|
161
|
|
|
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details); |
|
|
|
|
|
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
//dd($form_data); |
|
171
|
|
|
if ($ticket_settings_details['reject'] == true) { |
|
172
|
|
|
return ['0' => false, '1' => false]; |
|
|
|
|
|
|
173
|
|
|
} else { |
|
174
|
|
|
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $phonecode, $mobile_number, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status']); |
|
175
|
|
|
|
|
176
|
|
|
return $create_ticket; |
|
177
|
|
|
} |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* function to check the rules applied to the ticket workflow. |
|
182
|
|
|
* |
|
183
|
|
|
* @param type $to_check |
|
184
|
|
|
* @param type $condition |
|
185
|
|
|
* @param type $statement |
|
186
|
|
|
* |
|
187
|
|
|
* @return type boolean |
|
188
|
|
|
*/ |
|
189
|
|
|
public function checkRuleCondition($to_check, $condition, $statement) |
|
190
|
|
|
{ |
|
191
|
|
|
if ($condition == 'equal') { |
|
192
|
|
|
$return = $this->checkEqual($statement, $to_check); |
|
193
|
|
|
} elseif ($condition == 'not_equal') { |
|
194
|
|
|
$return = $this->checkNotEqual($statement, $to_check); |
|
195
|
|
|
} elseif ($condition == 'contains') { |
|
196
|
|
|
$return = $this->checkContains($statement, $to_check); |
|
197
|
|
|
} elseif ($condition == 'dn_contain') { |
|
198
|
|
|
$return = $this->checkDoNotContain($statement, $to_check); |
|
199
|
|
|
} elseif ($condition == 'starts') { |
|
200
|
|
|
$return = $this->checkStarts($statement, $to_check); |
|
201
|
|
|
} elseif ($condition == 'ends') { |
|
202
|
|
|
$return = $this->checkEnds($statement, $to_check); |
|
203
|
|
|
} |
|
204
|
|
|
// elseif($condition == 'match') { |
|
|
|
|
|
|
205
|
|
|
// |
|
206
|
|
|
// } elseif($condition == 'not_match') { |
|
207
|
|
|
// |
|
208
|
|
|
// } |
|
209
|
|
|
return $return; |
|
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* function to check if the equal functions are applied. |
|
214
|
|
|
* |
|
215
|
|
|
* @param type $statement |
|
216
|
|
|
* @param type $to_check |
|
217
|
|
|
* |
|
218
|
|
|
* @return bool |
|
219
|
|
|
*/ |
|
220
|
|
|
public function checkEqual($statement, $to_check) |
|
221
|
|
|
{ |
|
222
|
|
|
if ($statement == $to_check) { |
|
223
|
|
|
return true; |
|
224
|
|
|
} else { |
|
225
|
|
|
return false; |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* function to check if the not-equal functions are applied. |
|
231
|
|
|
* |
|
232
|
|
|
* @param type $statement |
|
233
|
|
|
* @param type $to_check |
|
234
|
|
|
* |
|
235
|
|
|
* @return bool |
|
236
|
|
|
*/ |
|
237
|
|
|
public function checkNotEqual($statement, $to_check) |
|
238
|
|
|
{ |
|
239
|
|
|
if ($statement != $to_check) { |
|
240
|
|
|
return true; |
|
241
|
|
|
} else { |
|
242
|
|
|
return false; |
|
243
|
|
|
} |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* function to check if the contains functions are applied. |
|
248
|
|
|
* |
|
249
|
|
|
* @param type $statement |
|
250
|
|
|
* @param type $to_check |
|
251
|
|
|
* |
|
252
|
|
|
* @return bool |
|
253
|
|
|
*/ |
|
254
|
|
|
public function checkContains($statement, $to_check) |
|
255
|
|
|
{ |
|
256
|
|
|
if (strpos($to_check, $statement) !== false) { |
|
257
|
|
|
return true; |
|
258
|
|
|
} else { |
|
259
|
|
|
return false; |
|
260
|
|
|
} |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* function to check if the do not contain functions are applied. |
|
265
|
|
|
* |
|
266
|
|
|
* @param type $statement |
|
267
|
|
|
* @param type $to_check |
|
268
|
|
|
* |
|
269
|
|
|
* @return bool |
|
270
|
|
|
*/ |
|
271
|
|
|
public function checkDoNotContain($statement, $to_check) |
|
272
|
|
|
{ |
|
273
|
|
|
if (strpos($to_check, $statement) == false) { |
|
|
|
|
|
|
274
|
|
|
return true; |
|
275
|
|
|
} else { |
|
276
|
|
|
return false; |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* function to check if the start functions are applied. |
|
282
|
|
|
* |
|
283
|
|
|
* @param type $statement |
|
284
|
|
|
* @param type $to_check |
|
285
|
|
|
* |
|
286
|
|
|
* @return bool |
|
287
|
|
|
*/ |
|
288
|
|
View Code Duplication |
public function checkStarts($statement, $to_check) |
|
|
|
|
|
|
289
|
|
|
{ |
|
290
|
|
|
if (substr($to_check, 0, strlen($statement)) == $statement) { |
|
291
|
|
|
return true; |
|
292
|
|
|
} else { |
|
293
|
|
|
return false; |
|
294
|
|
|
} |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* function to check if the ends functions are applied. |
|
299
|
|
|
* |
|
300
|
|
|
* @param type $statement |
|
301
|
|
|
* @param type $to_check |
|
302
|
|
|
* |
|
303
|
|
|
* @return bool |
|
304
|
|
|
*/ |
|
305
|
|
View Code Duplication |
public function checkEnds($statement, $to_check) |
|
|
|
|
|
|
306
|
|
|
{ |
|
307
|
|
|
$to_check = strip_tags($to_check); |
|
308
|
|
|
if (substr($to_check, -strlen($statement)) == $statement) { |
|
309
|
|
|
return true; |
|
310
|
|
|
} else { |
|
311
|
|
|
return false; |
|
312
|
|
|
} |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
// function startsWith($to_check, $statement) { |
|
|
|
|
|
|
316
|
|
|
// // search backwards starting from haystack length characters from the end |
|
317
|
|
|
// return $statement === "" || strrpos($to_check, $statement, -strlen($to_check)) !== false; |
|
318
|
|
|
// } |
|
319
|
|
|
|
|
320
|
|
|
// function endsWith($to_check, $statement) { |
|
|
|
|
|
|
321
|
|
|
// // search forward starting from end minus needle length characters |
|
322
|
|
|
// return $statement === "" || (($temp = strlen($to_check) - strlen($statement)) >= 0 && strpos($to_check, $statement, $temp) !== false); |
|
323
|
|
|
// } |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* function to apply the action to a ticket. |
|
327
|
|
|
* |
|
328
|
|
|
* @param type $workflow_id |
|
329
|
|
|
* @param type $ticket_settings_details |
|
330
|
|
|
* |
|
331
|
|
|
* @return type array |
|
332
|
|
|
*/ |
|
333
|
|
|
public function applyActionCondition($workflow_id, $ticket_settings_details) |
|
334
|
|
|
{ |
|
335
|
|
|
$workflow_actions = WorkflowAction::where('workflow_id', '=', $workflow_id)->get(); |
|
336
|
|
|
foreach ($workflow_actions as $workflow_action) { |
|
337
|
|
|
if ($workflow_action->condition == 'reject') { |
|
338
|
|
|
$ticket_settings_details = $this->rejectTicket($ticket_settings_details); |
|
|
|
|
|
|
339
|
|
|
} elseif ($workflow_action->condition == 'department') { |
|
340
|
|
|
$ticket_settings_details = $this->changeDepartment($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
341
|
|
|
} elseif ($workflow_action->condition == 'priority') { |
|
342
|
|
|
$ticket_settings_details = $this->changePriority($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
343
|
|
|
} elseif ($workflow_action->condition == 'sla') { |
|
344
|
|
|
$ticket_settings_details = $this->changeSla($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
345
|
|
|
} elseif ($workflow_action->condition == 'team') { |
|
346
|
|
|
$ticket_settings_details = $this->changeTeam($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
347
|
|
|
} elseif ($workflow_action->condition == 'agent') { |
|
348
|
|
|
$ticket_settings_details = $this->changeAgent($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
349
|
|
|
} elseif ($workflow_action->condition == 'helptopic') { |
|
350
|
|
|
$ticket_settings_details = $this->changeHelptopic($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
351
|
|
|
} elseif ($workflow_action->condition == 'status') { |
|
352
|
|
|
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details); |
|
|
|
|
|
|
353
|
|
|
} |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
return $ticket_settings_details; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* function to reject ticket. |
|
361
|
|
|
* |
|
362
|
|
|
* @param array $ticket_settings_details |
|
363
|
|
|
* |
|
364
|
|
|
* @return type array |
|
365
|
|
|
*/ |
|
366
|
|
|
public function rejectTicket($ticket_settings_details) |
|
367
|
|
|
{ |
|
368
|
|
|
$ticket_settings_details['reject'] = true; |
|
369
|
|
|
|
|
370
|
|
|
return $ticket_settings_details; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* function to change the department of a ticket. |
|
375
|
|
|
* |
|
376
|
|
|
* @param type $workflow_action |
|
377
|
|
|
* @param type $ticket_settings_details |
|
378
|
|
|
* |
|
379
|
|
|
* @return type array |
|
380
|
|
|
*/ |
|
381
|
|
View Code Duplication |
public function changeDepartment($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
382
|
|
|
{ |
|
383
|
|
|
$dept = Department::where('id', '=', $workflow_action->action)->first(); |
|
384
|
|
|
if ($dept == null) { |
|
385
|
|
|
return $ticket_settings_details; |
|
386
|
|
|
} else { |
|
387
|
|
|
$ticket_settings_details['dept'] = $dept->id; |
|
388
|
|
|
|
|
389
|
|
|
return $ticket_settings_details; |
|
390
|
|
|
} |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* function to change the priority of a ticket. |
|
395
|
|
|
* |
|
396
|
|
|
* @param type $workflow_action |
|
397
|
|
|
* @param type $ticket_settings_details |
|
398
|
|
|
* |
|
399
|
|
|
* @return type array |
|
400
|
|
|
*/ |
|
401
|
|
View Code Duplication |
public function changePriority($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
402
|
|
|
{ |
|
403
|
|
|
$priority = Ticket_Priority::where('priority_id', '=', $workflow_action->action)->first(); |
|
404
|
|
|
if ($priority == null) { |
|
405
|
|
|
return $ticket_settings_details; |
|
406
|
|
|
} else { |
|
407
|
|
|
$ticket_settings_details['priority'] = $priority->priority_id; |
|
408
|
|
|
|
|
409
|
|
|
return $ticket_settings_details; |
|
410
|
|
|
} |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* function to change the SLA of a ticket. |
|
415
|
|
|
* |
|
416
|
|
|
* @param type $workflow_action |
|
417
|
|
|
* @param type $ticket_settings_details |
|
418
|
|
|
* |
|
419
|
|
|
* @return type array |
|
420
|
|
|
*/ |
|
421
|
|
View Code Duplication |
public function changeSla($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
422
|
|
|
{ |
|
423
|
|
|
$sla_plan = Sla_plan::where('id', '=', $workflow_action->action)->first(); |
|
424
|
|
|
if ($sla_plan == null) { |
|
425
|
|
|
return $ticket_settings_details; |
|
426
|
|
|
} else { |
|
427
|
|
|
$ticket_settings_details['sla'] = $sla_plan->id; |
|
428
|
|
|
|
|
429
|
|
|
return $ticket_settings_details; |
|
430
|
|
|
} |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
/** |
|
434
|
|
|
* function to assign tean to a ticket. |
|
435
|
|
|
* |
|
436
|
|
|
* @param type $workflow_action |
|
437
|
|
|
* @param type $ticket_settings_details |
|
438
|
|
|
* |
|
439
|
|
|
* @return type array |
|
440
|
|
|
*/ |
|
441
|
|
View Code Duplication |
public function changeTeam($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
442
|
|
|
{ |
|
443
|
|
|
$team = Teams::where('id', '=', $workflow_action->action)->first(); |
|
444
|
|
|
if ($team == null) { |
|
445
|
|
|
return $ticket_settings_details; |
|
446
|
|
|
} else { |
|
447
|
|
|
$ticket_settings_details['team'] = $team->id; |
|
448
|
|
|
|
|
449
|
|
|
return $ticket_settings_details; |
|
450
|
|
|
} |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* function to assing a ticket to an agent. |
|
455
|
|
|
* |
|
456
|
|
|
* @param type $workflow_action |
|
457
|
|
|
* @param type $ticket_settings_details |
|
458
|
|
|
* |
|
459
|
|
|
* @return type array |
|
460
|
|
|
*/ |
|
461
|
|
|
public function changeAgent($workflow_action, $ticket_settings_details) |
|
462
|
|
|
{ |
|
463
|
|
|
$agent = User::where('id', '=', $workflow_action->action)->where('role', '!=', 'user')->first(); |
|
464
|
|
|
if ($agent == null) { |
|
465
|
|
|
return $ticket_settings_details; |
|
466
|
|
|
} else { |
|
467
|
|
|
$ticket_settings_details['assign'] = $agent->id; |
|
468
|
|
|
|
|
469
|
|
|
return $ticket_settings_details; |
|
470
|
|
|
} |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
/** |
|
474
|
|
|
* function to change the helptopic of a ticket. |
|
475
|
|
|
* |
|
476
|
|
|
* @param type $workflow_action |
|
477
|
|
|
* @param type $ticket_settings_details |
|
478
|
|
|
* |
|
479
|
|
|
* @return type array |
|
480
|
|
|
*/ |
|
481
|
|
View Code Duplication |
public function changeHelptopic($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
482
|
|
|
{ |
|
483
|
|
|
$help_topic = Help_topic::where('id', '=', $workflow_action->action)->first(); |
|
484
|
|
|
if ($help_topic == null) { |
|
485
|
|
|
return $ticket_settings_details; |
|
486
|
|
|
} else { |
|
487
|
|
|
$ticket_settings_details['help_topic'] = $help_topic->id; |
|
488
|
|
|
|
|
489
|
|
|
return $ticket_settings_details; |
|
490
|
|
|
} |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
/** |
|
494
|
|
|
* function to change the status of a ticket. |
|
495
|
|
|
* |
|
496
|
|
|
* @param type $workflow_action |
|
497
|
|
|
* @param type $ticket_settings_details |
|
498
|
|
|
* |
|
499
|
|
|
* @return type array |
|
500
|
|
|
*/ |
|
501
|
|
View Code Duplication |
public function changeStatus($workflow_action, $ticket_settings_details) |
|
|
|
|
|
|
502
|
|
|
{ |
|
503
|
|
|
$status = Ticket_Status::where('id', '=', $workflow_action->action)->first(); |
|
504
|
|
|
if ($status == null) { |
|
505
|
|
|
return $ticket_settings_details; |
|
506
|
|
|
} else { |
|
507
|
|
|
$ticket_settings_details['status'] = $status->id; |
|
508
|
|
|
|
|
509
|
|
|
return $ticket_settings_details; |
|
510
|
|
|
} |
|
511
|
|
|
} |
|
512
|
|
|
} |
|
513
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: