From c2370f352b0cb610b63c85c802c01954e57d534b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 16 May 2014 15:03:28 +0200 Subject: [PATCH 1/7] escape for insert SQL expedition module --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index ba956ccdef4..3f41cdbc07b 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -203,8 +203,8 @@ class Expedition extends CommonObject $sql.= ") VALUES ("; $sql.= "'(PROV)'"; $sql.= ", ".$conf->entity; - $sql.= ", ".($this->ref_customer?"'".$this->ref_customer."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->ref_int."'":"null"); + $sql.= ", ".($this->ref_customer?"'".$this->db->escape($this->ref_customer)."'":"null"); + $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ".$user->id; $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); From 5709179cf03f8a9aa41bacdc247374d431fb24e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 May 2014 00:05:49 +0200 Subject: [PATCH 2/7] Fix: Box was not added on correct side --- htdocs/admin/boxes.php | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 31d313b84e9..5c2c8176842 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -57,7 +57,7 @@ if ($action == 'add') $db->begin(); - // Initialize distinctfkuser with all already existing values of fk_user (user that use a personalized view of boxes for pos) + // Initialize distinct fkuser with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") $distinctfkuser=array(); if (! $error) { @@ -85,14 +85,31 @@ if ($action == 'add') } } + $distinctfkuser['0']='0'; // Add entry for fk_user = 0. We must use string as key and val + foreach($distinctfkuser as $fk_user) { - if (! $error && $fk_user != 0) // We will add fk_user = 0 later. + if (! $error && $fk_user != '') { + $nbboxonleft=$nbboxonright=0; + $sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".GETPOST("pos","alpha")." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; + dol_syslog("boxes.php activate box sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + while($obj = $db->fetch_object($resql)) + { + $boxorder=$obj->box_order; + if (preg_match('/A/',$boxorder)) $nbboxonleft++; + if (preg_match('/B/',$boxorder)) $nbboxonright++; + } + } + else dol_print_error($db); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; $sql.= "box_id, position, box_order, fk_user, entity"; $sql.= ") values ("; - $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', ".$fk_user.", ".$conf->entity; + $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; $sql.= ")"; dol_syslog("boxes.php activate box sql=".$sql); @@ -105,24 +122,6 @@ if ($action == 'add') } } - // If value 0 was not included, we add it. - if (! $error) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; - $sql.= "box_id, position, box_order, fk_user, entity"; - $sql.= ") values ("; - $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', 0, ".$conf->entity; - $sql.= ")"; - - dol_syslog("boxes.php activate box sql=".$sql); - $resql = $db->query($sql); - if (! $resql) - { - $errmesg=$db->lasterror(); - $error++; - } - } - if (! $error) { header("Location: boxes.php"); From 5a5c8585782afb485671e04aed94f164192012ed Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 19 May 2014 16:21:59 +0200 Subject: [PATCH 3/7] =?UTF-8?q?=20[=20bug=20#1399=20]=20[pgsql]=20Silent?= =?UTF-8?q?=20warning=20when=20setting=20a=20propal=20as=20"factur=C3=A9e"?= =?UTF-8?q?=20in=20propal.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 07cc056c322..9fbc33607bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. Fix: TCPDF error file not found in member card generation. Fix: [ bug #1380 ] Customer invoices are not grouped in company results report. Fix: [ bug #1393 ] PHP Warning when creating a supplier invoice. +Fix: [ bug #1399 ] [pgsql] Silent warning when setting a propal as "facturée" in propal.php ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** Fix: Can't add user for a task. diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2d3d5f7557c..244333a9a93 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1702,7 +1702,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture=".$this->db->idate($now).", fk_user_cloture=".$user->id; + $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); From 753ef28168ded4280bdfb5154ca4645e1e36c6aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 May 2014 16:08:05 +0200 Subject: [PATCH 4/7] Fix: Data are clean once registered into dictionnaries. --- htdocs/admin/dict.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 616244767d1..62e78ae95e2 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -522,9 +522,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $result = $db->query($sql); if ($result) // Add is ok { - //$oldid=$id; - //$_POST=array('id'=>$oldid); // Clean $_POST array, we keep only - //$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition + $_POST=array('id'=>$id); // Clean $_POST array, we keep only } else { From 366bd64c4f0c5e006e269e58f39ad701d70c7890 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 May 2014 19:44:53 +0200 Subject: [PATCH 5/7] Fix: When number reach 9999 with default numbering module, next number will be 10000 instead of 0000 and error. --- htdocs/core/db/pgsql.class.php | 3 ++- htdocs/core/lib/functions2.lib.php | 9 ++++++++- .../core/modules/commande/mod_commande_marbre.php | 8 +++++--- .../core/modules/contract/mod_contract_serpis.php | 8 +++++--- .../modules/expedition/mod_expedition_safor.php | 8 +++++--- htdocs/core/modules/facture/mod_facture_mars.php | 11 +++++++---- htdocs/core/modules/facture/mod_facture_terre.php | 15 +++++++++------ htdocs/core/modules/fichinter/mod_pacific.php | 8 +++++--- .../core/modules/livraison/mod_livraison_jade.php | 8 +++++--- .../core/modules/project/mod_project_simple.php | 8 +++++--- .../core/modules/project/task/mod_task_simple.php | 8 +++++--- .../core/modules/propale/mod_propale_marbre.php | 10 ++++++---- .../modules/societe/mod_codeclient_monkey.php | 6 ++++-- .../mod_facture_fournisseur_cactus.php | 11 +++++++---- .../mod_commande_fournisseur_muguet.php | 8 +++++--- 15 files changed, 83 insertions(+), 46 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index cb63f012114..f7c173a401d 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -214,7 +214,8 @@ class DoliDBPgsql extends DoliDB // nuke unsigned $line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line); - + $line=preg_replace('/as signed/i','as integer',$line); + // blob -> text $line=preg_replace('/\w*blob/i','text',$line); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 1a090087bb4..3e6beaa9eeb 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -536,7 +536,7 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti * @param Societe $objsoc The company that own the object we need a counter for * @param string $date Date to use for the {y},{m},{d} tags. * @param string $mode 'next' for next value or 'last' for last value - * @return string New value + * @return string New value (numeric) or error message */ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next') { @@ -798,6 +798,12 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m { $counter++; + // If value for $counter has a length higher than $maskcounter chars + if ($counter >= pow(10, dol_strlen($maskcounter))) + { + $counter='ErrorMaxNumberReachForThisMask'; + } + if (! empty($maskrefclient_maskcounter)) { //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n
"; @@ -839,6 +845,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskrefclient_counter = $maskrefclient_obj->val; } else dol_print_error($db); + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; $maskrefclient_counter++; } diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index b26f265cb25..b68dbc1644c 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -71,7 +71,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -105,7 +105,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -126,7 +126,9 @@ class mod_commande_marbre extends ModeleNumRefCommandes //$date=time(); $date=$object->date; $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index d819fb06af8..78b0a829fa9 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -69,7 +69,7 @@ class mod_contract_serpis extends ModelNumRefContracts $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -102,7 +102,7 @@ class mod_contract_serpis extends ModelNumRefContracts global $db,$conf; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -122,7 +122,9 @@ class mod_contract_serpis extends ModelNumRefContracts $date=$contract->date_contrat; $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 13fe06aded1..e575f5c93af 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -69,7 +69,7 @@ class mod_expedition_safor extends ModelNumRefExpedition $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -102,7 +102,7 @@ class mod_expedition_safor extends ModelNumRefExpedition global $db,$conf; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -122,7 +122,9 @@ class mod_expedition_safor extends ModelNumRefExpedition $date=time(); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 852d499e66e..b75133215c8 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -75,7 +75,7 @@ class mod_facture_mars extends ModeleNumRefFactures $fayymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$this->prefixinvoice."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -138,7 +138,7 @@ class mod_facture_mars extends ModeleNumRefFactures // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -159,7 +159,8 @@ class mod_facture_mars extends ModeleNumRefFactures if ($mode == 'last') { - $num = sprintf("%04s",$max); + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max); $ref=''; $sql = "SELECT facnumber as ref"; @@ -182,7 +183,9 @@ class mod_facture_mars extends ModeleNumRefFactures { $date=$facture->date; // This is invoice date (not creation date) $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 799dc1da204..2d62132e677 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -73,7 +73,7 @@ class mod_facture_terre extends ModeleNumRefFactures $fayymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$this->prefixinvoice."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -95,7 +95,7 @@ class mod_facture_terre extends ModeleNumRefFactures $fayymm=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$this->prefixcreditnote."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -116,7 +116,7 @@ class mod_facture_terre extends ModeleNumRefFactures $fayymm=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$this->prefixdeposit."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -154,7 +154,7 @@ class mod_facture_terre extends ModeleNumRefFactures // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -175,7 +175,8 @@ class mod_facture_terre extends ModeleNumRefFactures if ($mode == 'last') { - $num = sprintf("%04s",$max); + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max); $ref=''; $sql = "SELECT facnumber as ref"; @@ -198,7 +199,9 @@ class mod_facture_terre extends ModeleNumRefFactures { $date=$facture->date; // This is invoice date (not creation date) $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 227d04f5ba5..38ef8b401d6 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -72,7 +72,7 @@ class mod_pacific extends ModeleNumRefFicheinter $fayymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " WHERE entity = ".$conf->entity; @@ -108,7 +108,7 @@ class mod_pacific extends ModeleNumRefFicheinter // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -124,7 +124,9 @@ class mod_pacific extends ModeleNumRefFicheinter //$date=time(); $date=$object->datec; $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); return $this->prefix.$yymm."-".$num; } diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index f3835620896..33056364574 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -78,7 +78,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder $fayymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -112,7 +112,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -134,7 +134,9 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder $date=$object->date_delivery; if (empty($date)) $date=dol_now(); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index cce6e638336..4f13c40c970 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -72,7 +72,7 @@ class mod_project_simple extends ModeleNumRefProjects $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."projet"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -108,7 +108,7 @@ class mod_project_simple extends ModeleNumRefProjects // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."projet"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -130,7 +130,9 @@ class mod_project_simple extends ModeleNumRefProjects //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 13c23cb4f73..e0a18711ca6 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -72,7 +72,7 @@ class mod_task_simple extends ModeleNumRefTask $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(task.ref FROM " . $posindice . ")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, "; $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid"; $sql .= " AND task.ref LIKE '" . $this->prefix . "____-%'"; @@ -109,7 +109,7 @@ class mod_task_simple extends ModeleNumRefTask // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; @@ -130,7 +130,9 @@ class mod_task_simple extends ModeleNumRefTask //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index d14c176e08b..15e06d995d1 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -73,7 +73,7 @@ class mod_propale_marbre extends ModeleNumRefPropales $pryymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -110,7 +110,7 @@ class mod_propale_marbre extends ModeleNumRefPropales // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -130,7 +130,9 @@ class mod_propale_marbre extends ModeleNumRefPropales $date = time(); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; @@ -150,4 +152,4 @@ class mod_propale_marbre extends ModeleNumRefPropales } -?> +?> \ No newline at end of file diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 1e55a6256f3..95f3fa27b2c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -119,7 +119,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(SUBSTRING(".$field." FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; $sql.= " AND entity IN (".getEntity('societe', 1).")"; @@ -139,7 +139,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $date = dol_now(); $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 0084a951882..19eb47e6a08 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -73,7 +73,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices $siyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; $sql.= " WHERE ref LIKE '".$this->prefixinvoice."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -112,7 +112,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; $sql.= " WHERE ref LIKE '".$prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -133,7 +133,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($mode == 'last') { - $num = sprintf("%04s",$max); + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max); $ref=''; $sql = "SELECT ref as ref"; @@ -156,7 +157,9 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices { $date=$object->date; // This is invoice date (not creation date) $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 66c07355b29..c321b408d24 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -73,7 +73,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders $coyymm=''; $max=''; $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -108,7 +108,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders // D'abord on recupere la valeur max $posindice=8; - $sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " WHERE ref like '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -125,7 +125,9 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders $date=$object->date_commande; // Not always defined if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); return $this->prefix.$yymm."-".$num; } From 4a89446162fa55d982ba0def71ac0e53db0890ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 May 2014 19:47:41 +0200 Subject: [PATCH 6/7] Fix: When number reach 9999 with default numbering module, next number will be 10000 instead of 0000 and error. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 07cc056c322..525ee67f65a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,8 @@ Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. Fix: TCPDF error file not found in member card generation. Fix: [ bug #1380 ] Customer invoices are not grouped in company results report. Fix: [ bug #1393 ] PHP Warning when creating a supplier invoice. +Fix: When number reach 9999 with default numbering module, next number + will be 10000 instead of 0000 and error. ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** Fix: Can't add user for a task. From 4a7e9e4d0b97b35a71d5b5e3a796cceb6cee2ce9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 May 2014 19:54:40 +0200 Subject: [PATCH 7/7] Fix: CRLF --- htdocs/core/db/pgsql.class.php | 2 +- htdocs/core/lib/functions2.lib.php | 2 +- htdocs/core/modules/contract/mod_contract_serpis.php | 4 ++-- htdocs/core/modules/expedition/mod_expedition_safor.php | 4 ++-- htdocs/core/modules/livraison/mod_livraison_jade.php | 4 ++-- htdocs/core/modules/project/mod_project_simple.php | 4 ++-- htdocs/core/modules/project/task/mod_task_simple.php | 4 ++-- htdocs/core/modules/propale/mod_propale_marbre.php | 4 ++-- htdocs/core/modules/societe/mod_codeclient_monkey.php | 4 ++-- .../supplier_invoice/mod_facture_fournisseur_cactus.php | 4 ++-- .../supplier_order/mod_commande_fournisseur_muguet.php | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index f7c173a401d..010fcf191cc 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -214,7 +214,7 @@ class DoliDBPgsql extends DoliDB // nuke unsigned $line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line); - $line=preg_replace('/as signed/i','as integer',$line); + $line=preg_replace('/as signed/i','as integer',$line); // blob -> text $line=preg_replace('/\w*blob/i','text',$line); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3e6beaa9eeb..2bd3c757e47 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -802,7 +802,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($counter >= pow(10, dol_strlen($maskcounter))) { $counter='ErrorMaxNumberReachForThisMask'; - } + } if (! empty($maskrefclient_maskcounter)) { diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 78b0a829fa9..cd21c5164ac 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -123,8 +123,8 @@ class mod_contract_serpis extends ModelNumRefContracts $date=$contract->date_contrat; $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index e575f5c93af..ceec6107e58 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -123,8 +123,8 @@ class mod_expedition_safor extends ModelNumRefExpedition $date=time(); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index 33056364574..e1b749bbf2f 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -135,8 +135,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder if (empty($date)) $date=dol_now(); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 4f13c40c970..686fa74dc43 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -131,8 +131,8 @@ class mod_project_simple extends ModeleNumRefProjects //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index e0a18711ca6..8d6ea553519 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -131,8 +131,8 @@ class mod_task_simple extends ModeleNumRefTask //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 15e06d995d1..5d8b8e169df 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -131,8 +131,8 @@ class mod_propale_marbre extends ModeleNumRefPropales $date = time(); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 95f3fa27b2c..4c24f5691a5 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -140,8 +140,8 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $date = dol_now(); $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 19eb47e6a08..e35226b20fd 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -158,8 +158,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices $date=$object->date; // This is invoice date (not creation date) $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); return $prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index c321b408d24..fea7c4f21e0 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -126,8 +126,8 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders $yymm = strftime("%y%m",$date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s",$max+1); + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); return $this->prefix.$yymm."-".$num; }