New: Personalisation des boxes par un picto.

This commit is contained in:
Laurent Destailleur 2005-02-01 17:55:16 +00:00
parent 86ff67819d
commit fad86554d2
4 changed files with 54 additions and 44 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,16 +21,16 @@
* *
*/ */
/*! \file htdocs/boxes.php /** \file htdocs/boxes.php
\brief Fichier de la classe boxes \brief Fichier de la classe boxes
\author Rodolphe Qiedeville \author Rodolphe Qiedeville
\author Laurent Destailleur \author Laurent Destailleur
\version $Revision$ \version $Revision$
*/ */
/*! \class infoBox /** \class infoBox
\brief Classe permettant la gestion des boxes sur une page \brief Classe permettant la gestion des boxes sur une page
\remarks Cette classe est utilisé par les fichiers includes/boxes/box_xxx.php \remarks Cette classe est utilisé par les fichiers includes/boxes/box_xxx.php
\remarks qui sont les modules de boites \remarks qui sont les modules de boites
@ -39,51 +39,60 @@
class infoBox class infoBox
{ {
/*! /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param $head tableau des entetes de colonnes * \param $head tableau des entetes de colonnes
* \param $contents tableau des lignes * \param $contents tableau des lignes
*/ */
function infoBox($head, $contents) function infoBox($head, $contents)
{ {
global $langs;
$MAXLENGTHBOX=70; // Mettre 0 pour pas de limite
$var = true; $var = true;
$bcx[0] = 'class="box_pair"'; $bcx[0] = 'class="box_pair"';
$bcx[1] = 'class="box_impair"'; $bcx[1] = 'class="box_impair"';
$nbcol=sizeof($contents[0]); $nbcol=sizeof($contents[0])+1;
print '<table width="100%" cellpadding="2" cellspacing="0" class="noborder">'; print '<table width="100%" class="noborder">';
// Affiche titre de la boite
print '<tr class="box_titre"><td'; print '<tr class="box_titre"><td';
if ($nbcol > 0) { print ' colspan="'.$nbcol.'"'; } if ($nbcol > 0) { print ' colspan="'.$nbcol.'"'; }
print '>'.$head[0]['text']."</td></tr>"; print '>'.$head[0]['text']."</td></tr>";
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; $var=!$var;
print '<tr valign="top" '.$bcx[$var].'>'; print '<tr valign="top" '.$bcx[$var].'>';
for ($j=0, $m=sizeof($contents[$i]); $j<$m; $j++) // Affiche chaque cellule
for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++)
{ {
print "<td"; $tdparam="";
if (strlen($contents[$i][$j]['align']) > 0) if ($contents[$i][$j]['align']) $tdparam.=' align="'. $contents[$i][$j]['align'].'"';
{ if ($contents[$i][$j]['width']) $tdparam.=' width="'. $contents[$i][$j]['width'].'"';
print ' align="'. $contents[$i][$j]['align'].'"';
}
if (strlen($contents[$i][$j]['width']) > 0)
{
print ' width="'. $contents[$i][$j]['width'].'"';
}
print'>';
if (strlen($contents[$i][$j]['url']) > 0) if ($contents[$i][$j]['logo']) print '<td width="16">';
{ else print '<td '.$tdparam.'>';
print '<a href="'.$contents[$i][$j]['url'].'">';
print $contents[$i][$j]['text'] . "</a></td>"; if ($contents[$i][$j]['url']) print '<a href="'.$contents[$i][$j]['url'].'" title="'.$contents[$i][$j]['text'].'">';
} if ($contents[$i][$j]['logo']) {
else $logo=eregi_replace("^object_","",$contents[$i][$j]['logo']);
{ print img_object($langs->trans("Show"),$logo);
print $contents[$i][$j]['text'] . "</td>"; print '</a></td><td '.$tdparam.'><a href="'.$contents[$i][$j]['url'].'" title="'.$contents[$i][$j]['text'].'">';
} }
$texte=$contents[$i][$j]['text'];
if ($MAXLENGTHBOX && strlen($texte) > $MAXLENGTHBOX)
{
$texte=substr($texte,0,$MAXLENGTHBOX)."...";
}
print $texte;
if ($contents[$i][$j]['url']) print '</a>';
print "</td>";
} }
print '</tr>'; print '</tr>';
} }

View File

@ -34,7 +34,7 @@ if ($user->rights->produit->lire)
$info_box_contents = array(); $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 .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= " ORDER BY p.datec DESC"; $sql .= " ORDER BY p.datec DESC";
$sql .= $db->plimit(5, 0); $sql .= $db->plimit(5, 0);
@ -50,13 +50,12 @@ if ($user->rights->produit->lire)
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$info_box_contents[$i][0] = array('align' => 'left', $info_box_contents[$i][0] = array('align' => 'left',
'logo' => 'object_product', 'logo' => ($objp->fk_product_type?'object_service':'object_product'),
'text' => $objp->label, 'text' => $objp->label,
'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid);
$info_box_contents[$i][1] = array('align' => 'right', $info_box_contents[$i][1] = array('align' => 'right',
'text' => price($objp->price), 'text' => price($objp->price));
'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid);
$i++; $i++;
} }
} }

View File

@ -61,7 +61,7 @@ if ($user->rights->propale->lire)
'text' => $objp->ref, 'text' => $objp->ref,
'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid); '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, 'text' => $objp->nom,
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp); 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
$i++; $i++;

View File

@ -32,13 +32,15 @@ $info_box_head[] = array('text' => "Les 5 derniers produits/services contract
$info_box_contents = array(); $info_box_contents = array();
$sql = "SELECT s.nom,s.idp, p.label, c.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 WHERE s.idp = c.fk_soc AND c.fk_product = p.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) if($user->societe_id)
{ {
$sql .= " AND s.idp = $user->societe_id"; $sql .= " AND s.idp = $user->societe_id";
} }
$sql .= " ORDER BY c.tms DESC "; $sql .= " ORDER BY c.tms DESC ";
/* /*
* *
*/ */
@ -57,14 +59,14 @@ if ($result)
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$info_box_contents[$i][0] = array('align' => 'left', $info_box_contents[$i][0] = array('align' => 'left',
'logo' => 'object_product', 'logo' => ($objp->fk_product_type?'object_service':'object_product'),
'text' => $objp->nom,
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
$info_box_contents[$i][1] = array('align' => 'left',
'text' => $objp->label, 'text' => $objp->label,
'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid); '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++; $i++;
} }
} }