Le modèle de numérotation de facture générique mercure est opérationnel (Le prefix et l'offset ne sont oas encore géré)

This commit is contained in:
Laurent Destailleur 2008-03-04 01:14:45 +00:00
parent 1cd42f728a
commit 68595e00e5
8 changed files with 141 additions and 593 deletions

View File

@ -17,15 +17,13 @@
* 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.
*
* $Id$
*/
/**
\file htdocs/admin/facture.php
\ingroup facture
\brief Page d'administration/configuration du module Facture
\version $Revision$
\version $Id$
*/
require("./pre.inc.php");
@ -47,6 +45,16 @@ $dir = DOL_DOCUMENT_ROOT."/includes/modules/facture/";
/*
* Actions
*/
if ($_POST["action"] == 'updateMask')
{
$maskconstinvoice=$_POST['maskconstinvoice'];
$maskconstcredit=$_POST['maskconstcredit'];
$maskinvoice=$_POST['maskinvoice'];
$maskcredit=$_POST['maskcredit'];
if ($maskconstinvoice) dolibarr_set_const($db,$maskconstinvoice,$maskinvoice);
if ($maskconstcredit) dolibarr_set_const($db,$maskconstcredit,$maskcredit);
}
if ($_GET["action"] == 'specimen')
{
$modele=$_GET["module"];

View File

@ -17,28 +17,24 @@
* 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/facture/mercure/mercure.modules.php
\ingroup facture
\brief Fichier contenant la classe du modèle de numérotation de référence de facture Mercure
\version $Revision$
\brief Class filte of Mercure numbering module for invoice
\version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
/**
\class mod_facture_pluton
\brief Classe du modèle de numérotation de référence de facture Mercure
\brief Classe du mod<EFBFBD>le de num<EFBFBD>rotation de r<EFBFBD>f<EFBFBD>rence de facture Mercure
*/
class mod_facture_mercure extends ModeleNumRefFactures
{
var $version='development'; // 'development', 'experimental', 'dolibarr'
var $version='experimental'; // 'development', 'experimental', 'dolibarr'
var $prefixinvoice;
var $prefixcreditnote;
var $matrice;
@ -51,7 +47,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
var $searchLastWithPreviousYear;
var $error = '';
/** \brief Renvoi la description du modele de numérotation
/** \brief Renvoi la description du modele de numerotation
* \return string Texte descripif
*/
function info()
@ -65,16 +61,18 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte = $langs->trans('MercureNumRefModelDesc1')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstinvoice" value="FACTURE_MERCURE_MASK_INVOICE">';
$texte.= '<input type="hidden" name="maskconstcredit" value="FACTURE_MERCURE_MASK_CREDIT">';
$texte.= '<table class="nobordernopadding" width="100%">';
// Paramétrage du prefix des factures
$texte.= '<tr><td>Modele numérotation factures</td>';
// Parametrage du prefix des factures
$texte.= '<tr><td>'.$langs->trans("InvoiceStandard").'</td>';
// $texte.= '<td align="right"><input type="text" class="flat" size="24" name="prefixfacture" value="'.$conf->global->FACTURE_NUM_PREFIX.'"></td>';
$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->FACTURE_MERCURE_MASK_INVOICE.'">',$langs->trans("MercureMaskCodes"),1,1).'</td>';
$texte.= '</tr>';
// Paramétrage du prefix des avoirs
$texte.= '<tr><td>Modèle numérotation avoirs</td>';
// Parametrage du prefix des avoirs
$texte.= '<tr><td>'.$langs->trans("InvoiceAvoir").'</td>';
//$texte.= '<td align="right"><input type="text" class="flat" size="24" name="prefixavoir" value="'.$conf->global->AVOIR_NUM_PREFIX.'"></td>';
$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->FACTURE_MERCURE_MASK_CREDIT.'">',$langs->trans("MercureMaskCodes"),1,1).'</td>';
$texte.= '</tr>';
@ -87,147 +85,95 @@ class mod_facture_mercure extends ModeleNumRefFactures
return $texte;
}
/** \brief Renvoi un exemple de numérotation
/** \brief Renvoi un exemple de numerotation
* \return string Example
*/
function getExample()
{
global $conf,$langs;
global $conf,$langs,$mysoc;
$numExample = '';
$buildResult = $this->buildMatrice();
$numExample = $this->getNextValue($mysoc,$facture);
if ($buildResult == 1)
{
// On récupère le nombre de chiffres du compteur
$arg = '%0'.$this->numbitcounter.'s';
$num = sprintf($arg,$conf->global->FACTURE_NUM_DELTA?$conf->global->FACTURE_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;
if (! $numExample)
{
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
/** \brief Renvoi prochaine valeur attribuée
* \param objsoc Objet société
/** \brief Renvoi prochaine valeur attribuee
* \param objsoc Objet societe
* \param facture Objet facture
* \return string Valeur
*/
function getNextValue($objsoc,$facture)
{
global $db,$conf;
$buildResult = $this->buildMatrice($objsoc,$facture);
if ($buildResult == 1)
{
function getNextValue($objsoc,$facture)
{
global $db,$conf;
// On récupère la valeur max (réponse immédiate car champ indéxé)
$posindice = $this->numbitcounter;
$searchyy='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
if ($conf->global->FACTURE_NUM_RESTART_BEGIN_YEAR)
{
$sql.= " WHERE facnumber REGEXP '^".$this->searchLast."'";
}
else if ($facture->type == 2)
{
$sql.= " WHERE type = 2 AND facnumber REGEXP '^".$this->prefixcreditnote."'";
}
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $searchyy = substr($row[0],0,-$posindice);
}
if ($conf->global->FACTURE_NUM_DELTA || $conf->global->AVOIR_NUM_DELTA)
{
//on vérifie si il y a une année précédente
//pour éviter que le delta soit appliqué de nouveau sur la nouvelle année
$previousyy='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber REGEXP '^".$this->searchLastWithPreviousYear."'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $previousyy = substr($row[0],0,-$posindice);
}
}
// On défini critere recherche compteur
if ($facture->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
if (! $mask) return 'Error format not defined';
// Si au moins un champ respectant le modèle a été trouvée
if (eregi('^'.$this->searchLastWithNoYear.'',$searchyy))
{
// 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 REGEXP '^".$searchyy."'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$max = $row[0];
}
}
else if ($facture->type < 2 && $conf->global->FACTURE_NUM_DELTA != '' && !eregi('^'.$this->searchLastWithPreviousYear.'',$previousyy))
{
// on applique le delta une seule fois
$max=$conf->global->FACTURE_NUM_DELTA?$conf->global->FACTURE_NUM_DELTA-1:0;
}
else if ($facture->type == 2 && $conf->global->AVOIR_NUM_DELTA != '' && !eregi('^'.$this->searchLastWithPreviousYear.'',$previousyy))
{
// on applique le delta une seule fois
$max=$conf->global->AVOIR_NUM_DELTA?$conf->global->AVOIR_NUM_DELTA-1:0;
}
else
{
$max=0;
}
// Replace all code that ar not {0...0}
$newmask=$mask;
$newmask=str_ireplace('{yyyy}','yyyy',$newmask);
$newmask=str_ireplace('{yy}','yy',$newmask);
$newmask=str_ireplace('{mm}','mm',$newmask);
$newmask=str_ireplace('{dd}','dd',$newmask);
//print "newmask=".$newmask;
$posnumstart=strpos($newmask,'{0'); // Pos of {
$posnumend =strpos($newmask,'0}')+1; // Pos of }
if ($posnumstart <= 0 || $posnumend <= 1) return 'Error in format';
$sqlstring='SUBSTRING(facnumber, '.($posnumstart+1).', '.($posnumend-$posnumstart-1).')';
//print "x".$sqlstring;
$counter=0;
$sql = "SELECT MAX(".$sqlstring.") as val";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber not like '(%'";
if ($facture->type == 2) $sql.= " AND type = 2";
else $sql.=" AND type != 2";
//print $sql;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$counter = $obj->val;
}
if (eregi('[^0-9]',$counter)) $counter=0;
$counter++;
$sizeofnum=$posnumend-$posnumstart;
//print $counter."-".$sizeofnum."-".$posnumstart."-".$posnumend;
// Build numFinal
$numFinal = $mask;
// We replace special codes
$numFinal = str_ireplace('{yyyy}',date("Y"),$numFinal);
$numFinal = str_ireplace('{yy}',date("y"),$numFinal);
$numFinal = str_ireplace('{mm}',date("m"),$numFinal);
$numFinal = str_ireplace('{dd}',date("d"),$numFinal);
// On replace le prefix de l'avoir
if ($conf->global->AVOIR_NUM_WITH_INVOICE && $facture->type == 2)
{
$this->prefix = $this->prefixcreditnote;
}
// On applique le nombre de chiffres du compteur
$arg = '%0'.$this->numbitcounter.'s';
$num = sprintf($arg,$max+1);
$numFinal = '';
foreach($this->numMatrice as $objetMatrice)
{
if ($objetMatrice == '-') $numFinal .= $objetMatrice;
if ($objetMatrice == '$prefix') $numFinal .= $this->prefix;
if ($objetMatrice == '$yy') $numFinal .= $this->yy;
if ($objetMatrice == '$mm') $numFinal .= $this->mm;
if ($objetMatrice == '$num') $numFinal .= $num;
}
dolibarr_syslog("mod_facture_pluton::getNextValue return ".$numFinal);
return $numFinal;
}
}
// Now we replace the counter
$nummask='{'.str_pad('',$sizeofnum-1,"0").'}';
$numcount=str_pad($counter,$sizeofnum-1,"0",STR_PAD_LEFT);
//print 'x'.$nummask.'-'.$sizeofnum.'y';
$numFinal = str_ireplace($nummask,$numcount,$numFinal);
dolibarr_syslog("mod_facture_mercure::getNextValue return ".$numFinal);
return $numFinal;
}
/** \brief Renvoie la référence de commande suivante non utilisée
* \param objsoc Objet société
/** \brief Renvoie la reference de commande suivante non utilisee
* \param objsoc Objet societe
* \param facture Objet facture
* \return string Texte descripif
*/
@ -236,165 +182,6 @@ class mod_facture_mercure extends ModeleNumRefFactures
return $this->getNextValue($objsoc,$facture);
}
/** \brief Construction de la matrice de numérotation
* \param objsoc Objet société
* \return string Valeur
*/
function buildMatrice($objsoc=0,$facture='')
{
global $conf;
$this->prefixinvoice = $conf->global->FACTURE_NUM_PREFIX;
$this->prefixcreditnote = $conf->global->AVOIR_NUM_PREFIX;
$this->matrice = $conf->global->FACTURE_NUM_MATRICE;
$this->searchLast = '';
$this->searchLastWithNoYear = '';
$this->searchLastWithPreviousYear = '';
$this->version='development';
if ($this->matrice != '')
{
$resultatMatrice = Array();
$matricePrefix = "PREF|COM"; // PREF : prefix libre (ex: FA pour facture, AV pour avoir), COM : prefix du client
$matriceYear = "[A]{2,4}"; // l'année est sur 2 ou 4 chiffres
$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,
'year'=>$matriceYear,
'month'=>$matriceMonth,
'counter'=>$matriceCounter
);
// on détermine l'emplacement des tirets
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$j = 0;
$k = 0;
// 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')
{
// Les avoirs peuvent suivre la numérotation des factures
if (!$conf->global->AVOIR_NUM_WITH_INVOICE && $facture->type == 2)
{
$thisPrefix = $this->prefixcreditnote;
}
else
{
$thisPrefix = $this->prefixinvoice;
}
$this->prefix = $thisPrefix;
$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($facture) && $facture->date)
{
$create_month = strftime("%m",$facture->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",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;
}
}
}
?>

View File

@ -1,157 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 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/facture/neptune/neptune.modules.php
\ingroup facture
\brief Fichier contenant la classe du modèle de numérotation de référence de facture Neptune
\version $Revision$
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
/**
\class mod_facture_neptune
\brief Classe du modèle de numérotation de référence de facture Neptune
*/
class mod_facture_neptune extends ModeleNumRefFactures
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
/** \brief Renvoi la description du modele de numérotation
* \return string Texte descripif
*/
function info()
{
global $langs;
$langs->load("bills");
$texte = $langs->trans('NeptuneNumRefModelDesc1')."<br>\n";
$texte.= $langs->trans('NeptuneNumRefModelDesc2');
if (defined("FACTURE_NEPTUNE_DELTA"))
{
$texte .= ' ('.$langs->trans('DefinedAndHasThisValue').' : '.FACTURE_NEPTUNE_DELTA.')';
}
else
{
$texte .= ' ('.$langs->trans('IsNotDefined').')';
}
return $texte;
}
/** \brief Renvoi un exemple de numérotation
* \return string Example
*/
function getExample()
{
global $conf;
if ($conf->global->FACTURE_NEPTUNE_DELTA)
{
return "FA04".sprintf("%04d",$conf->global->FACTURE_NEPTUNE_DELTA);
}
else
{
return "FA040001";
}
}
/** \brief Renvoie la référence de facture suivante non utilisée
* \param objsoc Objet société
* \param facture Objet facture
* \return string Texte descripif
*/
function getNextValue($objsoc,$facture)
{
global $db,$conf;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$fayy = 'FA'.strftime("%y",time());
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '${fayy}%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$fayy='';
if ($row) $fayy = substr($row[0],0,4);
}
//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 = 'FA'.strftime("%y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")-1));
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '${lastyy}%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$lastyy='';
if ($row) $lastyy = substr($row[0],0,4);
}
// Si champ respectant le modèle a été trouvée
if (eregi('^FA[0-9][0-9]',$fayy))
{
// Recherche rapide car restreint par un like sur champ indexé
$posindice=5;
$sql = "SELECT MAX(0+SUBSTRING(facnumber,$posindice))";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '${fayy}%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$max = $row[0];
}
}
else if (!eregi('FA[0-9][0-9]',$lastyy))
{
$max=$conf->global->FACTURE_NEPTUNE_DELTA?$conf->global->FACTURE_NEPTUNE_DELTA:0;
}
else
{
$max=0;
}
$yy = strftime("%y",time());
$num = sprintf("%04s",$max+1);
return "FA$yy$num";
}
/** \brief Renvoie la référence de facture suivante non utilisée
* \param objsoc Objet société
* \param facture Objet facture
* \return string Texte descripif
*/
function getNumRef($objsoc=0,$facture)
{
return $this->getNextValue($objsoc,$facture);
}
}
?>

View File

@ -26,7 +26,7 @@
/**
\file htdocs/includes/modules/facture/pluton/pluton.modules.php
\ingroup facture
\brief Fichier contenant la classe du modèle de numérotation de référence de facture Pluton
\brief Fichier contenant la classe du mod<EFBFBD>le de num<EFBFBD>rotation de r<EFBFBD>f<EFBFBD>rence de facture Pluton
\version $Revision$
*/
@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
/**
\class mod_facture_pluton
\brief Classe du modèle de numérotation de référence de facture Pluton
\brief Classe du mod<EFBFBD>le de num<EFBFBD>rotation de r<EFBFBD>f<EFBFBD>rence de facture Pluton
*/
class mod_facture_pluton extends ModeleNumRefFactures
{
@ -51,7 +51,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
var $searchLastWithPreviousYear;
var $error = '';
/** \brief Renvoi la description du modele de numérotation
/** \brief Renvoi la description du modele de num<EFBFBD>rotation
* \return string Texte descripif
*/
function info()
@ -65,8 +65,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte = $langs->trans('PlutonNumRefModelDesc1')."<br>\n";
$texte.= '<table class="nobordernopadding" width="100%">';
// Paramétrage de la matrice
$texte.= '<tr><td>Matrice de disposition des objets (prefix,mois,année,compteur...)</td>';
// Param<EFBFBD>trage de la matrice
$texte.= '<tr><td>Matrice de disposition des objets (prefix,mois,ann<EFBFBD>e,compteur...)</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="updateMatrice">';
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="matrice" value="'.$conf->global->FACTURE_NUM_MATRICE.'"></td>';
@ -74,8 +74,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("MatriceInvoiceDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// Paramétrage du prefix des factures
$texte.= '<tr><td>Préfix des factures</td>';
// Param<EFBFBD>trage du prefix des factures
$texte.= '<tr><td>Pr<EFBFBD>fix des factures</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="updatePrefixFacture">';
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefixfacture" value="'.$conf->global->FACTURE_NUM_PREFIX.'"></td>';
@ -83,8 +83,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixInvoiceDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// Paramétrage du prefix des avoirs
$texte.= '<tr><td>Préfix des avoirs</td>';
// Param<EFBFBD>trage du prefix des avoirs
$texte.= '<tr><td>Pr<EFBFBD>fix des avoirs</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="updatePrefixAvoir">';
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefixavoir" value="'.$conf->global->AVOIR_NUM_PREFIX.'"></td>';
@ -92,7 +92,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixCreditNoteDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// On détermine un offset sur le compteur des factures
// On d<EFBFBD>termine un offset sur le compteur des factures
$texte.= '<tr><td>Appliquer un offset sur le compteur des factures</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="setOffsetInvoice">';
@ -101,7 +101,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// On détermine un offset sur le compteur des avoirs
// On d<EFBFBD>termine un offset sur le compteur des avoirs
$texte.= '<tr><td>Appliquer un offset sur le compteur des avoirs</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="setOffsetCreditNote">';
@ -110,8 +110,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$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.= '<tr><td>Le compteur se remet à zéro en début d\'année</td>';
// On d<EFBFBD>fini si le compteur se remet <20> zero en debut d'ann<6E>e
$texte.= '<tr><td>Le compteur se remet <EFBFBD> z<>ro en d<>but d\'ann<6E>e</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="setNumRestart">';
$texte.= '<td align="right">';
@ -120,8 +120,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// On défini si le compteur des avoirs s'incrémente avec les factures
$texte.= '<tr><td>La numérotation des avoirs s\'incrémente avec les factures</td>';
// On d<EFBFBD>fini si le compteur des avoirs s'incr<63>mente avec les factures
$texte.= '<tr><td>La num<EFBFBD>rotation des avoirs s\'incr<63>mente avec les factures</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="setNumWithInvoice">';
$texte.= '<td align="right">';
@ -130,8 +130,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("CreditNoteNumWithInvoiceDesc"),1,1).'</td>';
$texte.= '</tr></form>';
// On affiche le debut d'année fiscale
$texte.= '<tr><td colspan="3">Début d\'année fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'</td>';
// On affiche le debut d'ann<EFBFBD>e fiscale
$texte.= '<tr><td colspan="3">D<EFBFBD>but d\'ann<6E>e fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'</td>';
$texte.= '</tr>';
$texte.= '</table><br>';
@ -139,7 +139,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
return $texte;
}
/** \brief Renvoi un exemple de numérotation
/** \brief Renvoi un exemple de num<EFBFBD>rotation
* \return string Example
*/
function getExample()
@ -152,11 +152,11 @@ class mod_facture_pluton extends ModeleNumRefFactures
if ($buildResult == 1)
{
// On récupère le nombre de chiffres du compteur
// On r<EFBFBD>cup<EFBFBD>re le nombre de chiffres du compteur
$arg = '%0'.$this->numbitcounter.'s';
$num = sprintf($arg,$conf->global->FACTURE_NUM_DELTA?$conf->global->FACTURE_NUM_DELTA:1);
//On construit le numéro à partir de la matrice
//On construit le num<EFBFBD>ro <20> partir de la matrice
foreach($this->numMatrice as $objetMatrice)
{
if ($objetMatrice == '-') $numExample .= $objetMatrice;
@ -173,8 +173,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
return $numExample;
}
/** \brief Renvoi prochaine valeur attribuée
* \param objsoc Objet société
/** \brief Renvoi prochaine valeur attribu<EFBFBD>e
* \param objsoc Objet soci<EFBFBD>t<EFBFBD>
* \param facture Objet facture
* \return string Valeur
*/
@ -187,7 +187,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
if ($buildResult == 1)
{
// On récupère la valeur max (réponse immédiate car champ indéxé)
// On r<EFBFBD>cup<EFBFBD>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
$posindice = $this->numbitcounter;
$searchyy='';
$sql = "SELECT MAX(facnumber)";
@ -209,8 +209,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
if ($conf->global->FACTURE_NUM_DELTA || $conf->global->AVOIR_NUM_DELTA)
{
//on vérifie si il y a une année précédente
//pour éviter que le delta soit appliqué de nouveau sur la nouvelle année
//on v<EFBFBD>rifie si il y a une ann<6E>e pr<70>c<EFBFBD>dente
//pour <EFBFBD>viter que le delta soit appliqu<71> de nouveau sur la nouvelle ann<6E>e
$previousyy='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
@ -223,10 +223,10 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
}
// Si au moins un champ respectant le modèle a été trouvée
// Si au moins un champ respectant le mod<EFBFBD>le a <20>t<EFBFBD> trouv<75>e
if (eregi('^'.$this->searchLastWithNoYear.'',$searchyy))
{
// Recherche rapide car restreint par un like sur champ indexé
// Recherche rapide car restreint par un like sur champ index<EFBFBD>
$sql = "SELECT MAX(0+SUBSTRING(facnumber,-".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber REGEXP '^".$searchyy."'";
@ -278,8 +278,8 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
/** \brief Renvoie la référence de commande suivante non utilisée
* \param objsoc Objet société
/** \brief Renvoie la r<EFBFBD>f<EFBFBD>rence de commande suivante non utilis<EFBFBD>e
* \param objsoc Objet soci<EFBFBD>t<EFBFBD>
* \param facture Objet facture
* \return string Texte descripif
*/
@ -288,9 +288,10 @@ class mod_facture_pluton extends ModeleNumRefFactures
return $this->getNextValue($objsoc,$facture);
}
/** \brief Construction de la matrice de numérotation
* \param objsoc Objet société
* \return string Valeur
/**
* \brief Construction de la matrice de numrotation
* \param objsoc Objet societe
* \return string Valeur
*/
function buildMatrice($objsoc=0,$facture='')
{
@ -308,10 +309,10 @@ class mod_facture_pluton extends ModeleNumRefFactures
$resultatMatrice = Array();
$matricePrefix = "PREF|COM"; // PREF : prefix libre (ex: FA pour facture, AV pour avoir), COM : prefix du client
$matriceYear = "[A]{2,4}"; // l'année est sur 2 ou 4 chiffres
$matriceYear = "[A]{2,4}"; // l'ann<EFBFBD>e est sur 2 ou 4 chiffres
$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
$matriceTiret = "[-]{1}"; // on recherche si il y a des tirets de s<EFBFBD>paration
$matriceSearch = Array('prefix'=>$matricePrefix,
'year'=>$matriceYear,
@ -319,13 +320,13 @@ class mod_facture_pluton extends ModeleNumRefFactures
'counter'=>$matriceCounter
);
// on détermine l'emplacement des tirets
// on d<EFBFBD>termine l'emplacement des tirets
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$j = 0;
$k = 0;
// on détermine les objets de la matrice
// on d<EFBFBD>termine les objets de la matrice
for ($i = 0; $i < count($resultTiret); $i++)
{
foreach($resultTiret[$i] as $idResultTiret => $valueResultTiret)
@ -345,7 +346,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
$resultCount = eregi(''.$valueMatrice.'',$valueResultTiret,$resultatMatrice);
if ($resultCount)
{
// On récupère le préfix utilisé
// On r<EFBFBD>cup<EFBFBD>re le pr<70>fix utilis<69>
if ($idMatrice == 'prefix')
{
if ($resultatMatrice[0] == 'COM')
@ -366,7 +367,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
else if ($resultatMatrice[0] == 'PREF')
{
// Les avoirs peuvent suivre la numérotation des factures
// Les avoirs peuvent suivre la num<EFBFBD>rotation des factures
if (!$conf->global->AVOIR_NUM_WITH_INVOICE && $facture->type == 2)
{
$thisPrefix = $this->prefixcreditnote;
@ -385,9 +386,9 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
else if ($idMatrice == 'year')
{
// On récupère le nombre de chiffres pour l'année
// On r<EFBFBD>cup<EFBFBD>re le nombre de chiffres pour l'ann<6E>e
$numbityear = $resultCount;
// On défini le mois du début d'année fiscale
// On d<EFBFBD>fini le mois du d<>but d'ann<6E>e fiscale
$current_month = date("n");
if (is_object($facture) && $facture->date)
@ -399,7 +400,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
$create_month = $current_month;
}
// On change d'année fiscal si besoin
// On change d'ann<EFBFBD>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",mktime(0,0,0,date("m"),date("d"),date("Y")+1)),$numbityear);
@ -420,7 +421,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
else if ($idMatrice == 'month')
{
// On récupère le mois si besoin
// On r<EFBFBD>cup<EFBFBD>re le mois si besoin
$this->mm = strftime("%m",time());
$this->numMatrice[$k] = '$mm';
$this->searchLast .= '[0-9][0-9]';
@ -430,7 +431,7 @@ class mod_facture_pluton extends ModeleNumRefFactures
}
else if ($idMatrice == 'counter')
{
// On récupère le nombre de chiffres pour le compteur
// On r<EFBFBD>cup<EFBFBD>re le nombre de chiffres pour le compteur
$this->numbitcounter = $resultCount;
$this->numMatrice[$k] = '$num';
$k++;

View File

@ -1,90 +0,0 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* 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/facture/uranus/uranus.modules.php
\ingroup facture
\brief Fichier contenant la classe du modèle de numérotation de référence de facture Uranus
\version $Revision$
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
/*!
\class mod_facture_uranus
\brief Classe du modèle de numérotation de référence de facture Uranus
*/
class mod_facture_uranus extends ModeleNumRefFactures
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
/*! \brief Renvoi la description du modele de numérotation
* \return string Texte descripif
*/
function info()
{
global $langs;
$langs->load("bills");
return '
'.$langs->trans('UranusNumRefModelDesc1');
}
/*! \brief Renvoi un exemple de numérotation
* \return string Example
*/
function getExample()
{
return "5000001";
}
/*! \brief Renvoie la référence de facture suivante non utilisée
* \param objsoc Objet société
* \return string Texte descripif
*/
function getNumRef($objsoc=0)
{
global $db;
$y = substr(strftime("%y",time()), -1);
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE fk_statut > 0";
$sql .= " AND facnumber LIKE '$y%'";
$sql .= " AND CHAR_LENGTH(facnumber) = 7";
if ( $db->query($sql) )
{
$row = $db->fetch_row(0);
$num = $row[0] + 1;
}
return "$y" . substr("000000".$num, -6 );
}
}
?>

View File

@ -361,7 +361,7 @@ MarsNumRefModelDesc3=If the constant FACTURE_MARS_DELTA is defined, an offset is
# mercure
MercureNumRefModelDesc1=Return a customizable invoice number according to a defined mask.
MercureMaskCodes=You may enter all mask of numbering. In this mask, the following tags could be used:<br><b>{000000}</b> correspond to a number which will be incremented on each invoice. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros at the left in order to have as many zeros as the mask. <br><b>{000000+000}</b> same as previous but a corresponding offset to the number to the right of + is applied. <br><b>{dd}</b> invoice day (01 à 31).<br><b>{mm}</b> invoice month (01 à 12).<br><b>{yy}</b> or {yyyy} year over 2 or 4 numbers of the invoice.<br><b>{pre}</b> prefix of the third parties.<br>All other characters in the mask will remain intact.<br>Spaces are not allowed.<br><br><u>Example on the 99th invoice of the third party SFR done 31/01/2007:</u><br><b>ABC-{yy}{mm}-{000000}</b> will give <b>ABC-0701-000099</b><br><b>{0000}-{pre}/{dd}/INV</b> will give <b>0099-SFR/31/INV</b><br>
MercureMaskCodes=You may enter all mask of numbering. In this mask, the following tags could be used:<br><b>{000000}</b> correspond to a number which will be incremented on each invoice. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros at the left in order to have as many zeros as the mask. <br><b>{000000+000}</b> same as previous but a corresponding offset to the number to the right of + is applied. <br><b>{dd}</b> invoice day (01 à 31).<br><b>{mm}</b> invoice month (01 à 12).<br><b>{yy}</b> or {yyyy} year over 2 or 4 numbers of the invoice.<br>All other characters in the mask will remain intact.<br>Spaces are not allowed.<br><br><u>Example on the 99th invoice of the third party TheCompany done 31/01/2007:</u><br><b>ABC-{yy}{mm}-{000000}</b> will give <b>ABC-0701-000099</b><br><b>{0000}-ZZZ/{dd}/XXX</b> will give <b>0099-ZZZ/31/XXX</b><br>
# neptune
NeptuneNumRefModelDesc1=Return the invoice number under the format of the prefix FA followed by the year over 2 numbers and a simple counter over 4 numbers.

View File

@ -244,4 +244,3 @@ FiscalMonthStart=Starting month of the fiscal year
# Tigre
TigreNumRefModelDesc1=Return a customizable customer/supplier number according to a defined mask.
MercureMaskCodes=You may enter all mask of numbering. In this mask, the following tags could be used:<br><b>{000000}</b> correspond to a number which will be incremented on each customer/supplier. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros at the left in order to have as many zeros as the mask. <br><b>{dd}</b> days of the establishment code customer/supplier (01 à 31).<br><b>{mm}</b> months of the establishment code customer/supplier (01 à 12).<br><b>{yy}</b> or {yyyy} year over 2 or 4 numbers of the establishment of the code customer/supplier.<br><b>{pre}</b> prefix of the third parties.<br>All other characters in the mask will remain intact.<br> You can use as separator characters following: slash, dash and backslash <br> Differentiating the elements used with a pipe <b>|</b> (altgr 6).<br>Spaces are not allowed.<br><br><u>Example of simple customer/supplier code</u><br><b>CC|(00000)</b> will give <b>CC00001</b><br><b>CF|-|(00000)</b> will give <b>CF-00001</b><br><br><u>Example on the 99th invoice of the third party SFR done 31/01/2007:</u><br><b>ABC-{yy}{mm}-{000000}</b> will give <b>ABC-0701-000099</b><br><b>{0000}-{pre}/{dd}/INV</b> will give <b>0099-SFR/31/INV</b><br>

View File

@ -360,7 +360,7 @@ MarsNumRefModelDesc3=Si la constante FACTURE_MARS_DELTA est d
# mercure
MercureNumRefModelDesc1=Renvoie un numéro de facture personalisable selon un masque à définir.
MercureMaskCodes=Vous pouvez saisir tout masque de numérotation. Dans ce masque, les balises suivantes peuvent etre utilisées:<br><b>{000000}</b> correspond a un numéro qui sera incrémenté à chaque facture. Mettre autant de zéro que la longueur désirée du compteur. Le compteur sera complété par des 0 à gauche afin d'avoir autant de zéro que dans le masque.<br><b>{000000+000}</b> idem précédemment mais un offset correpondant au nombre à droite du + est appliqué.<br><b>{dd}</b> jour de la facture (01 à 31).<br><b>{mm}</b> jour de la facture (01 à 12).<br><b>{yy}</b> ou {yyyy} annee sur 2 ou 4 chiffres de la facture.<br><b>{pre}</b> prefix du tiers.<br>Tout autre caractère dans le masque sera laissé inchangé.<br>Les espaces ne sont pas permis.<br><br><u>Exemple sur la 99eme facture du tiers SFR faite le 31/01/2007:</u><br><b>ABC-{yy}{mm}-{000000}</b> donnera <b>ABC-0701-000099</b><br><b>{0000}-{pre}/{dd}/INV</b> donnera <b>0099-SFR/31/INV</b><br>
MercureMaskCodes=Vous pouvez saisir tout masque de numérotation. Dans ce masque, les balises suivantes peuvent etre utilisées:<br><b>{000000}</b> correspond a un numéro qui sera incrémenté à chaque facture. Mettre autant de zéro que la longueur désirée du compteur. Le compteur sera complété par des 0 à gauche afin d'avoir autant de zéro que dans le masque.<br><b>{000000+000}</b> idem précédemment mais un offset correpondant au nombre à droite du + est appliqué.<br><b>{dd}</b> jour de la facture (01 à 31).<br><b>{mm}</b> jour de la facture (01 à 12).<br><b>{yy}</b> ou {yyyy} annee sur 2 ou 4 chiffres de la facture.<br>Tout autre caractère dans le masque sera laissé inchangé.<br>Les espaces ne sont pas permis.<br><br><u>Exemple sur la 99eme facture du tiers LaCompanie faite le 31/01/2007:</u><br><b>ABC-{yy}{mm}-{000000}</b> donnera <b>ABC-0701-000099</b><br><b>{0000}-XXX/{dd}/YYY</b> donnera <b>0099-XXX/31/YYY</b><br>
# neptune
NeptuneNumRefModelDesc1=Renvoie le numéro de facture sous une forme du préfix FA suivi de l'année sur 2 chiffres et d'un compteur simple sur 4 chiffres.