Skip to content
Snippets Groups Projects
Commit 85a549e2 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: remplacement de LIKE dans la requete sql par REGEXP afin de palier au...

Fix: remplacement de LIKE dans la requete sql par REGEXP afin de palier au différent format de numérotation
parent 7d5b36c3
No related branches found
No related tags found
No related merge requests found
......@@ -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 rcupre 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')
......
......@@ -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 rcupre 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')
......
......@@ -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 rcupre 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')
......
......@@ -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 rcupre 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')
......
......@@ -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 rcupre 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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment