From 68595e00e5778f5fda572af13990ce94d1fecba0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Mar 2008 01:14:45 +0000 Subject: [PATCH] =?UTF-8?q?Le=20mod=C3=A8le=20de=20num=C3=A9rotation=20de?= =?UTF-8?q?=20facture=20g=C3=A9n=C3=A9rique=20mercure=20est=20op=C3=A9rati?= =?UTF-8?q?onnel=20(Le=20prefix=20et=20l'offset=20ne=20sont=20oas=20encore?= =?UTF-8?q?=20g=C3=A9r=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/facture.php | 14 +- .../facture/mercure/mercure.modules.php | 381 ++++-------------- .../facture/neptune/neptune.modules.php | 157 -------- .../modules/facture/pluton/pluton.modules.php | 87 ++-- .../modules/facture/uranus/uranus.modules.php | 90 ----- htdocs/langs/en_US/bills.lang | 2 +- htdocs/langs/en_US/companies.lang | 1 - htdocs/langs/fr_FR/bills.lang | 2 +- 8 files changed, 141 insertions(+), 593 deletions(-) delete mode 100644 htdocs/includes/modules/facture/neptune/neptune.modules.php delete mode 100644 htdocs/includes/modules/facture/uranus/uranus.modules.php diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index c02500e2758..9a67bb549ad 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -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"]; diff --git a/htdocs/includes/modules/facture/mercure/mercure.modules.php b/htdocs/includes/modules/facture/mercure/mercure.modules.php index c6dff27cc8f..22c338f5660 100644 --- a/htdocs/includes/modules/facture/mercure/mercure.modules.php +++ b/htdocs/includes/modules/facture/mercure/mercure.modules.php @@ -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�le de num�rotation de r�f�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')."
\n"; $texte.= '
'; $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; - // Paramétrage du prefix des factures - $texte.= ''; + // Parametrage du prefix des factures + $texte.= ''; // $texte.= ''; $texte.= ''; $texte.= ''; - // Paramétrage du prefix des avoirs - $texte.= ''; + // Parametrage du prefix des avoirs + $texte.= ''; //$texte.= ''; $texte.= ''; $texte.= ''; @@ -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; - } - } } ?> \ No newline at end of file diff --git a/htdocs/includes/modules/facture/neptune/neptune.modules.php b/htdocs/includes/modules/facture/neptune/neptune.modules.php deleted file mode 100644 index 8cda16e6a7a..00000000000 --- a/htdocs/includes/modules/facture/neptune/neptune.modules.php +++ /dev/null @@ -1,157 +0,0 @@ - - * Copyright (C) 2004-2005 Laurent Destailleur - * Copyright (C) 2005 Regis Houssin - * - * 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')."
\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); - } - -} - -?> diff --git a/htdocs/includes/modules/facture/pluton/pluton.modules.php b/htdocs/includes/modules/facture/pluton/pluton.modules.php index a4a1c6ad03e..51beedfe509 100644 --- a/htdocs/includes/modules/facture/pluton/pluton.modules.php +++ b/htdocs/includes/modules/facture/pluton/pluton.modules.php @@ -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�le de num�rotation de r�f�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�le de num�rotation de r�f�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�rotation * \return string Texte descripif */ function info() @@ -65,8 +65,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte = $langs->trans('PlutonNumRefModelDesc1')."
\n"; $texte.= '
Modele numérotation factures
'.$langs->trans("InvoiceStandard").''.$form->textwithhelp('',$langs->trans("MercureMaskCodes"),1,1).'
Modèle numérotation avoirs
'.$langs->trans("InvoiceAvoir").''.$form->textwithhelp('',$langs->trans("MercureMaskCodes"),1,1).'
'; - // Paramétrage de la matrice - $texte.= ''; + // Param�trage de la matrice + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; @@ -74,8 +74,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''; $texte.= ''; - // Paramétrage du prefix des factures - $texte.= ''; + // Param�trage du prefix des factures + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; @@ -83,8 +83,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''; $texte.= ''; - // Paramétrage du prefix des avoirs - $texte.= ''; + // Param�trage du prefix des avoirs + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; @@ -92,7 +92,7 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''; $texte.= ''; - // On détermine un offset sur le compteur des factures + // On d�termine un offset sur le compteur des factures $texte.= ''; $texte.= ''; $texte.= ''; @@ -101,7 +101,7 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''; $texte.= ''; - // On détermine un offset sur le compteur des avoirs + // On d�termine un offset sur le compteur des avoirs $texte.= ''; $texte.= ''; $texte.= ''; @@ -110,8 +110,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''; $texte.= ''; - // On défini si le compteur se remet à zero en debut d'année - $texte.= ''; + // On d�fini si le compteur se remet � zero en debut d'ann�e + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; - // On défini si le compteur des avoirs s'incrémente avec les factures - $texte.= ''; + // On d�fini si le compteur des avoirs s'incr�mente avec les factures + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; - // On affiche le debut d'année fiscale - $texte.= ''; + // On affiche le debut d'ann�e fiscale + $texte.= ''; $texte.= ''; $texte.= '
Matrice de disposition des objets (prefix,mois,année,compteur...)
Matrice de disposition des objets (prefix,mois,ann�e,compteur...)'.$form->textwithhelp('',$langs->trans("MatriceInvoiceDesc"),1,1).'
Préfix des factures
Pr�fix des factures
'.$form->textwithhelp('',$langs->trans("PrefixInvoiceDesc"),1,1).'
Préfix des avoirs
Pr�fix des avoirs
'.$form->textwithhelp('',$langs->trans("PrefixCreditNoteDesc"),1,1).'
Appliquer un offset sur le compteur des factures
'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'
Appliquer un offset sur le compteur des avoirs
'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'
Le compteur se remet à zéro en début d\'année
Le compteur se remet � z�ro en d�but d\'ann�e
'; @@ -120,8 +120,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'
La numérotation des avoirs s\'incrémente avec les factures
La num�rotation des avoirs s\'incr�mente avec les factures
'; @@ -130,8 +130,8 @@ class mod_facture_pluton extends ModeleNumRefFactures $texte.= ''.$form->textwithhelp('',$langs->trans("CreditNoteNumWithInvoiceDesc"),1,1).'
Début d\'année fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'
D�but d\'ann�e fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'

'; @@ -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�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�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 + //On construit le num�ro � 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�e + * \param objsoc Objet soci�t� * \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�cup�re la valeur max (r�ponse imm�diate car champ ind�x�) $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�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"; @@ -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�le a �t� trouv�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� $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�f�rence de commande suivante non utilis�e + * \param objsoc Objet soci�t� * \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�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�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�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�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�cup�re le pr�fix utilis� 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�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�cup�re le nombre de chiffres pour l'ann�e $numbityear = $resultCount; - // On défini le mois du début d'année fiscale + // On d�fini le mois du d�but d'ann�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�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�cup�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�cup�re le nombre de chiffres pour le compteur $this->numbitcounter = $resultCount; $this->numMatrice[$k] = '$num'; $k++; diff --git a/htdocs/includes/modules/facture/uranus/uranus.modules.php b/htdocs/includes/modules/facture/uranus/uranus.modules.php deleted file mode 100644 index 78d24d3246c..00000000000 --- a/htdocs/includes/modules/facture/uranus/uranus.modules.php +++ /dev/null @@ -1,90 +0,0 @@ - - * Copyright (C) 2005 Regis Houssin - * - * 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 ); - - } -} -?> diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 89c8a1b8b0e..59e84ae8bc3 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -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:
{000000} 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.
{000000+000} same as previous but a corresponding offset to the number to the right of + is applied.
{dd} invoice day (01 à 31).
{mm} invoice month (01 à 12).
{yy} or {yyyy} year over 2 or 4 numbers of the invoice.
{pre} prefix of the third parties.
All other characters in the mask will remain intact.
Spaces are not allowed.

Example on the 99th invoice of the third party SFR done 31/01/2007:
ABC-{yy}{mm}-{000000} will give ABC-0701-000099
{0000}-{pre}/{dd}/INV will give 0099-SFR/31/INV
+MercureMaskCodes=You may enter all mask of numbering. In this mask, the following tags could be used:
{000000} 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.
{000000+000} same as previous but a corresponding offset to the number to the right of + is applied.
{dd} invoice day (01 à 31).
{mm} invoice month (01 à 12).
{yy} or {yyyy} year over 2 or 4 numbers of the invoice.
All other characters in the mask will remain intact.
Spaces are not allowed.

Example on the 99th invoice of the third party TheCompany done 31/01/2007:
ABC-{yy}{mm}-{000000} will give ABC-0701-000099
{0000}-ZZZ/{dd}/XXX will give 0099-ZZZ/31/XXX
# 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. diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 2afc6b7ed4d..583c410c48d 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -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:
{000000} 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.
{dd} days of the establishment code customer/supplier (01 à 31).
{mm} months of the establishment code customer/supplier (01 à 12).
{yy} or {yyyy} year over 2 or 4 numbers of the establishment of the code customer/supplier.
{pre} prefix of the third parties.
All other characters in the mask will remain intact.
You can use as separator characters following: slash, dash and backslash
Differentiating the elements used with a pipe | (altgr 6).
Spaces are not allowed.

Example of simple customer/supplier code
CC|(00000) will give CC00001
CF|-|(00000) will give CF-00001

Example on the 99th invoice of the third party SFR done 31/01/2007:
ABC-{yy}{mm}-{000000} will give ABC-0701-000099
{0000}-{pre}/{dd}/INV will give 0099-SFR/31/INV
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 278e8113ff0..5ae64a2213d 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -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:
{000000} 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.
{000000+000} idem précédemment mais un offset correpondant au nombre à droite du + est appliqué.
{dd} jour de la facture (01 à 31).
{mm} jour de la facture (01 à 12).
{yy} ou {yyyy} annee sur 2 ou 4 chiffres de la facture.
{pre} prefix du tiers.
Tout autre caractère dans le masque sera laissé inchangé.
Les espaces ne sont pas permis.

Exemple sur la 99eme facture du tiers SFR faite le 31/01/2007:
ABC-{yy}{mm}-{000000} donnera ABC-0701-000099
{0000}-{pre}/{dd}/INV donnera 0099-SFR/31/INV
+MercureMaskCodes=Vous pouvez saisir tout masque de numérotation. Dans ce masque, les balises suivantes peuvent etre utilisées:
{000000} 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.
{000000+000} idem précédemment mais un offset correpondant au nombre à droite du + est appliqué.
{dd} jour de la facture (01 à 31).
{mm} jour de la facture (01 à 12).
{yy} ou {yyyy} annee sur 2 ou 4 chiffres de la facture.
Tout autre caractère dans le masque sera laissé inchangé.
Les espaces ne sont pas permis.

Exemple sur la 99eme facture du tiers LaCompanie faite le 31/01/2007:
ABC-{yy}{mm}-{000000} donnera ABC-0701-000099
{0000}-XXX/{dd}/YYY donnera 0099-XXX/31/YYY
# 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.