@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function index() |
22 | 22 | { |
23 | 23 | |
24 | - $tickets = $this->paginate($this->Tickets->find('all', ['contain'=>['Tickettypes', 'Ticketstatuses']])); |
|
24 | + $tickets = $this->paginate($this->Tickets->find('all', ['contain'=>['Tickettypes', 'Ticketstatuses']])); |
|
25 | 25 | |
26 | 26 | $this->set(compact('tickets')); |
27 | 27 | $this->set('_serialize', ['tickets']); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | } |
62 | 62 | $this->Flash->error(__('The ticket could not be saved. Please, try again.')); |
63 | 63 | } |
64 | - $types = $this->Tickets->Tickettypes->find('list'); |
|
65 | - $statuses = $this->Tickets->Ticketstatuses->find('list'); |
|
64 | + $types = $this->Tickets->Tickettypes->find('list'); |
|
65 | + $statuses = $this->Tickets->Ticketstatuses->find('list'); |
|
66 | 66 | $this->set(compact('ticket', 'types', 'statuses')); |
67 | 67 | $this->set('_serialize', ['ticket']); |
68 | 68 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | } |
89 | 89 | $this->Flash->error(__('The ticket could not be saved. Please, try again.')); |
90 | 90 | } |
91 | - $tickettypes = $this->Tickets->Tickettypes->find('list'); |
|
92 | - $ticketstatuses = $this->Tickets->Ticketstatuses->find('list'); |
|
91 | + $tickettypes = $this->Tickets->Tickettypes->find('list'); |
|
92 | + $ticketstatuses = $this->Tickets->Ticketstatuses->find('list'); |
|
93 | 93 | $this->set(compact('ticket', 'tickettypes', 'ticketstatuses')); |
94 | 94 | $this->set('_serialize', ['ticket']); |
95 | 95 | } |
@@ -114,29 +114,29 @@ discard block |
||
114 | 114 | return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'index']); |
115 | 115 | } |
116 | 116 | |
117 | - public function addOperation($id = null) { |
|
118 | - $ticket = $this->Tickets->get($id, [ |
|
117 | + public function addOperation($id = null) { |
|
118 | + $ticket = $this->Tickets->get($id, [ |
|
119 | 119 | 'contain' => [] |
120 | 120 | ]); |
121 | 121 | |
122 | - $this->loadModel('Operations'); |
|
123 | - $newOperation = $this->Operations->newEntity(); |
|
124 | - if ($this->request->is('post')) { |
|
125 | - $datetimeStart = Time::parseDateTime($this->request->data['start']); |
|
126 | - $datetimeEnd = Time::parseDateTime($this->request->data['end']); |
|
127 | - $newOperation->ticket_id = $this->request->data['ticket_id']; |
|
128 | - $newOperation->description = $this->request->data['description']; |
|
129 | - $newOperation->start = $datetimeStart; |
|
130 | - $newOperation->end = $datetimeEnd; |
|
122 | + $this->loadModel('Operations'); |
|
123 | + $newOperation = $this->Operations->newEntity(); |
|
124 | + if ($this->request->is('post')) { |
|
125 | + $datetimeStart = Time::parseDateTime($this->request->data['start']); |
|
126 | + $datetimeEnd = Time::parseDateTime($this->request->data['end']); |
|
127 | + $newOperation->ticket_id = $this->request->data['ticket_id']; |
|
128 | + $newOperation->description = $this->request->data['description']; |
|
129 | + $newOperation->start = $datetimeStart; |
|
130 | + $newOperation->end = $datetimeEnd; |
|
131 | 131 | if ($this->Operations->save($newOperation)) { |
132 | 132 | $this->Flash->success(__('The new operation has been saved.')); |
133 | 133 | return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'view', $this->request->data['ticket_id']]); |
134 | 134 | } |
135 | 135 | $this->Flash->error(__('The new operation could not be saved. Please, try again.')); |
136 | 136 | } |
137 | - $newOperation->ticket_id = $id; |
|
138 | - $this->set('newOperation', $newOperation); |
|
139 | - } |
|
137 | + $newOperation->ticket_id = $id; |
|
138 | + $this->set('newOperation', $newOperation); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @param null $operation_id |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | 'contain' => ['Tickets'] |
150 | 150 | ]); |
151 | 151 | if ($this->request->is(['patch', 'post', 'put'])) { |
152 | - $this->request->data['start'] = Time::parseDateTime($this->request->data['start']); |
|
153 | - $this->request->data['end'] = Time::parseDateTime($this->request->data['end']); |
|
152 | + $this->request->data['start'] = Time::parseDateTime($this->request->data['start']); |
|
153 | + $this->request->data['end'] = Time::parseDateTime($this->request->data['end']); |
|
154 | 154 | $operation = $this->Operations->patchEntity($operation, $this->request->data); |
155 | 155 | |
156 | 156 | if ($this->Operations->save($operation)) { |
@@ -164,25 +164,25 @@ discard block |
||
164 | 164 | $this->set('_serialize', ['operation']); |
165 | 165 | } |
166 | 166 | |
167 | - public function viewOperation($id = null) { |
|
167 | + public function viewOperation($id = null) { |
|
168 | 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 | - } |
|
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 | 177 | |
178 | - public function deleteOperation($id = null) { |
|
178 | + public function deleteOperation($id = null) { |
|
179 | 179 | |
180 | - $this->loadModel('Operations'); |
|
181 | - $this->request->allowMethod(['post', 'delete']); |
|
180 | + $this->loadModel('Operations'); |
|
181 | + $this->request->allowMethod(['post', 'delete']); |
|
182 | 182 | $operation = $this->Operations->get($id, [ |
183 | - 'contain' => ['Tickets'] |
|
184 | - ] |
|
185 | - ); |
|
183 | + 'contain' => ['Tickets'] |
|
184 | + ] |
|
185 | + ); |
|
186 | 186 | if ($this->Operations->delete($operation)) { |
187 | 187 | $this->Flash->success(__('The operation has been deleted.')); |
188 | 188 | } else { |
@@ -190,5 +190,5 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | return $this->redirect(['prefix'=>false, 'controller'=>'Tickets', 'action' => 'view', $operation->ticket_id]); |
193 | - } |
|
193 | + } |
|
194 | 194 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $this->loadComponent('Flash'); |
46 | 46 | $this->loadComponent('Security'); |
47 | 47 | $this->loadComponent('Csrf'); |
48 | - $this->loadComponent('Auth', [ |
|
49 | - 'authorize' => ['Controller'], |
|
48 | + $this->loadComponent('Auth', [ |
|
49 | + 'authorize' => ['Controller'], |
|
50 | 50 | 'authenticate' => [ |
51 | 51 | 'Form' => [ |
52 | 52 | 'fields' => [ |
@@ -56,30 +56,30 @@ discard block |
||
56 | 56 | ] |
57 | 57 | ], |
58 | 58 | 'loginAction' => [ |
59 | - 'prefix' => 'admin', |
|
59 | + 'prefix' => 'admin', |
|
60 | 60 | 'controller' => 'Users', |
61 | 61 | 'action' => 'login' |
62 | 62 | ], |
63 | - 'logoutAction' => [ |
|
64 | - 'prefix' => 'admin', |
|
63 | + 'logoutAction' => [ |
|
64 | + 'prefix' => 'admin', |
|
65 | 65 | 'controller' => 'Users', |
66 | 66 | 'action' => 'login' |
67 | 67 | ], |
68 | - 'unauthorizedRedirect' => $this->referer() |
|
69 | - ]); |
|
70 | - $this->Auth->allow(); |
|
68 | + 'unauthorizedRedirect' => $this->referer() |
|
69 | + ]); |
|
70 | + $this->Auth->allow(); |
|
71 | 71 | } |
72 | 72 | |
73 | - public function isAuthorized($user) |
|
74 | - { |
|
75 | - // Admin can access every action |
|
76 | - if (isset($user['role']) && $user['role'] === 'admin') { |
|
77 | - return true; |
|
78 | - } |
|
73 | + public function isAuthorized($user) |
|
74 | + { |
|
75 | + // Admin can access every action |
|
76 | + if (isset($user['role']) && $user['role'] === 'admin') { |
|
77 | + return true; |
|
78 | + } |
|
79 | 79 | |
80 | - // Default permit |
|
81 | - return true; |
|
82 | - } |
|
80 | + // Default permit |
|
81 | + return true; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | 85 | /** |