diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 4f43a87f8e7daa58fe3e4fae24d93aa3061663f0..6ab43a277c05db83f0f2712c2fedb0582bd630d2 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -344,8 +344,7 @@ class RemiseCheque extends CommonObject $this->errno = 0; $this->db->begin(); - - //$numref=$this->getNextNumber(); + $numref = $this->getNextNumRef(); if ($this->errno == 0 && $numref) @@ -394,46 +393,6 @@ class RemiseCheque extends CommonObject } } - - /** - * Old module for cheque receipt numbering - * - * @return int Next ref of cheque - */ - function getNextNumber() - { - global $conf; - - $num=0; - - // We use +0 to convert varchar to ref for mysql, use ::integer for postgres. - // We must found a generic solution (Use a $db->toint function ?) - $sql = "SELECT "; - if ($this->db->type == 'pgsql') $sql.="MAX(ref::integer)"; - else $sql.="MAX(ref+0)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND ref not like '(%'"; - - dol_syslog("Remisecheque::getNextNumber", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $num = $row[0]; - $this->db->free($resql); - } - else - { - $this->errno = -1034; - dol_syslog("Remisecheque::Validate Erreur SELECT ($this->errno)", LOG_ERR); - } - - $num++; - - return $num; - } - /** * Return next reference of cheque receipts not already used (or last reference) * according to numbering module defined into constant FACTURE_ADDON