diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index bda972dbf63..6c96938e22e 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Andre Cianfarani @@ -19,15 +19,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/commande.php \ingroup commande \brief Page d'administration-configuration du module Commande - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -45,6 +43,14 @@ if (!$user->admin) /* * Actions */ + +if ($_POST["action"] == 'updateMask') +{ + $maskconstorder=$_POST['maskconstorder']; + $maskorder=$_POST['maskorder']; + if ($maskconstorder) dolibarr_set_const($db,$maskconstorder,$maskorder); +} + if ($_GET["action"] == 'specimen') { $modele=$_GET["module"]; @@ -198,6 +204,10 @@ if ($handle) $module = new $file; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print ''.$module->nom."\n"; print $module->info(); @@ -219,13 +229,24 @@ if ($handle) $commande=new Commande($db); - // Info - $htmltooltip=''; + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type=0; $nextval=$module->getNextValue($mysoc,$commande); - if ($nextval != $langs->trans("NotAvailable")) - { - $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; - } + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + print ''; print $html->textwithhelp('',$htmltooltip,1,0); print ''; @@ -402,9 +423,9 @@ print ''; print $html->textwithhelp('',$htmltooltip,1,0); print ''; diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index a173148bf71..d1dbb5d5193 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne @@ -19,16 +19,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$ - * $Source$ */ /** \file htdocs/admin/propale.php \ingroup propale \brief Page d'administration/configuration du module Propale - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -48,6 +45,13 @@ if (!$user->admin) * Actions */ +if ($_POST["action"] == 'updateMask') +{ + $maskconstpropal=$_POST['maskconstpropal']; + $maskpropal=$_POST['maskpropal']; + if ($maskconstpropal) dolibarr_set_const($db,$maskconstpropal,$maskpropal); +} + if ($_GET["action"] == 'specimen') { $modele=$_GET["module"]; @@ -231,6 +235,10 @@ if ($handle) $module = new $file; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print ''.$module->nom."\n"; print $module->info(); @@ -254,12 +262,22 @@ if ($handle) // Info $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc,$propale); - if ($nextval != $langs->trans("NotAvailable")) - { - $htmltooltip.=''.$langs->trans("NextValue").': '.$nextval; - } + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type=0; + $nextval=$module->getNextValue($mysoc,$propale); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + print ''; print $html->textwithhelp('',$htmltooltip,1,0); print ''; diff --git a/htdocs/includes/modules/commande/mod_commande_marbre.php b/htdocs/includes/modules/commande/mod_commande_marbre.php index d6aeaca9a7f..894fc73090c 100644 --- a/htdocs/includes/modules/commande/mod_commande_marbre.php +++ b/htdocs/includes/modules/commande/mod_commande_marbre.php @@ -16,16 +16,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ */ /** \file htdocs/includes/modules/commande/mod_commande_marbre.php \ingroup commande \brief Fichier contenant la classe du modèle de numérotation de référence de commande Marbre - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); @@ -36,17 +33,11 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php class mod_commande_marbre extends ModeleNumRefCommandes { + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='CO'; var $error=''; - - /* - * \brief Constructeur - */ - function mod_commande_marbre() - { - $this->nom = "Marbre"; - } - + var $nom='Marbre'; + /** \brief Renvoi la description du modele de numérotation * \return string Texte descripif @@ -92,10 +83,12 @@ class mod_commande_marbre extends ModeleNumRefCommandes return true; } - /** \brief Renvoi prochaine valeur attribuée - * \return string Valeur - */ - function getNextValue() + /** \brief Return next value + * \param objsoc Objet third party + * \param commande Object order + * \return string Value if OK, 0 if KO + */ + function getNextValue($objsoc=0,$commande) { global $db; diff --git a/htdocs/includes/modules/commande/mod_commande_saphir.php b/htdocs/includes/modules/commande/mod_commande_saphir.php index e9d401a945c..2ceecf8d434 100644 --- a/htdocs/includes/modules/commande/mod_commande_saphir.php +++ b/htdocs/includes/modules/commande/mod_commande_saphir.php @@ -17,103 +17,58 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ - * */ /** \file htdocs/includes/modules/commande/mod_commande_saphir.php \ingroup commande \brief Fichier contenant la classe du modèle de numérotation de référence de commande Saphir - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); + /** \class mod_commande_saphir \brief Classe du modèle de numérotation de référence de commande Saphir */ class mod_commande_saphir extends ModeleNumRefCommandes { - var $prefix; - var $matrice; - var $numMatrice = Array(); - var $yy; - var $mm; - var $numbitcounter; - var $searchLast; - var $searchLastWithNoYear; - var $searchLastWithPreviousYear; + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $error = ''; - - /** \brief Constructeur - */ - function mod_commande_saphir() - { - $this->nom = "Saphir"; - } + var $nom = 'Saphir'; + /** \brief Renvoi la description du modele de numérotation * \return string Texte descripif */ -function info() + function info() { global $conf,$langs; - $langs->load("bills"); + $langs->load("bills"); - $form = new Form($db); + $form = new Form($db); - $texte = $langs->trans('SaphirNumRefModelDesc1')."
\n"; - $texte.= ''; - - // Paramétrage de la matrice - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - - // Paramétrage du prefix des commandes - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - - // On détermine un offset sur le compteur - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - - // On défini si le compteur se remet à zero en debut d'année - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - - // On affiche le debut d'année fiscale - $texte.= ''; - $texte.= ''; - - $texte.= '
Matrice de disposition des objets (prefix,mois,année,compteur...)
'.$form->textwithhelp('',$langs->trans("MatriceOrderDesc"),1,1).'
Préfix des commandes
'.$form->textwithhelp('',$langs->trans("PrefixOrderDesc"),1,1).'
Appliquer un offset sur le compteur
'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'
Le compteur se remet à zéro en début d\'année
'; - $texte.= $form->selectyesno('numrestart',$conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR,1); - $texte.= ''.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'
Début d\'année fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'

'; + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + // Parametrage du prefix des factures + $texte.= ''; + $texte.= ''; - return $texte; + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithhelp('',$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"),$langs->transnoentities("Order")),1,1).' 
'; + $texte.= '
'; + + return $texte; } /** \brief Renvoi un exemple de numérotation @@ -121,119 +76,128 @@ function info() */ function getExample() { - global $conf,$langs; + global $conf,$langs,$mysoc; - $numExample = ''; - - //On construit la matrice - $buildResult = $this->buildMatrice(); + $numExample = $this->getNextValue($mysoc,$propalspecimen); - if ($buildResult == 1) - { - // On récupère le nombre de chiffres du compteur - $arg = '%0'.$this->numbitcounter.'s'; - $num = sprintf($arg,$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_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é - * \return string Valeur + /** \brief Return next value + * \param objsoc Objet third party + * \param commande Object order + * \return string Value if OK, 0 if KO */ function getNextValue($objsoc=0,$commande) { - global $db,$conf; - - //On construit la matrice - $buildResult = $this->buildMatrice($objsoc,$commande); - - if ($buildResult == 1) - { - // On récupère la valeur max (réponse immédiate car champ indéxé) - $posindice = $this->numbitcounter; - $searchyy=''; - $sql = "SELECT MAX(ref)"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'"; - $resql=$db->query($sql); - if ($resql) - { - $row = $db->fetch_row($resql); - if ($row) $searchyy = substr($row[0],0,-$posindice); - } - if ($conf->global->COMMANDE_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(ref)"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'"; - $resql=$db->query($sql); - if ($resql) - { - $row = $db->fetch_row($resql); - if ($row) $previousyy = substr($row[0],0,-$posindice); - } - } + global $db,$conf; - // 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(ref,-".$posindice."))"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - $sql.= " WHERE ref REGEXP '^".$searchyy."'"; - $resql=$db->query($sql); - if ($resql) - { - $row = $db->fetch_row($resql); - $max = $row[0]; - } - } - else if ($conf->global->COMMANDE_NUM_DELTA != '' && !eregi('^'.$this->searchLastWithPreviousYear.'',$previousyy)) - { - // on applique le delta une seule fois - $max=$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_NUM_DELTA-1:0; - } - else - { - $max=0; - } - - // 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_commande_saphir::getNextValue return ".$numFinal); - return $numFinal; - } - } + // On défini critere recherche compteur + $mask=$conf->global->COMMANDE_SAPHIR_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + // Extract value for mask counter, mask raz and mask offset + if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask'; + $masktri=$reg[1].$reg[2].$reg[3]; + $maskcounter=$reg[1]; + $maskraz=-1; + $maskoffset=0; + if (strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + + $maskwithonlyymcode=$mask; + $maskwithonlyymcode=eregi_replace('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$maskcounter,$maskwithonlyymcode); + $maskwithonlyymcode=eregi_replace('\{dd\}','dd',$maskwithonlyymcode); + $maskwithnocode=$maskwithonlyymcode; + $maskwithnocode=eregi_replace('\{yyyy\}','yyyy',$maskwithnocode); + $maskwithnocode=eregi_replace('\{yy\}','yy',$maskwithnocode); + $maskwithnocode=eregi_replace('\{y\}','y',$maskwithnocode); + $maskwithnocode=eregi_replace('\{mm\}','mm',$maskwithnocode); + //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; + + // If an offset is asked + if (! empty($reg[2]) && eregi('^\+',$reg[2])) $maskoffset=eregi_replace('^\+','',$reg[2]); + if (! empty($reg[3]) && eregi('^\+',$reg[3])) $maskoffset=eregi_replace('^\+','',$reg[3]); + + // If a restore to zero after a month is asked we check if there is already a value for this year. + if (! empty($reg[2]) && eregi('^@',$reg[2])) $maskraz=eregi_replace('^@','',$reg[2]); + if (! empty($reg[3]) && eregi('^@',$reg[3])) $maskraz=eregi_replace('^@','',$reg[3]); + 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; + + // Define $yearcomp and $monthcomp (that will be use de filter request to search max number) + $monthcomp=$maskraz; + $yearoffset=0; + $yearcomp=0; + if (date("m") < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year + if (strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y")+$yearoffset); + if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y")+$yearoffset); + if (strlen($reg[2]) == 1) $yearcomp=substr(date("y"),2,1)+$yearoffset; + + $sqlwhere=''; + $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."
\n"; + + $posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...) + if ($posnumstart < 0) return 'ErrorBadMask'; + $sqlstring='SUBSTRING(facnumber, '.($posnumstart+1).', '.strlen($maskcounter).')'; + //print "x".$sqlstring; + + // Get counter in database + $counter=0; + $sql = "SELECT MAX(".$sqlstring.") as val"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande"; + $sql.= " WHERE ref not like '(%'"; + if ($sqlwhere) $sql.=' AND '.$sqlwhere; + + //print $sql; + dolibarr_syslog("mod_commande_saphir::getNextValue sql=".$sql, LOG_DEBUG); + $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++; + + // 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('{y}' ,substr(date("y"),2,1),$numFinal); + $numFinal = str_ireplace('{mm}',date("m"),$numFinal); + $numFinal = str_ireplace('{dd}',date("d"),$numFinal); + + // Now we replace the counter + $maskbefore='{'.$masktri.'}'; + $maskafter=str_pad($counter,strlen($maskcounter),"0",STR_PAD_LEFT); + //print 'x'.$maskbefore.'-'.$maskafter.'y'; + $numFinal = str_ireplace($maskbefore,$maskafter,$numFinal); + + dolibarr_syslog("mod_commande_saphir::getNextValue return ".$numFinal); + return $numFinal; + } /** \brief Renvoie la référence de commande suivante non utilisée @@ -246,154 +210,6 @@ function info() return $this->getNextValue($objsoc,$commande); } - - /** \brief Construction de la matrice de numérotation - * \param objsoc Objet société - * \return string Valeur - */ - function buildMatrice($objsoc=0,$commande='') - { - global $conf; - - $this->prefix = $conf->global->COMMANDE_NUM_PREFIX; - $this->matrice = $conf->global->COMMANDE_NUM_MATRICE; - $this->searchLast = ''; - $this->searchLastWithNoYear = ''; - $this->searchLastWithPreviousYear = ''; - - if ($this->matrice != '') - { - $resultatMatrice = Array(); - - $matricePrefix = "PREF|COM"; // PREF : prefix libre (ex: C pour commande), 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') - { - $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($commande) && $commande->date) - { - $create_month = strftime("%m",$commande->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",dolibarr_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/mercure/mercure.modules.php b/htdocs/includes/modules/facture/mercure/mercure.modules.php index e97a84eedf9..9c4b842d182 100644 --- a/htdocs/includes/modules/facture/mercure/mercure.modules.php +++ b/htdocs/includes/modules/facture/mercure/mercure.modules.php @@ -36,18 +36,9 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php") class mod_facture_mercure extends ModeleNumRefFactures { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' - var $prefixinvoice; - var $prefixcreditnote; - var $matrice; - var $numMatrice = Array(); - var $yy; - var $mm; - var $numbitcounter; - var $searchLast; - var $searchLastWithNoYear; - var $searchLastWithPreviousYear; var $error = ''; + /** \brief Renvoi la description du modele de numerotation * \return string Texte descripif */ @@ -59,7 +50,7 @@ class mod_facture_mercure extends ModeleNumRefFactures $form = new Form($db); - $texte = $langs->trans('MercureNumRefModelDesc1')."
\n"; + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= '
'; $texte.= ''; $texte.= ''; @@ -67,18 +58,16 @@ class mod_facture_mercure extends ModeleNumRefFactures $texte.= ''; // Parametrage du prefix des factures - $texte.= ''; - // $texte.= ''; - $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; // Parametrage du prefix des avoirs - $texte.= ''; - //$texte.= ''; - $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'.$form->textwithhelp('',$langs->trans("MercureMaskCodes"),1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):'.$form->textwithhelp('',$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")),1,1).' 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").')'.$form->textwithhelp('',$langs->trans("MercureMaskCodes"),1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithhelp('',$langs->trans("MercureMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")),1,1).'
'; @@ -94,7 +83,7 @@ class mod_facture_mercure extends ModeleNumRefFactures { global $conf,$langs,$mysoc; - $numExample = $this->getNextValue($mysoc,$facture); + $numExample = $this->getNextValue($mysoc,$facturespecimen); if (! $numExample) { @@ -230,5 +219,4 @@ class mod_facture_mercure extends ModeleNumRefFactures } } - ?> \ No newline at end of file diff --git a/htdocs/includes/modules/propale/mod_propale_saphir.php b/htdocs/includes/modules/propale/mod_propale_saphir.php index 96ac0b77665..1231ba9094d 100644 --- a/htdocs/includes/modules/propale/mod_propale_saphir.php +++ b/htdocs/includes/modules/propale/mod_propale_saphir.php @@ -51,7 +51,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $form = new Form($db); - $texte = $langs->trans('SaphirNumRefModelDesc1')."
\n"; + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; $texte.= ''; $texte.= ''; @@ -89,10 +89,10 @@ class mod_propale_saphir extends ModeleNumRefPropales /** \brief Return next value * \param objsoc Object third party - * \param facture Object invoice + * \param propal Object proposal * \return string Value if OK, 0 if KO */ - function getNextValue($objsoc,$facture) + function getNextValue($objsoc,$propal) { global $db,$conf; @@ -163,14 +163,12 @@ class mod_propale_saphir extends ModeleNumRefPropales // Get counter in database $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"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE ref not like '(%'"; if ($sqlwhere) $sql.=' AND '.$sqlwhere; //print $sql; - dolibarr_syslog("mod_facture_mercure::getNextValue sql=".$sql, LOG_DEBUG); + dolibarr_syslog("mod_propale_saphir::getNextValue sql=".$sql, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af28f6d76ca..61f32a85871 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -186,6 +186,9 @@ SetupIsReadyForUse=Install is finished and Dolibarr is ready for use with new co CurrentVersion=Dolibarr current version CallUpdatePage=Go on page that update database structure and datas %s. LastStableVersion=Last stable version +GenericMaskCodes=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 %s. 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 beginning by first %s.
{000000@x} same as previous but counter is reset to zero when month x is reached (x between 1 and 12). If this option is used, tag {yy} is required and also {mm} if x is 2 or higher.
{dd} invoice day (01 à 31).
{mm} invoice month (01 à 12).
{yy} or {yyyy} or {y} 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 %s of the third party TheCompany done 31/01/2007:
ABC{yy}{mm}-{000000} will give ABC0701-000099
{0000+100}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX
+GenericNumRefModelDesc=Return a customizable number according to a defined mask. + # Modules Module0Name=Users & groups Module0Desc=Users and groups management diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index b91b693e305..a2685d3b0d0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -341,10 +341,6 @@ PDFTourteauDescription=Invoice model Tourteau DefinedAndHasThisValue=Defined and value to IsNotDefined=undefined -# 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 beginning by first invoice.
{000000@x} same as previous but counter is reset to zero when month x is reached (x between 1 and 12). If this option is used, tag {yy} is required and also {mm} if x is 2 or higher.
{dd} invoice day (01 à 31).
{mm} invoice month (01 à 12).
{yy} or {yyyy} or {y} 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 ABC0701-000099
{0000+100}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX
-# terre TerreNumRefModelDesc1=Return numero with format %syymm-nnnn for standard invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0 TerreNumRefModelError=A bill starting with $syymm already exists and is not compatible with this model of sequence. Remove it or rename it to activate this module. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 25daad40cd6..b7acb57792e 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -185,6 +185,9 @@ SetupIsReadyForUse=L'installation est termin CurrentVersion=Version en cours de Dolibarr CallUpdatePage=Appeler la page de mise a jour de la structure et données de la base %s. LastStableVersion=Dernière version stable +GenericMaskCodes=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 %s. 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é dès la premiere %s.
{000000@x} idem précédemment mais le compteur est remis à zero le xeme mois de l'année (x entre 1 et 12). Si cette option est utilisée, la balise {yy} est aussi obligatoire ainsi que {mm} si x vaut 2 ou plus
{dd} jour de la facture (01 à 31).
{mm} jour de la facture (01 à 12).
{yy} ou {yyyy} ou {y} 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 %s du tiers LaCompanie faite le 31/03/2007:
ABC{yy}{mm}-{000000} donnera ABC0703-000099
{0000+100}-XXX/{dd}/YYY donnera 0199-XXX/31/YYY
+GenericNumRefModelDesc=Renvoie un numéro personalisable selon un masque à définir. + # Modules Module0Name=Utilisateurs & groupes Module0Desc=Gestion des utilisateurs et groupes diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 93f84e59d03..1c4aac2dc31 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -340,10 +340,6 @@ PDFTourteauDescription=Mod DefinedAndHasThisValue=Définie et vaut IsNotDefined=N'est pas définie -# 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é dès la premiere facture.
{000000@x} idem précédemment mais le compteur est remis à zero le xeme mois de l'année (x entre 1 et 12). Si cette option est utilisée, la balise {yy} est aussi obligatoire ainsi que {mm} si x vaut 2 ou plus
{dd} jour de la facture (01 à 31).
{mm} jour de la facture (01 à 12).
{yy} ou {yyyy} ou {y} 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/03/2007:
ABC{yy}{mm}-{000000} donnera ABC0703-000099
{0000+100}-XXX/{dd}/YYY donnera 0199-XXX/31/YYY
-# terre TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures et %syymm-nnnn pour les avoirs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0 TerreNumRefModelError=Une facture commençant par $syymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module.