diff --git a/htdocs/includes/modules/commande/mod_commande_marbre.php b/htdocs/includes/modules/commande/mod_commande_marbre.php index a099c25e3f0..8932fb79745 100644 --- a/htdocs/includes/modules/commande/mod_commande_marbre.php +++ b/htdocs/includes/modules/commande/mod_commande_marbre.php @@ -99,7 +99,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; $sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -108,7 +108,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } else diff --git a/htdocs/includes/modules/facture/terre/terre.modules.php b/htdocs/includes/modules/facture/terre/terre.modules.php index 50aba6425e7..5f8b26cd0a7 100644 --- a/htdocs/includes/modules/facture/terre/terre.modules.php +++ b/htdocs/includes/modules/facture/terre/terre.modules.php @@ -124,7 +124,7 @@ class mod_facture_terre extends ModeleNumRefFactures // D'abord on recupere la valeur max (reponse immediate car champ ind�x�) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(facnumber,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber like '".$prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -134,7 +134,7 @@ class mod_facture_terre extends ModeleNumRefFactures if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } else diff --git a/htdocs/includes/modules/fichinter/mod_pacific.php b/htdocs/includes/modules/fichinter/mod_pacific.php index bdcd4ac9e35..38903821134 100644 --- a/htdocs/includes/modules/fichinter/mod_pacific.php +++ b/htdocs/includes/modules/fichinter/mod_pacific.php @@ -111,7 +111,7 @@ class mod_pacific extends ModeleNumRefFicheinter // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -120,7 +120,7 @@ class mod_pacific extends ModeleNumRefFicheinter if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } diff --git a/htdocs/includes/modules/livraison/mod_livraison_jade.php b/htdocs/includes/modules/livraison/mod_livraison_jade.php index d6ff91ae491..eef06e9b90c 100644 --- a/htdocs/includes/modules/livraison/mod_livraison_jade.php +++ b/htdocs/includes/modules/livraison/mod_livraison_jade.php @@ -90,7 +90,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder // Recherche rapide car restreint par un like sur champ indexe $posindice=5; - $sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))"; + $sql = "SELECT MAX(SUBSTRING(ref,$posindice)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " WHERE ref like '".$blyy."%'"; $sql.= " AND entity = ".$conf->entity; @@ -98,8 +98,9 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder $resql=$db->query($sql); if ($resql) { - $row = $db->fetch_row($resql); - $max = $row[0]; + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; } } else diff --git a/htdocs/includes/modules/project/mod_project_simple.php b/htdocs/includes/modules/project/mod_project_simple.php index 8b33ac4a2c5..7ac759b1090 100644 --- a/htdocs/includes/modules/project/mod_project_simple.php +++ b/htdocs/includes/modules/project/mod_project_simple.php @@ -72,7 +72,7 @@ class mod_project_simple extends ModeleNumRefProjects // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."projet"; $sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -81,7 +81,7 @@ class mod_project_simple extends ModeleNumRefProjects if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } else diff --git a/htdocs/includes/modules/propale/mod_propale_marbre.php b/htdocs/includes/modules/propale/mod_propale_marbre.php index bab038892ce..a25aba588b8 100644 --- a/htdocs/includes/modules/propale/mod_propale_marbre.php +++ b/htdocs/includes/modules/propale/mod_propale_marbre.php @@ -100,7 +100,7 @@ class mod_propale_marbre extends ModeleNumRefPropales // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -109,7 +109,7 @@ class mod_propale_marbre extends ModeleNumRefPropales if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } else diff --git a/htdocs/includes/modules/societe/mod_codeclient_monkey.php b/htdocs/includes/modules/societe/mod_codeclient_monkey.php index ba65a7736c1..821b5f77f79 100644 --- a/htdocs/includes/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/includes/modules/societe/mod_codeclient_monkey.php @@ -105,9 +105,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode if ($type == 0) $prefix=$this->prefixcustomer; if ($type == 1) $prefix=$this->prefixsupplier; - // D'abord on r�cup�re la valeur max (r�ponse imm�diate car champ ind�x�) + // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(".$field.",".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(".$field.",".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE ".$field." LIKE '".$prefix."%'"; @@ -115,7 +115,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } else diff --git a/htdocs/includes/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/includes/modules/supplier_order/mod_commande_fournisseur_muguet.php index 8d943a42d4a..2076ed46c90 100644 --- a/htdocs/includes/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/includes/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -98,7 +98,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " AND entity = ".$conf->entity; @@ -107,7 +107,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; + if ($obj) $max = intval($obj->max); else $max=0; } diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 0c0629631a1..1650effb460 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -479,6 +479,7 @@ class DoliDb } $ret = @pg_query($this->db, $query); + //print $query; if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query)) { // Si requete utilisateur, on la sauvegarde ainsi que son resultset