From a2b8b30a84f93c767061a326ec99f91deac416e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Feb 2009 19:06:12 +0000 Subject: [PATCH] Reorganize code to reduce memory usage --- htdocs/adherents/info.php | 6 ++-- htdocs/adherents/info_subscription.php | 3 +- htdocs/comm/action/info.php | 3 +- htdocs/comm/propal/info.php | 3 +- htdocs/commande/info.php | 8 ++--- htdocs/compta/bank/info.php | 7 +++-- htdocs/compta/facture/info.php | 6 ++-- htdocs/compta/paiement/info.php | 10 +++---- htdocs/contact/info.php | 7 +++-- htdocs/contrat/info.php | 3 +- htdocs/fichinter/info.php | 6 ++-- htdocs/fourn/facture/info.php | 6 ++-- htdocs/fourn/paiement/info.php | 12 ++++---- htdocs/lib/functions.lib.php | 41 -------------------------- htdocs/lib/functions2.lib.php | 41 ++++++++++++++++++++++++++ htdocs/product/stock/info.php | 15 ++++------ htdocs/societe/info.php | 3 +- htdocs/user/info.php | 14 ++++----- 18 files changed, 92 insertions(+), 102 deletions(-) diff --git a/htdocs/adherents/info.php b/htdocs/adherents/info.php index 6bdde42b05c..46b93fe5080 100644 --- a/htdocs/adherents/info.php +++ b/htdocs/adherents/info.php @@ -15,19 +15,17 @@ * 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$ */ /** \file htdocs/adherents/info.php \ingroup member \brief Page des informations d'un adherent - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); diff --git a/htdocs/adherents/info_subscription.php b/htdocs/adherents/info_subscription.php index dd7eaf0c723..68ded081c15 100644 --- a/htdocs/adherents/info_subscription.php +++ b/htdocs/adherents/info_subscription.php @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); @@ -55,7 +56,7 @@ $result=$subscription->fetch($rowid); $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id; $head[$h][1] = $langs->trans("SubscriptionCard"); $head[$h][2] = 'general'; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index d9e249e4ede..db78c34103f 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.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"); @@ -32,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); $langs->load("commercial"); // Security check -if ($user->societe_id > 0) +if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index fc8244aaa29..49b0e20cca0 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -26,6 +26,7 @@ */ require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); @@ -62,7 +63,7 @@ dol_print_object_info($propal); print ''; print ''; - + // Juste pour �viter bug IE qui r�organise mal div pr�c�dents si celui-ci absent print '
'; print '
'; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index fa52fdec477..ec2f8b7b063 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -15,19 +15,17 @@ * 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$ */ /** \file htdocs/commande/info.php \ingroup commande \brief Page des informations d'une commande - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php"); @@ -61,7 +59,7 @@ print ''; print ''; -// Juste pour �viter bug IE qui r�organise mal div pr�c�dents si celui-ci absent +// Juste pour eviter bug IE qui reorganise mal div precedents si celui-ci absent print '
'; print '
'; diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index 95581c993bf..89563dd2fcd 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2009 Laurent Destailleur * * 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 @@ -24,6 +24,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); $langs->load("banks"); @@ -46,12 +47,12 @@ $h=0; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$_GET["rowid"]; $head[$h][1] = $langs->trans("Card"); -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"]; $head[$h][1] = $langs->trans("Info"); $hselected = $h; -$h++; +$h++; dolibarr_fiche_head($head, $hselected, $langs->trans("LineRecord")); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 44c40324255..4aaf1ff2b1b 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -15,19 +15,17 @@ * 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$ */ /** \file htdocs/compta/facture/info.php \ingroup facture \brief Page des informations d'une facture - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); $langs->load("bills"); diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index d70ae109fdf..f9e80ba1cc0 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); $langs->load("bills"); @@ -32,8 +33,7 @@ $langs->load("companies"); /* - * Visualisation de la fiche - * + * View */ llxHeader(); @@ -47,12 +47,12 @@ $h=0; $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Card"); -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Info"); $hselected = $h; -$h++; +$h++; dolibarr_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice")); diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index ed0cd4cc319..b6c22c5109b 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php"); @@ -64,12 +65,12 @@ dolibarr_fiche_head($head, 'info', $langs->trans("Contact")); print '
'; $contact->info($_GET["id"]); print '
'; - + if ($contact->socid > 0) { $societe = new Societe($db); $societe->fetch($contact->socid); - + print $langs->trans("Company").' : '.$societe->getNomUrl(0).'
'; } diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php index e40a7e9232e..9930c4d72de 100644 --- a/htdocs/contrat/info.php +++ b/htdocs/contrat/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -24,6 +24,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 13c3ad1f923..b454dfab7af 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2009 Laurent Destailleur * * 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 @@ -24,6 +25,7 @@ */ require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); @@ -58,7 +60,7 @@ dol_print_object_info($fichinter); print ''; print ''; - + // Juste pour �viter bug IE qui r�organise mal div pr�c�dents si celui-ci absent print '
'; print '
'; diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 178d1abd292..56e6da4bfd0 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -15,19 +15,17 @@ * 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$ */ /** \file htdocs/fourn/facture/info.php \ingroup facture, fournisseur \brief Page des informations d'une facture fournisseur - \version $Revision$ + \version $Id$ */ require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); $langs->load("bills"); diff --git a/htdocs/fourn/paiement/info.php b/htdocs/fourn/paiement/info.php index 8d471629152..c387a673df0 100644 --- a/htdocs/fourn/paiement/info.php +++ b/htdocs/fourn/paiement/info.php @@ -15,20 +15,18 @@ * 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$ */ /** \file htdocs/fourn/paiement/info.php \ingroup facture \brief Onglet info d'un paiement fournisseur - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); -require(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php"); $langs->load("bills"); $langs->load("suppliers"); @@ -39,12 +37,12 @@ $h=0; $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Card"); -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Info"); $hselected = $h; -$h++; +$h++; dolibarr_fiche_head($head, $hselected, $langs->trans("SupplierPayment")); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index cd4992f9668..9f3f0e972ca 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -609,47 +609,6 @@ function dol_date($fmt, $timestamp, $gm=0) } -/** - * \brief Affiche les informations d'un objet - * \param object objet a afficher - */ -function dol_print_object_info($object) -{ - global $langs; - $langs->load("other"); - - if (isset($object->user_creation) && $object->user_creation->fullname) - print $langs->trans("CreatedBy")." : " . $object->user_creation->fullname . '
'; - - if (isset($object->date_creation)) - print $langs->trans("DateCreation")." : " . dolibarr_print_date($object->date_creation,"dayhourtext") . '
'; - - if (isset($object->user_modification) && $object->user_modification->fullname) - print $langs->trans("ModifiedBy")." : " . $object->user_modification->fullname . '
'; - - if (isset($object->date_modification)) - print $langs->trans("DateLastModification")." : " . dolibarr_print_date($object->date_modification,"dayhourtext") . '
'; - - if (isset($object->user_validation) && $object->user_validation->fullname) - print $langs->trans("ValidatedBy")." : " . $object->user_validation->fullname . '
'; - - if (isset($object->date_validation)) - print $langs->trans("DateValidation")." : " . dolibarr_print_date($object->date_validation,"dayhourtext") . '
'; - - if (isset($object->user_cloture) && $object->user_cloture->fullname ) - print $langs->trans("ClosedBy")." : " . $object->user_cloture->fullname . '
'; - - if (isset($object->date_cloture)) - print $langs->trans("DateClosing")." : " . dolibarr_print_date($object->date_cloture,"dayhourtext") . '
'; - - if (isset($object->user_rappro) && $object->user_rappro->fullname ) - print $langs->trans("ConciliatedBy")." : " . $object->user_rappro->fullname . '
'; - - if (isset($object->date_rappro)) - print $langs->trans("DateConciliating")." : " . dolibarr_print_date($object->date_rappro,"dayhourtext") . '
'; -} - - /** * \brief Return string with formated size * \param size Size to print diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 65a6b80bff9..46a697caa6f 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -26,6 +26,47 @@ */ +/** + * \brief Show informations on an object + * \param object Objet to show + */ +function dol_print_object_info($object) +{ + global $langs; + $langs->load("other"); + + if (isset($object->user_creation) && $object->user_creation->fullname) + print $langs->trans("CreatedBy")." : " . $object->user_creation->fullname . '
'; + + if (isset($object->date_creation)) + print $langs->trans("DateCreation")." : " . dolibarr_print_date($object->date_creation,"dayhourtext") . '
'; + + if (isset($object->user_modification) && $object->user_modification->fullname) + print $langs->trans("ModifiedBy")." : " . $object->user_modification->fullname . '
'; + + if (isset($object->date_modification)) + print $langs->trans("DateLastModification")." : " . dolibarr_print_date($object->date_modification,"dayhourtext") . '
'; + + if (isset($object->user_validation) && $object->user_validation->fullname) + print $langs->trans("ValidatedBy")." : " . $object->user_validation->fullname . '
'; + + if (isset($object->date_validation)) + print $langs->trans("DateValidation")." : " . dolibarr_print_date($object->date_validation,"dayhourtext") . '
'; + + if (isset($object->user_cloture) && $object->user_cloture->fullname ) + print $langs->trans("ClosedBy")." : " . $object->user_cloture->fullname . '
'; + + if (isset($object->date_cloture)) + print $langs->trans("DateClosing")." : " . dolibarr_print_date($object->date_cloture,"dayhourtext") . '
'; + + if (isset($object->user_rappro) && $object->user_rappro->fullname ) + print $langs->trans("ConciliatedBy")." : " . $object->user_rappro->fullname . '
'; + + if (isset($object->date_rappro)) + print $langs->trans("DateConciliating")." : " . dolibarr_print_date($object->date_rappro,"dayhourtext") . '
'; +} + + /** * \brief Return true if email syntax is ok * \param address email (Ex: "toto@titi.com", "John Do ") diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index d7762fd6e74..16c85e63570 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2009 Laurent Destailleur * * 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 @@ -24,25 +24,20 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); $langs->load("stocks"); -llxHeader(); - - /* - * Visualisation de la fiche - * + * View */ +llxHeader(); + $entrepot = new Entrepot($db); $entrepot->fetch($_GET["id"]); $entrepot->info($_GET["id"]); - -/* - * Affichage onglets - */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 166dbcbb8ca..758d61d09a7 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -24,6 +24,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); diff --git a/htdocs/user/info.php b/htdocs/user/info.php index cd84359ff72..0de745d22aa 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -14,39 +14,35 @@ * 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/user/info.php \ingroup core \brief Page des informations d'un utilisateur - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/usergroups.lib.php'); require_once(DOL_DOCUMENT_ROOT."/user.class.php"); $langs->load("users"); -// S�curit� acc�s client et commerciaux +// Security check $id = isset($_GET["id"])?$_GET["id"]:''; - $fuser = new User($db); $fuser->id = $id; $fuser->fetch(); - // If user is not user read and no permission to read other users, we stop if (($fuser->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); - + /* - * Visualisation de la fiche - * + * View */ llxHeader();