2
0
forked from Wavyzz/dolibarr

Add tag {cccc0000} in generic numering modules (from a work of Raphael)

This commit is contained in:
Laurent Destailleur
2008-06-20 21:10:24 +00:00
parent 2af507d7a3
commit fb982b6fd3
11 changed files with 384 additions and 649 deletions

View File

@@ -15,95 +15,95 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/commande/mod_commande_opale.php
\ingroup commande
\brief Fichier contenant la classe du mod<6F>le de num<75>rotation de r<>f<EFBFBD>rence de commande Opale
\version $Revision$
*/
/**
\file htdocs/includes/modules/commande/mod_commande_opale.php
\ingroup commande
\brief Fichier contenant la classe du mod<6F>le de num<75>rotation de r<>f<EFBFBD>rence de commande Opale
\version $Id$
*/
include_once("modules_commande.php");
/**
\class mod_commande_opale
\brief Classe du mod<6F>le de num<75>rotation de r<>f<EFBFBD>rence de commande Opale
*/
\class mod_commande_opale
\brief Classe du mod<6F>le de num<75>rotation de r<>f<EFBFBD>rence de commande Opale
*/
class mod_commande_opale extends ModeleNumRefCommandes
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';
var $nom = 'Opale';
/** \brief Constructeur
*/
function mod_commande_opale()
{
$this->nom = "Opale";
}
/** \brief Constructeur
*/
function mod_commande_opale()
{
$this->nom = "Opale";
}
/** \brief Renvoi la description du modele de num<75>rotation
* \return string Texte descripif
*/
function info()
{
return "Renvoie le num<75>ro sous la forme num<75>rique COMhexa, o<> hexa repr<70>sente un incr<63>ment global cod<6F> en h<>xad<61>cimal. (COM-000-001 <20> COM-FFF-FFF)";
}
/** \brief Renvoi un exemple de num<75>rotation
* \return string Example
*/
function getExample()
{
return "COM-000-001";
}
/** \brief Renvoi la description du modele de num<75>rotation
* \return string Texte descripif
*/
function info()
{
return "Renvoie le num<75>ro sous la forme num<75>rique COMhexa, o<> hexa repr<70>sente un incr<63>ment global cod<6F> en h<>xad<61>cimal. (COM-000-001 <20> COM-FFF-FFF)";
}
/** \brief Renvoi prochaine valeur attribu<62>e
* \return string Valeur
*/
function getNextValue()
{
global $db;
/** \brief Renvoi un exemple de num<75>rotation
* \return string Example
*/
function getExample()
{
return "COM-000-001";
}
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
$com='';
$sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like 'COM%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row)
{
//on extrait la valeur max et on la passe en d<>cimale
$max = hexdec((substr($row[0],4,3)).(substr($row[0],8,3)));
}
}
else
{
$max=0;
}
$yy = strftime("%y",time());
$hex = strtoupper(dechex($max+1));
$ref = substr("000000".($hex),-6);
return 'COM-'.substr($ref,0,3)."-".substr($ref,3,3);
}
/** \brief Renvoie la r<>f<EFBFBD>rence de commande suivante non utilis<69>e
* \param objsoc Objet soci<63>t<EFBFBD>
* \return string Texte descripif
*/
function commande_get_num($objsoc=0)
{
return $this->getNextValue();
}
/** \brief Renvoi prochaine valeur attribu<62>e
* \return string Valeur
*/
function getNextValue()
{
global $db;
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
$com='';
$sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like 'COM%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row)
{
//on extrait la valeur max et on la passe en d<>cimale
$max = hexdec((substr($row[0],4,3)).(substr($row[0],8,3)));
}
}
else
{
$max=0;
}
$yy = strftime("%y",time());
$hex = strtoupper(dechex($max+1));
$ref = substr("000000".($hex),-6);
return 'COM-'.substr($ref,0,3)."-".substr($ref,3,3);
}
/** \brief Renvoie la r<>f<EFBFBD>rence de commande suivante non utilis<69>e
* \param objsoc Objet soci<63>t<EFBFBD>
* \return string Texte descripif
*/
function commande_get_num($objsoc=0)
{
return $this->getNextValue();
}
}
?>