Skip to content
Snippets Groups Projects
Commit 1c43e655 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Numbering for terre

parent fda9eb1c
No related branches found
No related tags found
No related merge requests found
......@@ -120,16 +120,17 @@ class mod_facture_terre extends ModeleNumRefFactures
else $prefix=$this->prefixinvoice;
// D'abord on rcupre la valeur max (rponse immdiate car champ indx)
$fayymm='';
$sql = "SELECT MAX(facnumber)";
$posindice=8;
$sql = "SELECT MAX(facnumber+SUBSTRING(facnumber,".$posindice.")) as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$prefix."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $fayymm = substr($row[0],0,6);
$obj = $db->fetch_object($resql);
if ($obj) $max = $obj->ref;
else $max=0;
}
else
{
......@@ -137,26 +138,6 @@ class mod_facture_terre extends ModeleNumRefFactures
return -1;
}
// Si champ respectant le modle a t trouve
if (eregi('^'.$prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
{
// Recherche rapide car restreint par un like sur champ index
$posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$fayymm."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$max = $row[0];
}
}
else
{
$max=0;
}
//$date=time();
$date=$facture->date;
$yymm = strftime("%y%m",$date);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment