Commit 2309895e authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Ajout : transaction lors de la sauvegarde du type d'annexe

parent 23ea76c0
...@@ -203,6 +203,9 @@ class TypagesController extends AppController { ...@@ -203,6 +203,9 @@ class TypagesController extends AppController {
$this->redirect($this->Referers->get()); $this->redirect($this->Referers->get());
} }
$success = true;
$this->Typage->begin();
if ($this->request->params['action'] === 'add') { if ($this->request->params['action'] === 'add') {
$data = $this->request->data; $data = $this->request->data;
$data['Typage']['createdbyorganisation'] = $this->Session->read('Organisation.id'); $data['Typage']['createdbyorganisation'] = $this->Session->read('Organisation.id');
...@@ -213,10 +216,16 @@ class TypagesController extends AppController { ...@@ -213,10 +216,16 @@ class TypagesController extends AppController {
} }
$this->Typage->create($data); $this->Typage->create($data);
if (false !== $this->Typage->save(null, ['atomic' => true])) { $success = $success && false !== $this->Typage->save(null, ['atomic' => false]);
if ($success == true) {
$this->Typage->commit();
$this->Session->setFlash(__d('typage', 'typage.flashsuccesSaveTypage'), 'flashsuccess'); $this->Session->setFlash(__d('typage', 'typage.flashsuccesSaveTypage'), 'flashsuccess');
$this->redirect($this->Referers->get()); $this->redirect($this->Referers->get());
} else { } else {
$this->Typage->rollback();
$this->Session->setFlash(__d('typage', 'typage.flasherrorSaveTypage'), 'flasherror'); $this->Session->setFlash(__d('typage', 'typage.flasherrorSaveTypage'), 'flasherror');
} }
} elseif ($this->request->params['action'] === 'edit') { } elseif ($this->request->params['action'] === 'edit') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment