2007-05-03 17:54:21 +02:00
|
|
|
|
<?php
|
|
|
|
|
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
|
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
|
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-05-04 11:23:15 +02:00
|
|
|
|
\file htdocs/includes/modules/commande/mod_commande_saphir.php
|
|
|
|
|
|
\ingroup commande
|
2007-05-03 17:54:21 +02:00
|
|
|
|
\brief Fichier contenant la classe du mod<EFBFBD>le de num<EFBFBD>rotation de r<EFBFBD>f<EFBFBD>rence de commande Saphir
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\class mod_commande_saphir
|
|
|
|
|
|
\brief Classe du mod<EFBFBD>le de num<EFBFBD>rotation de r<EFBFBD>f<EFBFBD>rence de commande Saphir
|
|
|
|
|
|
*/
|
|
|
|
|
|
class mod_commande_saphir extends ModeleNumRefCommandes
|
|
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
var $prefix;
|
|
|
|
|
|
var $matrice;
|
|
|
|
|
|
var $numMatrice = Array();
|
|
|
|
|
|
var $yy;
|
|
|
|
|
|
var $mm;
|
|
|
|
|
|
var $numbitcounter;
|
|
|
|
|
|
var $searchLast;
|
|
|
|
|
|
var $searchLastWithNoYear;
|
|
|
|
|
|
var $searchLastWithPreviousYear;
|
|
|
|
|
|
var $error = '';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
|
|
|
|
|
|
/** \brief Constructeur
|
|
|
|
|
|
*/
|
|
|
|
|
|
function mod_commande_saphir()
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->nom = "Saphir";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Renvoi la description du modele de num<EFBFBD>rotation
|
|
|
|
|
|
* \return string Texte descripif
|
|
|
|
|
|
*/
|
|
|
|
|
|
function info()
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
|
|
|
|
|
|
$langs->load("bills");
|
|
|
|
|
|
|
|
|
|
|
|
$form = new Form($db);
|
|
|
|
|
|
|
|
|
|
|
|
$texte = $langs->trans('SaphirNumRefModelDesc1')."<br>\n";
|
|
|
|
|
|
$texte.= '<table class="nobordernopadding" width="100%">';
|
|
|
|
|
|
|
|
|
|
|
|
// Param<61>trage de la matrice
|
|
|
|
|
|
$texte.= '<tr><td>Matrice de disposition des objets (prefix,mois,ann<6E>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->COMMANDE_NUM_MATRICE.'"></td>';
|
|
|
|
|
|
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
|
|
|
|
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("MatriceOrderDesc"),1,1).'</td>';
|
|
|
|
|
|
$texte.= '</tr></form>';
|
|
|
|
|
|
|
|
|
|
|
|
// Param<61>trage du prefix des commandes
|
|
|
|
|
|
$texte.= '<tr><td>Pr<50>fix des commandes</td>';
|
|
|
|
|
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2007-05-19 14:53:48 +02:00
|
|
|
|
$texte.= '<input type="hidden" name="action" value="updatePrefix">';
|
|
|
|
|
|
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefix" value="'.$conf->global->COMMANDE_NUM_PREFIX.'"></td>';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
|
|
|
|
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixOrderDesc"),1,1).'</td>';
|
|
|
|
|
|
$texte.= '</tr></form>';
|
|
|
|
|
|
|
|
|
|
|
|
// On d<>termine un offset sur le compteur
|
|
|
|
|
|
$texte.= '<tr><td>Appliquer un offset sur le compteur</td>';
|
|
|
|
|
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
|
|
|
|
$texte.= '<input type="hidden" name="action" value="setOffset">';
|
2007-05-15 17:53:46 +02:00
|
|
|
|
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="offset" value="'.$conf->global->COMMANDE_NUM_DELTA.'"></td>';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
|
|
|
|
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'</td>';
|
|
|
|
|
|
$texte.= '</tr></form>';
|
|
|
|
|
|
|
|
|
|
|
|
// On d<>fini le debut d'ann<6E>e fiscale
|
|
|
|
|
|
$texte.= '<tr><td>D<>but d\'ann<6E>e fiscale</td>';
|
|
|
|
|
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
|
|
|
|
$texte.= '<input type="hidden" name="action" value="setFiscalMonth">';
|
|
|
|
|
|
$texte.= '<td align="right">';
|
|
|
|
|
|
$texte.= $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonth',1);
|
|
|
|
|
|
$texte.= '</td><td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
|
|
|
|
$texte.= '<td aligne="center">'.$form->textwithwarning('',$langs->trans("FiscalMonthStartDesc"),1).'</td>';
|
|
|
|
|
|
$texte.= '</tr></form>';
|
|
|
|
|
|
|
|
|
|
|
|
// On d<>fini si le compteur se remet <20> zero en debut d'ann<6E>e
|
|
|
|
|
|
$texte.= '<tr><td>Le compteur se remet <20> 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">';
|
|
|
|
|
|
$texte.= $form->selectyesno('numrestart',$conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR,1);
|
|
|
|
|
|
$texte.= '</td><td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
|
|
|
|
|
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'</td>';
|
|
|
|
|
|
$texte.= '</tr></form>';
|
|
|
|
|
|
|
|
|
|
|
|
$texte.= '</table><br>';
|
|
|
|
|
|
|
|
|
|
|
|
return $texte;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Renvoi un exemple de num<EFBFBD>rotation
|
|
|
|
|
|
* \return string Example
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getExample()
|
|
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
global $conf,$langs;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$numExample = '';
|
|
|
|
|
|
|
|
|
|
|
|
//On construit la matrice
|
|
|
|
|
|
$buildResult = $this->buildMatrice();
|
2007-05-03 17:54:21 +02:00
|
|
|
|
|
2007-05-19 19:14:14 +02:00
|
|
|
|
if ($buildResult == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>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<75>ro <20> partir de la matrice
|
|
|
|
|
|
foreach($this->numMatrice as $objetMatrice)
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
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;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
2007-05-19 19:14:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$numExample = $langs->trans('NotConfigured');
|
|
|
|
|
|
}
|
|
|
|
|
|
return $numExample;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2007-05-19 19:14:14 +02:00
|
|
|
|
/** \brief Renvoi prochaine valeur attribu<EFBFBD>e
|
2007-05-03 17:54:21 +02:00
|
|
|
|
* \param objsoc Objet soci<EFBFBD>t<EFBFBD>
|
|
|
|
|
|
* \return string Valeur
|
|
|
|
|
|
*/
|
2007-05-19 19:14:14 +02:00
|
|
|
|
function getNextValue($objsoc=0,$commande)
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
global $db,$conf;
|
|
|
|
|
|
|
2007-05-19 19:14:14 +02:00
|
|
|
|
//On construit la matrice
|
|
|
|
|
|
$buildResult = $this->buildMatrice($objsoc,$commande);
|
|
|
|
|
|
|
|
|
|
|
|
if ($buildResult == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
|
|
|
|
|
$posindice = $this->numbitcounter;
|
|
|
|
|
|
$searchyy='';
|
|
|
|
|
|
$sql = "SELECT MAX(ref)";
|
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
2007-07-19 19:32:06 +02:00
|
|
|
|
if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'";
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$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<6E>e pr<70>c<EFBFBD>dente
|
|
|
|
|
|
//pour <20>viter que le delta soit appliqu<71> de nouveau sur la nouvelle ann<6E>e
|
|
|
|
|
|
$previousyy='';
|
|
|
|
|
|
$sql = "SELECT MAX(ref)";
|
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
2007-07-19 19:32:06 +02:00
|
|
|
|
$sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'";
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
$row = $db->fetch_row($resql);
|
|
|
|
|
|
if ($row) $previousyy = substr($row[0],0,-$posindice);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Si au moins un champ respectant le mod<6F>le a <20>t<EFBFBD> trouv<75>e
|
|
|
|
|
|
if (eregi('^'.$this->searchLastWithNoYear.'',$searchyy))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Recherche rapide car restreint par un like sur champ index<65>
|
|
|
|
|
|
$sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))";
|
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
2007-07-19 19:32:06 +02:00
|
|
|
|
$sql.= " WHERE ref REGEXP '^".$searchyy."'";
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Renvoie la r<EFBFBD>f<EFBFBD>rence de commande suivante non utilis<EFBFBD>e
|
|
|
|
|
|
* \param objsoc Objet soci<EFBFBD>t<EFBFBD>
|
|
|
|
|
|
* \param commande Objet commande
|
|
|
|
|
|
* \return string Texte descripif
|
|
|
|
|
|
*/
|
|
|
|
|
|
function commande_get_num($objsoc=0,$commande)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->getNextValue($objsoc,$commande);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Construction de la matrice de num<EFBFBD>rotation
|
|
|
|
|
|
* \param objsoc Objet soci<EFBFBD>t<EFBFBD>
|
|
|
|
|
|
* \return string Valeur
|
|
|
|
|
|
*/
|
|
|
|
|
|
function buildMatrice($objsoc=0,$commande='')
|
|
|
|
|
|
{
|
|
|
|
|
|
global $conf;
|
|
|
|
|
|
|
2007-05-19 14:53:48 +02:00
|
|
|
|
$this->prefix = $conf->global->COMMANDE_NUM_PREFIX;
|
|
|
|
|
|
$this->matrice = $conf->global->COMMANDE_NUM_MATRICE;
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->searchLast = '';
|
|
|
|
|
|
$this->searchLastWithNoYear = '';
|
|
|
|
|
|
$this->searchLastWithPreviousYear = '';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
|
2007-05-19 14:53:48 +02:00
|
|
|
|
if ($this->matrice != '')
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
$resultatMatrice = Array();
|
|
|
|
|
|
|
|
|
|
|
|
$matricePrefix = "PREF|COM"; // PREF : prefix libre (ex: C pour commande), COM : prefix du client
|
|
|
|
|
|
$matriceYear = "[A]{2,4}"; // l'ann<6E>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
|
|
|
|
|
|
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$matriceSearch = Array('prefix'=>$matricePrefix,
|
2007-05-03 17:54:21 +02:00
|
|
|
|
'year'=>$matriceYear,
|
|
|
|
|
|
'month'=>$matriceMonth,
|
|
|
|
|
|
'counter'=>$matriceCounter
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// on d<>termine l'emplacement des tirets
|
2007-05-19 14:53:48 +02:00
|
|
|
|
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
2007-05-03 17:54:21 +02:00
|
|
|
|
|
|
|
|
|
|
$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])
|
|
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->numMatrice[$k] = '-';
|
|
|
|
|
|
$this->searchLast .= '-';
|
|
|
|
|
|
$this->searchLastWithNoYear .= '-';
|
|
|
|
|
|
$this->searchLastWithPreviousYear .= '-';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$j = $resultTiret[$i][1];
|
|
|
|
|
|
$k++;
|
|
|
|
|
|
}
|
2007-05-19 19:14:14 +02:00
|
|
|
|
foreach($matriceSearch as $idMatrice => $valueMatrice)
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
$resultCount = eregi(''.$valueMatrice.'',$valueResultTiret,$resultatMatrice);
|
|
|
|
|
|
if ($resultCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>re le pr<70>fix utilis<69>
|
2007-05-19 19:14:14 +02:00
|
|
|
|
if ($idMatrice == 'prefix')
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
if ($resultatMatrice[0] == 'COM')
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
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++;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
2007-05-19 19:14:14 +02:00
|
|
|
|
else if ($resultatMatrice[0] == 'PREF')
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->numMatrice[$k] = '$prefix';
|
|
|
|
|
|
$this->searchLast .= $this->prefix;
|
|
|
|
|
|
$this->searchLastWithNoYear .= $this->prefix;
|
|
|
|
|
|
$this->searchLastWithPreviousYear .= $this->prefix;
|
|
|
|
|
|
$k++;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ($idMatrice == 'year')
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>re le nombre de chiffres pour l'ann<6E>e
|
|
|
|
|
|
$numbityear = $resultCount;
|
|
|
|
|
|
// On d<>fini le mois du d<>but d'ann<6E>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<6E>e fiscal si besoin
|
2007-05-28 21:47:21 +02:00
|
|
|
|
if($conf->global->SOCIETE_FISCAL_MONTH_START > 1 && $current_month >= $conf->global->SOCIETE_FISCAL_MONTH_START && $create_month >= $conf->global->SOCIETE_FISCAL_MONTH_START)
|
2007-05-03 17:54:21 +02:00
|
|
|
|
{
|
2007-08-08 17:14:52 +02:00
|
|
|
|
$this->yy = substr(strftime("%Y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")+1)),$numbityear);
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->yy = substr(strftime("%Y",time()),$numbityear);
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->numMatrice[$k] = '$yy';
|
|
|
|
|
|
$this->searchLast .= $this->yy;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
for ($l = 1; $l <= $numbityear; $l++)
|
|
|
|
|
|
{
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->searchLastWithNoYear .= '[0-9]';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
2007-08-08 17:14:52 +02:00
|
|
|
|
$previousYear = substr(strftime("%Y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")-1)),$numbityear);
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->searchLastWithPreviousYear .= $previousYear;
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$k++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ($idMatrice == 'month')
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>re le mois si besoin
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->mm = strftime("%m",time());
|
|
|
|
|
|
$this->numMatrice[$k] = '$mm';
|
2007-07-19 19:32:06 +02:00
|
|
|
|
$this->searchLast .= '[0-9][0-9]';
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->searchLastWithNoYear .= '[0-9][0-9]';
|
2007-07-19 19:32:06 +02:00
|
|
|
|
$this->searchLastWithPreviousYear .= '[0-9][0-9]';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$k++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ($idMatrice == 'counter')
|
|
|
|
|
|
{
|
|
|
|
|
|
// On r<>cup<75>re le nombre de chiffres pour le compteur
|
2007-05-19 19:14:14 +02:00
|
|
|
|
$this->numbitcounter = $resultCount;
|
|
|
|
|
|
$this->numMatrice[$k] = '$num';
|
2007-05-03 17:54:21 +02:00
|
|
|
|
$k++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-05-19 19:14:14 +02:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return -3;
|
|
|
|
|
|
}
|
2007-05-19 14:53:48 +02:00
|
|
|
|
}
|
2007-05-03 17:54:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|