diff --git a/htdocs/fourn/commande/modules/mod_commande_fournisseur_orchidee.php b/htdocs/fourn/commande/modules/mod_commande_fournisseur_orchidee.php index 5c8fa333f19..d9cf3cf749f 100644 --- a/htdocs/fourn/commande/modules/mod_commande_fournisseur_orchidee.php +++ b/htdocs/fourn/commande/modules/mod_commande_fournisseur_orchidee.php @@ -173,7 +173,7 @@ function info() $searchyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - if ($conf->global->COMMANDE_FOURNISSEUR_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'"; + if ($conf->global->COMMANDE_FOURNISSEUR_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'"; $resql=$db->query($sql); if ($resql) { @@ -188,7 +188,7 @@ function info() $previousyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'"; + $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'"; $resql=$db->query($sql); if ($resql) { @@ -203,7 +203,7 @@ function info() // Recherche rapide car restreint par un like sur champ indexé $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " WHERE ref like '${searchyy}%'"; + $sql.= " WHERE ref REGEXP '^".$searchyy."'"; $resql=$db->query($sql); if ($resql) { @@ -375,9 +375,9 @@ function info() // On récupère le mois si besoin $this->mm = strftime("%m",time()); $this->numMatrice[$k] = '$mm'; - $this->searchLast .= $this->mm; + $this->searchLast .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]'; - $this->searchLastWithPreviousYear .= $this->mm; + $this->searchLastWithPreviousYear .= '[0-9][0-9]'; $k++; } else if ($idMatrice == 'counter') diff --git a/htdocs/includes/modules/commande/mod_commande_saphir.php b/htdocs/includes/modules/commande/mod_commande_saphir.php index 5422950443e..a237edd5442 100644 --- a/htdocs/includes/modules/commande/mod_commande_saphir.php +++ b/htdocs/includes/modules/commande/mod_commande_saphir.php @@ -175,7 +175,7 @@ function info() $searchyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'"; + if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'"; $resql=$db->query($sql); if ($resql) { @@ -189,7 +189,7 @@ function info() $previousyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - $sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'"; + $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'"; $resql=$db->query($sql); if ($resql) { @@ -204,7 +204,7 @@ function info() // Recherche rapide car restreint par un like sur champ indexé $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))"; $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - $sql.= " WHERE ref like '${searchyy}%'"; + $sql.= " WHERE ref REGEXP '^".$searchyy."'"; $resql=$db->query($sql); if ($resql) { @@ -377,9 +377,9 @@ function info() // On récupère le mois si besoin $this->mm = strftime("%m",time()); $this->numMatrice[$k] = '$mm'; - $this->searchLast .= $this->mm; + $this->searchLast .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]'; - $this->searchLastWithPreviousYear .= $this->mm; + $this->searchLastWithPreviousYear .= '[0-9][0-9]'; $k++; } else if ($idMatrice == 'counter') diff --git a/htdocs/includes/modules/facture/pluton/pluton.modules.php b/htdocs/includes/modules/facture/pluton/pluton.modules.php index 0273f02272c..99023075962 100644 --- a/htdocs/includes/modules/facture/pluton/pluton.modules.php +++ b/htdocs/includes/modules/facture/pluton/pluton.modules.php @@ -199,7 +199,7 @@ function info() $sql.= " FROM ".MAIN_DB_PREFIX."facture"; if ($conf->global->FACTURE_NUM_RESTART_BEGIN_YEAR) { - $sql.= " WHERE facnumber like '".$this->searchLast."%'"; + $sql.= " WHERE facnumber REGEXP '^".$this->searchLast."'"; } else if ($facture->type == 2) { @@ -219,7 +219,7 @@ function info() $previousyy=''; $sql = "SELECT MAX(facnumber)"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; - $sql.= " WHERE facnumber like '$".$this->searchLastWithPreviousYear."%'"; + $sql.= " WHERE facnumber REGEXP '^".$this->searchLastWithPreviousYear."'"; $resql=$db->query($sql); if ($resql) { @@ -234,7 +234,7 @@ function info() // Recherche rapide car restreint par un like sur champ indexé $sql = "SELECT MAX(0+SUBSTRING(facnumber,-".$posindice."))"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; - $sql.= " WHERE facnumber like '${searchyy}%'"; + $sql.= " WHERE facnumber REGEXP '^".$searchyy."'"; $resql=$db->query($sql); if ($resql) { @@ -428,9 +428,9 @@ function info() // On récupère le mois si besoin $this->mm = strftime("%m",time()); $this->numMatrice[$k] = '$mm'; - $this->searchLast .= $this->mm; + $this->searchLast .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]'; - $this->searchLastWithPreviousYear .= $this->mm; + $this->searchLastWithPreviousYear .= '[0-9][0-9]'; $k++; } else if ($idMatrice == 'counter') diff --git a/htdocs/includes/modules/propale/mod_propale_saphir.php b/htdocs/includes/modules/propale/mod_propale_saphir.php index 48ac5c59a67..c0e80d48374 100644 --- a/htdocs/includes/modules/propale/mod_propale_saphir.php +++ b/htdocs/includes/modules/propale/mod_propale_saphir.php @@ -175,7 +175,7 @@ function info() $searchyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; - if ($conf->global->PROPALE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'"; + if ($conf->global->PROPALE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'"; $resql=$db->query($sql); if ($resql) { @@ -190,7 +190,7 @@ function info() $previousyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; - $sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'"; + $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'"; $resql=$db->query($sql); if ($resql) { @@ -205,7 +205,7 @@ function info() // Recherche rapide car restreint par un like sur champ indexé $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; - $sql.= " WHERE ref like '${searchyy}%'"; + $sql.= " WHERE ref like '^".$searchyy."'"; $resql=$db->query($sql); if ($resql) { @@ -366,9 +366,9 @@ function info() // On récupère le mois si besoin $this->mm = strftime("%m",time()); $this->numMatrice[$k] = '$mm'; - $this->searchLast .= $this->mm; + $this->searchLast .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]'; - $this->searchLastWithPreviousYear .= $this->mm; + $this->searchLastWithPreviousYear .= '[0-9][0-9]'; $k++; } else if ($idMatrice == 'counter') diff --git a/htdocs/livraison/mods/mod_livraison_saphir.php b/htdocs/livraison/mods/mod_livraison_saphir.php index 2e53de5d29d..9a33dc0df6a 100644 --- a/htdocs/livraison/mods/mod_livraison_saphir.php +++ b/htdocs/livraison/mods/mod_livraison_saphir.php @@ -176,7 +176,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder $searchyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - if ($conf->global->LIVRAISON_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'"; + if ($conf->global->LIVRAISON_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'"; $resql=$db->query($sql); if ($resql) { @@ -191,7 +191,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder $previousyy=''; $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'"; + $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'"; $resql=$db->query($sql); if ($resql) { @@ -206,7 +206,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder // Recherche rapide car restreint par un like sur champ indexé $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE ref like '${searchyy}%'"; + $sql.= " WHERE ref REGEXP '^".$searchyy."'"; $resql=$db->query($sql); if ($resql) { @@ -379,9 +379,9 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder // On récupère le mois si besoin $this->mm = strftime("%m",time()); $this->numMatrice[$k] = '$mm'; - $this->searchLast .= $this->mm; + $this->searchLast .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]'; - $this->searchLastWithPreviousYear .= $this->mm; + $this->searchLastWithPreviousYear .= '[0-9][0-9]'; $k++; } else if ($idMatrice == 'counter')