diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 0a33c822392..c5c6571c351 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -438,7 +438,6 @@ else if ($action == 'setstatut' && $user->rights->propale->cloturer)
{
$mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'
';
$action='statut';
- $action='statut';
}
else
{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 497607988e8..ef21b9a7aa0 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1815,32 +1815,38 @@ abstract class CommonObject
}
/**
- * Set statut of an object
+ * Set status of an object
*
- * @param int $statut Statut to set
+ * @param int $status Status to set
* @param int $elementId Id of element to force (use this->id by default)
* @param string $elementType Type of element to force (use ->this->element by default)
* @return int <0 if KO, >0 if OK
*/
- function setStatut($statut,$elementId='',$elementType='')
+ function setStatut($status,$elementId='',$elementType='')
{
$elementId = (!empty($elementId)?$elementId:$this->id);
$elementTable = (!empty($elementType)?$elementType:$this->table_element);
+
+ $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
- $sql.= " SET fk_statut = ".$statut;
+ $sql.= " SET fk_statut = ".$status;
$sql.= " WHERE rowid=".$elementId;
dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->error=$this->db->lasterror();
- dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
- return -1;
+ if ($this->db->query($sql))
+ {
+ $this->db->commit();
+ $this->statut = $status;
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -1;
}
-
- return 1;
}