Qual: Modification de l'architecture des boites pour qu'elles fonctionnent sous formes de "classes".
Modification nécessaire pour plus de simplicité et souplesse dans leur utilisation ainsi que pour permettre leur internationnalisation.
This commit is contained in:
parent
5603130f61
commit
6aa1ffc805
@ -32,74 +32,53 @@
|
||||
|
||||
/** \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
|
||||
*/
|
||||
|
||||
class infoBox
|
||||
class InfoBox
|
||||
{
|
||||
var $db;
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param $head tableau des entetes de colonnes
|
||||
* \param $contents tableau des lignes
|
||||
* \param $DB Handler d'accès base
|
||||
*/
|
||||
function infoBox($head, $contents)
|
||||
function InfoBox($DB)
|
||||
{
|
||||
global $langs;
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
$MAXLENGTHBOX=70; // Mettre 0 pour pas de limite
|
||||
|
||||
$var = true;
|
||||
$bcx[0] = 'class="box_pair"';
|
||||
$bcx[1] = 'class="box_impair"';
|
||||
$nbcol=sizeof($contents[0])+1;
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
// Affiche titre de la boite
|
||||
print '<tr class="box_titre"><td';
|
||||
if ($nbcol > 0) { print ' colspan="'.$nbcol.'"'; }
|
||||
print '>'.$head[0]['text']."</td></tr>";
|
||||
|
||||
// Affiche chaque ligne de la boite
|
||||
for ($i=0, $n=sizeof($contents); $i < $n; $i++)
|
||||
/**
|
||||
* \brief Retourne liste des boites elligibles pour la zone
|
||||
* \param $zone ID de la zone (0 pour la Homepage, ...)
|
||||
* \return array Tableau des boites qualifiées
|
||||
*/
|
||||
function listBoxes($zone)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr valign="top" '.$bcx[$var].'>';
|
||||
$boxes=array();
|
||||
|
||||
// Affiche chaque cellule
|
||||
for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++)
|
||||
$sql = "SELECT b.rowid, b.box_id, d.file";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql .= " WHERE b.box_id = d.rowid";
|
||||
$sql .= " AND position = ".$zone;
|
||||
$sql .= " ORDER BY box_order";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$tdparam="";
|
||||
if ($contents[$i][$j]['align']) $tdparam.=' align="'. $contents[$i][$j]['align'].'"';
|
||||
if ($contents[$i][$j]['width']) $tdparam.=' width="'. $contents[$i][$j]['width'].'"';
|
||||
|
||||
if ($contents[$i][$j]['text']) {
|
||||
if ($contents[$i][$j]['logo']) print '<td width="16">';
|
||||
else print '<td '.$tdparam.'>';
|
||||
|
||||
if ($contents[$i][$j]['url']) print '<a href="'.$contents[$i][$j]['url'].'" title="'.$contents[$i][$j]['text'].'">';
|
||||
if ($contents[$i][$j]['logo']) {
|
||||
$logo=eregi_replace("^object_","",$contents[$i][$j]['logo']);
|
||||
print img_object($langs->trans("Show"),$logo);
|
||||
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)
|
||||
$num = $this->db->num_rows($result);
|
||||
$j = 0;
|
||||
while ($j < $num)
|
||||
{
|
||||
$texte=substr($texte,0,$MAXLENGTHBOX)."...";
|
||||
}
|
||||
print $texte;
|
||||
if ($contents[$i][$j]['url']) print '</a>';
|
||||
|
||||
print "</td>";
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$boxes[$j]=eregi_replace('.php$','',$obj->file);
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
print '</tr>';
|
||||
else {
|
||||
return array();
|
||||
}
|
||||
return $boxes;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -27,15 +27,25 @@
|
||||
\brief Module de génération de l'affichage de la box boutique livres
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 20 derniers ouvrages");
|
||||
|
||||
$info_box_contents = array();
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_boutique_livre extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max derniers ouvrages");
|
||||
|
||||
$sql = "SELECT l.ref, l.title, l.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."livre as l ";
|
||||
$sql .= " ORDER BY l.date_ajout DESC ";
|
||||
$sql .= $db->plimit(20, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -49,7 +59,7 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_book',
|
||||
'text' => $objp->title,
|
||||
'url' => DOL_URL_ROOT."/boutique/livre/fiche.php?id=".$objp->rowid);
|
||||
@ -58,5 +68,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,10 +27,19 @@
|
||||
\brief Module de génération de l'affichage de la box clients
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 derniers clients enregistrés");
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
class box_clients extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max derniers clients enregistrés");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.client = 1";
|
||||
@ -39,7 +48,7 @@ if ($user->societe_id > 0)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY s.datec DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -53,7 +62,7 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_company',
|
||||
'text' => stripslashes($objp->nom),
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
@ -62,5 +71,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,13 +27,21 @@
|
||||
\brief Module de génération de l'affichage de la box commandes
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_commandes extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
if ($user->rights->commande->lire)
|
||||
{
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 dernières commandes");
|
||||
|
||||
$info_box_contents = array();
|
||||
$this->info_box_head = array('text' => "Les $max dernières commandes");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,p.ref,".$db->pdate("p.date_commande")." as dp,p.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as p WHERE p.fk_soc = s.idp";
|
||||
@ -42,7 +50,7 @@ if ($user->rights->commande->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY p.date_commande DESC, p.ref DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -56,17 +64,25 @@ if ($user->rights->commande->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_order',
|
||||
'text' => $objp->ref,
|
||||
'url' => DOL_URL_ROOT."/commande/fiche.php?id=".$objp->rowid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -29,26 +29,44 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require_once("includes/magpierss/rss_fetch.inc");
|
||||
require_once("./includes/magpierss/rss_fetch.inc");
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_external_rss extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
for($site = 0; $site < 1; $site++) {
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 dernières infos du site " . @constant("EXTERNAL_RSS_TITLE_". $site));
|
||||
$info_box_contents = array();
|
||||
$this->info_box_head = array('text' => "Les $max dernières infos du site " . @constant("EXTERNAL_RSS_TITLE_". $site));
|
||||
$rss = fetch_rss( @constant("EXTERNAL_RSS_URLRSS_" . $site) );
|
||||
for($i = 0; $i < 5 ; $i++){
|
||||
for($i = 0; $i < $max ; $i++){
|
||||
$item = $rss->items[$i];
|
||||
$href = $item['link'];
|
||||
$title = utf8_decode(urldecode($item['title']));
|
||||
$title=ereg_replace("([[:alnum:]])\?([[:alnum:]])","\\1'\\2",$title); // Gère problème des apostrophes mal codée/décodée par utf8
|
||||
$title=ereg_replace("^\s+","",$title); // Supprime espaces de début
|
||||
$info_box_contents["$href"]="$title";
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents["$href"]="$title";
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_rss',
|
||||
'text' => $title,
|
||||
'url' => $href);
|
||||
}
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,13 +27,21 @@
|
||||
\brief Module de génération de l'affichage de la box factures
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_factures extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 dernières factures clients enregistrées");
|
||||
|
||||
$info_box_contents = array();
|
||||
$this->info_box_head = array('text' => "Les $max dernières factures clients enregistrées");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp";
|
||||
@ -42,7 +50,7 @@ if ($user->rights->facture->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -56,18 +64,26 @@ if ($user->rights->facture->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_bill',
|
||||
'text' => $objp->facnumber,
|
||||
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -28,15 +28,22 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_factures_fourn extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max dernières factures fournisseurs enregistrées");
|
||||
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 dernières factures fournisseurs enregistrées");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp";
|
||||
if($user->societe_id)
|
||||
@ -44,7 +51,7 @@ if ($user->rights->facture->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -58,18 +65,25 @@ if ($user->rights->facture->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_bill',
|
||||
'text' => $objp->facnumber,
|
||||
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,14 +27,21 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_factures_fourn_imp extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$nbtoshow=5;
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les $nbtoshow plus anciennes factures fournisseurs impayées");
|
||||
|
||||
$info_box_contents = array();
|
||||
$this->info_box_head = array('text' => "Les $max plus anciennes factures fournisseurs impayées");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp AND f.paye=0 AND fk_statut = 1";
|
||||
@ -43,7 +50,7 @@ if ($user->rights->facture->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -56,12 +63,12 @@ if ($user->rights->facture->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_product',
|
||||
'text' => $objp->facnumber,
|
||||
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
|
||||
@ -69,6 +76,14 @@ if ($user->rights->facture->lire)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,15 +27,22 @@
|
||||
\brief Module de génération de l'affichage de la box factures impayees
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_factures_imp extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max plus anciennes factures clients impayées");
|
||||
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$nbtoshow=5;
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les $nbtoshow plus anciennes factures clients impayées");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND f.paye=0 AND fk_statut = 1";
|
||||
if($user->societe_id)
|
||||
@ -43,7 +50,7 @@ if ($user->rights->facture->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
|
||||
$sql .= $db->plimit($nbtoshow, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -56,19 +63,26 @@ if ($user->rights->facture->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_bill',
|
||||
'text' => $objp->facnumber,
|
||||
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -26,10 +26,19 @@
|
||||
\brief Module de génération de l'affichage de la box fournisseurs
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 derniers fournisseurs enregistrés");
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
class box_fournisseurs extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max5 derniers fournisseurs enregistrés");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur = 1";
|
||||
@ -38,7 +47,7 @@ if ($user->societe_id > 0)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY s.datec DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -52,7 +61,7 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_company',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
@ -61,5 +70,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -21,17 +21,25 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
/**
|
||||
\file htdocs/includes/boxes/box_osc_client.php
|
||||
\ingroup osc
|
||||
\brief Module de génération de l'affichage de la box osc client
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Clients");
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
class box_osc_clients extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Nombre de client");
|
||||
|
||||
$sql = "SELECT count(*) as cus FROM ".DB_NAME_OSC.".customers";
|
||||
|
||||
@ -46,7 +54,7 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'center',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'center',
|
||||
'logo' => 'object_product',
|
||||
'text' => $objp->cus,
|
||||
'url' => DOL_URL_ROOT."/boutique/client/index.php");
|
||||
@ -54,6 +62,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,38 +27,57 @@
|
||||
\brief Module de génération de l'affichage de la box produits
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_produits extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max derniers produits/services enregistrés");
|
||||
|
||||
if ($user->rights->produit->lire)
|
||||
{
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 derniers produits/services enregistrés");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
$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);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'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',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'right',
|
||||
'text' => price($objp->price));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,13 +27,21 @@
|
||||
\brief Module de génération de l'affichage de la box propales
|
||||
*/
|
||||
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_propales extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
if ($user->rights->propale->lire)
|
||||
{
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 dernières propositions");
|
||||
|
||||
$info_box_contents = array();
|
||||
$this->info_box_head = array('text' => "Les $max dernières propositions");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,p.ref,".$db->pdate("p.datep")." as dp,p.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p WHERE p.fk_soc = s.idp";
|
||||
@ -42,7 +50,7 @@ if ($user->rights->propale->lire)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY p.datep DESC, p.ref DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -56,17 +64,26 @@ if ($user->rights->propale->lire)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_propal',
|
||||
'text' => $objp->ref,
|
||||
'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid);
|
||||
|
||||
$info_box_contents[$i][1] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,10 +27,20 @@
|
||||
\brief Module de génération de l'affichage de la box prospect
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 derniers prospects enregistrés");
|
||||
|
||||
$info_box_contents = array();
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
|
||||
class box_prospect extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max derniers prospects enregistrés");
|
||||
|
||||
$sql = "SELECT s.nom,s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.client = 2";
|
||||
@ -39,7 +49,7 @@ if ($user->societe_id > 0)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY s.datec DESC ";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -53,7 +63,7 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => 'object_company',
|
||||
'text' => stripslashes($objp->nom),
|
||||
'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?id=".$objp->idp);
|
||||
@ -62,5 +72,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -27,10 +27,19 @@
|
||||
\brief Module de génération de l'affichage de la box services_vendus
|
||||
*/
|
||||
|
||||
$info_box_head = array();
|
||||
$info_box_head[] = array('text' => "Les 5 derniers produits/services contractés");
|
||||
include_once("./includes/boxes/modules_boxes.php");
|
||||
|
||||
$info_box_contents = array();
|
||||
|
||||
class box_services_vendus extends ModeleBoxes {
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
|
||||
$this->info_box_head = array('text' => "Les $max derniers produits/services contractés");
|
||||
|
||||
$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";
|
||||
@ -40,11 +49,7 @@ if($user->societe_id)
|
||||
$sql .= " AND s.idp = $user->societe_id";
|
||||
}
|
||||
$sql .= " ORDER BY c.tms DESC ";
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$sql .= $db->plimit(5, 0);
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -58,12 +63,12 @@ if ($result)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$info_box_contents[$i][0] = array('align' => 'left',
|
||||
$this->info_box_contents[$i][0] = 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',
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => $objp->nom,
|
||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||
|
||||
@ -71,5 +76,13 @@ if ($result)
|
||||
}
|
||||
}
|
||||
|
||||
new infoBox($info_box_head, $info_box_contents);
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
117
htdocs/includes/boxes/modules_boxes.php
Normal file
117
htdocs/includes/boxes/modules_boxes.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2005 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$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/includes/boxes/modules_boxes.php
|
||||
\ingroup facture
|
||||
\brief Fichier contenant la classe mère des boites
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class ModeleBoxes
|
||||
\brief Classe mère des boites
|
||||
*/
|
||||
|
||||
class ModeleBoxes
|
||||
{
|
||||
var $MAXLENGTHBOX=70; // Mettre 0 pour pas de limite
|
||||
|
||||
var $error='';
|
||||
|
||||
|
||||
/**
|
||||
\brief Renvoi le dernier message d'erreur de création de facture
|
||||
*/
|
||||
function error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Methode standard d'affichage des boites
|
||||
\param $head tableau des caractéristiques du titre
|
||||
\param $contents tableau des lignes de contenu
|
||||
*/
|
||||
function showBox($head, $contents)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$bcx[0] = 'class="box_pair"';
|
||||
$bcx[1] = 'class="box_impair"';
|
||||
|
||||
$var = true;
|
||||
$nbcol=sizeof($contents[0])+1;
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
// Affiche titre de la boite
|
||||
print '<tr class="box_titre"><td';
|
||||
if ($nbcol > 0) { print ' colspan="'.$nbcol.'"'; }
|
||||
print '>'.$head['text']."</td></tr>";
|
||||
|
||||
// Affiche chaque ligne de la boite
|
||||
for ($i=0, $n=sizeof($contents); $i < $n; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr valign="top" '.$bcx[$var].'>';
|
||||
|
||||
// Affiche chaque cellule
|
||||
for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++)
|
||||
{
|
||||
$tdparam="";
|
||||
if ($contents[$i][$j]['align']) $tdparam.=' align="'. $contents[$i][$j]['align'].'"';
|
||||
if ($contents[$i][$j]['width']) $tdparam.=' width="'. $contents[$i][$j]['width'].'"';
|
||||
|
||||
if ($contents[$i][$j]['text']) {
|
||||
if ($contents[$i][$j]['logo']) print '<td width="16">';
|
||||
else print '<td '.$tdparam.'>';
|
||||
|
||||
if ($contents[$i][$j]['url']) print '<a href="'.$contents[$i][$j]['url'].'" title="'.$contents[$i][$j]['text'].'">';
|
||||
if ($contents[$i][$j]['logo']) {
|
||||
$logo=eregi_replace("^object_","",$contents[$i][$j]['logo']);
|
||||
print img_object($langs->trans("Show"),$logo);
|
||||
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 "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -30,6 +30,8 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
$user->getrights('');
|
||||
|
||||
|
||||
// Simule le menu par défaut sur Home
|
||||
$_GET["mainmenu"]="home";
|
||||
@ -49,54 +51,33 @@ print "<br>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Boites
|
||||
* Affichage des boites
|
||||
*
|
||||
*/
|
||||
$user->getrights('');
|
||||
|
||||
$sql = "SELECT b.rowid, b.box_id, d.file";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql .= " WHERE b.box_id = d.rowid";
|
||||
$sql .= " AND position = 0"; // 0 = valeur pour la page accueil
|
||||
$sql .= " ORDER BY box_order";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$j = 0;
|
||||
|
||||
while ($j < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$boxes[$j] = "includes/boxes/".$obj->file;
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
include_once("./boxes.php");
|
||||
$infobox=new InfoBox($db);
|
||||
$boxes=$infobox->listboxes("0"); // 0 = valeur pour la page accueil
|
||||
|
||||
$NBCOLS=2; // Nombre de colonnes pour les boites
|
||||
print '<table width="100%">';
|
||||
|
||||
for ($ii=0, $ni=sizeof($boxes); $ii<$ni; $ii++)
|
||||
{
|
||||
if ($ii % 2 == 0)
|
||||
{
|
||||
print "<tr>\n";
|
||||
}
|
||||
|
||||
if ($ii % $NBCOLS == 0) print "<tr>\n";
|
||||
print '<td valign="top" width="50%">';
|
||||
include($boxes[$ii]);
|
||||
|
||||
// Affichage boite ii
|
||||
include_once("./includes/boxes/".$boxes[$ii].".php");
|
||||
$box=new $boxes[$ii]();
|
||||
$box->loadBox();
|
||||
$box->showBox();
|
||||
|
||||
print "</td>";
|
||||
|
||||
if ( ($ii -1) / 3 == 0)
|
||||
{
|
||||
print "</tr>\n";
|
||||
if ($ii % $NBCOLS == ($NBCOLS-1)) print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($ii % $NBCOLS == ($NBCOLS-1)) print "</tr>\n";
|
||||
print "</table>";
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
|
||||
@ -103,7 +103,6 @@ require_once(DOL_DOCUMENT_ROOT ."/user.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/menu.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/boxes.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/address.class.php");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user