1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin\helpdesk; |
4
|
|
|
|
5
|
|
|
// controllers |
6
|
|
|
use App\Http\Controllers\Controller; |
7
|
|
|
// requests |
8
|
|
|
use App\Http\Requests\helpdesk\CompanyRequest; |
9
|
|
|
use App\Http\Requests\helpdesk\EmailRequest; |
10
|
|
|
use App\Http\Requests\helpdesk\Job\TaskRequest; |
11
|
|
|
use App\Http\Requests\helpdesk\RatingUpdateRequest; |
12
|
|
|
use App\Http\Requests\helpdesk\StatusRequest; |
13
|
|
|
// models |
14
|
|
|
use App\Http\Requests\helpdesk\SystemRequest; |
15
|
|
|
use App\Model\helpdesk\Agent\Department; |
16
|
|
|
use App\Model\helpdesk\Email\Emails; |
17
|
|
|
use App\Model\helpdesk\Email\Template; |
18
|
|
|
use App\Model\helpdesk\Manage\Help_topic; |
19
|
|
|
use App\Model\helpdesk\Manage\Sla_plan; |
20
|
|
|
use App\Model\helpdesk\Notification\UserNotification; |
21
|
|
|
use App\Model\helpdesk\Ratings\Rating; |
22
|
|
|
use App\Model\helpdesk\Settings\Alert; |
23
|
|
|
use App\Model\helpdesk\Settings\CommonSettings; |
24
|
|
|
use App\Model\helpdesk\Settings\Company; |
25
|
|
|
use App\Model\helpdesk\Settings\Email; |
26
|
|
|
use App\Model\helpdesk\Settings\Responder; |
27
|
|
|
use App\Model\helpdesk\Settings\System; |
28
|
|
|
use App\Model\helpdesk\Settings\Ticket; |
29
|
|
|
use App\Model\helpdesk\Ticket\Ticket_Priority; |
30
|
|
|
use App\Model\helpdesk\Utility\Date_format; |
31
|
|
|
use App\Model\helpdesk\Utility\Date_time_format; |
32
|
|
|
use App\Model\helpdesk\Utility\Time_format; |
33
|
|
|
use App\Model\helpdesk\Utility\Timezones; |
34
|
|
|
use App\Model\helpdesk\Workflow\WorkflowClose; |
35
|
|
|
// classes |
36
|
|
|
use DateTime; |
37
|
|
|
use DB; |
38
|
|
|
use Exception; |
39
|
|
|
use File; |
40
|
|
|
use Illuminate\Http\Request; |
41
|
|
|
use Input; |
42
|
|
|
use Lang; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* SettingsController. |
46
|
|
|
* |
47
|
|
|
* @author Ladybird <[email protected]> |
48
|
|
|
*/ |
49
|
|
|
class SettingsController extends Controller |
50
|
|
|
{ |
51
|
|
|
/** |
52
|
|
|
* Create a new controller instance. |
53
|
|
|
* |
54
|
|
|
* @return void |
|
|
|
|
55
|
|
|
*/ |
56
|
|
|
public function __construct() |
57
|
|
|
{ |
58
|
|
|
// $this->smtp(); |
|
|
|
|
59
|
|
|
$this->middleware('auth'); |
60
|
|
|
$this->middleware('roles'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param int $id |
|
|
|
|
65
|
|
|
* @param $compant instance of company table |
66
|
|
|
* |
67
|
|
|
* get the form for company setting page |
68
|
|
|
* |
69
|
|
|
* @return Response |
70
|
|
|
*/ |
71
|
|
|
public function getcompany(Company $company) |
72
|
|
|
{ |
73
|
|
|
try { |
74
|
|
|
/* fetch the values of company from company table */ |
75
|
|
|
$companys = $company->whereId('1')->first(); |
|
|
|
|
76
|
|
|
/* Direct to Company Settings Page */ |
77
|
|
|
return view('themes.default1.admin.helpdesk.settings.company', compact('companys')); |
78
|
|
|
} catch (Exception $e) { |
79
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Update the specified resource in storage. |
85
|
|
|
* |
86
|
|
|
* @param type int $id |
87
|
|
|
* @param type Company $company |
88
|
|
|
* @param type CompanyRequest $request |
89
|
|
|
* |
90
|
|
|
* @return Response |
91
|
|
|
*/ |
92
|
|
View Code Duplication |
public function postcompany($id, Company $company, CompanyRequest $request) |
|
|
|
|
93
|
|
|
{ |
94
|
|
|
/* fetch the values of company request */ |
95
|
|
|
$companys = $company->whereId('1')->first(); |
|
|
|
|
96
|
|
|
if (Input::file('logo')) { |
97
|
|
|
$name = Input::file('logo')->getClientOriginalName(); |
98
|
|
|
$destinationPath = 'uploads/company/'; |
99
|
|
|
$fileName = rand(0000, 9999).'.'.$name; |
100
|
|
|
Input::file('logo')->move($destinationPath, $fileName); |
101
|
|
|
$companys->logo = $fileName; |
102
|
|
|
} |
103
|
|
|
if ($request->input('use_logo') == null) { |
104
|
|
|
$companys->use_logo = '0'; |
105
|
|
|
} |
106
|
|
|
/* Check whether function success or not */ |
107
|
|
|
try { |
108
|
|
|
$companys->fill($request->except('logo'))->save(); |
109
|
|
|
/* redirect to Index page with Success Message */ |
110
|
|
|
return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully')); |
111
|
|
|
} catch (Exception $e) { |
112
|
|
|
/* redirect to Index page with Fails Message */ |
113
|
|
|
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>'); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* function to delete system logo. |
119
|
|
|
* |
120
|
|
|
* @return type string |
121
|
|
|
*/ |
122
|
|
View Code Duplication |
public function deleteLogo() |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
$path = $_GET['data1']; //get file path of logo image |
125
|
|
|
if (!unlink($path)) { |
126
|
|
|
return 'false'; |
127
|
|
|
} else { |
128
|
|
|
$companys = Company::where('id', '=', 1)->first(); |
129
|
|
|
$companys->logo = null; |
130
|
|
|
$companys->use_logo = '0'; |
131
|
|
|
$companys->save(); |
132
|
|
|
|
133
|
|
|
return 'true'; |
134
|
|
|
} |
135
|
|
|
// return $res; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* get the form for System setting page. |
140
|
|
|
* |
141
|
|
|
* @param type System $system |
142
|
|
|
* @param type Department $department |
143
|
|
|
* @param type Timezones $timezone |
144
|
|
|
* @param type Date_format $date |
145
|
|
|
* @param type Date_time_format $date_time |
146
|
|
|
* @param type Time_format $time |
147
|
|
|
* |
148
|
|
|
* @return type Response |
149
|
|
|
*/ |
150
|
|
|
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings) |
151
|
|
|
{ |
152
|
|
|
try { |
153
|
|
|
/* fetch the values of system from system table */ |
154
|
|
|
$systems = $system->whereId('1')->first(); |
|
|
|
|
155
|
|
|
/* Fetch the values from Department table */ |
156
|
|
|
$departments = $department->get(); |
|
|
|
|
157
|
|
|
/* Fetch the values from Timezones table */ |
158
|
|
|
$timezones = $timezone->get(); |
|
|
|
|
159
|
|
|
/* Fetch status value of common settings */ |
160
|
|
|
$common_setting = $common_settings->select('status') |
|
|
|
|
161
|
|
|
->where('option_name', '=', 'user_set_ticket_status') |
162
|
|
|
->first(); |
163
|
|
|
$send_otp = $common_settings->select('status') |
|
|
|
|
164
|
|
|
->where('option_name', '=', 'send_otp') |
165
|
|
|
->first(); |
166
|
|
|
$email_mandatory = $common_settings->select('status') |
|
|
|
|
167
|
|
|
->where('option_name', '=', 'email_mandatory') |
168
|
|
|
->first(); |
169
|
|
|
/* Direct to System Settings Page */ |
170
|
|
|
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time', 'common_setting', 'send_otp', 'email_mandatory')); |
171
|
|
|
} catch (Exception $e) { |
172
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Update the specified resource in storage. |
178
|
|
|
* |
179
|
|
|
* @param type int $id |
180
|
|
|
* @param type System $system |
181
|
|
|
* @param type SystemRequest $request |
182
|
|
|
* |
183
|
|
|
* @return type Response |
184
|
|
|
*/ |
185
|
|
|
public function postsystem($id, System $system, SystemRequest $request) |
|
|
|
|
186
|
|
|
{ |
187
|
|
|
try { |
188
|
|
|
/* fetch the values of system request */ |
189
|
|
|
$systems = $system->whereId('1')->first(); |
|
|
|
|
190
|
|
|
/* fill the values to coompany table */ |
191
|
|
|
/* Check whether function success or not */ |
192
|
|
|
$systems->fill($request->input())->save(); |
193
|
|
|
$rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first(); |
194
|
|
|
if ($request->enable_rtl != null) { |
|
|
|
|
195
|
|
|
$rtl->option_value = 1; |
196
|
|
|
} else { |
197
|
|
|
$rtl->option_value = 0; |
198
|
|
|
} |
199
|
|
|
$rtl->save(); |
200
|
|
|
|
201
|
|
|
$usts = CommonSettings::where('option_name', '=', 'user_set_ticket_status')->first(); |
202
|
|
|
if ($usts->status != $request->user_set_ticket_status) { |
|
|
|
|
203
|
|
|
$usts->status = $request->user_set_ticket_status; |
|
|
|
|
204
|
|
|
$usts->save(); |
205
|
|
|
} |
206
|
|
|
$sotp = CommonSettings::where('option_name', '=', 'send_otp') |
|
|
|
|
207
|
|
|
->update(['status' => $request->send_otp]); |
|
|
|
|
208
|
|
|
$email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory') |
|
|
|
|
209
|
|
|
->update(['status' => $request->email_mandatory]); |
|
|
|
|
210
|
|
|
|
211
|
|
|
if ($request->has('itil')) { |
212
|
|
|
$itil = $request->input('itil'); |
213
|
|
|
$sett = CommonSettings::firstOrCreate(['option_name'=>'itil']); |
|
|
|
|
214
|
|
|
$sett->status = $itil; |
215
|
|
|
$sett->save(); |
216
|
|
|
} |
217
|
|
|
/* redirect to Index page with Success Message */ |
218
|
|
|
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully')); |
219
|
|
|
} catch (Exception $e) { |
220
|
|
|
/* redirect to Index page with Fails Message */ |
221
|
|
|
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage()); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* get the form for Ticket setting page. |
227
|
|
|
* |
228
|
|
|
* @param type Ticket $ticket |
229
|
|
|
* @param type Sla_plan $sla |
230
|
|
|
* @param type Help_topic $topic |
231
|
|
|
* @param type Priority $priority |
232
|
|
|
* |
233
|
|
|
* @return type Response |
234
|
|
|
*/ |
235
|
|
|
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) |
236
|
|
|
{ |
237
|
|
|
try { |
238
|
|
|
/* fetch the values of ticket from ticket table */ |
239
|
|
|
$tickets = $ticket->whereId('1')->first(); |
|
|
|
|
240
|
|
|
/* Fetch the values from SLA Plan table */ |
241
|
|
|
$slas = $sla->get(); |
|
|
|
|
242
|
|
|
/* Fetch the values from Help_topic table */ |
243
|
|
|
$topics = $topic->get(); |
|
|
|
|
244
|
|
|
/* Direct to Ticket Settings Page */ |
245
|
|
|
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority')); |
246
|
|
|
} catch (Exception $e) { |
247
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
248
|
|
|
} |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Update the specified Ticket in storage. |
253
|
|
|
* |
254
|
|
|
* @param type int $id |
255
|
|
|
* @param type Ticket $ticket |
256
|
|
|
* @param type Request $request |
257
|
|
|
* |
258
|
|
|
* @return type Response |
259
|
|
|
*/ |
260
|
|
View Code Duplication |
public function postticket($id, Ticket $ticket, Request $request) |
|
|
|
|
261
|
|
|
{ |
262
|
|
|
try { |
263
|
|
|
/* fetch the values of ticket request */ |
264
|
|
|
$tickets = $ticket->whereId('1')->first(); |
|
|
|
|
265
|
|
|
/* fill the values to coompany table */ |
266
|
|
|
$tickets->fill($request->except('captcha', 'claim_response', 'assigned_ticket', 'answered_ticket', 'agent_mask', 'html', 'client_update'))->save(); |
267
|
|
|
/* insert checkbox to Database */ |
268
|
|
|
$tickets->captcha = $request->input('captcha'); |
269
|
|
|
$tickets->claim_response = $request->input('claim_response'); |
270
|
|
|
$tickets->assigned_ticket = $request->input('assigned_ticket'); |
271
|
|
|
$tickets->answered_ticket = $request->input('answered_ticket'); |
272
|
|
|
$tickets->agent_mask = $request->input('agent_mask'); |
273
|
|
|
$tickets->html = $request->input('html'); |
274
|
|
|
$tickets->client_update = $request->input('client_update'); |
275
|
|
|
$tickets->collision_avoid = $request->input('collision_avoid'); |
276
|
|
|
/* Check whether function success or not */ |
277
|
|
|
$tickets->save(); |
278
|
|
|
/* redirect to Index page with Success Message */ |
279
|
|
|
return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully')); |
280
|
|
|
} catch (Exception $e) { |
281
|
|
|
/* redirect to Index page with Fails Message */ |
282
|
|
|
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>'); |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* get the form for Email setting page. |
288
|
|
|
* |
289
|
|
|
* @param type Email $email |
290
|
|
|
* @param type Template $template |
291
|
|
|
* @param type Emails $email1 |
292
|
|
|
* |
293
|
|
|
* @return type Response |
294
|
|
|
*/ |
295
|
|
|
public function getemail(Email $email, Template $template, Emails $email1) |
296
|
|
|
{ |
297
|
|
|
try { |
298
|
|
|
/* fetch the values of email from Email table */ |
299
|
|
|
$emails = $email->whereId('1')->first(); |
|
|
|
|
300
|
|
|
/* Fetch the values from Template table */ |
301
|
|
|
$templates = $template->get(); |
|
|
|
|
302
|
|
|
/* Fetch the values from Emails table */ |
303
|
|
|
$emails1 = $email1->get(); |
|
|
|
|
304
|
|
|
/* Direct to Email Settings Page */ |
305
|
|
|
return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1')); |
306
|
|
|
} catch (Exception $e) { |
307
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
308
|
|
|
} |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Update the specified email setting in storage. |
313
|
|
|
* |
314
|
|
|
* @param type int $id |
315
|
|
|
* @param type Email $email |
316
|
|
|
* @param type EmailRequest $request |
317
|
|
|
* |
318
|
|
|
* @return type Response |
319
|
|
|
*/ |
320
|
|
View Code Duplication |
public function postemail($id, Email $email, EmailRequest $request) |
|
|
|
|
321
|
|
|
{ |
322
|
|
|
try { |
323
|
|
|
/* fetch the values of email request */ |
324
|
|
|
$emails = $email->whereId('1')->first(); |
|
|
|
|
325
|
|
|
/* fill the values to email table */ |
326
|
|
|
$emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save(); |
327
|
|
|
/* insert checkboxes to database */ |
328
|
|
|
// $emails->email_fetching = $request->input('email_fetching'); |
|
|
|
|
329
|
|
|
// $emails->notification_cron = $request->input('notification_cron'); |
|
|
|
|
330
|
|
|
$emails->all_emails = $request->input('all_emails'); |
331
|
|
|
$emails->email_collaborator = $request->input('email_collaborator'); |
332
|
|
|
$emails->strip = $request->input('strip'); |
333
|
|
|
$emails->attachment = $request->input('attachment'); |
334
|
|
|
/* Check whether function success or not */ |
335
|
|
|
$emails->save(); |
336
|
|
|
/* redirect to Index page with Success Message */ |
337
|
|
|
return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully')); |
338
|
|
|
} catch (Exception $e) { |
339
|
|
|
/* redirect to Index page with Fails Message */ |
340
|
|
|
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>'); |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* get the form for cron job setting page. |
346
|
|
|
* |
347
|
|
|
* @param type Email $email |
348
|
|
|
* @param type Template $template |
349
|
|
|
* @param type Emails $email1 |
350
|
|
|
* |
351
|
|
|
* @return type Response |
352
|
|
|
*/ |
353
|
|
|
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow) |
354
|
|
|
{ |
355
|
|
|
// try { |
356
|
|
|
/* fetch the values of email from Email table */ |
357
|
|
|
$emails = $email->whereId('1')->first(); |
|
|
|
|
358
|
|
|
/* Fetch the values from Template table */ |
359
|
|
|
$templates = $template->get(); |
|
|
|
|
360
|
|
|
/* Fetch the values from Emails table */ |
361
|
|
|
$emails1 = $email1->get(); |
|
|
|
|
362
|
|
|
|
363
|
|
|
$workflow = $workflow->whereId('1')->first(); |
|
|
|
|
364
|
|
|
$cron_path = base_path('artisan'); |
365
|
|
|
$command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>"; |
366
|
|
|
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>"; |
367
|
|
|
$warn = ''; |
368
|
|
|
$condition = new \App\Model\MailJob\Condition(); |
369
|
|
|
$job = $condition->checkActiveJob(); |
|
|
|
|
370
|
|
|
$commands = [ |
371
|
|
|
'' => 'Select', |
372
|
|
|
'everyMinute' => 'Every Minute', |
373
|
|
|
'everyFiveMinutes' => 'Every Five Minute', |
374
|
|
|
'everyTenMinutes' => 'Every Ten Minute', |
375
|
|
|
'everyThirtyMinutes' => 'Every Thirty Minute', |
376
|
|
|
'hourly' => 'Every Hour', |
377
|
|
|
'daily' => 'Every Day', |
378
|
|
|
'dailyAt' => 'Daily at', |
379
|
|
|
'weekly' => 'Every Week', |
380
|
|
|
'monthly' => 'Monthly', |
381
|
|
|
'yearly' => 'Yearly', |
382
|
|
|
]; |
383
|
|
|
$followupcommands = [ |
384
|
|
|
'' => 'Select', |
385
|
|
|
'everyMinute' => 'Every Minute', |
386
|
|
|
'everyFiveMinutes' => 'Every Five Minute', |
387
|
|
|
'everyTenMinutes' => 'Every Ten Minute', |
388
|
|
|
'everyThirtyMinutes' => 'Every Thirty Minute', |
389
|
|
|
'hourly' => 'Every Hour', |
390
|
|
|
'daily' => 'Every Day', |
391
|
|
|
'weekly' => 'Every Week', |
392
|
|
|
'monthly' => 'Monthly', |
393
|
|
|
'yearly' => 'Yearly', |
394
|
|
|
]; |
395
|
|
|
if (ini_get('register_argc_argv') == '') { |
|
|
|
|
396
|
|
|
//$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron"; |
|
|
|
|
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared')); |
400
|
|
|
// } catch { |
|
|
|
|
401
|
|
|
// } |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Update the specified schedular in storage for cron job. |
406
|
|
|
* |
407
|
|
|
* @param type Email $email |
408
|
|
|
* @param type EmailRequest $request |
409
|
|
|
* |
410
|
|
|
* @return type Response |
411
|
|
|
*/ |
412
|
|
|
public function postSchedular(Email $email, Template $template, Emails $email1, TaskRequest $request, WorkflowClose $workflow) |
|
|
|
|
413
|
|
|
{ |
414
|
|
|
try { |
415
|
|
|
/* fetch the values of email request */ |
416
|
|
|
$emails = $email->whereId('1')->first(); |
|
|
|
|
417
|
|
|
if ($request->email_fetching) { |
|
|
|
|
418
|
|
|
$emails->email_fetching = $request->email_fetching; |
|
|
|
|
419
|
|
|
} else { |
420
|
|
|
$emails->email_fetching = 0; |
421
|
|
|
} |
422
|
|
|
if ($request->notification_cron) { |
|
|
|
|
423
|
|
|
$emails->notification_cron = $request->notification_cron; |
|
|
|
|
424
|
|
|
} else { |
425
|
|
|
$emails->notification_cron = 0; |
426
|
|
|
} |
427
|
|
|
$emails->save(); |
428
|
|
|
//workflow |
429
|
|
|
$work = $workflow->whereId('1')->first(); |
|
|
|
|
430
|
|
|
if ($request->condition) { |
|
|
|
|
431
|
|
|
$work->condition = 1; |
432
|
|
|
} else { |
433
|
|
|
$work->condition = 0; |
434
|
|
|
} |
435
|
|
|
$work->save(); |
436
|
|
|
$this->saveConditions(); |
437
|
|
|
/* redirect to Index page with Success Message */ |
438
|
|
|
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success')); |
439
|
|
|
} catch (Exception $e) { |
440
|
|
|
/* redirect to Index page with Fails Message */ |
441
|
|
|
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>'); |
442
|
|
|
} |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* get the form for Responder setting page. |
447
|
|
|
* |
448
|
|
|
* @param type Responder $responder |
449
|
|
|
* |
450
|
|
|
* @return type Response |
451
|
|
|
*/ |
452
|
|
|
public function getresponder(Responder $responder) |
453
|
|
|
{ |
454
|
|
|
try { |
455
|
|
|
/* fetch the values of responder from responder table */ |
456
|
|
|
$responders = $responder->whereId('1')->first(); |
|
|
|
|
457
|
|
|
/* Direct to Responder Settings Page */ |
458
|
|
|
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders')); |
459
|
|
|
} catch (Exception $e) { |
460
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
461
|
|
|
} |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Update the specified autoresponse in storage. |
466
|
|
|
* |
467
|
|
|
* @param type Responder $responder |
468
|
|
|
* @param type Request $request |
469
|
|
|
* |
470
|
|
|
* @return type |
471
|
|
|
*/ |
472
|
|
View Code Duplication |
public function postresponder(Responder $responder, Request $request) |
|
|
|
|
473
|
|
|
{ |
474
|
|
|
try { |
475
|
|
|
/* fetch the values of responder request */ |
476
|
|
|
$responders = $responder->whereId('1')->first(); |
|
|
|
|
477
|
|
|
/* insert Checkbox value to DB */ |
478
|
|
|
$responders->new_ticket = $request->input('new_ticket'); |
479
|
|
|
$responders->agent_new_ticket = $request->input('agent_new_ticket'); |
480
|
|
|
$responders->submitter = $request->input('submitter'); |
481
|
|
|
$responders->participants = $request->input('participants'); |
482
|
|
|
$responders->overlimit = $request->input('overlimit'); |
483
|
|
|
/* fill the values to coompany table */ |
484
|
|
|
/* Check whether function success or not */ |
485
|
|
|
$responders->save(); |
486
|
|
|
/* redirect to Index page with Success Message */ |
487
|
|
|
return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully')); |
488
|
|
|
} catch (Exception $e) { |
489
|
|
|
/* redirect to Index page with Fails Message */ |
490
|
|
|
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>'); |
491
|
|
|
} |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* get the form for Alert setting page. |
496
|
|
|
* |
497
|
|
|
* @param type Alert $alert |
498
|
|
|
* |
499
|
|
|
* @return type Response |
500
|
|
|
*/ |
501
|
|
|
public function getalert(Alert $alert) |
502
|
|
|
{ |
503
|
|
|
try { |
504
|
|
|
/* fetch the values of alert from alert table */ |
505
|
|
|
$alerts = $alert->whereId('1')->first(); |
|
|
|
|
506
|
|
|
/* Direct to Alert Settings Page */ |
507
|
|
|
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts')); |
508
|
|
|
} catch (Exception $e) { |
509
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
510
|
|
|
} |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* Update the specified alert in storage. |
515
|
|
|
* |
516
|
|
|
* @param type $id |
517
|
|
|
* @param type Alert $alert |
518
|
|
|
* @param type Request $request |
519
|
|
|
* |
520
|
|
|
* @return type Response |
521
|
|
|
*/ |
522
|
|
View Code Duplication |
public function postalert($id, Alert $alert, Request $request) |
|
|
|
|
523
|
|
|
{ |
524
|
|
|
try { |
525
|
|
|
/* fetch the values of alert request */ |
526
|
|
|
$alerts = $alert->whereId('1')->first(); |
|
|
|
|
527
|
|
|
/* Insert Checkbox to DB */ |
528
|
|
|
$alerts->assignment_status = $request->input('assignment_status'); |
529
|
|
|
$alerts->ticket_status = $request->input('ticket_status'); |
530
|
|
|
$alerts->overdue_department_member = $request->input('overdue_department_member'); |
531
|
|
|
$alerts->sql_error = $request->input('sql_error'); |
532
|
|
|
$alerts->excessive_failure = $request->input('excessive_failure'); |
533
|
|
|
$alerts->overdue_status = $request->input('overdue_status'); |
534
|
|
|
$alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent'); |
535
|
|
|
$alerts->overdue_department_manager = $request->input('overdue_department_manager'); |
536
|
|
|
$alerts->internal_status = $request->input('internal_status'); |
537
|
|
|
$alerts->internal_last_responder = $request->input('internal_last_responder'); |
538
|
|
|
$alerts->internal_assigned_agent = $request->input('internal_assigned_agent'); |
539
|
|
|
$alerts->internal_department_manager = $request->input('internal_department_manager'); |
540
|
|
|
$alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent'); |
541
|
|
|
$alerts->assignment_team_leader = $request->input('assignment_team_leader'); |
542
|
|
|
$alerts->assignment_team_member = $request->input('assignment_team_member'); |
543
|
|
|
$alerts->system_error = $request->input('system_error'); |
544
|
|
|
$alerts->transfer_department_member = $request->input('transfer_department_member'); |
545
|
|
|
$alerts->transfer_department_manager = $request->input('transfer_department_manager'); |
546
|
|
|
$alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent'); |
547
|
|
|
$alerts->transfer_status = $request->input('transfer_status'); |
548
|
|
|
$alerts->message_organization_accmanager = $request->input('message_organization_accmanager'); |
549
|
|
|
$alerts->message_department_manager = $request->input('message_department_manager'); |
550
|
|
|
$alerts->message_assigned_agent = $request->input('message_assigned_agent'); |
551
|
|
|
$alerts->message_last_responder = $request->input('message_last_responder'); |
552
|
|
|
$alerts->message_status = $request->input('message_status'); |
553
|
|
|
$alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager'); |
554
|
|
|
$alerts->ticket_department_manager = $request->input('ticket_department_manager'); |
555
|
|
|
$alerts->ticket_department_member = $request->input('ticket_department_member'); |
556
|
|
|
$alerts->ticket_admin_email = $request->input('ticket_admin_email'); |
557
|
|
|
|
558
|
|
|
if ($request->input('system_error') == null) { |
559
|
|
|
$str = '%0%'; |
560
|
|
|
$path = app_path('../config/app.php'); |
561
|
|
|
$content = \File::get($path); |
562
|
|
|
$content = str_replace('%1%', $str, $content); |
563
|
|
|
\File::put($path, $content); |
564
|
|
|
} else { |
565
|
|
|
$str = '%1%'; |
566
|
|
|
$path = app_path('../config/app.php'); |
567
|
|
|
$content = \File::get($path); |
568
|
|
|
$content = str_replace('%0%', $str, $content); |
569
|
|
|
\File::put($path, $content); |
570
|
|
|
} |
571
|
|
|
/* fill the values to coompany table */ |
572
|
|
|
/* Check whether function success or not */ |
573
|
|
|
$alerts->save(); |
574
|
|
|
/* redirect to Index page with Success Message */ |
575
|
|
|
return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully')); |
576
|
|
|
} catch (Exception $e) { |
577
|
|
|
/* redirect to Index page with Fails Message */ |
578
|
|
|
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>'); |
579
|
|
|
} |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
/** |
583
|
|
|
* Generate Api key. |
584
|
|
|
* |
585
|
|
|
* @return type json |
586
|
|
|
*/ |
587
|
|
|
public function generateApiKey() |
588
|
|
|
{ |
589
|
|
|
$key = str_random(32); |
590
|
|
|
|
591
|
|
|
return $key; |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* Main Settings Page. |
596
|
|
|
* |
597
|
|
|
* @return type view |
598
|
|
|
*/ |
599
|
|
|
public function settings() |
600
|
|
|
{ |
601
|
|
|
return view('themes.default1.admin.helpdesk.setting'); |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
/** |
605
|
|
|
* @param int $id |
|
|
|
|
606
|
|
|
* @param $compant instance of company table |
607
|
|
|
* |
608
|
|
|
* get the form for company setting page |
609
|
|
|
* |
610
|
|
|
* @return Response |
611
|
|
|
*/ |
612
|
|
View Code Duplication |
public function getStatuses() |
|
|
|
|
613
|
|
|
{ |
614
|
|
|
try { |
615
|
|
|
/* fetch the values of company from company table */ |
616
|
|
|
$statuss = \DB::table('ticket_status')->get(); |
617
|
|
|
/* Direct to Company Settings Page */ |
618
|
|
|
return view('themes.default1.admin.helpdesk.settings.status', compact('statuss')); |
619
|
|
|
} catch (Exception $e) { |
620
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
621
|
|
|
} |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* @param int $id |
626
|
|
|
* @param $compant instance of company table |
627
|
|
|
* |
628
|
|
|
* get the form for company setting page |
629
|
|
|
* |
630
|
|
|
* @return Response |
631
|
|
|
*/ |
632
|
|
View Code Duplication |
public function getEditStatuses($id) |
|
|
|
|
633
|
|
|
{ |
634
|
|
|
try { |
635
|
|
|
/* fetch the values of company from company table */ |
636
|
|
|
$status = \DB::table('ticket_status')->where('id', '=', $id)->first(); |
637
|
|
|
/* Direct to Company Settings Page */ |
638
|
|
|
return view('themes.default1.admin.helpdesk.settings.status-edit', compact('status')); |
639
|
|
|
} catch (Exception $e) { |
640
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* @param int $id |
646
|
|
|
* @param $compant instance of company table |
647
|
|
|
* |
648
|
|
|
* get the form for company setting page |
649
|
|
|
* |
650
|
|
|
* @return Response |
651
|
|
|
*/ |
652
|
|
View Code Duplication |
public function editStatuses($id, StatusRequest $request) |
|
|
|
|
653
|
|
|
{ |
654
|
|
|
try { |
655
|
|
|
/* fetch the values of company from company table */ |
656
|
|
|
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first(); |
657
|
|
|
$statuss->name = $request->input('name'); |
658
|
|
|
$statuss->icon_class = $request->input('icon_class'); |
659
|
|
|
$statuss->email_user = $request->input('email_user'); |
660
|
|
|
$statuss->sort = $request->input('sort'); |
661
|
|
|
$delete = $request->input('deleted'); |
662
|
|
|
if ($delete == 'yes') { |
663
|
|
|
$statuss->state = 'delete'; |
664
|
|
|
} else { |
665
|
|
|
$statuss->state = $request->input('state'); |
666
|
|
|
} |
667
|
|
|
$statuss->sort = $request->input('sort'); |
668
|
|
|
$statuss->save(); |
669
|
|
|
/* Direct to Company Settings Page */ |
670
|
|
|
return redirect()->back()->with('success', Lang::get('lang.status_has_been_updated_successfully')); |
671
|
|
|
} catch (Exception $e) { |
672
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
673
|
|
|
} |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* create a status. |
678
|
|
|
* |
679
|
|
|
* @param \App\Model\helpdesk\Ticket\Ticket_Status $statuss |
680
|
|
|
* @param \App\Http\Requests\helpdesk\StatusRequest $request |
681
|
|
|
* |
682
|
|
|
* @return type redirect |
683
|
|
|
*/ |
684
|
|
View Code Duplication |
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request) |
|
|
|
|
685
|
|
|
{ |
686
|
|
|
try { |
687
|
|
|
/* fetch the values of company from company table */ |
688
|
|
|
$statuss->name = $request->input('name'); |
|
|
|
|
689
|
|
|
$statuss->icon_class = $request->input('icon_class'); |
|
|
|
|
690
|
|
|
$statuss->email_user = $request->input('email_user'); |
|
|
|
|
691
|
|
|
$statuss->sort = $request->input('sort'); |
|
|
|
|
692
|
|
|
$delete = $request->input('delete'); |
693
|
|
|
if ($delete == 'yes') { |
694
|
|
|
$statuss->state = 'deleted'; |
|
|
|
|
695
|
|
|
} else { |
696
|
|
|
$statuss->state = $request->input('state'); |
|
|
|
|
697
|
|
|
} |
698
|
|
|
$statuss->sort = $request->input('sort'); |
|
|
|
|
699
|
|
|
$statuss->save(); |
700
|
|
|
/* Direct to Company Settings Page */ |
701
|
|
|
return redirect()->back()->with('success', Lang::get('lang.status_has_been_created_successfully')); |
702
|
|
|
} catch (Exception $ex) { |
703
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
704
|
|
|
} |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* delete a status. |
709
|
|
|
* |
710
|
|
|
* @param type $id |
711
|
|
|
* |
712
|
|
|
* @return type redirect |
713
|
|
|
*/ |
714
|
|
|
public function deleteStatuses($id) |
715
|
|
|
{ |
716
|
|
|
try { |
717
|
|
View Code Duplication |
if ($id > 5) { |
|
|
|
|
718
|
|
|
/* fetch the values of company from company table */ |
719
|
|
|
\App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete(); |
720
|
|
|
/* Direct to Company Settings Page */ |
721
|
|
|
return redirect()->back()->with('success', Lang::get('lang.status_has_been_deleted')); |
722
|
|
|
} else { |
723
|
|
|
return redirect()->back()->with('failed', Lang::get('lang.you_cannot_delete_this_status')); |
724
|
|
|
} |
725
|
|
|
} catch (Exception $e) { |
726
|
|
|
return redirect()->back()->with('fails', $e->getMessage()); |
727
|
|
|
} |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
/** |
731
|
|
|
* get the page of notification settings. |
732
|
|
|
* |
733
|
|
|
* @return type view |
734
|
|
|
*/ |
735
|
|
|
public function notificationSettings() |
736
|
|
|
{ |
737
|
|
|
return view('themes.default1.admin.helpdesk.settings.notification'); |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
/** |
741
|
|
|
* delete a notification. |
742
|
|
|
* |
743
|
|
|
* @return type redirect |
744
|
|
|
*/ |
745
|
|
View Code Duplication |
public function deleteReadNoti() |
|
|
|
|
746
|
|
|
{ |
747
|
|
|
$markasread = UserNotification::where('is_read', '=', 1)->get(); |
748
|
|
|
foreach ($markasread as $mark) { |
749
|
|
|
$mark->delete(); |
750
|
|
|
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete(); |
751
|
|
|
} |
752
|
|
|
|
753
|
|
|
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_read_notifications')); |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* delete a notification log. |
758
|
|
|
* |
759
|
|
|
* @return type redirect |
760
|
|
|
*/ |
761
|
|
|
public function deleteNotificationLog() |
762
|
|
|
{ |
763
|
|
|
$days = Input::get('no_of_days'); |
764
|
|
|
if ($days == null) { |
765
|
|
|
return redirect()->back()->with('fails', 'Please enter valid no of days'); |
766
|
|
|
} |
767
|
|
|
$date = new DateTime(); |
768
|
|
|
$date->modify($days.' day'); |
769
|
|
|
$formatted_date = $date->format('Y-m-d H:i:s'); |
770
|
|
|
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get(); |
771
|
|
|
foreach ($markasread as $mark) { |
772
|
|
|
$mark->delete(); |
773
|
|
|
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete(); |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.'); |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* To display the list of ratings in the system. |
781
|
|
|
* |
782
|
|
|
* @return type View |
783
|
|
|
*/ |
784
|
|
|
public function RatingSettings() |
785
|
|
|
{ |
786
|
|
|
try { |
787
|
|
|
$ratings = Rating::orderBy('display_order', 'asc')->get(); |
788
|
|
|
|
789
|
|
|
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings')); |
790
|
|
|
} catch (Exception $ex) { |
791
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
792
|
|
|
} |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* edit a rating. |
797
|
|
|
* |
798
|
|
|
* @param type $id |
799
|
|
|
* |
800
|
|
|
* @return type view |
801
|
|
|
*/ |
802
|
|
View Code Duplication |
public function editRatingSettings($id) |
|
|
|
|
803
|
|
|
{ |
804
|
|
|
try { |
805
|
|
|
$rating = Rating::whereId($id)->first(); |
806
|
|
|
|
807
|
|
|
return view('themes.default1.admin.helpdesk.settings.edit-ratings', compact('rating')); |
808
|
|
|
} catch (Exception $ex) { |
809
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
810
|
|
|
} |
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
/** |
814
|
|
|
* To store rating data. |
815
|
|
|
* |
816
|
|
|
* @return type Redirect |
817
|
|
|
*/ |
818
|
|
|
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request) |
819
|
|
|
{ |
820
|
|
|
try { |
821
|
|
|
$rating = $ratings->whereId($id)->first(); |
|
|
|
|
822
|
|
|
$rating->name = $request->input('name'); |
823
|
|
|
$rating->display_order = $request->input('display_order'); |
824
|
|
|
$rating->allow_modification = $request->input('allow_modification'); |
825
|
|
|
$rating->rating_scale = $request->input('rating_scale'); |
826
|
|
|
// $rating->rating_area = $request->input('rating_area'); |
|
|
|
|
827
|
|
|
$rating->restrict = $request->input('restrict'); |
828
|
|
|
$rating->save(); |
829
|
|
|
|
830
|
|
|
return redirect()->back()->with('success', Lang::get('lang.ratings_updated_successfully')); |
831
|
|
|
} catch (Exception $ex) { |
832
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
833
|
|
|
} |
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
/** |
837
|
|
|
* get the create rating page. |
838
|
|
|
* |
839
|
|
|
* @return type redirect |
840
|
|
|
*/ |
841
|
|
|
public function createRating() |
842
|
|
|
{ |
843
|
|
|
try { |
844
|
|
|
return view('themes.default1.admin.helpdesk.settings.create-ratings'); |
845
|
|
|
} catch (Exception $ex) { |
846
|
|
|
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>'); |
847
|
|
|
} |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
/** |
851
|
|
|
* store a rating value. |
852
|
|
|
* |
853
|
|
|
* @param \App\Model\helpdesk\Ratings\Rating $rating |
854
|
|
|
* @param \App\Model\helpdesk\Ratings\RatingRef $ratingrefs |
855
|
|
|
* @param \App\Http\Requests\helpdesk\RatingRequest $request |
856
|
|
|
* |
857
|
|
|
* @return type redirect |
858
|
|
|
*/ |
859
|
|
|
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request) |
860
|
|
|
{ |
861
|
|
|
$rating->name = $request->input('name'); |
|
|
|
|
862
|
|
|
$rating->display_order = $request->input('display_order'); |
|
|
|
|
863
|
|
|
$rating->allow_modification = $request->input('allow_modification'); |
|
|
|
|
864
|
|
|
$rating->rating_scale = $request->input('rating_scale'); |
|
|
|
|
865
|
|
|
$rating->rating_area = $request->input('rating_area'); |
|
|
|
|
866
|
|
|
$rating->restrict = $request->input('restrict'); |
|
|
|
|
867
|
|
|
$rating->save(); |
868
|
|
|
$ratingrefs->rating_id = $rating->id; |
|
|
|
|
869
|
|
|
$ratingrefs->save(); |
870
|
|
|
|
871
|
|
|
return redirect()->back()->with('success', Lang::get('lang.successfully_created_this_rating')); |
872
|
|
|
} |
873
|
|
|
|
874
|
|
|
/** |
875
|
|
|
* To delete a type of rating. |
876
|
|
|
* |
877
|
|
|
* @return type Redirect |
878
|
|
|
*/ |
879
|
|
|
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs) |
880
|
|
|
{ |
881
|
|
|
$ratingrefs->where('rating_id', '=', $slug)->delete(); |
|
|
|
|
882
|
|
|
Rating::whereId($slug)->delete(); |
883
|
|
|
|
884
|
|
|
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully')); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
public function saveConditions() |
888
|
|
|
{ |
889
|
|
|
if (\Input::get('fetching-commands') && \Input::get('notification-commands')) { |
890
|
|
|
$fetching_commands = \Input::get('fetching-commands'); |
891
|
|
|
$fetching_dailyAt = \Input::get('fetching-dailyAt'); |
892
|
|
|
$notification_commands = \Input::get('notification-commands'); |
893
|
|
|
$notification_dailyAt = \Input::get('notification-dailyAt'); |
894
|
|
|
$work_commands = \Input::get('work-commands'); |
895
|
|
|
$workflow_dailyAt = \Input::get('workflow-dailyAt'); |
896
|
|
|
$fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt); |
897
|
|
|
$notification_command = $this->getCommand($notification_commands, $notification_dailyAt); |
898
|
|
|
$work_command = $this->getCommand($work_commands, $workflow_dailyAt); |
899
|
|
|
$jobs = ['fetching'=>$fetching_command, 'notification'=>$notification_command, 'work'=>$work_command]; |
900
|
|
|
$this->storeCommand($jobs); |
901
|
|
|
} |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
public function getCommand($command, $daily_at) |
905
|
|
|
{ |
906
|
|
|
if ($command == 'dailyAt') { |
907
|
|
|
$command = "dailyAt,$daily_at"; |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
return $command; |
911
|
|
|
} |
912
|
|
|
|
913
|
|
|
public function storeCommand($array = []) |
914
|
|
|
{ |
915
|
|
|
$command = new \App\Model\MailJob\Condition(); |
916
|
|
|
$commands = $command->get(); |
|
|
|
|
917
|
|
|
if ($commands->count() > 0) { |
918
|
|
|
foreach ($commands as $condition) { |
919
|
|
|
$condition->delete(); |
920
|
|
|
} |
921
|
|
|
} |
922
|
|
|
if (count($array) > 0) { |
923
|
|
|
foreach ($array as $key=>$save) { |
924
|
|
|
$command->create([ |
925
|
|
|
'job' => $key, |
926
|
|
|
'value'=> $save, |
927
|
|
|
]); |
928
|
|
|
} |
929
|
|
|
} |
930
|
|
|
} |
931
|
|
|
|
932
|
|
|
public function getTicketNumber(Request $request) |
933
|
|
|
{ |
934
|
|
|
$this->validate($request, [ |
935
|
|
|
'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'], |
936
|
|
|
'type' => 'required', |
937
|
|
|
]); |
938
|
|
|
|
939
|
|
|
$format = $request->input('format'); |
940
|
|
|
$type = $request->input('type'); |
941
|
|
|
$number = $this->switchNumber($format, $type); |
942
|
|
|
|
943
|
|
|
return $number; |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
public function switchNumber($format, $type) |
947
|
|
|
{ |
948
|
|
|
switch ($type) { |
949
|
|
|
case 'random': |
950
|
|
|
return $this->createRandomNumber($format); |
951
|
|
|
case 'sequence': |
952
|
|
|
return $this->createSequencialNumber($format); |
953
|
|
|
} |
954
|
|
|
} |
955
|
|
|
|
956
|
|
View Code Duplication |
public function createRandomNumber($format) |
|
|
|
|
957
|
|
|
{ |
958
|
|
|
$number = ''; |
959
|
|
|
$array = str_split($format); |
960
|
|
|
for ($i = 0; $i < count($array); $i++) { |
|
|
|
|
961
|
|
|
if ($array[$i] === '$') { |
962
|
|
|
$number .= $this->getRandomAlphebet(); |
963
|
|
|
} |
964
|
|
|
if ($array[$i] === '#') { |
965
|
|
|
$number .= rand(0, 9); |
966
|
|
|
} |
967
|
|
|
if ($array[$i] !== '$' && $array[$i] !== '#') { |
968
|
|
|
$number .= $array[$i]; |
969
|
|
|
} |
970
|
|
|
} |
971
|
|
|
|
972
|
|
|
return $number; |
973
|
|
|
} |
974
|
|
|
|
975
|
|
View Code Duplication |
public function createSequencialNumber($format) |
|
|
|
|
976
|
|
|
{ |
977
|
|
|
$number = ''; |
978
|
|
|
$array_format = str_split($format); |
979
|
|
|
$count = count($array_format); |
980
|
|
|
for ($i = 0; $i < $count; $i++) { |
981
|
|
|
//dd($sub); |
982
|
|
|
if ($array_format[$i] === '$') { |
983
|
|
|
$number .= 'A'; |
984
|
|
|
} |
985
|
|
|
|
986
|
|
|
if ($array_format[$i] === '#') { |
987
|
|
|
$number .= '0'; |
988
|
|
|
} |
989
|
|
|
|
990
|
|
|
if ($array_format[$i] !== '$' && $array_format[$i] !== '#') { |
991
|
|
|
$number .= $array_format[$i]; |
992
|
|
|
} |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
return $number; |
996
|
|
|
//return $this->nthTicketNumber($number); |
|
|
|
|
997
|
|
|
} |
998
|
|
|
|
999
|
|
|
public function checkCurrentFormat($current, $format) |
1000
|
|
|
{ |
1001
|
|
|
$check = true; |
1002
|
|
|
$array_current = str_split($current); |
1003
|
|
|
$array_format = str_split($format); |
1004
|
|
|
$count_current = count($array_current); |
1005
|
|
|
$count_format = count($array_format); |
1006
|
|
|
if ($count_current === $count_format) { |
1007
|
|
|
return false; |
1008
|
|
|
} |
1009
|
|
|
for ($i = 0; $i < $count_current; $i++) { |
1010
|
|
|
if ($array_current[$i] !== $array_format[$i]) { |
1011
|
|
|
return false; |
1012
|
|
|
} |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
return $check; |
1016
|
|
|
} |
1017
|
|
|
|
1018
|
|
|
public function nthTicketNumber($current, $type, $format, $force = false) |
1019
|
|
|
{ |
1020
|
|
|
$check = $this->checkCurrentFormat($current, $format); |
1021
|
|
|
if ($check === false && $force === false) { |
1022
|
|
|
$current = $this->createSequencialNumber($format); |
1023
|
|
|
} |
1024
|
|
|
if ($type === 'sequence') { |
1025
|
|
|
$pos_first = stripos($current, '-'); |
1026
|
|
|
$pos_last = strpos($current, '-', $pos_first + 1); |
1027
|
|
|
$current = str_replace('-', '', $current); |
1028
|
|
|
$number = ++$current; |
1029
|
|
|
if ($pos_first) { |
1030
|
|
|
$number = substr_replace($number, '-', $pos_first, 0); |
1031
|
|
|
} |
1032
|
|
|
if ($pos_last) { |
1033
|
|
|
$number = substr_replace($number, '-', $pos_last, 0); |
1034
|
|
|
} |
1035
|
|
|
} |
1036
|
|
|
if ($type === 'random') { |
1037
|
|
|
$number = $this->createRandomNumber($format); |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
return $number; |
|
|
|
|
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
public function getRandomAlphebet() |
1044
|
|
|
{ |
1045
|
|
|
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
1046
|
|
|
$shuffled = str_shuffle($alpha); |
1047
|
|
|
$shuffled_array = str_split($shuffled); |
1048
|
|
|
$char = $shuffled_array[0]; |
1049
|
|
|
|
1050
|
|
|
return $char; |
1051
|
|
|
} |
1052
|
|
|
} |
1053
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.