summaryrefslogtreecommitdiff
path: root/generator/after-bake/src/Controller/ServicesController.php
diff options
context:
space:
mode:
Diffstat (limited to 'generator/after-bake/src/Controller/ServicesController.php')
-rw-r--r--generator/after-bake/src/Controller/ServicesController.php34
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']);