diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 849e0772a94..796765678bf 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -241,12 +241,21 @@ while (($file = readdir($handle))!==false)
}
print '';
+ $facture=new Facture($db);
+
// Info
$htmltooltip='';
- $nextval=$module->getNextValue($mysoc,'');
+ $facture->type=0;
+ $nextval=$module->getNextValue($mysoc,$facture);
if ($nextval != $langs->trans("NotAvailable"))
{
- $htmltooltip=''.$langs->trans("NextValue").': '.$nextval;
+ $htmltooltip.=''.$langs->trans("NextValueForInvoices").': '.$nextval.'
';
+ }
+ $facture->type=2;
+ $nextval=$module->getNextValue($mysoc,$facture);
+ if ($nextval != $langs->trans("NotAvailable"))
+ {
+ $htmltooltip.=''.$langs->trans("NextValueForCreditNotes").': '.$nextval;
}
print '
';
print $html->textwithhelp('',$htmltooltip,1,0);
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index e80f991b509..ad8fb5f9f5b 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -166,7 +166,7 @@ if ($handle)
// Info
$htmltooltip='';
- $nextval=$module->getNextValue();
+ $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip=''.$langs->trans("NextValue").': '.$nextval;
diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php
index 6c0f14e3c72..de552514a93 100644
--- a/htdocs/admin/fournisseur.php
+++ b/htdocs/admin/fournisseur.php
@@ -165,7 +165,7 @@ if ($handle)
// Info
$htmltooltip='';
- $nextval=$module->getNextValue();
+ $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip=''.$langs->trans("NextValue").': '.$nextval;
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index 26d70289184..863a6157bc9 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -187,7 +187,7 @@ if ($handle)
// Info
$htmltooltip='';
- $nextval=$module->getNextValue();
+ $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip=''.$langs->trans("NextValue").': '.$nextval;
diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php
index 62b06846311..92ab6c0315d 100644
--- a/htdocs/admin/propale.php
+++ b/htdocs/admin/propale.php
@@ -218,7 +218,7 @@ if ($handle)
// Info
$htmltooltip='';
- $nextval=$module->getNextValue();
+ $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip=''.$langs->trans("NextValue").': '.$nextval;
diff --git a/htdocs/includes/modules/facture/deneb/deneb.modules.php b/htdocs/includes/modules/facture/deneb/deneb.modules.php
index 9123e66f414..04cd3db39a0 100644
--- a/htdocs/includes/modules/facture/deneb/deneb.modules.php
+++ b/htdocs/includes/modules/facture/deneb/deneb.modules.php
@@ -20,7 +20,6 @@
*
* $Id$
* $Source$
- *
*/
/**
diff --git a/htdocs/includes/modules/facture/janus/janus.modules.php b/htdocs/includes/modules/facture/janus/janus.modules.php
index c3f9ffbaa10..5da1a1cea72 100644
--- a/htdocs/includes/modules/facture/janus/janus.modules.php
+++ b/htdocs/includes/modules/facture/janus/janus.modules.php
@@ -20,7 +20,6 @@
*
* $Id$
* $Source$
- *
*/
/*!
diff --git a/htdocs/includes/modules/facture/mars/mars.modules.php b/htdocs/includes/modules/facture/mars/mars.modules.php
index cf14fb58e7b..1d829bc7d10 100644
--- a/htdocs/includes/modules/facture/mars/mars.modules.php
+++ b/htdocs/includes/modules/facture/mars/mars.modules.php
@@ -21,7 +21,6 @@
*
* $Id$
* $Source$
- *
*/
/**
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index 2f626470bd9..2c84b9e97ba 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -91,48 +91,49 @@ class ModelePDFFactures extends FPDF
\class ModeleNumRefFactures
\brief Classe mère des modèles de numérotation des références de facture
*/
-
class ModeleNumRefFactures
{
- var $error='';
-
- /** \brief Renvoi la description par defaut du modele de numérotation
- * \return string Texte descripif
- */
- function info()
- {
- global $langs;
- $langs->load("bills");
- return $langs->trans("NoDescription");
- }
-
- /** \brief Renvoi un exemple de numérotation
- * \return string Example
- */
- function getExample()
- {
- global $langs;
- $langs->load("bills");
- return $langs->trans("NoExample");
- }
-
- /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
- * de conflits qui empechera cette numérotation de fonctionner.
- * \return boolean false si conflit, true si ok
- */
- function canBeActivated()
- {
- return true;
- }
-
- /** \brief Renvoi prochaine valeur attribuée
- * \return string Valeur
- */
- function getNextValue()
- {
- global $langs;
- return $langs->trans("NotAvailable");
- }
+ var $error='';
+
+ /** \brief Renvoi la description par defaut du modele de numérotation
+ * \return string Texte descripif
+ */
+ function info()
+ {
+ global $langs;
+ $langs->load("bills");
+ return $langs->trans("NoDescription");
+ }
+
+ /** \brief Renvoi un exemple de numérotation
+ * \return string Example
+ */
+ function getExample()
+ {
+ global $langs;
+ $langs->load("bills");
+ return $langs->trans("NoExample");
+ }
+
+ /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
+ * de conflits qui empechera cette numérotation de fonctionner.
+ * \return boolean false si conflit, true si ok
+ */
+ function canBeActivated()
+ {
+ return true;
+ }
+
+ /** \brief Renvoi prochaine valeur attribuée
+ * \param objsoc Objet societe
+ * \param facture Objet facture
+ * \return string Valeur
+ */
+ function getNextValue($objsoc,$facture)
+ {
+ global $langs;
+ return $langs->trans("NotAvailable");
+ }
}
diff --git a/htdocs/includes/modules/facture/neptune/neptune.modules.php b/htdocs/includes/modules/facture/neptune/neptune.modules.php
index bb166181dc2..61d5b625dc1 100644
--- a/htdocs/includes/modules/facture/neptune/neptune.modules.php
+++ b/htdocs/includes/modules/facture/neptune/neptune.modules.php
@@ -20,7 +20,6 @@
*
* $Id$
* $Source$
- *
*/
/**
@@ -82,7 +81,7 @@ class mod_facture_neptune extends ModeleNumRefFactures
* \param facture Objet facture
* \return string Texte descripif
*/
- function getNextValue($objsoc=0,$facture)
+ function getNextValue($objsoc,$facture)
{
global $db,$conf;
diff --git a/htdocs/includes/modules/facture/orion/orion.modules.php b/htdocs/includes/modules/facture/orion/orion.modules.php
index a7ed314a1bf..1556f5086a7 100644
--- a/htdocs/includes/modules/facture/orion/orion.modules.php
+++ b/htdocs/includes/modules/facture/orion/orion.modules.php
@@ -20,7 +20,6 @@
*
* $Id$
* $Source$
- *
*/
/**
diff --git a/htdocs/includes/modules/facture/terre/terre.modules.php b/htdocs/includes/modules/facture/terre/terre.modules.php
index 1a4c27dc79b..05d6b4530fa 100644
--- a/htdocs/includes/modules/facture/terre/terre.modules.php
+++ b/htdocs/includes/modules/facture/terre/terre.modules.php
@@ -36,7 +36,8 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
class mod_facture_terre extends ModeleNumRefFactures
{
- var $prefix='FA';
+ var $prefixinvoice='FA';
+ var $prefixcreditnote='AV';
var $error='';
/** \brief Renvoi la description du modele de numérotation
@@ -48,7 +49,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$langs->load("bills");
- return $langs->trans('TerreNumRefModelDesc1',$this->prefix);
+ return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote);
}
/** \brief Renvoi un exemple de numérotation
@@ -56,7 +57,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/
function getExample()
{
- return $this->prefix."0501-0001";
+ return $this->prefixinvoice."0501-0001";
}
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
@@ -67,41 +68,65 @@ class mod_facture_terre extends ModeleNumRefFactures
{
global $langs;
- $langs->load("bills");
+ $langs->load("bills");
- $fayymm='';
+ // Check invoice num
+ $fayymm='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $sql.= " WHERE facnumber like '".$this->prefixinvoice."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $fayymm = substr($row[0],0,6);
}
- if (! $fayymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
- {
- return true;
- }
- else
+ if ($fayymm && eregi($this->prefixinvoice.'[0-9][0-9][0-9][0-9]',$fayymm))
{
$this->error=$langs->trans('TerreNumRefModelError');
return false;
}
+
+ // Check credit note num
+ $fayymm='';
+
+ $sql = "SELECT MAX(facnumber)";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $sql.= " WHERE facnumber like '".$this->prefixcreditnote."%'";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $row = $db->fetch_row($resql);
+ if ($row) $fayymm = substr($row[0],0,6);
+ }
+ if ($fayymm && eregi($this->prefixcreditnote.'[0-9][0-9][0-9][0-9]',$fayymm))
+ {
+ $this->error=$langs->trans('TerreNumRefModelError');
+ return false;
+ }
+
+ return true;
}
/** \brief Renvoi prochaine valeur attribuée
+ * \param objsoc Objet societe
* \param facture Objet facture
* \return string Valeur
*/
- function getNextValue($facture)
+ function getNextValue($objsoc,$facture)
{
global $db;
+ if ($facture->type == 2) $prefix=$this->prefixcreditnote;
+ else $prefix=$this->prefixinvoice;
+
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$fayymm='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $sql.= " WHERE facnumber like '".$prefix."%'";
+
$resql=$db->query($sql);
if ($resql)
{
@@ -115,7 +140,7 @@ class mod_facture_terre extends ModeleNumRefFactures
}
// Si champ respectant le modèle a été trouvée
- if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
+ if (eregi('^'.$prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
{
// Recherche rapide car restreint par un like sur champ indexé
$posindice=8;
@@ -136,8 +161,8 @@ class mod_facture_terre extends ModeleNumRefFactures
$yymm = strftime("%y%m",time());
$num = sprintf("%04s",$max+1);
- dolibarr_syslog("mod_facture_terre::getNextValue return ".$this->prefix."$yymm-$num");
- return $this->prefix."$yymm-$num";
+ dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix."$yymm-$num");
+ return $prefix."$yymm-$num";
}
/** \brief Renvoie la référence de facture suivante non utilisée
@@ -147,7 +172,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/
function getNumRef($objsoc=0,$facture)
{
- return $this->getNextValue($facture);
+ return $this->getNextValue($objsoc,$facture);
}
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 7abefd6b44d..36aa2e2164b 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -22,6 +22,8 @@ NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
JavascriptDisabled=Javascript disabled
UsePopupCalendar=Use popup for dates input
NextValue=Next value
+NextValueForInvoices=Next value (invoices)
+NextValueForCreditNotes=Next value (credit notes)
MustBeLowerThanPHPLimit=Note: your PHP limits upload size to %s %s, whatever is thi sparameter value
NoMaxSizeByPHPLimit=Note: No limit are built in your PHP
ComptaSetup=Accounting module setup
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 5db37c3d0a1..41bb0f0534a 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -14,9 +14,9 @@ InvoiceStandardDesc=This kind of invoice is the common invoice.
InvoiceReplacement=Replacement invoice. Must replace invoice with reference
InvoiceReplacementAsk=Replacement invoice for invoice
InvoiceReplacementDesc=Replacement invoice is used to cancel and replace completely an invoice with no paiement already recevided. Reference of canceled invoice is required.
-InvoiceAvoir=Avoir invoice
-InvoiceAvoirAsk=Avoir invoice to correct invoice
-InvoiceAvoirDesc=La facture d'avoir est une facture négative destinée à compenser une facture comportant un montant supérieur à ce qui a été ou sera réellement payé (toutes causes possibles).
+InvoiceAvoir=Credit note
+InvoiceAvoirAsk=Credit note to correct invoice
+InvoiceAvoirDesc=The credit note is a negative invoice used to solve fact that an invoice has an higher amount that amount that was or will be payed (all possible reasons).
ReplaceInvoice=Replace invoice %s
ReplacedByInvoice=Replaced by invoice %s
CorrectInvoice=Correct invoice %s
@@ -119,7 +119,7 @@ ConfirmClassifyPayedPartiallyReasonDiscountVat=Remainder to pay (%s %s) i
ConfirmClassifyPayedPartiallyReasonAbandon=Debit irremediably not recoverable (bad customer...)
ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: « escompte net de taxe »)
ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
-ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix à prendre si les autres ne sont pas applicables
+ConfirmClassifyPayedPartiallyAvoir=Use this choice if all other does not suit
ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement
ConfirmCustomerPayment=Do you confirm this paiement input for %s %s ?
ValidateBill=Validate invoice
@@ -128,7 +128,7 @@ NumberOfBillsByMonth=Nb of invoices by month
ShowBill=Show invoice
ShowInvoice=Show invoice
ShowInvoiceReplace=Show replacing invoice
-ShowInvoiceAvoir=Show avoir invoice
+ShowInvoiceAvoir=Show credit note
ShowPayment=Show payment
File=File
AlreadyPayed=Already payed
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index a68726b65f5..08f29d2342d 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -22,6 +22,8 @@ NotAvailableWhenAjaxDisabled=Non disponible quand Ajax d
JavascriptDisabled=Javascript désactivé
UsePopupCalendar=Utiliser les popups pour la saisie des dates
NextValue=Prochaine valeur
+NextValueForInvoices=Prochaine valeur (factures)
+NextValueForCreditNotes=Prochaine valeur (avoirs)
MustBeLowerThanPHPLimit=Remarque: Votre PHP limite naturellement la taille à %s %s maximum, quelque soit la valeur de ce paramètre
NoMaxSizeByPHPLimit=Aucune limite interne à votre serveur PHP
ComptaSetup=Configuration du module Comptabilité
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index 3384eb2b7ae..a54e6400b8d 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -315,7 +315,7 @@ OrionNumRefModelDesc3=D
OrionNumRefModelDesc4=Dans cette exemple nous aurons au 1er septembre 2006 une facture nommée FA0700354.
# terre
-TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0
+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 $fayymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module.
# titan
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index e9d5af6e274..b0813c63ec7 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -73,7 +73,8 @@ if (isset($dolibarr_auto_user)) $authmode=array('auto');
$sessionname="DOLSESSID_".$dolibarr_main_db_name;
session_name($sessionname);
session_start();
-//dolibarr_syslog("We are in a session. Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]);
+dolibarr_syslog("Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]);
+dolibarr_syslog("Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]);
// Si la demande du login a déjà eu lieu, on le récupère depuis la session
// sinon appel du module qui réalise sa demande.
@@ -83,7 +84,7 @@ if (! session_id() || ! isset($_SESSION["dol_login"]))
{
// On est pas déjà authentifié, on demande le login/mot de passe
// A l'issu de cette demande, le login et un jeton doivent avoir été placé
- // en session dans dol_login et dol_token et la page rappelée.
+ // en session dans dol_login et la page rappelée.
// MODE AUTO
if (in_array('auto',$authmode) && ! $login)
@@ -221,7 +222,7 @@ if (! isset($_SESSION["dol_login"]))
{
// Nouvelle session pour ce login
$_SESSION["dol_login"]=$user->login;
- dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"]);
+ dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
$user->update_last_login_date();
}
|