|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
namespace App\Controller\Admin; |
|
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
use App\Controller\AppController; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Tickettypes Controller |
|
8
|
|
|
* |
|
9
|
|
|
* @property \App\Model\Table\TickettypesTable $Tickettypes |
|
10
|
|
|
*/ |
|
|
|
|
|
|
11
|
|
|
class TickettypesController extends AppController |
|
12
|
|
|
{ |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Index method |
|
16
|
|
|
* |
|
17
|
|
|
* @return \Cake\Network\Response|null |
|
|
|
|
|
|
18
|
|
|
*/ |
|
19
|
1 |
|
public function index() |
|
20
|
|
|
{ |
|
|
|
|
|
|
21
|
1 |
|
$tickettypes = $this->paginate($this->Tickettypes); |
|
22
|
|
|
|
|
23
|
1 |
|
$title = "Type of ticket"; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
1 |
|
$this->set(compact(['tickettypes', 'title'])); |
|
26
|
1 |
|
$this->set('_serialize', ['tickettypes']); |
|
27
|
1 |
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* View method |
|
31
|
|
|
* |
|
32
|
|
|
* @param string|null $id Tickettype id. |
|
|
|
|
|
|
33
|
|
|
* @return \Cake\Network\Response|null |
|
|
|
|
|
|
34
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
|
|
|
|
|
35
|
|
|
*/ |
|
36
|
|
|
public function view($id = null) |
|
37
|
|
|
{ |
|
|
|
|
|
|
38
|
|
|
$tickettype = $this->Tickettypes->get($id, [ |
|
39
|
|
|
'contain' => [] |
|
|
|
|
|
|
40
|
|
|
]); |
|
41
|
|
|
|
|
42
|
|
|
$this->set('tickettype', $tickettype); |
|
43
|
|
|
$this->set('_serialize', ['tickettype']); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Add method |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise. |
|
50
|
|
|
*/ |
|
51
|
|
|
public function add() |
|
52
|
|
|
{ |
|
|
|
|
|
|
53
|
|
|
$tickettype = $this->Tickettypes->newEmptyEntity(); |
|
54
|
|
|
if ($this->request->is('post')) { |
|
55
|
|
|
$tickettype = $this->Tickettypes->patchEntity($tickettype, $this->getRequest()->getData()); |
|
56
|
|
|
if ($this->Tickettypes->save($tickettype)) { |
|
57
|
|
|
$this->Flash->success(__('The tickettype has been saved.')); |
|
58
|
|
|
|
|
59
|
|
|
return $this->redirect(['prefix'=>'Admin', 'controller'=>'Tickettypes', 'action' => 'index']); |
|
|
|
|
|
|
60
|
|
|
} |
|
|
|
|
|
|
61
|
|
|
$this->Flash->error(__('The tickettype could not be saved. Please, try again.')); |
|
62
|
|
|
} |
|
|
|
|
|
|
63
|
|
|
$this->set(compact('tickettype')); |
|
64
|
|
|
$this->set('_serialize', ['tickettype']); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Edit method |
|
69
|
|
|
* |
|
70
|
|
|
* @param string|null $id Tickettype id. |
|
|
|
|
|
|
71
|
|
|
* @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise. |
|
|
|
|
|
|
72
|
|
|
* @throws \Cake\Network\Exception\NotFoundException When record not found. |
|
|
|
|
|
|
73
|
|
|
*/ |
|
74
|
|
|
public function edit($id = null) |
|
75
|
|
|
{ |
|
|
|
|
|
|
76
|
|
|
$tickettype = $this->Tickettypes->get($id, [ |
|
77
|
|
|
'contain' => [] |
|
|
|
|
|
|
78
|
|
|
]); |
|
79
|
|
|
if ($this->request->is(['patch', 'post', 'put'])) { |
|
80
|
|
|
$tickettype = $this->Tickettypes->patchEntity($tickettype, $this->request->data); |
|
81
|
|
|
if ($this->Tickettypes->save($tickettype)) { |
|
82
|
|
|
$this->Flash->success(__('The tickettype has been saved.')); |
|
83
|
|
|
|
|
84
|
|
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickettypes', 'action' => 'index']); |
|
|
|
|
|
|
85
|
|
|
} |
|
|
|
|
|
|
86
|
|
|
$this->Flash->error(__('The tickettype could not be saved. Please, try again.')); |
|
87
|
|
|
} |
|
|
|
|
|
|
88
|
|
|
$this->set(compact('tickettype')); |
|
89
|
|
|
$this->set('_serialize', ['tickettype']); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Delete method |
|
94
|
|
|
* |
|
95
|
|
|
* @param string|null $id Tickettype id. |
|
|
|
|
|
|
96
|
|
|
* @return \Cake\Network\Response|null Redirects to index. |
|
|
|
|
|
|
97
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
|
|
|
|
|
98
|
|
|
*/ |
|
99
|
1 |
|
public function delete($id = null) |
|
100
|
|
|
{ |
|
|
|
|
|
|
101
|
1 |
|
$this->request->allowMethod(['post', 'delete']); |
|
102
|
1 |
|
$tickettype = $this->Tickettypes->get($id); |
|
103
|
1 |
|
if ($this->Tickettypes->delete($tickettype)) { |
|
104
|
1 |
|
$this->Flash->success(__('The tickettype has been deleted.')); |
|
105
|
|
|
} else { |
|
|
|
|
|
|
106
|
|
|
$this->Flash->error(__('The tickettype could not be deleted. Please, try again.')); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
1 |
|
return $this->redirect(['prefix'=>false, 'controller'=>'Tickettypes', 'action' => 'index']); |
|
|
|
|
|
|
110
|
|
|
} |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|