From fad86554d2f1f97508ec74c20f2fd047dc4f5572 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Feb 2005 17:55:16 +0000 Subject: [PATCH] New: Personalisation des boxes par un picto. --- htdocs/boxes.php | 73 +++++++++++-------- htdocs/includes/boxes/box_produits.php | 7 +- htdocs/includes/boxes/box_propales.php | 2 +- htdocs/includes/boxes/box_services_vendus.php | 16 ++-- 4 files changed, 54 insertions(+), 44 deletions(-) diff --git a/htdocs/boxes.php b/htdocs/boxes.php index ef85d031ff6..335b446634e 100644 --- a/htdocs/boxes.php +++ b/htdocs/boxes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2005 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 @@ -21,16 +21,16 @@ * */ -/*! \file htdocs/boxes.php - \brief Fichier de la classe boxes - \author Rodolphe Qiedeville - \author Laurent Destailleur - \version $Revision$ +/** \file htdocs/boxes.php + \brief Fichier de la classe boxes + \author Rodolphe Qiedeville + \author Laurent Destailleur + \version $Revision$ */ -/*! \class infoBox +/** \class infoBox \brief Classe permettant la gestion des boxes sur une page \remarks Cette classe est utilisé par les fichiers includes/boxes/box_xxx.php \remarks qui sont les modules de boites @@ -39,51 +39,60 @@ class infoBox { - /*! + /** * \brief Constructeur de la classe * \param $head tableau des entetes de colonnes * \param $contents tableau des lignes */ function infoBox($head, $contents) { + global $langs; + + $MAXLENGTHBOX=70; // Mettre 0 pour pas de limite + $var = true; $bcx[0] = 'class="box_pair"'; $bcx[1] = 'class="box_impair"'; - $nbcol=sizeof($contents[0]); + $nbcol=sizeof($contents[0])+1; - print ''; + print '
'; + // Affiche titre de la boite print ' 0) { print ' colspan="'.$nbcol.'"'; } print '>'.$head[0]['text'].""; - for ($i=0, $n=sizeof($contents); $i<$n; $i++) + // Affiche chaque ligne de la boite + for ($i=0, $n=sizeof($contents); $i < $n; $i++) { $var=!$var; print ''; - for ($j=0, $m=sizeof($contents[$i]); $j<$m; $j++) + // Affiche chaque cellule + for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++) { - print " 0) - { - print ' align="'. $contents[$i][$j]['align'].'"'; - } - if (strlen($contents[$i][$j]['width']) > 0) - { - print ' width="'. $contents[$i][$j]['width'].'"'; - } - print'>'; + $tdparam=""; + if ($contents[$i][$j]['align']) $tdparam.=' align="'. $contents[$i][$j]['align'].'"'; + if ($contents[$i][$j]['width']) $tdparam.=' width="'. $contents[$i][$j]['width'].'"'; - if (strlen($contents[$i][$j]['url']) > 0) - { - print ''; - print $contents[$i][$j]['text'] . ""; - } - else - { - print $contents[$i][$j]['text'] . ""; - } + if ($contents[$i][$j]['logo']) print '"; } print ''; } diff --git a/htdocs/includes/boxes/box_produits.php b/htdocs/includes/boxes/box_produits.php index e46e03d0dc9..24c0f9a891a 100644 --- a/htdocs/includes/boxes/box_produits.php +++ b/htdocs/includes/boxes/box_produits.php @@ -34,7 +34,7 @@ if ($user->rights->produit->lire) $info_box_contents = array(); - $sql = "SELECT p.label, p.rowid, p.price"; + $sql = "SELECT p.label, p.rowid, p.price, p.fk_product_type"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " ORDER BY p.datec DESC"; $sql .= $db->plimit(5, 0); @@ -50,13 +50,12 @@ if ($user->rights->produit->lire) $objp = $db->fetch_object($result); $info_box_contents[$i][0] = array('align' => 'left', - 'logo' => 'object_product', + 'logo' => ($objp->fk_product_type?'object_service':'object_product'), 'text' => $objp->label, 'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid); $info_box_contents[$i][1] = array('align' => 'right', - 'text' => price($objp->price), - 'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid); + 'text' => price($objp->price)); $i++; } } diff --git a/htdocs/includes/boxes/box_propales.php b/htdocs/includes/boxes/box_propales.php index b0371cc9869..1d5daa3b2a5 100644 --- a/htdocs/includes/boxes/box_propales.php +++ b/htdocs/includes/boxes/box_propales.php @@ -61,7 +61,7 @@ if ($user->rights->propale->lire) 'text' => $objp->ref, 'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid); - $info_box_contents[$i][1] = array('align' => 'center', + $info_box_contents[$i][1] = array('align' => 'left', 'text' => $objp->nom, 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp); $i++; diff --git a/htdocs/includes/boxes/box_services_vendus.php b/htdocs/includes/boxes/box_services_vendus.php index 899db6d0fde..24bca727ea1 100644 --- a/htdocs/includes/boxes/box_services_vendus.php +++ b/htdocs/includes/boxes/box_services_vendus.php @@ -32,13 +32,15 @@ $info_box_head[] = array('text' => "Les 5 derniers produits/services contract $info_box_contents = array(); -$sql = "SELECT s.nom,s.idp, p.label, c.rowid"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."product as p WHERE s.idp = c.fk_soc AND c.fk_product = p.rowid"; +$sql = "SELECT s.nom, s.idp, p.label, p.fk_product_type, c.rowid"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."product as p"; +$sql .= " WHERE s.idp = c.fk_soc AND c.fk_product = p.rowid"; if($user->societe_id) { $sql .= " AND s.idp = $user->societe_id"; } $sql .= " ORDER BY c.tms DESC "; + /* * */ @@ -57,14 +59,14 @@ if ($result) $objp = $db->fetch_object($result); $info_box_contents[$i][0] = array('align' => 'left', - 'logo' => 'object_product', - 'text' => $objp->nom, - 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp); - - $info_box_contents[$i][1] = array('align' => 'left', + 'logo' => ($objp->fk_product_type?'object_service':'object_product'), 'text' => $objp->label, 'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid); + $info_box_contents[$i][1] = array('align' => 'left', + 'text' => $objp->nom, + 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp); + $i++; } }
'; + else print ''; + + if ($contents[$i][$j]['url']) print ''; + if ($contents[$i][$j]['logo']) { + $logo=eregi_replace("^object_","",$contents[$i][$j]['logo']); + print img_object($langs->trans("Show"),$logo); + print ''; + } + $texte=$contents[$i][$j]['text']; + if ($MAXLENGTHBOX && strlen($texte) > $MAXLENGTHBOX) + { + $texte=substr($texte,0,$MAXLENGTHBOX)."..."; + } + print $texte; + if ($contents[$i][$j]['url']) print ''; + + print "