|
1
|
|
|
<?php |
|
2
|
|
|
namespace App\Controller; |
|
3
|
|
|
|
|
4
|
|
|
use App\Controller\AppController; |
|
5
|
|
|
use Cake\I18n\Time; |
|
6
|
|
|
use Cake\I18n\I18n; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Tickets Controller |
|
10
|
|
|
* |
|
11
|
|
|
* @property \App\Model\Table\TicketsTable $Tickets |
|
12
|
|
|
*/ |
|
13
|
|
|
class TicketsController extends AppController |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Index method |
|
18
|
|
|
* |
|
19
|
|
|
* @return \Cake\Network\Response|null |
|
20
|
|
|
*/ |
|
21
|
1 |
|
public function index() |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
1 |
|
$tickets = $this->paginate($this->Tickets->find('all', ['contain'=>['Tickettypes', 'Ticketstatuses']])); |
|
25
|
|
|
|
|
26
|
1 |
|
$this->set(compact('tickets')); |
|
27
|
1 |
|
$this->set('_serialize', ['tickets']); |
|
28
|
1 |
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* View method |
|
32
|
|
|
* |
|
33
|
|
|
* @param string|null $id Ticket id. |
|
34
|
|
|
* @return \Cake\Network\Response|null |
|
35
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function view($id = null) |
|
38
|
|
|
{ |
|
39
|
1 |
|
$ticket = $this->Tickets->get($id, [ |
|
40
|
1 |
|
'contain' => ['Operations', 'Tickettypes'] |
|
41
|
|
|
]); |
|
42
|
|
|
|
|
43
|
1 |
|
$this->set('ticket', $ticket); |
|
44
|
1 |
|
$this->set('_serialize', ['ticket']); |
|
45
|
1 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Add method |
|
49
|
|
|
* |
|
50
|
|
|
* @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise. |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function add() |
|
53
|
|
|
{ |
|
54
|
1 |
|
$ticket = $this->Tickets->newEntity(); |
|
55
|
1 |
|
if ($this->request->is('post')) { |
|
56
|
1 |
|
$ticket = $this->Tickets->patchEntity($ticket, $this->request->data); |
|
|
|
|
|
|
57
|
1 |
|
if ($this->Tickets->save($ticket)) { |
|
58
|
1 |
|
$this->Flash->success(__('The ticket has been saved.')); |
|
59
|
|
|
|
|
60
|
1 |
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'index']); |
|
61
|
|
|
} |
|
62
|
|
|
$this->Flash->error(__('The ticket could not be saved. Please, try again.')); |
|
63
|
|
|
} |
|
64
|
1 |
|
$types = $this->Tickets->Tickettypes->find('list'); |
|
|
|
|
|
|
65
|
1 |
|
$statuses = $this->Tickets->Ticketstatuses->find('list'); |
|
|
|
|
|
|
66
|
1 |
|
$this->set(compact('ticket', 'types', 'statuses')); |
|
67
|
1 |
|
$this->set('_serialize', ['ticket']); |
|
68
|
1 |
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Edit method |
|
72
|
|
|
* |
|
73
|
|
|
* @param string|null $id Ticket id. |
|
74
|
|
|
* @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise. |
|
75
|
|
|
* @throws \Cake\Network\Exception\NotFoundException When record not found. |
|
76
|
|
|
*/ |
|
77
|
1 |
|
public function edit($id = null) |
|
78
|
|
|
{ |
|
79
|
1 |
|
$ticket = $this->Tickets->get($id, [ |
|
80
|
1 |
|
'contain' => ['Tickettypes'] |
|
81
|
|
|
]); |
|
82
|
1 |
|
if ($this->request->is(['patch', 'post', 'put'])) { |
|
83
|
1 |
|
$ticket = $this->Tickets->patchEntity($ticket, $this->request->data); |
|
|
|
|
|
|
84
|
1 |
|
if ($this->Tickets->save($ticket)) { |
|
85
|
1 |
|
$this->Flash->success(__('The ticket has been saved.')); |
|
86
|
|
|
|
|
87
|
1 |
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'index']); |
|
88
|
|
|
} |
|
89
|
|
|
$this->Flash->error(__('The ticket could not be saved. Please, try again.')); |
|
90
|
|
|
} |
|
91
|
1 |
|
$tickettypes = $this->Tickets->Tickettypes->find('list'); |
|
|
|
|
|
|
92
|
1 |
|
$ticketstatuses = $this->Tickets->Ticketstatuses->find('list'); |
|
|
|
|
|
|
93
|
1 |
|
$this->set(compact('ticket', 'tickettypes', 'ticketstatuses')); |
|
94
|
1 |
|
$this->set('_serialize', ['ticket']); |
|
95
|
1 |
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Delete method |
|
99
|
|
|
* |
|
100
|
|
|
* @param string|null $id Ticket id. |
|
101
|
|
|
* @return \Cake\Network\Response|null Redirects to index. |
|
102
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function delete($id = null) |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->request->allowMethod(['post', 'delete']); |
|
107
|
1 |
|
$ticket = $this->Tickets->get($id); |
|
108
|
1 |
|
if ($this->Tickets->delete($ticket)) { |
|
109
|
1 |
|
$this->Flash->success(__('The ticket has been deleted.')); |
|
110
|
|
|
} else { |
|
111
|
|
|
$this->Flash->error(__('The ticket could not be deleted. Please, try again.')); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
1 |
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'index']); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
1 |
|
public function addOperation($id = null) { |
|
118
|
1 |
|
$ticket = $this->Tickets->get($id, [ |
|
|
|
|
|
|
119
|
1 |
|
'contain' => [] |
|
120
|
|
|
]); |
|
121
|
|
|
|
|
122
|
1 |
|
$this->loadModel('Operations'); |
|
123
|
1 |
|
$newOperation = $this->Operations->newEntity(); |
|
|
|
|
|
|
124
|
1 |
|
if ($this->request->is('post')) { |
|
125
|
1 |
|
$datetimeStart = Time::parseDateTime($this->request->data['start']); |
|
|
|
|
|
|
126
|
1 |
|
$datetimeEnd = Time::parseDateTime($this->request->data['end']); |
|
|
|
|
|
|
127
|
1 |
|
$newOperation->ticket_id = $this->request->data['ticket_id']; |
|
|
|
|
|
|
128
|
1 |
|
$newOperation->description = $this->request->data['description']; |
|
|
|
|
|
|
129
|
1 |
|
$newOperation->start = $datetimeStart; |
|
130
|
1 |
|
$newOperation->end = $datetimeEnd; |
|
131
|
1 |
|
if ($this->Operations->save($newOperation)) { |
|
132
|
|
|
$this->Flash->success(__('The new operation has been saved.')); |
|
133
|
|
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'view', $this->request->data['ticket_id']]); |
|
|
|
|
|
|
134
|
|
|
} |
|
135
|
1 |
|
$this->Flash->error(__('The new operation could not be saved. Please, try again.')); |
|
136
|
|
|
} |
|
137
|
1 |
|
$newOperation->ticket_id = $id; |
|
138
|
1 |
|
$this->set('newOperation', $newOperation); |
|
139
|
1 |
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @param null $operation_id |
|
|
|
|
|
|
143
|
|
|
* @return \Cake\Network\Response|null |
|
144
|
|
|
*/ |
|
145
|
1 |
|
public function editOperation($operation_id = null) { |
|
146
|
|
|
|
|
147
|
1 |
|
$this->loadModel('Operations'); |
|
148
|
1 |
|
$operation = $this->Operations->get($operation_id, [ |
|
|
|
|
|
|
149
|
1 |
|
'contain' => ['Tickets'] |
|
150
|
|
|
]); |
|
151
|
1 |
|
if ($this->request->is(['patch', 'post', 'put'])) { |
|
152
|
1 |
|
$this->request->data['start'] = Time::parseDateTime($this->request->data['start']); |
|
|
|
|
|
|
153
|
1 |
|
$this->request->data['end'] = Time::parseDateTime($this->request->data['end']); |
|
|
|
|
|
|
154
|
1 |
|
$operation = $this->Operations->patchEntity($operation, $this->request->data); |
|
|
|
|
|
|
155
|
|
|
|
|
156
|
1 |
|
if ($this->Operations->save($operation)) { |
|
157
|
|
|
$this->Flash->success(__('The operation has been saved.')); |
|
158
|
|
|
|
|
159
|
|
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'view', $this->request->data['ticket_id']]); |
|
|
|
|
|
|
160
|
|
|
} |
|
161
|
1 |
|
$this->Flash->error(__('The operation could not be saved. Please, try again.')); |
|
162
|
|
|
} |
|
163
|
1 |
|
$this->set(compact('operation')); |
|
164
|
1 |
|
$this->set('_serialize', ['operation']); |
|
165
|
1 |
|
} |
|
166
|
|
|
|
|
167
|
|
|
public function viewOperation($id = null) { |
|
168
|
|
|
|
|
169
|
|
|
$this->loadModel('Operations'); |
|
170
|
|
|
$operation = $this->Operations->get($id, [ |
|
|
|
|
|
|
171
|
|
|
'contain' => ['Tickets'] |
|
172
|
|
|
]); |
|
173
|
|
|
|
|
174
|
|
|
$this->set('operation', $operation); |
|
175
|
|
|
$this->set('_serialize', ['operation']); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function deleteOperation($id = null) { |
|
179
|
|
|
|
|
180
|
|
|
$this->loadModel('Operations'); |
|
181
|
|
|
$this->request->allowMethod(['post', 'delete']); |
|
182
|
|
|
$operation = $this->Operations->get($id, [ |
|
|
|
|
|
|
183
|
|
|
'contain' => ['Tickets'] |
|
184
|
|
|
] |
|
185
|
|
|
); |
|
186
|
|
|
if ($this->Operations->delete($operation)) { |
|
187
|
|
|
$this->Flash->success(__('The operation has been deleted.')); |
|
188
|
|
|
} else { |
|
189
|
|
|
$this->Flash->error(__('The operation could not be deleted. Please, try again.')); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'view', $operation->ticket_id]); |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.