forked from Wavyzz/dolibarr
Fix: Numbering errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -93,16 +93,17 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
|||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
||||||
$coyymm='';
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(ref)";
|
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
||||||
$sql.= " WHERE ref like '".$this->prefix."%'";
|
$sql.= " WHERE ref like '".$this->prefix."%'";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($row) $coyymm = substr($row[0],0,6);
|
if ($obj) $max = $obj->max;
|
||||||
|
else $max=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -110,25 +111,6 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si champ respectant le mod<6F>le a <20>t<EFBFBD> trouv<75>e
|
|
||||||
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$coyymm))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ index<65>
|
|
||||||
$posindice=8;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
|
||||||
$sql.= " WHERE ref like '${coyymm}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
//$date=time();
|
//$date=time();
|
||||||
$date=$commande->date;
|
$date=$commande->date;
|
||||||
$yymm = strftime("%y%m",$date);
|
$yymm = strftime("%y%m",$date);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
|
|
||||||
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(facnumber+SUBSTRING(facnumber,".$posindice.")) as ref";
|
$sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice.")) as max";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
$sql.= " WHERE facnumber like '".$prefix."%'";
|
$sql.= " WHERE facnumber like '".$prefix."%'";
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj) $max = $obj->ref;
|
if ($obj) $max = $obj->max;
|
||||||
else $max=0;
|
else $max=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -95,14 +95,17 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
||||||
$pryymm='';
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(ref)";
|
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||||
|
$sql.= " WHERE ref like '".$this->prefix."%'";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($row) $pryymm = substr($row[0],0,6);
|
if ($obj) $max = $obj->max;
|
||||||
|
else $max=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -110,27 +113,9 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si champ respectant le mod<6F>le a <20>t<EFBFBD> trouv<75>e
|
$date=$propal->date;
|
||||||
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$pryymm))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ index<65>
|
|
||||||
$posindice=8;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '".$pryymm."%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
//$yymm = strftime("%y%m",time());
|
//$yymm = strftime("%y%m",time());
|
||||||
$yymm = strftime("%y%m",$propal->date);
|
$yymm = strftime("%y%m",$date);
|
||||||
$num = sprintf("%04s",$max+1);
|
$num = sprintf("%04s",$max+1);
|
||||||
|
|
||||||
dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
|
|||||||
Reference in New Issue
Block a user