Ajout fonction dcalage sur fin de mois

This commit is contained in:
Laurent Destailleur 2006-04-20 18:57:38 +00:00
parent 1040ba2f0a
commit 3312604442
8 changed files with 83 additions and 50 deletions

View File

@ -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 '<td>';
print $valuetoshow;
print '</td>';
@ -406,7 +407,8 @@ if ($_GET["id"])
print '</td>';
}
// La source de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'source') {
elseif ($fieldlist[$field] == 'source')
{
print '<td>';
$elementList = array("internal"=>$langs->trans("Internal"),
"external"=>$langs->trans("External"));
@ -427,13 +429,16 @@ if ($_GET["id"])
elseif ($fieldlist[$field] == 'nbjour') {
print '<td><input type="text" class="flat" value="" size="3" name="'.$fieldlist[$field].'"></td>';
}
elseif ($fieldlist[$field] == 'decalage') {
print '<td><input type="text" class="flat" value="" size="3" name="'.$fieldlist[$field].'"></td>';
}
elseif ($fieldlist[$field] == 'fdm') {
print '<td>';
$html->selectyesno('fdm','',1);
print '</td>';
}
else {
print '<td><input type="text" class="flat" value="" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat" value="" name="'.$fieldlist[$field].'" ></td>';
}
}
print '<td colspan=3><input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'"></td>';
@ -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 '<td>&nbsp;</td>';
print '</tr>';
@ -501,7 +507,7 @@ if ($_GET["id"])
print '<td>'.$valuetoshow.'</td>';
}
print '<td>';
print '<td align="center">';
// Est-ce une entrée du dictionnaire qui peut etre désactivée ?
$iserasable=1; // Oui par defaut

View File

@ -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;
}

View File

@ -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 <a href="%s">Update now</a>.
WebServer=Web server

View File

@ -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
DefaultLanguage=Langue à utiliser par défaut
Offset=Décalage

View File

@ -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 <a href="%s">Mettre à jour</a>.
WebServer=Serveur Web

View File

@ -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;

View File

@ -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;

View File

@ -1,37 +1,38 @@
-- Generated from dolibarr_mysql2pgsql
-- (c) 2004, PostgreSQL Inc.
-- (c) 2005, Laurent Destailleur.
-- ============================================================================
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
--
-- 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 <rodolphe@quiedeville.org>
--
-- 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
);