Qual: Rorganisation un peu plus logique de certaines fonctions. Rduction de la taille du fichier html.form.class.php qui est charg a chaque fois et qui consomme a lui seul 1Mo

This commit is contained in:
Laurent Destailleur 2008-01-10 17:12:07 +00:00
parent eccdbc59b8
commit d7d4904cff
28 changed files with 429 additions and 340 deletions

View File

@ -497,7 +497,7 @@ else
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyCurrency").'</td><td>';
print $form->currency_name($conf->global->MAIN_MONNAIE,1);
print currency_name($conf->global->MAIN_MONNAIE,1);
print ' ('.$conf->global->MAIN_MONNAIE.')';
print '</td></tr>';
@ -733,4 +733,46 @@ else
$db->close();
llxFooter('$Date$ - $Revision$');
/**
* \brief Retourne le nom traduit ou code+nom d'une devise
* \param code_iso Code iso de la devise
* \param withcode 1=affiche code + nom
* \return string Nom traduit de la devise
*/
function currency_name($code_iso,$withcode=0)
{
global $langs;
// Si il existe une traduction, on peut renvoyer de suite le libellé
if ($langs->trans("Currency".$code_iso)!="Currency".$code_iso)
{
return $langs->trans("Currency".$code_iso);
}
// Si pas de traduction, on consulte libellé par défaut en table
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE code_iso='$code_iso';";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
if ($num)
{
$obj = $this->db->fetch_object();
$label=($obj->label!='-'?$obj->label:'');
if ($withcode) return $label==$code_iso?"$code_iso":"$code_iso - $label";
else return $label;
}
else
{
return $code_iso;
}
}
}
?>

View File

@ -34,6 +34,7 @@ require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("companies");
$langs->load("commercial");
@ -188,8 +189,8 @@ if ($_GET["id"] > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?id='.$act->id);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -32,6 +31,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('compta');
$langs->load('other');
@ -160,8 +160,8 @@ if ($propalid > 0)
if ($mesg) { print "$mesg<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?propalid='.$propal->id);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -31,6 +30,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$user->getrights('commande');
if (!$user->rights->commande->lire)
@ -154,9 +154,9 @@ if ($id > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?id='.$commande->id);
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$commande->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -32,6 +31,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/invoice.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('propal');
$langs->load('compta');
@ -162,8 +162,8 @@ if ($facid > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?facid='.$facture->id);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -26,8 +26,10 @@
*/
require("./pre.inc.php");
require_once("../../tva.class.php");
require_once("../../chargesociales.class.php");
require_once(DOL_DOCUMENT_ROOT."/tva.class.php");
require_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
$langs->load("bills");
@ -67,7 +69,7 @@ else {
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
}
$html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
// Affiche rapport
print '<table class="noborder" width="100%">';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -26,6 +26,8 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
$year_start=isset($_GET["year_start"])?$_GET["year_start"]:$_POST["year_start"];
$year_current = strftime("%Y",time());
@ -74,7 +76,7 @@ else {
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
}
$html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
/*

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -26,6 +26,7 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
$year=$_GET["year"];
@ -67,7 +68,7 @@ else {
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
}
$html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
// Charge tableau

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
*
* This program is free software; you can redistribute it and/or modify
@ -27,6 +27,8 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
$langs->load("companies");
$year=$_GET["year"];
@ -67,7 +69,7 @@ else {
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
}
$html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
// Charge tableau

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -26,6 +26,8 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
$year_start=isset($_GET["year_start"])?$_GET["year_start"]:$_POST["year_start"];
$year_current = strftime("%Y",time());
@ -71,7 +73,7 @@ else {
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
}
$html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
if ($modecompta == 'CREANCES-DETTES') {

View File

@ -723,6 +723,20 @@ class Contact extends CommonObject
}
/**
* \brief Retourne le libelle de civilite du contact
* \return string Nom traduit de la civilité
*/
function getCivilityLabel()
{
global $langs;
$langs->load("dict");
$code=$this->civilite_id;
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code;
}
/**
* \brief Return full name (name+' '+lastname)
* \param langs Lang for output

View File

@ -119,7 +119,7 @@ else
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print $contact->getCivilityLabel();
print '</td></tr>';
print '</table>';

View File

@ -511,7 +511,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
// Civility
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print $contact->getCivilityLabel();
print '</td></tr>';
print '<tr><td>Poste/Fonction</td><td colspan="3">'.$contact->poste.'</td>';

View File

@ -122,7 +122,7 @@ else
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print $contact->getCivilityLabel();
print '</td></tr>';
// LDAP DN

View File

@ -142,7 +142,7 @@ if ($_GET["action"] == 'edit')
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print $contact->getCivilityLabel();
print '</td></tr>';
// Birthday
@ -208,7 +208,7 @@ else
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print $contact->getCivilityLabel();
print '</td></tr>';
// Birthday

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -29,6 +29,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("companies");
$langs->load('other');
@ -164,7 +165,8 @@ if ($socid > 0)
if ($mesg) { print "$mesg<br>"; }
// Affiche formulaire upload
$html->form_attach_new_file('docsoc.php?socid='.$socid);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/docsoc.php?socid='.$socid);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -32,6 +31,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('bills');
$langs->load('other');
@ -162,8 +162,8 @@ if ($facid > 0)
if ($mesg) { print $mesg.'<br>'; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?facid='.$facture->id);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id);
// Affiche liste des documents existant
print_titre($langs->trans('AttachedFiles'));

View File

@ -1801,19 +1801,6 @@ class Form
}
/**
* \brief Retourne le nom traduit de la civilité
* \param code Code de la civilité
* \return string Nom traduit de la civilité
*/
function civilite_name($code)
{
global $langs;
$langs->load("dict");
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code;
}
/**
* \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné.
* \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
@ -1917,24 +1904,6 @@ class Form
}
/**
* \brief Retourne le formulaire de saisie d'un identifiant professionnel (siren, siret, etc...)
* \param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* \param soc Objet societe
* \param htmlname Nom de la zone input
*/
function id_prof($idprof,$soc,$htmlname,$selected='')
{
global $langs;
$formlength=16;
if ($idprof==1 && $soc->pays_code == 'FR') $formlength=9;
if ($idprof==2 && $soc->pays_code == 'FR') $formlength=14;
if ($idprof==3 && $soc->pays_code == 'FR') $formlength=4;
if ($idprof==4 && $soc->pays_code == 'FR') $formlength=12;
print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
}
/**
* \brief Retourne le nom traduit ou code+nom d'un pays
* \param id id du pays
@ -1967,46 +1936,6 @@ class Form
}
}
/**
* \brief Retourne le nom traduit ou code+nom d'une devise
* \param code_iso Code iso de la devise
* \param withcode 1=affiche code + nom
* \return string Nom traduit de la devise
*/
function currency_name($code_iso,$withcode=0)
{
global $langs;
// Si il existe une traduction, on peut renvoyer de suite le libellé
if ($langs->trans("Currency".$code_iso)!="Currency".$code_iso)
{
return $langs->trans("Currency".$code_iso);
}
// Si pas de traduction, on consulte libellé par défaut en table
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE code_iso='$code_iso';";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
if ($num)
{
$obj = $this->db->fetch_object();
$label=($obj->label!='-'?$obj->label:'');
if ($withcode) return $label==$code_iso?"$code_iso":"$code_iso - $label";
else return $label;
}
else
{
return $code_iso;
}
}
}
/**
* \brief Affiche formulaire de demande de confirmation
@ -2267,64 +2196,6 @@ class Form
}
/**
* \brief Affiche formulaire ajout fichier
* \param url Url
* \param titre Titre zone
* \param addcancel 1=Ajoute un bouton 'Annuler'
* \return int <0 si ko, >0 si ok
*/
function form_attach_new_file($url,$titre='',$addcancel=0)
{
global $conf,$langs;
if ($conf->upload != 0)
{
print "\n\n<!-- Start form attach new file -->\n";
if (! $titre) $titre=$langs->trans("AttachANewFile");
print_titre($titre);
print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
print '<table width="100%" class="noborder">';
print '<tr><td width="50%" valign="top">';
$max=$conf->upload; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
if (eregi('m$',$maxphp)) $maxphp=$maxphp*1024;
if (eregi('k$',$maxphp)) $maxphp=$maxphp;
// Now $max and $maxphp are in Kb
if ($maxphp > 0) $max=min($max,$maxphp);
if ($conf->upload > 0)
{
print '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
print '<input class="flat" type="file" name="userfile" size="70">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'">';
if ($addcancel)
{
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb").')';
print "</td></tr>";
print "</table>";
print '</form>';
print '<br>';
print "\n<!-- End form attach new file -->\n\n";
}
return 1;
}
/**
* \brief Affiche formulaire de selection de la remise fixe
* \param page Page
@ -2658,59 +2529,6 @@ class Form
print '</select>';
}
/**
*
*
*
*
*/
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
{
global $langs,$conf,$mysoc;
if (is_object($societe_vendeuse->pays_code))
{
$code_pays=$societe_vendeuse->pays_code;
}
else
{
$code_pays=$mysoc->pays_code; // Pour compatibilite ascendente
}
// Recherche liste des codes TVA du pays vendeur
$sql = "SELECT t.taux,t.recuperableonly";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
$sql .= " AND t.active = 1";
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
for ($i = 0; $i < $num; $i++)
{
$obj = $this->db->fetch_object($resql);
$txtva[ $i ] = $obj->taux;
$libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':'');
}
}
// Définition du taux à pré-sélectionner
if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
// Si taux par defaut n'a pu etre trouvé, on prend dernier.
// Comme ils sont triés par ordre croissant, dernier = plus élevé = taux courant
if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1];
$nbdetaux = sizeof($txtva);
for ($i = 0 ; $i < $nbdetaux ; $i++)
{
$this->tva_taux_value[$i] = $txtva[$i];
$this->tva_taux_libelle[$i] = $libtva[$i];
}
}
/**
* \brief Affiche zone de selection de date
@ -3050,15 +2868,6 @@ class Form
}
/**
* \brief Renvoie la chaine de caractère décrivant l'erreur
*/
function error()
{
return $this->error;
}
/**
* \brief Selection de oui/non en chaine (renvoie yes/no)
* \param name Nom du select
@ -3092,83 +2901,6 @@ class Form
return $resultyesno;
}
/**
* \brief Checkbox
*
*/
function checkbox($name,$checked=0,$value=1)
{
if ($checked==1){
print "<input type=\"checkbox\" name=\"$name\" value=\"$value\" checked />\n";
}else{
print "<input type=\"checkbox\" name=\"$name\" value=\"$value\" />\n";
}
}
/**
* \brief Affiche la cartouche générique d'un rapport
* \param nom Valeur pour nom du rapport
* \param variante Lien optionnel de variante du rapport
* \param period Periode du reporting
* \param periodlink Lien pour changer de période
* \param description Description
* \param builddate Date génération
* \param exportlink Lien pour export
*/
function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink)
{
global $langs;
print "\n\n<!-- debut cartouche rapport -->\n";
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"];
$head[$h][1] = $langs->trans("Report");
dolibarr_fiche_head($head, $hselected, $societe->nom);
print '<table width="100%" class="border">';
// Ligne de titre
print '<tr>';
print '<td valign="top" width="110">'.$langs->trans("ReportName").'</td>';
if (! $variante) print '<td colspan="3">';
else print '<td>';
print $nom;
if ($variante) print '</td><td colspan="2">'.$variante;
print '</td>';
print '</tr>';
// Ligne de la periode d'analyse du rapport
print '<tr>';
print '<td>'.$langs->trans("ReportPeriod").'</td>';
if (! $periodlink) print '<td colspan="3">';
else print '<td>';
print $period;
if ($periodlink) print '</td><td colspan="2">'.$periodlink;
print '</td>';
print '</tr>';
// Ligne de description
print '<tr>';
print '<td valign="top">'.$langs->trans("ReportDescription").'</td>';
print '<td colspan="3">'.$description.'</td>';
print '</tr>';
// Ligne d'export
print '<tr>';
print '<td>'.$langs->trans("GeneratedOn").'</td>';
if (! $exportlink) print '<td colspan="3">';
else print '<td>';
print dolibarr_print_date($builddate);
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
print '</td></tr>';
print '</table>';
print '</div>';
print "\n<!-- fin cartouche rapport -->\n\n";
}
/**
* \brief Affiche la cartouche de la liste des documents d'une propale, facture...
* \param modulepart propal=propal, facture=facture, ...

View File

@ -0,0 +1,108 @@
<?php
/* Copyright (c) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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$
*/
/**
\file htdocs/html.formfile.class.php
\brief Fichier de la classe des fonctions prédéfinie de composants html fichiers
*/
/**
\class FormFile
\brief Classe permettant la génération de composants html fichiers
*/
class FormFile
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'accès base de donnée
*/
function FormFile($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Affiche formulaire ajout fichier
* \param url Url
* \param titre Titre zone
* \param addcancel 1=Ajoute un bouton 'Annuler'
* \return int <0 si ko, >0 si ok
*/
function form_attach_new_file($url,$titre='',$addcancel=0)
{
global $conf,$langs;
if ($conf->upload != 0)
{
print "\n\n<!-- Start form attach new file -->\n";
if (! $titre) $titre=$langs->trans("AttachANewFile");
print_titre($titre);
print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
print '<table width="100%" class="noborder">';
print '<tr><td width="50%" valign="top">';
$max=$conf->upload; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
if (eregi('m$',$maxphp)) $maxphp=$maxphp*1024;
if (eregi('k$',$maxphp)) $maxphp=$maxphp;
// Now $max and $maxphp are in Kb
if ($maxphp > 0) $max=min($max,$maxphp);
if ($conf->upload > 0)
{
print '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
print '<input class="flat" type="file" name="userfile" size="70">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'">';
if ($addcancel)
{
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb").')';
print "</td></tr>";
print "</table>";
print '</form>';
print '<br>';
print "\n<!-- End form attach new file -->\n\n";
}
return 1;
}
}
?>

View File

@ -28,14 +28,6 @@
/**
\file htdocs/lib/functions.inc.php
\brief Ensemble de fonctions de base de dolibarr sous forme d'include
\author Rodolphe Quiedeville
\author Jean-Louis Bergamo
\author Laurent Destailleur
\author Sebastien Di Cintio
\author Benoit Mortier
\version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include
*/
// Pour compatibilité lors de l'upgrade
@ -3422,4 +3414,15 @@ function dol_htmloutput_errors($mesgstring='',$mesgarray='')
return $ret;
}
/**
* \brief This function output memory used by PHP and exit everything. Used for debugging purpose.
*/
function stopwithmem()
{
print memory_get_usage();
llxFooter();
exit;
}
?>

91
htdocs/lib/report.inc.php Normal file
View File

@ -0,0 +1,91 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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$
*/
/**
\file htdocs/lib/report.inc.php
\brief Ensemble de fonctions de base de dolibarr pour reporting sous forme d'include
*/
/**
* \brief Affiche la cartouche générique d'un rapport
* \param nom Valeur pour nom du rapport
* \param variante Lien optionnel de variante du rapport
* \param period Periode du reporting
* \param periodlink Lien pour changer de période
* \param description Description
* \param builddate Date génération
* \param exportlink Lien pour export
*/
function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink)
{
global $langs;
print "\n\n<!-- debut cartouche rapport -->\n";
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"];
$head[$h][1] = $langs->trans("Report");
dolibarr_fiche_head($head, $hselected, $societe->nom);
print '<table width="100%" class="border">';
// Ligne de titre
print '<tr>';
print '<td valign="top" width="110">'.$langs->trans("ReportName").'</td>';
if (! $variante) print '<td colspan="3">';
else print '<td>';
print $nom;
if ($variante) print '</td><td colspan="2">'.$variante;
print '</td>';
print '</tr>';
// Ligne de la periode d'analyse du rapport
print '<tr>';
print '<td>'.$langs->trans("ReportPeriod").'</td>';
if (! $periodlink) print '<td colspan="3">';
else print '<td>';
print $period;
if ($periodlink) print '</td><td colspan="2">'.$periodlink;
print '</td>';
print '</tr>';
// Ligne de description
print '<tr>';
print '<td valign="top">'.$langs->trans("ReportDescription").'</td>';
print '<td colspan="3">'.$description.'</td>';
print '</tr>';
// Ligne d'export
print '<tr>';
print '<td>'.$langs->trans("GeneratedOn").'</td>';
if (! $exportlink) print '<td colspan="3">';
else print '<td>';
print dolibarr_print_date($builddate);
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
print '</td></tr>';
print '</table>';
print '</div>';
print "\n<!-- fin cartouche rapport -->\n\n";
}
?>

View File

@ -29,6 +29,15 @@
\version $Revision$
*/
// Pour le tuning optionnel. Activer si la variable d'environnement DOL_TUNING est positionnee.
// A appeler avant tout. Fait l'equivalent de la fonction dol_microtime_float
$micro_start_time=0;
if (! empty($_SERVER['DOL_TUNING']))
{
list($usec, $sec) = explode(" ", microtime());
$micro_start_time=((float)$usec + (float)$sec);
}
// Forcage du parametrage PHP magic_quotes_gpc et nettoyage des parametres
// (Sinon il faudrait a chaque POST, conditionner
// la lecture de variable par stripslashes selon etat de get_magic_quotes).
@ -77,9 +86,11 @@ foreach ($_POST as $key => $val)
require_once("master.inc.php");
// Chargement des includes complementaire de presentation
if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php");
if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
stopwithmem();
if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php');
// Init session
@ -610,11 +621,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
*/
function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0)
{
global $user, $conf, $langs, $db, $micro_start_time;
// Pour le tuning optionnel. Activer si la variable d'environnement DOL_TUNING
// est positionne A appeler avant tout.
if (isset($_SERVER['DOL_TUNING'])) $micro_start_time=dol_microtime_float(true);
global $user, $conf, $langs, $db;
if (! $conf->css) $conf->css ='/theme/eldy/eldy.css.php';
@ -960,7 +967,7 @@ function llxFooter($foot='',$limitIEbug=1)
print "\n</div>\n".'<!-- end div class="fiche" -->'."\n";
print "\n</div>\n".'<!-- end div class="vmenuplusfiche" -->'."\n";
if (isset($_SERVER['DOL_TUNING']))
if (! empty($_SERVER['DOL_TUNING']))
{
$micro_end_time=dol_microtime_float(true);
print '<script language="javascript" type="text/javascript">window.status="Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -33,6 +32,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("other");
$langs->load("products");
@ -175,8 +175,8 @@ if ($product->id)
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?id='.$product->id);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$product->id);
$errorlevel=error_reporting();

View File

@ -686,9 +686,9 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
// on revient en erreur
//
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/';
$null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
$smarty->assign('tva_taux_value', $html->tva_taux_value);
$smarty->assign('tva_taux_libelle', $html->tva_taux_libelle);
$tvaarray = load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
$smarty->assign('tva_taux_value', $tvaarray['value']);
$smarty->assign('tva_taux_libelle', $tvaarray['label']);
$smarty->display($_GET["canvas"].'-create.tpl');
}
}
@ -1044,9 +1044,9 @@ if ($_GET["id"] || $_GET["ref"])
}
else
{
$null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
$smarty->assign('tva_taux_value', $html->tva_taux_value);
$smarty->assign('tva_taux_libelle', $html->tva_taux_libelle);
$tvaarray = load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
$smarty->assign('tva_taux_value', $tvaarray['value']);
$smarty->assign('tva_taux_libelle', $tvaarray['label']);
$smarty->display($product->canvas.'-edit.tpl');
}
}
@ -1485,4 +1485,60 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$db->close();
llxFooter('$Date$ - $Revision$');
/**
* \brief Load tva_taux_value and tva_taux_libelle array
* \remarks Ne sert que pour smarty
*/
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
{
global $langs,$conf,$mysoc;
$retarray=array();
if (is_object($societe_vendeuse->pays_code))
{
$code_pays=$societe_vendeuse->pays_code;
}
else
{
$code_pays=$mysoc->pays_code; // Pour compatibilite ascendente
}
// Recherche liste des codes TVA du pays vendeur
$sql = "SELECT t.taux,t.recuperableonly";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
$sql .= " AND t.active = 1";
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
for ($i = 0; $i < $num; $i++)
{
$obj = $this->db->fetch_object($resql);
$txtva[ $i ] = $obj->taux;
$libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':'');
}
}
// Définition du taux à pré-sélectionner
if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
// Si taux par defaut n'a pu etre trouvé, on prend dernier.
// Comme ils sont triés par ordre croissant, dernier = plus élevé = taux courant
if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1];
$nbdetaux = sizeof($txtva);
for ($i = 0 ; $i < $nbdetaux ; $i++)
{
$retarray['value'][$i] = $txtva[$i];
$retarray['label'][$i] = $libtva[$i];
}
return $retarray;
}
?>

View File

@ -18,7 +18,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
*
@ -19,7 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -34,6 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("products");
$langs->load("bills");
@ -172,8 +172,8 @@ if ($_GET["id"] || $_GET["ref"])
if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer)
{
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1);
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1);
}
// Affiche photos

View File

@ -794,7 +794,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(1,$soc,'idprof1',$soc->siren);
$soc->show_input_id_prof(1,'idprof1',$soc->siren);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
@ -803,7 +803,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(2,$soc,'idprof2',$soc->siret);
$soc->show_input_id_prof(2,'idprof2',$soc->siret);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
@ -814,7 +814,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(3,$soc,'idprof3',$soc->ape);
$soc->show_input_id_prof(3,'idprof3',$soc->ape);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
@ -823,7 +823,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(4,$soc,'idprof4',$soc->idprof4);
$soc->show_input_id_prof(4,'idprof4',$soc->idprof4);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';

View File

@ -1908,6 +1908,31 @@ class Societe
}
}
/**
* \brief Retourne le formulaire de saisie d'un identifiant professionnel (siren, siret, etc...)
* \param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* \param htmlname Nom de la zone input
*/
function show_input_id_prof($idprof,$htmlname)
{
global $langs;
$formlength=16;
if ($this->pays_code == 'FR')
{
if ($idprof==1) $formlength=9;
if ($idprof==2) $formlength=14;
if ($idprof==3) $formlength=4;
if ($idprof==4) $formlength=12;
}
$selected='';
if ($idprof==1) $selected=$soc->siren;
if ($idprof==2) $selected=$soc->siret;
if ($idprof==3) $selected=$soc->ape;
if ($idprof==4) $selected=$soc->idprof4;
print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
}
}
?>