FIX Use PROV as temporary ID for leaves

This commit is contained in:
Laurent Destailleur 2019-11-24 18:25:55 +01:00
parent bc5270ce76
commit 19fb6bfd17
2 changed files with 75 additions and 59 deletions

View File

@ -976,8 +976,6 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{
if ($this->id)
{ {
$this->ref = $initialref; $this->ref = $initialref;
@ -1052,7 +1050,6 @@ class Commande extends CommonOrder
} }
else dol_print_error($resqlcontact); else dol_print_error($resqlcontact);
} }
}
if (!$error) if (!$error)
{ {

View File

@ -304,7 +304,24 @@ class Holiday extends CommonObject
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
if (!$notrigger) if ($this->id)
{
// update ref
$initialref = '(PROV'.$this->id.')';
if (!empty($this->ref)) $initialref = $this->ref;
$sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
$this->ref = $initialref;
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0) $error++;
}
if (!$error && !$notrigger)
{ {
// Call trigger // Call trigger
$result = $this->call_trigger('HOLIDAY_CREATE', $user); $result = $this->call_trigger('HOLIDAY_CREATE', $user);
@ -312,6 +329,8 @@ class Holiday extends CommonObject
// End call triggers // End call triggers
} }
} }
}
}
// Commit or rollback // Commit or rollback
if ($error) if ($error)