@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | $this->addBehavior('Timestamp'); |
| 40 | 40 | |
| 41 | - $this->hasMany('Tickets', [ |
|
| 41 | + $this->hasMany('Tickets', [ |
|
| 42 | 42 | 'foreignKey' => 'tickettype_id' |
| 43 | 43 | ]); |
| 44 | 44 | |
@@ -43,10 +43,10 @@ |
||
| 43 | 43 | $this->hasMany('Operations', [ |
| 44 | 44 | 'foreignKey' => 'ticket_id' |
| 45 | 45 | ]); |
| 46 | - $this->belongsTo('Tickettypes', [ |
|
| 46 | + $this->belongsTo('Tickettypes', [ |
|
| 47 | 47 | 'foreignKey' => 'tickettype_id' |
| 48 | 48 | ]); |
| 49 | - $this->belongsTo('Ticketstatuses', [ |
|
| 49 | + $this->belongsTo('Ticketstatuses', [ |
|
| 50 | 50 | 'foreignKey' => 'ticketstatus_id' |
| 51 | 51 | ]); |
| 52 | 52 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | 'password' |
| 40 | 40 | ]; |
| 41 | 41 | |
| 42 | - protected function _setPassword($password) |
|
| 42 | + protected function _setPassword($password) |
|
| 43 | 43 | { |
| 44 | 44 | return (new DefaultPasswordHasher)->hash($password); |
| 45 | 45 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | // Admin account |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - if(!Configure::read('Security.salt')) |
|
| 30 | + if (!Configure::read('Security.salt')) |
|
| 31 | 31 | { |
| 32 | 32 | $salt = $this->in('Salt:'); |
| 33 | 33 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | Configure::write('Datasources.default.quoteIdentifiers', false); |
| 49 | 49 | Configure::write('Datasources.default.url', env('DATABASE_URL', null)); |
| 50 | 50 | $file = new File('config/app_local.php', false); |
| 51 | - if(!$file->exists()) { |
|
| 52 | - if($ris = Configure::dump('app_local', 'default')) { |
|
| 51 | + if (!$file->exists()) { |
|
| 52 | + if ($ris = Configure::dump('app_local', 'default')) { |
|
| 53 | 53 | $this->out("Wrote config file app_local.php"); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | 'limit' => 11, |
| 19 | 19 | 'null' => false, |
| 20 | 20 | ]); |
| 21 | - $table->addColumn('name', 'string', [ |
|
| 21 | + $table->addColumn('name', 'string', [ |
|
| 22 | 22 | 'default' => null, |
| 23 | 23 | 'limit' => 255, |
| 24 | 24 | 'null' => false, |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | $tickettypes = $this->paginate($this->Tickettypes); |
| 22 | 22 | |
| 23 | - $title = "Type of ticket"; |
|
| 23 | + $title = "Type of ticket"; |
|
| 24 | 24 | |
| 25 | 25 | $this->set(compact(['tickettypes', 'title'])); |
| 26 | 26 | $this->set('_serialize', ['tickettypes']); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 22 | + /** |
|
| 23 | 23 | * Index method |
| 24 | 24 | * |
| 25 | 25 | * @return \Cake\Network\Response|null |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | return $this->redirect(['prefix'=>'admin', 'controller'=>'Users', 'action' => 'index']); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function login() { |
|
| 119 | - if ($this->request->is('post')) { |
|
| 118 | + public function login() { |
|
| 119 | + if ($this->request->is('post')) { |
|
| 120 | 120 | $user = $this->Auth->identify(); |
| 121 | - $this->set('lu', $user); |
|
| 121 | + $this->set('lu', $user); |
|
| 122 | 122 | if ($user) { |
| 123 | 123 | $this->Auth->setUser($user); |
| 124 | 124 | return $this->redirect($this->Auth->redirectUrl()); |
| 125 | 125 | } |
| 126 | 126 | $this->Flash->error(__('Invalid username or password, try again')); |
| 127 | 127 | } |
| 128 | - } |
|
| 129 | - public function logout() |
|
| 130 | - { |
|
| 131 | - return $this->redirect($this->Auth->logout()); |
|
| 132 | - } |
|
| 128 | + } |
|
| 129 | + public function logout() |
|
| 130 | + { |
|
| 131 | + return $this->redirect($this->Auth->logout()); |
|
| 132 | + } |
|
| 133 | 133 | } |
@@ -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 | /** |