diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c59e20c8035..f0a4b6f1f79 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -542,12 +542,19 @@ if (empty($reshook)) } // Classify billed - else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { - $object->cloture($user, 4, ''); + else if ($action == 'classifybilled' && $user->rights->propal->cloturer) + { + $result=$object->cloture($user, 4, ''); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } // Reopen proposal - else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) + { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { $object->reopen($user, 1); @@ -555,33 +562,54 @@ if (empty($reshook)) } // Close proposal - else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) + { if (! GETPOST('statut')) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); $action = 'statut'; } else { // prevent browser refresh from closing proposal several times - if ($object->statut == Propal::STATUS_VALIDATED) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); + if ($object->statut == Propal::STATUS_VALIDATED) + { + $result=$object->cloture($user, GETPOST('statut'), GETPOST('note')); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } } } // Classify billed - else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { - $object->cloture($user, 4, ''); + else if ($action == 'classifybilled' && $user->rights->propal->cloturer) + { + $result=$object->cloture($user, 4, ''); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } // Reopen proposal - else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) + { // prevent browser refresh from reopening proposal several times - if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { - $object->reopen($user, 1); + if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) + { + $result=$object->reopen($user, 1); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } } // Close proposal - else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) + { if (! GETPOST('statut')) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); $action = 'statut'; @@ -2203,7 +2231,8 @@ if ($action == 'create') } // Create an invoice and classify billed - if ($object->statut == Propal::STATUS_SIGNED) { + if ($object->statut == Propal::STATUS_SIGNED) + { if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { print '
' . $langs->trans("AddBill") . '
'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6ff361f9205..d0102eb6d43 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1854,7 +1854,6 @@ class Propal extends CommonObject { global $langs,$conf; - $this->statut = $statut; $error=0; $now=dol_now(); @@ -1882,7 +1881,7 @@ class Propal extends CommonObject if ($result < 0) { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -2; } @@ -1913,7 +1912,9 @@ class Propal extends CommonObject if ( ! $error ) { - $this->db->commit(); + $this->statut = $statut; + + $this->db->commit(); return 1; } else @@ -1924,7 +1925,7 @@ class Propal extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; }