From 960e3ea5beb557d43db507cf5b10eadeec49e763 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Aug 2005 16:36:07 +0000 Subject: [PATCH] =?UTF-8?q?Qual:=20Mise=20en=20facteur=20du=20code.=20Fix:?= =?UTF-8?q?=20N'affiche=20pas=20tableau=20d'=E9tat=20global=20si=20utilisa?= =?UTF-8?q?teur=20externe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/index.php | 232 +++++++++++++++++++---------------------------- 1 file changed, 91 insertions(+), 141 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 45611856075..5a91ac2bedc 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -18,10 +18,8 @@ * * $Id$ * $Source$ - * */ - /** \file htdocs/index.php \brief Page accueil par defaut @@ -88,151 +86,103 @@ print ''; /* - * Dolibarr State Board + * Tableau de bord d'états Dolibarr (statistiques) + * Non affiché pour un utilisateur externe */ -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; - -$var=true; - -// Nbre de sociétés clients/prospects -if ($conf->societe->enabled && $user->rights->societe->lire ) +if ($user->societe_id == 0) { - include_once("./client.class.php"); - $board=new Client($db); - $board->load_state_board(); - - foreach($board->nb as $key=>$val) + print '
'; + print '
'.$langs->trans("DolibarrStateBoard").' 
'; + print ''; + print ''; + print ''; + print ''; + + $var=true; + + // Condition à vérifier pour affichage de chaque ligne du tableau de bord + $conditions=array($conf->societe->enabled && $user->rights->societe->lire, + $conf->societe->enabled && $user->rights->societe->lire, + $conf->fournisseur->enabled && $user->rights->fournisseur->lire, + $conf->adherent->enabled && $user->rights->adherent->lire, + $conf->produit->enabled && $user->rights->produit->lire, + $conf->service->enabled && $user->rights->produit->lire, + $conf->telephonie->enabled && $user->rights->telephonie->ligne->lire_restreint); + // Fichiers des classes qui contiennent la methode load_state_board pour chaque ligne + $includes=array(DOL_DOCUMENT_ROOT."/client.class.php", + DOL_DOCUMENT_ROOT."/client.class.php", + DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php", + DOL_DOCUMENT_ROOT."/adherents/adherent.class.php", + DOL_DOCUMENT_ROOT."/product.class.php", + DOL_DOCUMENT_ROOT."/service.class.php", + DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); + // Nom des classes qui contiennent la methode load_state_board pour chaque ligne + $classes=array('Client', + 'Client', + 'Fournisseur', + 'Adherent', + 'Product', + 'Service', + 'LigneTel'); + // Clé du tableau retourné par la methode laod_state_bord pour chaque ligne + $keys=array('customers', + 'prospects', + 'suppliers', + 'members', + 'products', + 'services', + 'sign'); + // Icon des lignes du tableau de bord + $icons=array('company', + 'company', + 'company', + 'user', + 'product', + 'service', + 'phone'); + // Titre des lignes du tableau de bord + $titres=array($langs->trans("Customers"), + $langs->trans("Prospects"), + $langs->trans("Suppliers"), + $langs->trans("Members"), + $langs->trans("Products"), + $langs->trans("Services"), + $langs->trans("Lignes de téléphonie suivis")); + // Liens des lignes du tableau de bord + $links=array(DOL_URL_ROOT.'/comm/clients.php', + DOL_URL_ROOT.'/comm/prospect/prospects.php', + DOL_URL_ROOT.'/fourn/liste.php', + DOL_URL_ROOT.'/adherents/liste.php?statut=1&mainmenu=members', + DOL_URL_ROOT.'/product/liste.php?type=0&mainmenu=products', + DOL_URL_ROOT.'/product/liste.php?type=1&mainmenu=products', + DOL_URL_ROOT.'/telephonie/ligne/index.php'); + + // Boucle et affiche chaque ligne du tableau + foreach ($keys as $key=>$val) { - $var=!$var; - print ''; - print ''; - print ''; - print ''; + if ($conditions[$key]) + { + $classe=$classes[$key]; + // Cherche dans cache si le load_state_board deja réalisé + if (! is_object($boardloaded[$classe])) + { + include_once($includes[$key]); + $board=new $classe($db); + $board->load_state_board($user); + $boardloaded[$classe]=$board; + } + else $board=$boardloaded[$classe]; + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } } + + print '
'.$langs->trans("DolibarrStateBoard").' 
'.img_object($langs->trans("Customers"),"company").''; - if ($key == "customers") print $langs->trans("Customers"); - if ($key == "prospects") print $langs->trans("Prospects"); - print ''; - if ($key == "customers") print ''; - if ($key == "prospects") print ''; - print $val; - print '
'.img_object($titres[$key],$icons[$key]).''.$titres[$key].''.$board->nb[$val].'
'; } -// Nbre de sociétés fournisseurs -if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire) -{ - include_once("./fourn/fournisseur.class.php"); - $board=new Fournisseur($db); - $board->load_state_board(); - - foreach($board->nb as $key=>$val) - { - $var=!$var; - print ''.img_object($langs->trans("Suppliers"),"company").''; - print ''; - if ($key == "suppliers") print $langs->trans("Suppliers"); - print ''; - print ''; - if ($key == "suppliers") print ''; - print $val; - print ''; - print ''; - } -} - -// Nbre d'adhérents -if ($conf->adherent->enabled) -{ - include_once("./adherents/adherent.class.php"); - $board=new Adherent($db); - $board->load_state_board(); - - foreach($board->nb as $key=>$val) - { - $var=!$var; - print ''.img_object($langs->trans("Adherent"),"user").''; - print ''; - if ($key == "members") print $langs->trans("Adherents"); - print ''; - print ''; - if ($key == "members") print ''; - print $val; - print ''; - print ''; - } -} - -// Nbre de produits -if ($conf->produit->enabled && $user->rights->produit->lire) -{ - //include_once("./product.class.php"); - $board=new Product($db); - $board->load_state_board(); - - foreach($board->nb as $key=>$val) - { - $var=!$var; - print ''.img_object($langs->trans("Products"),"product").''; - print ''; - if ($key == "products") print $langs->trans("Products"); - print ''; - print ''; - if ($key == "products") print ''; - print $val; - print ''; - print ''; - } -} - -// Nbre de services -if ($conf->service->enabled && $user->rights->produit->lire) -{ - include_once("./service.class.php"); - $board=new Service($db); - $board->load_state_board(); - - foreach($board->nb as $key=>$val) - { - $var=!$var; - print ''.img_object($langs->trans("Services"),"service").''; - print ''; - if ($key == "services") print $langs->trans("Services"); - print ''; - print ''; - if ($key == "services") print ''; - print $val; - print ''; - print ''; - } -} - -// Nbre de lignes telephoniques suivies -if ($conf->telephonie->enabled && $user->rights->telephonie->ligne->lire_restreint) -{ - include_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); - $board=new LigneTel($db); - $board->load_state_board($user); - - foreach($board->nb as $key=>$val) - { - $var=!$var; - print ' '; - print 'Lignes téléphoniques suivies'; - print ''; - print $val; - print ''; - print ''; - } -} - -print ''; - - print '';