1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Itil\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Itil\Controllers\BaseServiceDeskController; |
6
|
|
|
use Exception; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
|
9
|
|
|
class InterfaceController extends BaseServiceDeskController { |
10
|
|
|
|
11
|
|
|
public function agentSidebar() { |
12
|
|
|
|
13
|
|
|
return view('itil::interface.agent.sidebar'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function agentTopbar() { |
17
|
|
|
|
18
|
|
|
return view('itil::interface.agent.topbar'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function agentTopSubbar() { |
22
|
|
|
|
23
|
|
|
return view('itil::interface.agent.topsubbar'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function adminSidebar() { |
27
|
|
|
|
28
|
|
|
return view('itil::interface.admin.sidebar'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function adminTopbar() { |
32
|
|
|
|
33
|
|
|
return view('itil::interface.admin.topbar'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function adminTopSubbar() { |
37
|
|
|
|
38
|
|
|
return view('itil::interface.admin.topsubbar'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function adminSettings() { |
42
|
|
|
|
43
|
|
|
return view('itil::interface.admin.settings'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function ticketDetailTable($event) { |
47
|
|
|
$id = $event->para1; |
48
|
|
|
return view("itil::interface.agent.ticket-head", compact('id')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
View Code Duplication |
public function generalInfo($id, $table, Request $request) { |
|
|
|
|
52
|
|
|
//dd($request); |
53
|
|
|
try { |
54
|
|
|
$store = UtilityController::storeGeneralInfo($id, $table, $request); |
55
|
|
|
//dd($store); |
56
|
|
|
if ($store == "success") { |
57
|
|
|
return redirect()->back()->with('success', 'Updated'); |
58
|
|
|
} |
59
|
|
|
throw new Exception("Sorry we can not process your request"); |
60
|
|
|
} catch (Exception $ex) { |
61
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
View Code Duplication |
public function deleteAttachments($attachid, $owner) { |
|
|
|
|
66
|
|
|
try { |
67
|
|
|
$attachments = new \App\Itil\Models\Common\Attachments(); |
68
|
|
|
$attachment = $attachments->where('id', $attachid)->where('owner', $owner)->first(); |
|
|
|
|
69
|
|
|
if ($attachment) { |
70
|
|
|
UtilityController::removeAttachment($attachment); |
71
|
|
|
} else { |
72
|
|
|
throw new Exception("Sorry we can not find your request"); |
73
|
|
|
} |
74
|
|
|
return redirect()->back()->with('success', 'Updated'); |
75
|
|
|
} catch (Exception $ex) { |
76
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
View Code Duplication |
public function downloadAttachments($attachid, $owner) { |
|
|
|
|
81
|
|
|
try { |
82
|
|
|
$attachments = new \App\Itil\Models\Common\Attachments(); |
83
|
|
|
$attachment = $attachments->where('id', $attachid)->where('owner', $owner)->first(); |
|
|
|
|
84
|
|
|
if ($attachment) { |
85
|
|
|
$attach = UtilityController::downloadAttachment($attachment); |
86
|
|
|
if ($attachment->saved == 2) { |
87
|
|
|
return response()->download($attach); |
88
|
|
|
} |
89
|
|
|
} else { |
90
|
|
|
throw new Exception("Sorry we can not find your request"); |
91
|
|
|
} |
92
|
|
|
} catch (Exception $ex) { |
93
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
View Code Duplication |
public function deleteGeneralByIdentifier($owner, $identifier) { |
|
|
|
|
98
|
|
|
try { |
99
|
|
|
$genereals = new \App\Itil\Models\Common\GeneralInfo(); |
100
|
|
|
$genereal = $genereals->where('owner', $owner)->where('key', $identifier)->first(); |
|
|
|
|
101
|
|
|
if ($genereal) { |
102
|
|
|
$attachments = new \App\Itil\Models\Common\Attachments(); |
103
|
|
|
$atach_owner = str_replace(":", ":$identifier:", $owner); |
104
|
|
|
$attachment = $attachments->where('owner', $atach_owner)->first(); |
|
|
|
|
105
|
|
|
if($attachment){ |
106
|
|
|
UtilityController::removeAttachment($attachment); |
107
|
|
|
} |
108
|
|
|
if ($identifier == "solution") { |
109
|
|
|
$title = $genereals->where('owner', $owner)->where('key', "solution-title")->first(); |
|
|
|
|
110
|
|
|
if ($title) { |
111
|
|
|
$title->delete(); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
$genereal->delete(); |
115
|
|
|
} else { |
116
|
|
|
throw new Exception("Sorry we can not find your request"); |
117
|
|
|
} |
118
|
|
|
return redirect()->back()->with('success', 'Updated'); |
119
|
|
|
} catch (Exception $ex) { |
120
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.