diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6068e6ec0c1..ebc4a29793c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -357,25 +357,25 @@ class BookKeeping extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->doc_date)."'"; $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); - $sql .= ",'".$this->db->escape($this->doc_type)."'"; - $sql .= ",'".$this->db->escape($this->doc_ref)."'"; - $sql .= ",".$this->fk_doc; - $sql .= ",".$this->fk_docdet; - $sql .= ",'".$this->db->escape($this->thirdparty_code)."'"; - $sql .= ",'".$this->db->escape($this->subledger_account)."'"; - $sql .= ",'".$this->db->escape($this->subledger_label)."'"; - $sql .= ",'".$this->db->escape($this->numero_compte)."'"; - $sql .= ",'".$this->db->escape($this->label_compte)."'"; - $sql .= ",'".$this->db->escape($this->label_operation)."'"; - $sql .= ",".$this->debit; - $sql .= ",".$this->credit; - $sql .= ",".$this->montant; - $sql .= ",'".$this->db->escape($this->sens)."'"; - $sql .= ",'".$this->db->escape($this->fk_user_author)."'"; - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",'".$this->db->escape($this->code_journal)."'"; - $sql .= ",'".$this->db->escape($this->journal_label)."'"; - $sql .= ",".$this->db->escape($this->piece_num); + $sql .= ", '".$this->db->escape($this->doc_type)."'"; + $sql .= ", '".$this->db->escape($this->doc_ref)."'"; + $sql .= ", ".$this->fk_doc; + $sql .= ", ".$this->fk_docdet; + $sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL"); + $sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL"); + $sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->numero_compte)."'"; + $sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->label_operation)."'"; + $sql .= ", ".$this->debit; + $sql .= ", ".$this->credit; + $sql .= ", ".$this->montant; + $sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->fk_user_author)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", '".$this->db->escape($this->code_journal)."'"; + $sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL"); + $sql .= ", ".$this->db->escape($this->piece_num); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")";