New: A generic propal numbering module (depreciate all others)
This commit is contained in:
parent
b9d36ccdc6
commit
f7d61cac0c
@ -1,173 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* 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/propale/mod_propale_diamant.php
|
|
||||||
\ingroup propale
|
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Diamant
|
|
||||||
\version $Revision$
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
|
||||||
|
|
||||||
|
|
||||||
/** \class mod_propale_diamant
|
|
||||||
\brief Classe du modèle de numérotation de référence de propale Diamant
|
|
||||||
*/
|
|
||||||
|
|
||||||
class mod_propale_diamant extends ModeleNumRefPropales
|
|
||||||
{
|
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_diamant()
|
|
||||||
{
|
|
||||||
$this->nom = "Diamant";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
$texte = "Renvoie le numéro sous la forme numérique PRYYNNNNN où YY représente l'année et NNNNN Le numéro d'incrément. Ce dernier n'est PAS remis à zéro en début d'année.<br>\n";
|
|
||||||
$texte.= "Si la constante PROPALE_DIAMANT_DELTA est définie, un offset est appliqué sur le compteur";
|
|
||||||
|
|
||||||
if (defined("PROPALE_DIAMANT_DELTA"))
|
|
||||||
{
|
|
||||||
$texte .= " (Définie et vaut: ".PROPALE_DIAMANT_DELTA.")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$texte .= " (N'est pas définie)";
|
|
||||||
}
|
|
||||||
return $texte;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
|
||||||
* \return string Example
|
|
||||||
*/
|
|
||||||
function getExample()
|
|
||||||
{
|
|
||||||
$y = strftime("%y",time());
|
|
||||||
|
|
||||||
if (defined("PROPALE_DIAMANT_DELTA"))
|
|
||||||
{
|
|
||||||
$num = sprintf("%02d",PROPALE_DIAMANT_DELTA);
|
|
||||||
return "PR".$y.substr("0000".$num, strlen("0000".$num)-5,5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "PR".$y."00001";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Valeur
|
|
||||||
*/
|
|
||||||
function getNextValue($objsoc=0)
|
|
||||||
{
|
|
||||||
global $db, $conf;
|
|
||||||
|
|
||||||
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
|
|
||||||
|
|
||||||
$prefix='PR';
|
|
||||||
$current_year = strftime("%y",time());
|
|
||||||
$last_year = strftime("%y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")-1));
|
|
||||||
|
|
||||||
$pryy = $prefix.$current_year;
|
|
||||||
|
|
||||||
$sql = "SELECT MAX(ref)";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${pryy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$pryy='';
|
|
||||||
if ($row[0]!='')
|
|
||||||
{
|
|
||||||
$pryy = substr($row[0],0,4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pryy = $prefix.$last_year;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//on vérifie si il y a une année précédente
|
|
||||||
//sinon le delta sera appliqué de nouveau sur la nouvelle année
|
|
||||||
$lastyy = $prefix.$last_year;
|
|
||||||
$sql = "SELECT MAX(ref)";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${lastyy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$lastyy='';
|
|
||||||
if ($row) $lastyy = substr($row[0],0,4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si au moins un champ respectant le modèle a été trouvée
|
|
||||||
if (eregi('PR[0-9][0-9]',$pryy))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ indexé
|
|
||||||
$posindice=5;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${pryy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!eregi('PR[0-9][0-9]',$lastyy))
|
|
||||||
{
|
|
||||||
$max=$conf->global->PROPALE_DIAMANT_DELTA?$conf->global->PROPALE_DIAMANT_DELTA:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = sprintf("%05s",$max+1);
|
|
||||||
$yy = strftime("%y",time());
|
|
||||||
|
|
||||||
return "PR$yy$num";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoie la référence de propale suivante non utilisée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function getNumRef($objsoc=0)
|
|
||||||
{
|
|
||||||
return $this->getNextValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,144 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* 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/propale/mod_propale_emeraude.php
|
|
||||||
\ingroup propale
|
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Emeraude
|
|
||||||
\version $Revision$
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
|
||||||
|
|
||||||
|
|
||||||
/** \class mod_propale_emeraude
|
|
||||||
\brief Classe du modèle de numérotation de référence de propale Emeraude
|
|
||||||
*/
|
|
||||||
|
|
||||||
class mod_propale_emeraude extends ModeleNumRefPropales
|
|
||||||
{
|
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_emeraude()
|
|
||||||
{
|
|
||||||
$this->nom = "Emeraude";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
global $conf,$langs;
|
|
||||||
|
|
||||||
$langs->load("propal");
|
|
||||||
|
|
||||||
$texte = $langs->trans('EmeraudeNumRefModelDesc1')."<br>\n";
|
|
||||||
$texte.= $langs->trans('EmeraudeNumRefModelDesc2')."<br>\n";
|
|
||||||
$texte.= $langs->trans('EmeraudeNumRefModelDesc3')."<br>\n";
|
|
||||||
$texte.= $langs->trans('EmeraudeNumRefModelDesc4')."<br>\n";
|
|
||||||
|
|
||||||
if ($conf->global->SOCIETE_FISCAL_MONTH_START)
|
|
||||||
{
|
|
||||||
$texte.= ' ('.$langs->trans('DefinedAndHasThisValue').' : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).')';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$texte.= ' ('.$langs->trans('IsNotDefined').')';
|
|
||||||
}
|
|
||||||
return $texte;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
|
||||||
* \return string Example
|
|
||||||
*/
|
|
||||||
function getExample()
|
|
||||||
{
|
|
||||||
return "PR0500001";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
|
||||||
* \return string Valeur
|
|
||||||
*/
|
|
||||||
function getNextValue($objsoc=0)
|
|
||||||
{
|
|
||||||
global $db,$conf;
|
|
||||||
|
|
||||||
// D'abord on défini l'année fiscale
|
|
||||||
$prefix='PR';
|
|
||||||
$current_month = date("n");
|
|
||||||
if($conf->global->SOCIETE_FISCAL_MONTH_START > 1 && $current_month >= $conf->global->SOCIETE_FISCAL_MONTH_START)
|
|
||||||
{
|
|
||||||
$yy = strftime("%y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")+1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$yy = strftime("%y",time());
|
|
||||||
}
|
|
||||||
|
|
||||||
// On récupère la valeur max (réponse immédiate car champ indéxé)
|
|
||||||
$fisc=$prefix.$yy;
|
|
||||||
$pryy='';
|
|
||||||
$sql = "SELECT MAX(ref)";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${fisc}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
if ($row) $pryy = substr($row[0],0,4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si au moins un champ respectant le modèle a été trouvé
|
|
||||||
if (eregi('PR[0-9][0-9]',$pryy))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ indexé
|
|
||||||
$date = strftime("%Y%m", time());
|
|
||||||
$posindice=5;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${pryy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = sprintf("%05s",$max+1);
|
|
||||||
|
|
||||||
return "PR$yy$num";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,138 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* 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/propale/mod_propale_ivoire.php
|
|
||||||
\ingroup propale
|
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Ivoire
|
|
||||||
\version $Revision$
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
|
||||||
|
|
||||||
|
|
||||||
/** \class mod_propale_ivoire
|
|
||||||
\brief Classe du modèle de numérotation de référence de propale Ivoire
|
|
||||||
*/
|
|
||||||
|
|
||||||
class mod_propale_ivoire extends ModeleNumRefPropales
|
|
||||||
{
|
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_ivoire()
|
|
||||||
{
|
|
||||||
$this->nom = "Ivoire";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
return "Renvoie le numéro sous la forme PRyynnnn où yy est l'année et nnnn un compteur sans remise à 0";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
|
||||||
* \return string Example
|
|
||||||
*/
|
|
||||||
function getExample()
|
|
||||||
{
|
|
||||||
return "PR050001";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Valeur
|
|
||||||
*/
|
|
||||||
function getNextValue($objsoc=0)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
|
|
||||||
|
|
||||||
$prefix='PR';
|
|
||||||
$current_year = strftime("%y",time());
|
|
||||||
$last_year = strftime("%y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")-1));
|
|
||||||
|
|
||||||
$pryy = $prefix.$current_year;
|
|
||||||
|
|
||||||
$sql = "SELECT MAX(ref)";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${pryy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$pryy='';
|
|
||||||
if ($row[0]!='')
|
|
||||||
{
|
|
||||||
$pryy = substr($row[0],0,4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pryy = $prefix.$last_year;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si au moins un champ respectant le modèle a été trouvée
|
|
||||||
if (eregi('PR[0-9][0-9]',$pryy))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ indexé
|
|
||||||
$posindice=5;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$sql.= " WHERE ref like '${pryy}%'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = sprintf("%04s",$max+1);
|
|
||||||
$yy = strftime("%y",time());
|
|
||||||
|
|
||||||
return "PR$yy$num";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoie la référence de propale suivante non utilisée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function getNumRef($objsoc=0)
|
|
||||||
{
|
|
||||||
return $this->getNextValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* 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/propale/mod_propale_jade.php
|
|
||||||
\ingroup propale
|
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Jade
|
|
||||||
\version $Revision$
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\class mod_propale_jade
|
|
||||||
\brief Classe du modèle de numérotation de référence de propale Jade
|
|
||||||
*/
|
|
||||||
|
|
||||||
class mod_propale_jade extends ModeleNumRefPropales
|
|
||||||
{
|
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_jade()
|
|
||||||
{
|
|
||||||
$this->nom = "Jade";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
return "Renvoie le numéro sous la forme PROPn ou n est un compteur continue sans remise à 0";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
|
||||||
* \return string Example
|
|
||||||
*/
|
|
||||||
function getExample()
|
|
||||||
{
|
|
||||||
return "PROP1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Valeur
|
|
||||||
*/
|
|
||||||
function getNextValue($objsoc=0)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row(0);
|
|
||||||
|
|
||||||
$num = $row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$y = strftime("%y",time());
|
|
||||||
|
|
||||||
return "PROP" . ($num+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoie la référence de propale suivante non utilisée
|
|
||||||
* \param objsoc Objet société
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function getNumRef($objsoc=0)
|
|
||||||
{
|
|
||||||
return $this->getNextValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -16,16 +16,13 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
* or see http://www.gnu.org/
|
* or see http://www.gnu.org/
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/propale/mod_propale_marbre.php
|
\file htdocs/includes/modules/propale/mod_propale_marbre.php
|
||||||
\ingroup propale
|
\ingroup propale
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Marbre
|
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Marbre
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
||||||
@ -37,15 +34,11 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php")
|
|||||||
|
|
||||||
class mod_propale_marbre extends ModeleNumRefPropales
|
class mod_propale_marbre extends ModeleNumRefPropales
|
||||||
{
|
{
|
||||||
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
var $prefix='PR';
|
var $prefix='PR';
|
||||||
var $error='';
|
var $error='';
|
||||||
|
var $nom = "Marbre";
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_marbre()
|
|
||||||
{
|
|
||||||
$this->nom = "Marbre";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
/** \brief Renvoi la description du modele de numérotation
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
|
|||||||
@ -1,140 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* 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/propale/mod_propale_rubis.php
|
|
||||||
\ingroup propale
|
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Rubis
|
|
||||||
\version $Revision$
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
|
||||||
|
|
||||||
|
|
||||||
/** \class mod_propale_rubis
|
|
||||||
\brief Classe du modèle de numérotation de référence de propale Rubis
|
|
||||||
*/
|
|
||||||
|
|
||||||
class mod_propale_rubis extends ModeleNumRefPropales
|
|
||||||
{
|
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_rubis()
|
|
||||||
{
|
|
||||||
$this->nom = "Rubis";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
|
||||||
* \return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
global $conf,$langs;
|
|
||||||
|
|
||||||
$langs->load("propal");
|
|
||||||
|
|
||||||
$texte = $langs->trans('RubisNumRefModelDesc1')."<br>\n";
|
|
||||||
$texte.= $langs->trans('RubisNumRefModelDesc2')."<br>\n";
|
|
||||||
$texte.= $langs->trans('RubisNumRefModelDesc3')."<br>\n";
|
|
||||||
$texte.= $langs->trans('RubisNumRefModelDesc4')."<br>\n";
|
|
||||||
|
|
||||||
if ($conf->global->SOCIETE_FISCAL_MONTH_START)
|
|
||||||
{
|
|
||||||
$texte.= ' ('.$langs->trans('DefinedAndHasThisValue').' : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).')';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$texte.= ' ('.$langs->trans('IsNotDefined').')';
|
|
||||||
}
|
|
||||||
return $texte;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
|
||||||
* \return string Example
|
|
||||||
*/
|
|
||||||
function getExample()
|
|
||||||
{
|
|
||||||
return "PR0600001";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
|
||||||
* \return string Valeur
|
|
||||||
*/
|
|
||||||
function getNextValue($objsoc=0)
|
|
||||||
{
|
|
||||||
global $db,$conf;
|
|
||||||
|
|
||||||
// D'abord on défini l'année fiscale
|
|
||||||
$prefix='PR';
|
|
||||||
$current_month = date("n");
|
|
||||||
if($conf->global->SOCIETE_FISCAL_MONTH_START > 1 && $current_month >= $conf->global->SOCIETE_FISCAL_MONTH_START)
|
|
||||||
{
|
|
||||||
$yy = strftime("%y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")+1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$yy = strftime("%y",time());
|
|
||||||
}
|
|
||||||
|
|
||||||
// On récupère la valeur max (réponse immédiate car champ indéxé)
|
|
||||||
$pryy='';
|
|
||||||
$sql = "SELECT MAX(ref)";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
if ($row) $pryy = substr($row[0],0,4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si au moins un champ respectant le modèle a été trouvée
|
|
||||||
if (eregi('PR[0-9][0-9]',$pryy))
|
|
||||||
{
|
|
||||||
// Recherche rapide car restreint par un like sur champ indexé
|
|
||||||
$posindice=5;
|
|
||||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = sprintf("%05s",$max+1);
|
|
||||||
|
|
||||||
return "PR$yy$num";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -17,103 +17,58 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
* or see http://www.gnu.org/
|
* or see http://www.gnu.org/
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/propale/mod_propale_saphir.php
|
\file htdocs/includes/modules/propale/mod_propale_saphir.php
|
||||||
\ingroup propale
|
\ingroup propale
|
||||||
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Saphir
|
\brief Fichier contenant la classe du modèle de numérotation de référence de propale Saphir
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class mod_propale_saphir
|
\class mod_propale_saphir
|
||||||
\brief Classe du modèle de numérotation de référence de propale Saphir
|
\brief Classe du modèle de numérotation de référence de propale Saphir
|
||||||
*/
|
*/
|
||||||
class mod_propale_saphir extends ModeleNumRefPropales
|
class mod_propale_saphir extends ModeleNumRefPropales
|
||||||
{
|
{
|
||||||
var $prefix;
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
var $matrice;
|
|
||||||
var $numMatrice = Array();
|
|
||||||
var $yy;
|
|
||||||
var $mm;
|
|
||||||
var $numbitcounter;
|
|
||||||
var $searchLast;
|
|
||||||
var $searchLastWithNoYear;
|
|
||||||
var $searchLastWithPreviousYear;
|
|
||||||
var $error = '';
|
var $error = '';
|
||||||
|
var $nom = 'Saphir';
|
||||||
|
|
||||||
/** \brief Constructeur
|
|
||||||
*/
|
|
||||||
function mod_propale_saphir()
|
|
||||||
{
|
|
||||||
$this->nom = "Saphir";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
/** \brief Renvoi la description du modele de numérotation
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
*/
|
*/
|
||||||
function info()
|
function info()
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
$texte = $langs->trans('SaphirNumRefModelDesc1')."<br>\n";
|
$texte = $langs->trans('SaphirNumRefModelDesc1')."<br>\n";
|
||||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
$texte.= '<input type="hidden" name="action" value="updateMask">';
|
||||||
|
$texte.= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
|
||||||
|
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||||
|
|
||||||
// Paramétrage de la matrice
|
// Parametrage du prefix des factures
|
||||||
$texte.= '<tr><td>Matrice de disposition des objets (prefix,mois,année,compteur...)</td>';
|
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskpropal" value="'.$conf->global->PROPALE_SAPHIR_MASK.'">',$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal")),1,1).'</td>';
|
||||||
$texte.= '<input type="hidden" name="action" value="updateMatrice">';
|
|
||||||
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="matrice" value="'.$conf->global->PROPALE_NUM_MATRICE.'"></td>';
|
|
||||||
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
||||||
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("MatriceProposalDesc"),1,1).'</td>';
|
|
||||||
$texte.= '</tr></form>';
|
|
||||||
|
|
||||||
// Paramétrage du prefix des commandes
|
$texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||||
$texte.= '<tr><td>Préfix des propositions commerciales</td>';
|
|
||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
||||||
$texte.= '<input type="hidden" name="action" value="updatePrefix">';
|
|
||||||
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefix" value="'.$conf->global->PROPALE_NUM_PREFIX.'"></td>';
|
|
||||||
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
||||||
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixProposalDesc"),1,1).'</td>';
|
|
||||||
$texte.= '</tr></form>';
|
|
||||||
|
|
||||||
// On détermine un offset sur le compteur
|
$texte.= '</tr>';
|
||||||
$texte.= '<tr><td>Appliquer un offset sur le compteur</td>';
|
|
||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
||||||
$texte.= '<input type="hidden" name="action" value="setOffset">';
|
|
||||||
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="offset" value="'.$conf->global->PROPALE_NUM_DELTA.'"></td>';
|
|
||||||
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
||||||
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'</td>';
|
|
||||||
$texte.= '</tr></form>';
|
|
||||||
|
|
||||||
// On défini si le compteur se remet à zero en debut d'année
|
$texte.= '</table>';
|
||||||
$texte.= '<tr><td>Le compteur se remet à zéro en début d\'année</td>';
|
$texte.= '</form>';
|
||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
||||||
$texte.= '<input type="hidden" name="action" value="setNumRestart">';
|
|
||||||
$texte.= '<td align="right">';
|
|
||||||
$texte.= $form->selectyesno('numrestart',$conf->global->PROPALE_NUM_RESTART_BEGIN_YEAR,1);
|
|
||||||
$texte.= '</td><td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
||||||
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'</td>';
|
|
||||||
$texte.= '</tr></form>';
|
|
||||||
|
|
||||||
// On affiche le debut d'année fiscale
|
return $texte;
|
||||||
$texte.= '<tr><td>Début d\'année fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'</td>';
|
|
||||||
$texte.= '</tr>';
|
|
||||||
|
|
||||||
$texte.= '</table><br>';
|
|
||||||
|
|
||||||
return $texte;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
/** \brief Renvoi un exemple de numérotation
|
||||||
@ -121,268 +76,130 @@ function info()
|
|||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs,$mysoc;
|
||||||
|
|
||||||
$numExample = '';
|
$numExample = $this->getNextValue($mysoc,$propalspecimen);
|
||||||
|
|
||||||
$buildResult = $this->buildMatrice();
|
if (! $numExample)
|
||||||
|
{
|
||||||
if ($buildResult == 1)
|
$numExample = $langs->trans('NotConfigured');
|
||||||
{
|
}
|
||||||
// On récupère le nombre de chiffres du compteur
|
return $numExample;
|
||||||
$arg = '%0'.$this->numbitcounter.'s';
|
|
||||||
$num = sprintf($arg,$conf->global->PROPALE_NUM_DELTA?$conf->global->PROPALE_NUM_DELTA:1);
|
|
||||||
|
|
||||||
//On construit le numéro à partir de la matrice
|
|
||||||
foreach($this->numMatrice as $objetMatrice)
|
|
||||||
{
|
|
||||||
if ($objetMatrice == '-') $numExample .= $objetMatrice;
|
|
||||||
if ($objetMatrice == '$prefix') $numExample .= $this->prefix;
|
|
||||||
if ($objetMatrice == '$yy') $numExample .= $this->yy;
|
|
||||||
if ($objetMatrice == '$mm') $numExample .= $this->mm;
|
|
||||||
if ($objetMatrice == '$num') $numExample .= $num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$numExample = $langs->trans('NotConfigured');
|
|
||||||
}
|
|
||||||
return $numExample;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Renvoi prochaine valeur attribuée
|
/** \brief Return next value
|
||||||
* \param objsoc Objet société
|
* \param objsoc Object third party
|
||||||
* \param propale Objet propale
|
* \param facture Object invoice
|
||||||
* \return string Valeur
|
* \return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
function getNextValue($objsoc=0,$propale='')
|
function getNextValue($objsoc,$facture)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
$buildResult = $this->buildMatrice($objsoc,$propale);
|
// On défini critere recherche compteur
|
||||||
|
$mask=$conf->global->PROPALE_SAPHIR_MASK;
|
||||||
|
|
||||||
if ($buildResult == 1)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
|
$this->error='NotConfigured';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// On récupère la valeur max (réponse immédiate car champ indéxé)
|
// Extract value for mask counter, mask raz and mask offset
|
||||||
$posindice = $this->numbitcounter;
|
if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask';
|
||||||
$searchyy='';
|
$masktri=$reg[1].$reg[2].$reg[3];
|
||||||
$sql = "SELECT MAX(ref)";
|
$maskcounter=$reg[1];
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
$maskraz=-1;
|
||||||
if ($conf->global->PROPALE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'";
|
$maskoffset=0;
|
||||||
$resql=$db->query($sql);
|
if (strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits';
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
if ($row) $searchyy = substr($row[0],0,-$posindice);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf->global->PROPALE_NUM_DELTA != '')
|
$maskwithonlyymcode=$mask;
|
||||||
{
|
$maskwithonlyymcode=eregi_replace('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$maskcounter,$maskwithonlyymcode);
|
||||||
//on vérifie si il y a une année précédente
|
$maskwithonlyymcode=eregi_replace('\{dd\}','dd',$maskwithonlyymcode);
|
||||||
//pour éviter que le delta soit appliqué de nouveau sur la nouvelle année
|
$maskwithnocode=$maskwithonlyymcode;
|
||||||
$previousyy='';
|
$maskwithnocode=eregi_replace('\{yyyy\}','yyyy',$maskwithnocode);
|
||||||
$sql = "SELECT MAX(ref)";
|
$maskwithnocode=eregi_replace('\{yy\}','yy',$maskwithnocode);
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
$maskwithnocode=eregi_replace('\{y\}','y',$maskwithnocode);
|
||||||
$sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'";
|
$maskwithnocode=eregi_replace('\{mm\}','mm',$maskwithnocode);
|
||||||
$resql=$db->query($sql);
|
//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
if ($row) $previousyy = substr($row[0],0,-$posindice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si au moins un champ respectant le modèle a été trouvée
|
// If an offset is asked
|
||||||
if (eregi('^'.$this->searchLastWithNoYear.'',$searchyy))
|
if (! empty($reg[2]) && eregi('^\+',$reg[2])) $maskoffset=eregi_replace('^\+','',$reg[2]);
|
||||||
{
|
if (! empty($reg[3]) && eregi('^\+',$reg[3])) $maskoffset=eregi_replace('^\+','',$reg[3]);
|
||||||
// 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 REGEXP '^".$searchyy."'";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$max = $row[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($conf->global->PROPALE_NUM_DELTA != '' && !eregi('^'.$this->searchLastWithPreviousYear.'',$previousyy))
|
|
||||||
{
|
|
||||||
// on applique le delta une seule fois
|
|
||||||
$max=$conf->global->PROPALE_NUM_DELTA?$conf->global->PROPALE_NUM_DELTA-1:0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$max=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On applique le nombre de chiffres du compteur
|
// If a restore to zero after a month is asked we check if there is already a value for this year.
|
||||||
$arg = '%0'.$this->numbitcounter.'s';
|
if (! empty($reg[2]) && eregi('^@',$reg[2])) $maskraz=eregi_replace('^@','',$reg[2]);
|
||||||
$num = sprintf($arg,$max+1);
|
if (! empty($reg[3]) && eregi('^@',$reg[3])) $maskraz=eregi_replace('^@','',$reg[3]);
|
||||||
$numFinal = '';
|
if ($maskraz >= 0)
|
||||||
|
{
|
||||||
|
if ($maskraz > 12) return 'ErrorBadMask';
|
||||||
|
if ($maskraz > 1 && ! eregi('^(.*)\{(y+)\}\{(m+)\}',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
|
||||||
|
if ($maskraz <= 1 && ! eregi('^(.*)\{(y+)\}',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask';
|
||||||
|
//print "x".$maskwithonlyymcode." ".$maskraz;
|
||||||
|
|
||||||
foreach($this->numMatrice as $objetMatrice)
|
// Define $yearcomp and $monthcomp (that will be use de filter request to search max number)
|
||||||
{
|
$monthcomp=$maskraz;
|
||||||
if ($objetMatrice == '-') $numFinal .= $objetMatrice;
|
$yearoffset=0;
|
||||||
if ($objetMatrice == '$prefix') $numFinal .= $this->prefix;
|
$yearcomp=0;
|
||||||
if ($objetMatrice == '$yy') $numFinal .= $this->yy;
|
if (date("m") < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year
|
||||||
if ($objetMatrice == '$mm') $numFinal .= $this->mm;
|
if (strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y")+$yearoffset);
|
||||||
if ($objetMatrice == '$num') $numFinal .= $num;
|
if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y")+$yearoffset);
|
||||||
}
|
if (strlen($reg[2]) == 1) $yearcomp=substr(date("y"),2,1)+$yearoffset;
|
||||||
|
|
||||||
dolibarr_syslog("mod_propale_saphir::getNextValue return ".$numFinal);
|
$sqlwhere='';
|
||||||
return $numFinal;
|
$sqlwhere.='SUBSTRING(facnumber, '.(strlen($reg[1])+1).', '.strlen($reg[2]).') >= '.$yearcomp;
|
||||||
}
|
if ($monthcomp > 1) // Test useless if monthcomp = 1 (or 0 is same as 1)
|
||||||
}
|
{
|
||||||
|
$sqlwhere.=' AND SUBSTRING(facnumber, '.(strlen($reg[1])+strlen($reg[2])+1).', '.strlen($reg[3]).') >= '.$monthcomp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
|
||||||
|
|
||||||
/** \brief Construction de la matrice de numérotation
|
$posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...)
|
||||||
* \param objsoc Objet société
|
if ($posnumstart < 0) return 'ErrorBadMask';
|
||||||
* \return string Valeur
|
$sqlstring='SUBSTRING(facnumber, '.($posnumstart+1).', '.strlen($maskcounter).')';
|
||||||
*/
|
//print "x".$sqlstring;
|
||||||
function buildMatrice($objsoc=0,$propale='')
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
$this->prefix = $conf->global->PROPALE_NUM_PREFIX;
|
// Get counter in database
|
||||||
$this->matrice = $conf->global->PROPALE_NUM_MATRICE;
|
$counter=0;
|
||||||
$this->searchLast = '';
|
$sql = "SELECT MAX(".$sqlstring.") as val";
|
||||||
$this->searchLastWithNoYear = '';
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
$this->searchLastWithPreviousYear = '';
|
$sql.= " WHERE facnumber not like '(%'";
|
||||||
|
if ($facture->type == 2) $sql.= " AND type = 2";
|
||||||
|
else $sql.=" AND type != 2";
|
||||||
|
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||||
|
|
||||||
if ($this->matrice != '')
|
//print $sql;
|
||||||
{
|
dolibarr_syslog("mod_facture_mercure::getNextValue sql=".$sql, LOG_DEBUG);
|
||||||
$resultatMatrice = Array();
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$counter = $obj->val;
|
||||||
|
}
|
||||||
|
else dolibarr_print_error($db);
|
||||||
|
if (empty($counter) || eregi('[^0-9]',$counter)) $counter=$maskoffset;
|
||||||
|
$counter++;
|
||||||
|
|
||||||
$matricePrefix = "PREF|COM"; // PREF : prefix libre (ex: PR pour propale), COM : prefix du client
|
// Build numFinal
|
||||||
$matriceYear = "[A]{2,4}"; // l'année est sur 2 ou 4 chiffres
|
$numFinal = $mask;
|
||||||
$matriceMonth = "[M]{2}"; // le mois est sur 2 chiffres
|
|
||||||
$matriceCounter = "[C]{1,}"; //le compteur a un nombre de chiffres libre
|
|
||||||
$matriceTiret = "[-]{1}"; // on recherche si il y a des tirets de séparation
|
|
||||||
|
|
||||||
$matriceSearch = Array('prefix'=>$matricePrefix,
|
// We replace special codes
|
||||||
'year'=>$matriceYear,
|
$numFinal = str_ireplace('{yyyy}',date("Y"),$numFinal);
|
||||||
'month'=>$matriceMonth,
|
$numFinal = str_ireplace('{yy}',date("y"),$numFinal);
|
||||||
'counter'=>$matriceCounter
|
$numFinal = str_ireplace('{y}' ,substr(date("y"),2,1),$numFinal);
|
||||||
);
|
$numFinal = str_ireplace('{mm}',date("m"),$numFinal);
|
||||||
|
$numFinal = str_ireplace('{dd}',date("d"),$numFinal);
|
||||||
|
|
||||||
// on détermine l'emplacement des tirets
|
// Now we replace the counter
|
||||||
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
$maskbefore='{'.$masktri.'}';
|
||||||
|
$maskafter=str_pad($counter,strlen($maskcounter),"0",STR_PAD_LEFT);
|
||||||
|
//print 'x'.$maskbefore.'-'.$maskafter.'y';
|
||||||
|
$numFinal = str_ireplace($maskbefore,$maskafter,$numFinal);
|
||||||
|
|
||||||
$j = 0;
|
dolibarr_syslog("mod_propale_saphir::getNextValue return ".$numFinal);
|
||||||
$k = 0;
|
return $numFinal;
|
||||||
|
}
|
||||||
|
|
||||||
// on détermine les objets de la matrice
|
|
||||||
for ($i = 0; $i < count($resultTiret); $i++)
|
|
||||||
{
|
|
||||||
foreach($resultTiret[$i] as $idResultTiret => $valueResultTiret)
|
|
||||||
{
|
|
||||||
// Ajout des tirets
|
|
||||||
if ($j != $resultTiret[$i][1])
|
|
||||||
{
|
|
||||||
$this->numMatrice[$k] = '-';
|
|
||||||
$this->searchLast .= '-';
|
|
||||||
$this->searchLastWithNoYear .= '-';
|
|
||||||
$this->searchLastWithPreviousYear .= '-';
|
|
||||||
$j = $resultTiret[$i][1];
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
foreach($matriceSearch as $idMatrice => $valueMatrice)
|
|
||||||
{
|
|
||||||
$resultCount = eregi(''.$valueMatrice.'',$valueResultTiret,$resultatMatrice);
|
|
||||||
if ($resultCount)
|
|
||||||
{
|
|
||||||
// On récupère le préfix utilisé
|
|
||||||
if ($idMatrice == 'prefix')
|
|
||||||
{
|
|
||||||
if ($resultatMatrice[0] == 'COM')
|
|
||||||
{
|
|
||||||
if ($objsoc->prefix_comm)
|
|
||||||
{
|
|
||||||
$this->prefix = $objsoc->prefix_comm;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->prefix = 'COM';
|
|
||||||
}
|
|
||||||
$this->numMatrice[$k] = '$prefix';
|
|
||||||
$this->searchLast .= $this->prefix;
|
|
||||||
$this->searchLastWithNoYear .= $this->prefix;
|
|
||||||
$this->searchLastWithPreviousYear .= $this->prefix;
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
else if ($resultatMatrice[0] == 'PREF')
|
|
||||||
{
|
|
||||||
$this->numMatrice[$k] = '$prefix';
|
|
||||||
$this->searchLast .= $this->prefix;
|
|
||||||
$this->searchLastWithNoYear .= $this->prefix;
|
|
||||||
$this->searchLastWithPreviousYear .= $this->prefix;
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($idMatrice == 'year')
|
|
||||||
{
|
|
||||||
// On récupère le nombre de chiffres pour l'année
|
|
||||||
$numbityear = $resultCount;
|
|
||||||
// On défini le mois du début d'année fiscale
|
|
||||||
$current_month = date("n");
|
|
||||||
|
|
||||||
if (is_object($propale) && $propale->date)
|
|
||||||
{
|
|
||||||
$create_month = strftime("%m",$propale->date);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$create_month = $current_month;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On change d'année fiscal si besoin
|
|
||||||
if($conf->global->SOCIETE_FISCAL_MONTH_START > 1 && $current_month >= $conf->global->SOCIETE_FISCAL_MONTH_START && $create_month >= $conf->global->SOCIETE_FISCAL_MONTH_START)
|
|
||||||
{
|
|
||||||
$this->yy = substr(strftime("%Y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")+1)),$numbityear);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->yy = substr(strftime("%Y",time()),$numbityear);
|
|
||||||
}
|
|
||||||
$this->numMatrice[$k] = '$yy';
|
|
||||||
$this->searchLast .= $this->yy;
|
|
||||||
for ($l = 1; $l <= $numbityear; $l++)
|
|
||||||
{
|
|
||||||
$this->searchLastWithNoYear .= '[0-9]';
|
|
||||||
}
|
|
||||||
$previousYear = substr(strftime("%Y",mktime(0,0,0,date("m"),date("d"),date("Y")-1)),$numbityear);
|
|
||||||
$this->searchLastWithPreviousYear .= $previousYear;
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
else if ($idMatrice == 'month')
|
|
||||||
{
|
|
||||||
// On récupère le mois si besoin
|
|
||||||
$this->mm = strftime("%m",time());
|
|
||||||
$this->numMatrice[$k] = '$mm';
|
|
||||||
$this->searchLast .= '[0-9][0-9]';
|
|
||||||
$this->searchLastWithNoYear .= '[0-9][0-9]';
|
|
||||||
$this->searchLastWithPreviousYear .= '[0-9][0-9]';
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
else if ($idMatrice == 'counter')
|
|
||||||
{
|
|
||||||
// On récupère le nombre de chiffres pour le compteur
|
|
||||||
$this->numbitcounter = $resultCount;
|
|
||||||
$this->numMatrice[$k] = '$num';
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user