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 | |
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')
-rw-r--r-- | generator/after-bake/src/Controller/ServicesController.php | 34 | ||||
-rw-r--r-- | generator/after-bake/src/Template/Adherents/view.ctp | 4 |
2 files changed, 36 insertions, 2 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']); diff --git a/generator/after-bake/src/Template/Adherents/view.ctp b/generator/after-bake/src/Template/Adherents/view.ctp index d986c5b..2edf6b9 100644 --- a/generator/after-bake/src/Template/Adherents/view.ctp +++ b/generator/after-bake/src/Template/Adherents/view.ctp @@ -213,8 +213,8 @@ break; case 5: /* Suspendu */ echo $this->Form->postLink( - __('Unsuspend'), ['controller' => 'Services', 'action' => 'unsuspend', $services->id], - ['confirm' => __('Are you sure you want to suspend # {0}?', $services->id)] + __('Activate'), ['controller' => 'Services', 'action' => 'activate', $services->id], + ['confirm' => __('Are you sure you want to activate # {0}?', $services->id)] ) . "\n"; echo $this->Form->postLink( __('Terminate'), ['controller' => 'Services', 'action' => 'terminate', $services->id], |