diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 8ae2406a832..90dd77d6cd5 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -235,6 +235,9 @@ if (empty($reshook)) { // Reopen if ($action == 'reopen' && $permissiontoadd) { // Test on permissions not required here $result = $object->reOpen(); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Confirm back to draft status diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index a6cdddd9c0e..0c837a50af0 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -2191,7 +2191,7 @@ class Reception extends CommonObject */ public function reOpen() { - global $conf, $langs, $user; + global $langs, $user; $error = 0; @@ -2201,6 +2201,8 @@ class Reception extends CommonObject $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0'; $resql = $this->db->query($sql); + $rollbackStatus = $this->status; + $rollbackBilled = $this->billed; if ($resql) { $this->statut = self::STATUS_VALIDATED; $this->status = self::STATUS_VALIDATED; @@ -2304,6 +2306,8 @@ class Reception extends CommonObject $this->db->commit(); return 1; } else { + $this->statut = $this->status = $rollbackStatus; + $this->billed = $rollbackBilled; $this->db->rollback(); return -1; }