1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Itil\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Itil\Controllers\BaseServiceDeskController; |
6
|
|
|
use App\Itil\Models\Problem\SdProblem; |
7
|
|
|
use App\Itil\Models\Problem\Impact; |
8
|
|
|
use App\Itil\Models\Problem\Location; |
9
|
|
|
use App\Model\helpdesk\Ticket\Ticket_Priority as Priority; |
10
|
|
|
use App\Itil\Requests\CreateProblemRequest; |
11
|
|
|
use Illuminate\Http\Request; |
12
|
|
|
use App\User; |
13
|
|
|
use App\Model\helpdesk\Agent\Groups as Group; |
14
|
|
|
use App\Model\helpdesk\Ticket\Ticket_Status as TicketType; |
15
|
|
|
use App\Model\helpdesk\Agent\Department; |
16
|
|
|
use App\Itil\Requests\CreateChangesRequest; |
17
|
|
|
|
18
|
|
|
class ProblemController extends BaseServiceDeskController { |
19
|
|
|
|
20
|
|
|
public function __construct() { |
21
|
|
|
$this->middleware('auth'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function index() { |
25
|
|
|
try { |
26
|
|
|
return view('itil::problem.index'); |
27
|
|
|
} catch (Exception $ex) { |
|
|
|
|
28
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
View Code Duplication |
public function getProblems() { |
|
|
|
|
33
|
|
|
try { |
34
|
|
|
$problem = new SdProblem(); |
35
|
|
|
$problems = $problem->select('id', 'department', 'status_type_id', 'from', 'subject')->get(); |
|
|
|
|
36
|
|
|
return \Datatable::Collection($problems) |
37
|
|
|
->showColumns('from') |
38
|
|
|
->addColumn('subject', function($model) { |
39
|
|
|
return str_limit($model->subject, 10); |
40
|
|
|
}) |
41
|
|
|
->addColumn('department', function($model) { |
42
|
|
|
$depertment_type_name = "Common"; |
43
|
|
|
$depertment_types = new Department; |
44
|
|
|
$depertment_type = $depertment_types->where('id', $model->department)->first(); |
|
|
|
|
45
|
|
|
if ($depertment_type) { |
46
|
|
|
$depertment_type_name = $depertment_type->name; |
47
|
|
|
} |
48
|
|
|
return $depertment_type_name; |
49
|
|
|
}) |
50
|
|
|
->addColumn('ticket_type', function($model) { |
51
|
|
|
$ticket_status_name = ""; |
52
|
|
|
$ticket_statuses = new TicketType; |
53
|
|
|
$ticket_status = $ticket_statuses->where('id', $model->status_type_id)->first(); |
|
|
|
|
54
|
|
|
if ($ticket_status) { |
55
|
|
|
$ticket_status_name = $ticket_status->name; |
56
|
|
|
} |
57
|
|
|
return $ticket_status_name; |
58
|
|
|
}) |
59
|
|
|
->addColumn('Action', function($model) { |
60
|
|
|
$url = url('service-desk/problem/' . $model->id . '/delete'); |
61
|
|
|
$delete = \App\Itil\Controllers\UtilityController::deletePopUp($model->id, $url, "Delete $model->subject"); |
62
|
|
|
return "<a href=" . url('service-desk/problem/' . $model->id . '/edit') . " class='btn btn-info btn-sm'>Edit</a> " |
63
|
|
|
. $delete |
64
|
|
|
. " <a href=" . url('service-desk/problem/' . $model->id . '/show') . " class='btn btn-primary btn-sm'>View</a>"; |
65
|
|
|
}) |
66
|
|
|
->searchColumns('description') |
67
|
|
|
->orderColumns('department', 'ticket_type', 'priority_id', 'location_type_id', 'agent_id') |
68
|
|
|
->make(); |
69
|
|
|
} catch (Exception $ex) { |
|
|
|
|
70
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
View Code Duplication |
public function create() { |
|
|
|
|
75
|
|
|
try { |
76
|
|
|
$assigned_ids = User::where('role', '!=', 'user')->lists('email', 'id')->toArray(); |
77
|
|
|
$group_ids = Group::lists('name', 'id')->toArray(); |
78
|
|
|
$impact_ids = Impact::lists('name', 'id')->toArray(); |
79
|
|
|
$location_type_ids = Location::lists('title', 'id')->toArray(); |
80
|
|
|
$priority_ids = Priority::lists('priority', 'priority_id')->toArray(); |
81
|
|
|
$status_type_ids = TicketType::lists('name', 'id')->toArray(); |
82
|
|
|
$departments = Department::lists('name', 'id')->toArray(); |
83
|
|
|
$from = User::lists('email', 'email')->toArray(); |
84
|
|
|
// $assets = SdAssets::lists('name', 'id')->toArray(); |
|
|
|
|
85
|
|
|
|
86
|
|
|
return view('itil::problem.create', compact('departments', 'assigned_ids', 'group_ids', 'impact_ids', 'location_type_ids', 'priority_ids', 'status_type_ids', 'from')); |
87
|
|
|
} catch (Exception $ex) { |
|
|
|
|
88
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function handleCreate(CreateProblemRequest $request) { |
93
|
|
|
// dd($request); |
|
|
|
|
94
|
|
|
|
95
|
|
|
try { |
96
|
|
|
$this->store($request); |
97
|
|
|
return \Redirect::route('service-desk.problem.index')->with('success', 'Problem Created Successfully'); |
98
|
|
|
} catch (Exception $ex) { |
|
|
|
|
99
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function edit($id) { |
104
|
|
|
// dd($id); |
|
|
|
|
105
|
|
|
try { |
106
|
|
|
|
107
|
|
|
$problem = SdProblem::findOrFail($id); |
108
|
|
|
$assigned_ids = User::where('role', '!=', 'user')->lists('email', 'id')->toArray(); |
109
|
|
|
$group_ids = Group::lists('name', 'id')->toArray(); |
110
|
|
|
$impact_ids = Impact::lists('name', 'id')->toArray(); |
111
|
|
|
$location_type_ids = Location::lists('title', 'id')->toArray(); |
112
|
|
|
$priority_ids = Priority::lists('priority', 'priority_id')->toArray(); |
113
|
|
|
$status_type_ids = TicketType::lists('name', 'id')->toArray(); |
114
|
|
|
$departments = Department::lists('name', 'id')->toArray(); |
115
|
|
|
// $assets = SdAssets::lists('name', 'id')->toArray(); |
|
|
|
|
116
|
|
|
$from = User::lists('email', 'email')->toArray(); |
117
|
|
|
return view('itil::problem.edit', compact('assets', 'problem', 'assigned_ids', 'group_ids', 'impact_ids', 'location_type_ids', 'priority_ids', 'status_type_ids', 'departments', 'from')); |
118
|
|
|
} catch (Exception $ex) { |
|
|
|
|
119
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
View Code Duplication |
public function handleEdit($id, CreateProblemRequest $request) { |
|
|
|
|
124
|
|
|
try { |
125
|
|
|
$this->update($id, $request); |
126
|
|
|
return \Redirect::route('service-desk.problem.index')->with('success', 'Problem Updated Successfully'); |
127
|
|
|
} catch (Exception $ex) { |
|
|
|
|
128
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function delete($id) { |
133
|
|
|
try { |
134
|
|
|
$sdproblems = SdProblem::findOrFail($id); |
135
|
|
|
$sdproblems->delete(); |
136
|
|
|
return \Redirect::route('service-desk.problem.index')->with('success', 'Problem Deleted Successfully'); |
137
|
|
|
} catch (Exception $ex) { |
|
|
|
|
138
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
142
|
|
View Code Duplication |
public function attachNewProblemToTicket(Request $request) { |
|
|
|
|
143
|
|
|
try { |
144
|
|
|
$ticketid = $request->input('ticketid'); |
145
|
|
|
$store = $this->store($request, $ticketid); |
|
|
|
|
146
|
|
|
if ($store) { |
147
|
|
|
\App\Itil\Controllers\UtilityController::saveTicketRelation($ticketid, 'sd_problem', $store->id); |
148
|
|
|
if (is_array($store->assets())) { |
149
|
|
|
$assetid = $store->assets(); |
|
|
|
|
150
|
|
|
|
151
|
|
|
\App\Itil\Controllers\UtilityController::saveTicketRelation($ticketid, 'sd_assets', $assetid); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
return redirect()->back()->with('success', 'Created new Problem and attached to this ticket'); |
155
|
|
|
} |
156
|
|
|
return redirect()->back()->with('fails', 'Sorry! We can not processs your request'); |
157
|
|
|
} catch (\Exception $ex) { |
158
|
|
|
dd($ex); |
159
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
163
|
|
View Code Duplication |
public function attachExistingProblemToTicket(Request $request) { |
|
|
|
|
164
|
|
|
try { |
165
|
|
|
$ticketid = $request->input('ticketid'); |
166
|
|
|
$problemid = $request->input('problemid'); |
167
|
|
|
\App\Itil\Controllers\UtilityController::saveTicketRelation($ticketid, 'sd_problem', $problemid); |
168
|
|
|
return redirect()->back()->with('success', 'Problem attached to this ticket'); |
169
|
|
|
} catch (Exception $ex) { |
|
|
|
|
170
|
|
|
dd($ex); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function store($request) { |
175
|
|
|
try { |
176
|
|
|
$sd_problems = new SdProblem; |
177
|
|
|
$assetid = $request->input('asset'); |
178
|
|
|
$attachments = $request->file('attachment'); |
179
|
|
|
$sd_problems->fill($request->input())->save(); |
180
|
|
|
\App\Itil\Controllers\UtilityController::attachment($sd_problems->id, 'sd_problem', $attachments); |
|
|
|
|
181
|
|
|
if (isAsset() == true) { |
|
|
|
|
182
|
|
|
\App\Itil\Controllers\UtilityController::storeAssetRelation('sd_problem', $sd_problems->id, $assetid); |
|
|
|
|
183
|
|
|
} |
184
|
|
|
return $sd_problems; |
185
|
|
|
} catch (Exception $ex) { |
|
|
|
|
186
|
|
|
dd($ex); |
187
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|
191
|
|
View Code Duplication |
public function update($id, $request) { |
|
|
|
|
192
|
|
|
try { |
193
|
|
|
$sd_problems = new SdProblem; |
194
|
|
|
$sd_problem = $sd_problems->find($id); |
|
|
|
|
195
|
|
|
$assetid = $request->input('asset'); |
196
|
|
|
$attachments = $request->file('attachment'); |
197
|
|
|
$sd_problem->fill($request->input())->save(); |
198
|
|
|
\App\Itil\Controllers\UtilityController::attachment($sd_problem->id, 'sd_problem', $attachments); |
199
|
|
|
if (isAsset() == true) { |
|
|
|
|
200
|
|
|
\App\Itil\Controllers\UtilityController::storeAssetRelation('sd_problem', $sd_problems->id, $assetid); |
|
|
|
|
201
|
|
|
} |
202
|
|
|
return "success"; |
203
|
|
|
} catch (Exception $ex) { |
|
|
|
|
204
|
|
|
dd($ex); |
205
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
209
|
|
View Code Duplication |
public function getAttachableProblem() { |
|
|
|
|
210
|
|
|
$model = new SdProblem(); |
211
|
|
|
$select = ['id', 'subject']; |
212
|
|
|
$problems = \App\Itil\Controllers\UtilityController::getModelWithSelect($model, $select); |
213
|
|
|
return \Datatable::Collection($problems->get()) |
214
|
|
|
->addColumn('id', function($model) { |
215
|
|
|
return \Form::radio('problemid', $model->id); |
216
|
|
|
}) |
217
|
|
|
->addColumn('subject', function($model) { |
218
|
|
|
$subject = str_limit($model->subject, 20, '...'); |
219
|
|
|
return "<p title=$model->subject>$subject<p>"; |
220
|
|
|
}) |
221
|
|
|
->addColumn('status', function($model) { |
222
|
|
|
$status = ""; |
223
|
|
|
$statusid = $model->status_type_id; |
224
|
|
|
$ticket_statuses = new \App\Model\helpdesk\Ticket\Ticket_Status(); |
225
|
|
|
$ticket_status = $ticket_statuses->find($statusid); |
|
|
|
|
226
|
|
|
if ($ticket_status) { |
227
|
|
|
$status = $ticket_status->name; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
return $status; |
231
|
|
|
}) |
232
|
|
|
->searchColumns('subject') |
233
|
|
|
->orderColumns('subject') |
234
|
|
|
->make(); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function timelineMarble($problem, $ticketid) { |
238
|
|
|
if ($problem) { |
239
|
|
|
echo $this->marble($problem, $ticketid); |
240
|
|
|
} |
241
|
|
|
echo ""; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
View Code Duplication |
public function marble($problem, $ticketid) { |
|
|
|
|
245
|
|
|
$subject = $problem->subject; |
246
|
|
|
$content = $problem->description; |
247
|
|
|
$problemid = $problem->id; |
248
|
|
|
return $this->marbleHtml($ticketid, $problemid, $subject, $content); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
View Code Duplication |
public function marbleHtml($ticketid, $problemid, $subject, $content) { |
|
|
|
|
252
|
|
|
$subject_trim = str_limit($subject, 20); |
253
|
|
|
$content_trim = str_limit($content, 20); |
254
|
|
|
$url = url('service-desk/problem/detach/' . $ticketid . '/' . $problemid); |
255
|
|
|
$detach_popup = \App\Itil\Controllers\UtilityController::deletePopUp($problemid, $url, "Delete", " ", "Delete", true); |
256
|
|
|
return "<div class='box box-primary'>" |
257
|
|
|
. "<div class='box-header'>" |
258
|
|
|
. "<h3 class='box-title'>Associated Problems</h3>" |
259
|
|
|
. "</div>" |
260
|
|
|
. "<div class='box-body row'>" |
261
|
|
|
. "<div class='col-md-12'>" |
262
|
|
|
. "<table class='table'>" |
263
|
|
|
. "<tr>" |
264
|
|
|
. "<th>" . ucfirst($subject_trim) . "</th>" |
265
|
|
|
. "<th>" . ucfirst($content_trim) . "</th>" |
266
|
|
|
. "<th>" . $detach_popup |
267
|
|
|
. " | <a href=" . url('service-desk/problem/' . $problemid . '/show') . ">View</a></th>" |
268
|
|
|
. "</table>" |
269
|
|
|
. "</div>" |
270
|
|
|
. "</div>" |
271
|
|
|
. "</div>"; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
public function detach($ticketid, $problemid) { |
275
|
|
|
$relation = \App\Itil\Controllers\UtilityController::getRelationOfTicketByTable($ticketid, 'sd_problem'); |
276
|
|
|
if (isAsset() == true) { |
|
|
|
|
277
|
|
|
\App\Itil\Controllers\UtilityController::detachAsset('sd_problem', $problemid); |
278
|
|
|
} |
279
|
|
|
if ($relation) { |
280
|
|
|
$relation->delete(); |
281
|
|
|
} |
282
|
|
|
return redirect()->back()->with('success', 'Detached successfully'); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
View Code Duplication |
public function show($id) { |
|
|
|
|
286
|
|
|
try { |
287
|
|
|
$problems = new SdProblem(); |
288
|
|
|
$problem = $problems->find($id); |
|
|
|
|
289
|
|
|
if ($problem) { |
290
|
|
|
|
291
|
|
|
return view('itil::problem.show', compact('problem')); |
292
|
|
|
} else { |
293
|
|
|
throw new \Exception('Sorry we can not find your request'); |
294
|
|
|
} |
295
|
|
|
} catch (\Exception $ex) { |
296
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
public function close($id) { |
301
|
|
|
try { |
302
|
|
|
$problems = new SdProblem(); |
303
|
|
|
$problem = $problems->find($id); |
|
|
|
|
304
|
|
|
if ($problem) { |
305
|
|
|
$problem->status_type_id = 3; |
306
|
|
|
$problem->save(); |
307
|
|
|
return redirect()->back()->with('success', 'Updated'); |
308
|
|
|
} else { |
309
|
|
|
throw new \Exception('Sorry we can not find your request'); |
310
|
|
|
} |
311
|
|
|
} catch (\Exception $ex) { |
312
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
|
316
|
|
View Code Duplication |
public function getChanges() { |
|
|
|
|
317
|
|
|
$change = new \App\Itil\Models\Changes\SdChanges(); |
318
|
|
|
$changes = $change->select('id', 'subject')->get(); |
|
|
|
|
319
|
|
|
return \Datatable::Collection($changes) |
320
|
|
|
->addColumn('id', function($model) { |
321
|
|
|
return "<input type='radio' name='change' value='" . $model->id . "'>"; |
322
|
|
|
}) |
323
|
|
|
->addColumn('subject', function($model) { |
324
|
|
|
return str_limit($model->subject, 20); |
325
|
|
|
}) |
326
|
|
|
->orderColumns('subject') |
327
|
|
|
->searchColumns('subject') |
328
|
|
|
->make(); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
View Code Duplication |
public function attachNewChange($id, CreateChangesRequest $request) { |
|
|
|
|
332
|
|
|
try { |
333
|
|
|
$change_controller = new ChangesController(); |
334
|
|
|
$change = $change_controller->changeshandleCreate($request, true); |
335
|
|
|
|
336
|
|
|
$this->changeAttach($id, $change->id); |
337
|
|
|
if ($change) { |
338
|
|
|
return redirect()->back()->with('success', 'Updated'); |
339
|
|
|
} |
340
|
|
|
} catch (\Exception $ex) { |
341
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
public function attachExistingChange($id, Request $request) { |
346
|
|
|
try { |
347
|
|
|
$changeid = $request->input('change'); |
348
|
|
|
$store = $this->changeAttach($id, $changeid); |
349
|
|
|
if ($store) { |
350
|
|
|
return redirect()->back()->with('success', 'Updated'); |
351
|
|
|
} |
352
|
|
|
} catch (\Exception $ex) { |
353
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
public function changeAttach($problemid, $changeid) { |
358
|
|
|
$relation = new \App\Itil\Models\Problem\ProblemChangeRelation(); |
359
|
|
|
return $relation->create([ |
360
|
|
|
'problem_id' => $problemid, |
361
|
|
|
'change_id' => $changeid, |
362
|
|
|
]); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
View Code Duplication |
public function detachChange($problemid) { |
|
|
|
|
366
|
|
|
try { |
367
|
|
|
$relations = new \App\Itil\Models\Problem\ProblemChangeRelation(); |
368
|
|
|
$relation = $relations->where('problem_id', $problemid)->first(); |
|
|
|
|
369
|
|
|
if ($relation) { |
370
|
|
|
$relation->delete(); |
371
|
|
|
} |
372
|
|
|
return redirect()->back()->with('success', 'Updated'); |
373
|
|
|
} catch (\Exception $ex) { |
374
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
375
|
|
|
} |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
} |
379
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.