diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-03-26 23:48:08 +0100 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-03-26 23:48:08 +0100 |
commit | 335aa289498cdf80f7b05da78ed24c1ade2c870f (patch) | |
tree | d9d9004b2b14435668734a855106000b64c665c2 /generator/after-bake/src/Controller | |
parent | ec4787db8a89bac903ab3f4ef2565cf78ceb384b (diff) | |
download | chd_gestion-335aa289498cdf80f7b05da78ed24c1ade2c870f.zip chd_gestion-335aa289498cdf80f7b05da78ed24c1ade2c870f.tar.gz chd_gestion-335aa289498cdf80f7b05da78ed24c1ade2c870f.tar.bz2 |
Services/Suspend : implenté.
Diffstat (limited to 'generator/after-bake/src/Controller')
-rw-r--r-- | generator/after-bake/src/Controller/ServicesController.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/generator/after-bake/src/Controller/ServicesController.php b/generator/after-bake/src/Controller/ServicesController.php index 0371623..57f9e5d 100644 --- a/generator/after-bake/src/Controller/ServicesController.php +++ b/generator/after-bake/src/Controller/ServicesController.php @@ -202,6 +202,18 @@ class ServicesController extends AppController } else { $this->Flash->error(__('Can\'t find a free IP public address. Please make sure that equipements are associated to the service.')); } + + } else if ($service->service_statut_id === 5 /* Suspendu */) { + $patch = array( + 'service_statut_id' => 4, /* Actif CHD */ + ); + $service = $this->Services->patchEntity($service, $patch); + if ($this->Services->save($service)) { + $this->Flash->success(__('The service has been saved.')); + } else { + $this->Flash->error(__('The service could not be saved. Please, try again.')); + } + } else { $this->Flash->error(__('Can\'t activate the service. Bad service state.')); } @@ -257,6 +269,28 @@ class ServicesController extends AppController $this->set('_serialize', ['service', 'new_service']); } + public function suspend($id = null) + { + $this->request->allowMethod(['post']); + $service = $this->Services->get($id); + if ( $service ) { + if ( $service->service_statut_id === 4 /* Actif CHD */ ) { + $patch = array( + 'service_statut_id' => 5, /* Suspendu */ + ); + $service = $this->Services->patchEntity($service, $patch); + if ($this->Services->save($service)) { + $this->Flash->success(__('The service has been saved.')); + } else { + $this->Flash->error(__('The service could not be saved. Please, try again.')); + } + } else { + $this->Flash->error(__('Can\'t terminate the service. Bad service state.')); + } + return $this->redirect(['controller' => 'Adherents', 'action' => 'view', $service->adherent_id]); + } + } + public function terminate($id = null) { $this->request->allowMethod(['post']); |