diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 4a33cf92ba9..794fb83571c 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -95,7 +95,7 @@ $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF
$tabsql[9] = "SELECT code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[10]= "SELECT t.rowid, t.taux, p.libelle as pays, t.recuperableonly, t.note, t.active FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
-$tabsql[12]= "SELECT rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, active FROM ".MAIN_DB_PREFIX."cond_reglement AS c";
+$tabsql[12]= "SELECT rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX."cond_reglement AS c";
$tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
// Tri par defaut
@@ -125,7 +125,7 @@ $tabfield[8] = "code,libelle";
$tabfield[9] = "code,code_iso,libelle";
$tabfield[10]= "pays,taux,recuperableonly,note";
$tabfield[11]= "element,source,code,libelle";
-$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm";
+$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
$tabfield[13]= "code,libelle,type";
// Nom des champs dans la table pour insertion d'un enregistrement
@@ -140,7 +140,7 @@ $tabfieldinsert[8] = "code,libelle";
$tabfieldinsert[9] = "code_iso,label";
$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,note";
$tabfieldinsert[11]= "element,source,code,libelle";
-$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm";
+$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
$tabfieldinsert[13]= "code,libelle,type";
// Nom du rowid si le champ n'est pas de type autoincrément
@@ -359,6 +359,7 @@ if ($_GET["id"])
if ($fieldlist[$field]=='recuperableonly') $valuetoshow=MENTION_NPR;
if ($fieldlist[$field]=='nbjour') $valuetoshow=$langs->trans("NbOfDays");
if ($fieldlist[$field]=='fdm') $valuetoshow=$langs->trans("AtEndOfMonth");
+ if ($fieldlist[$field]=='decalage') $valuetoshow=$langs->trans("Offset");
print '
';
print $valuetoshow;
print '
';
@@ -406,7 +407,8 @@ if ($_GET["id"])
print '';
}
// La source de l'element (pour les type de contact).'
- elseif ($fieldlist[$field] == 'source') {
+ elseif ($fieldlist[$field] == 'source')
+ {
print '
';
@@ -472,10 +477,11 @@ if ($_GET["id"])
if ($fieldlist[$field]=='recuperableonly') $valuetoshow=MENTION_NPR;
if ($fieldlist[$field]=='nbjour') $valuetoshow=$langs->trans("NbOfDays");
if ($fieldlist[$field]=='fdm') $valuetoshow=$langs->trans("AtEndOfMonth");
+ if ($fieldlist[$field]=='decalage') $valuetoshow=$langs->trans("Offset");
// Affiche nom du champ
print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],"&id=".$_GET["id"],"","",$sortfield);
}
- print_liste_field_titre($langs->trans("Activate")."/".$langs->trans("Disable"),"dict.php","active","&id=".$_GET["id"],"","",$sortfield);
+ print_liste_field_titre($langs->trans("Action"),"dict.php","active","&id=".$_GET["id"],"",'align="center"',$sortfield);
print '
';
// Est-ce une entrée du dictionnaire qui peut etre désactivée ?
$iserasable=1; // Oui par defaut
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 15516def055..dcb557315ca 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -567,7 +567,7 @@ class Facture
{
if (! $cond_reglement_id)
$cond_reglement_id=$this->cond_reglement_id;
- $sqltemp = 'SELECT c.fdm,c.nbjour';
+ $sqltemp = 'SELECT c.fdm,c.nbjour,c.decalage';
$sqltemp.= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c';
$sqltemp.= ' WHERE c.rowid='.$cond_reglement_id;
$resqltemp=$this->db->query($sqltemp);
@@ -578,6 +578,7 @@ class Facture
$obj = $this->db->fetch_object($resqltemp);
$cdr_nbjour = $obj->nbjour;
$cdr_fdm = $obj->fdm;
+ $cdr_decalage = $obj->decalage;
}
}
else
@@ -586,15 +587,34 @@ class Facture
return -1;
}
$this->db->free($resqltemp);
- // Definition de la date limite
+
+ /* Definition de la date limite */
+
+ // 1 : ajout du nombre de jours
$datelim = $this->date + ( $cdr_nbjour * 3600 * 24 );
+
+ // 2 : application de la règle "fin de mois"
if ($cdr_fdm)
{
$mois=date('m', $datelim);
$annee=date('Y', $datelim);
- $fins=array(31,28,31,30,31,30,31,31,30,31,30,31);
- $datelim=mktime(12,0,0,$mois,$fins[$mois-1],$annee);
+ if ($mois == 12)
+ {
+ $mois = 1;
+ $annee += 1;
+ }
+ else
+ {
+ $mois += 1;
+ }
+ // On se déplace au début du mois suivant, et on retire un jour
+ $datelim=mktime(12,0,0,$mois,1,$annee);
+ $datelim -= (3600 * 24);
}
+
+ // 3 : application du décalage
+ $datelim += ( $cdr_decalage * 3600 * 24);
+
return $datelim;
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index eb47cbdf3ff..d12717bf154 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -264,6 +264,7 @@ LabelUsedByDefault=Label used by default if no translation can be found for code
LabelOnDocuments=Label on documents
NbOfDays=Nb of days
AtEndOfMonth=At end of month
+Offset=Offset
AlwaysActive=Always active
UpdateRequired=Your system need to be updated. For this click on Update now.
WebServer=Web server
diff --git a/htdocs/langs/fr_BE/admin.lang b/htdocs/langs/fr_BE/admin.lang
index e3450660286..d9752b9fd53 100644
--- a/htdocs/langs/fr_BE/admin.lang
+++ b/htdocs/langs/fr_BE/admin.lang
@@ -67,4 +67,5 @@ Skin=Th
MaxSizeList=Longueur maximum des listes
TopMenuManager=Gestionnaire du menu du haut
MessageOfDay=Message du jour
-DefaultLanguage=Langue à utiliser par défaut
\ No newline at end of file
+DefaultLanguage=Langue à utiliser par défaut
+Offset=Décalage
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index a5a93f48251..e7cebc2f11c 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -264,6 +264,7 @@ LabelUsedByDefault=Libell
LabelOnDocuments=Libellé sur documents
NbOfDays=Nbre de jours
AtEndOfMonth=En fin de mois
+Offset=Décalage
AlwaysActive=Toujours actif
UpdateRequired=Votre système nécessite une mise à jour. Pour cela cliquez sur Mettre à jour.
WebServer=Serveur Web
diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql
index aed51fc9b90..8fdbe0d1c47 100644
--- a/mysql/migration/2.0.0-2.1.0.sql
+++ b/mysql/migration/2.0.0-2.1.0.sql
@@ -35,6 +35,8 @@ alter table llx_product add gencode varchar(255) DEFAULT NULL;
insert into llx_cond_reglement(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (6,'PROFORMA', 6,1, 'Proforma','Réglement avant livraison',0,0);
+alter table llx_cond_reglement add (decalage smallint(6) default 0);
+
alter table llx_commande add fk_cond_reglement int(11) DEFAULT NULL;
alter table llx_commande add fk_mode_reglement int(11) DEFAULT NULL;
diff --git a/mysql/tables/llx_cond_reglement.sql b/mysql/tables/llx_cond_reglement.sql
index 890e76a4ffc..f23afa66c23 100644
--- a/mysql/tables/llx_cond_reglement.sql
+++ b/mysql/tables/llx_cond_reglement.sql
@@ -29,5 +29,6 @@ create table llx_cond_reglement
libelle varchar(255),
libelle_facture text,
fdm tinyint, -- reglement fin de mois
- nbjour smallint
+ nbjour smallint,
+ decalage smallint
)type=innodb;
diff --git a/pgsql/tables/llx_cond_reglement.sql b/pgsql/tables/llx_cond_reglement.sql
index 457d55de305..3c9509c8b7d 100644
--- a/pgsql/tables/llx_cond_reglement.sql
+++ b/pgsql/tables/llx_cond_reglement.sql
@@ -1,37 +1,38 @@
--- Generated from dolibarr_mysql2pgsql
--- (c) 2004, PostgreSQL Inc.
--- (c) 2005, Laurent Destailleur.
-
--- ============================================================================
--- Copyright (C) 2002-2003 Rodolphe Quiedeville
---
--- 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.
---
--- $Id$
--- $Source$
---
--- ============================================================================
-
-create table llx_cond_reglement
-(
- rowid integer PRIMARY KEY,
- "code" varchar(16),
- "sortorder" smallint,
- "active" smallint DEFAULT 1,
- "libelle" varchar(255),
- "libelle_facture" text,
- "fdm" smallint, -- reglement fin de mois
- "nbjour" smallint
-);
+-- Generated from dolibarr_mysql2pgsql
+-- (c) 2004, PostgreSQL Inc.
+-- (c) 2005, Laurent Destailleur.
+
+-- ============================================================================
+-- Copyright (C) 2002-2003 Rodolphe Quiedeville
+--
+-- 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.
+--
+-- $Id$
+-- $Source$
+--
+-- ============================================================================
+
+create table llx_cond_reglement
+(
+ rowid integer PRIMARY KEY,
+ "code" varchar(16),
+ "sortorder" smallint,
+ "active" smallint DEFAULT 1,
+ "libelle" varchar(255),
+ "libelle_facture" text,
+ "fdm" smallint, -- reglement fin de mois
+ "nbjour" smallint,
+ "decalage" smallint
+);