diff --git a/htdocs/boxes.php b/htdocs/boxes.php
index 989902ca1a1..8cb244d3072 100644
--- a/htdocs/boxes.php
+++ b/htdocs/boxes.php
@@ -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
- */
- function infoBox($head, $contents)
- {
- global $langs;
+ /**
+ * \brief Constructeur de la classe
+ * \param $DB Handler d'accès base
+ */
+ function InfoBox($DB)
+ {
+ $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 '
';
-
- // Affiche titre de la boite
- print '| 0) { print ' colspan="'.$nbcol.'"'; }
- print '>'.$head[0]['text']." |
";
-
- // Affiche chaque ligne de la boite
- for ($i=0, $n=sizeof($contents); $i < $n; $i++)
- {
- $var=!$var;
- print '';
-
- // 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 '| ';
- 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 " | ";
+ /**
+ * \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)
+ {
+ $boxes=array();
+
+ $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)
+ {
+ $num = $this->db->num_rows($result);
+ $j = 0;
+ while ($j < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ $boxes[$j]=eregi_replace('.php$','',$obj->file);
+ $j++;
+ }
}
- }
- print '
';
- }
-
- print "
";
- }
+ else {
+ return array();
+ }
+ return $boxes;
+ }
+
}
?>
diff --git a/htdocs/includes/boxes/box_boutique_livre.php b/htdocs/includes/boxes/box_boutique_livre.php
index a6eaa20c770..500a7aaef0d 100644
--- a/htdocs/includes/boxes/box_boutique_livre.php
+++ b/htdocs/includes/boxes/box_boutique_livre.php
@@ -27,36 +27,54 @@
\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");
-$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);
-$result = $db->query($sql);
+class box_boutique_livre extends ModeleBoxes {
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $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);
+ 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($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $i++;
+ }
+ }
- $i++;
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
?>
diff --git a/htdocs/includes/boxes/box_clients.php b/htdocs/includes/boxes/box_clients.php
index 03bebef84b1..49e6ec46077 100644
--- a/htdocs/includes/boxes/box_clients.php
+++ b/htdocs/includes/boxes/box_clients.php
@@ -27,40 +27,57 @@
\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();
-$sql = "SELECT s.nom,s.idp";
-$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.client = 1";
-if ($user->societe_id > 0)
-{
- $sql .= " AND s.idp = $user->societe_id";
-}
-$sql .= " ORDER BY s.datec DESC ";
-$sql .= $db->plimit(5, 0);
+class box_clients extends ModeleBoxes {
-$result = $db->query($sql);
+ var $info_box_head = array();
+ var $info_box_contents = array();
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $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);
+ 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";
+ if ($user->societe_id > 0)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY s.datec DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $i++;
+ }
+ }
- $i++;
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
?>
diff --git a/htdocs/includes/boxes/box_commandes.php b/htdocs/includes/boxes/box_commandes.php
index cbdeb4207e8..8be6c95fb3b 100644
--- a/htdocs/includes/boxes/box_commandes.php
+++ b/htdocs/includes/boxes/box_commandes.php
@@ -27,46 +27,62 @@
\brief Module de génération de l'affichage de la box commandes
*/
-if ($user->rights->commande->lire)
-{
+include_once("./includes/boxes/modules_boxes.php");
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les 5 dernières commandes");
- $info_box_contents = array();
+class box_commandes extends ModeleBoxes {
- $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";
- if($user->societe_id)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ if ($user->rights->commande->lire)
+ {
+ $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";
+ if($user->societe_id)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY p.date_commande DESC, p.ref DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ $i++;
+ }
+ }
+ }
}
- $sql .= " ORDER BY p.date_commande DESC, p.ref DESC ";
- $sql .= $db->plimit(5, 0);
-
- $result = $db->query($sql);
- if ($result)
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
- $i++;
- }
- }
- new infoBox($info_box_head, $info_box_contents);
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_external_rss.php b/htdocs/includes/boxes/box_external_rss.php
index 453c7b52a8c..dbd2ae15c9e 100644
--- a/htdocs/includes/boxes/box_external_rss.php
+++ b/htdocs/includes/boxes/box_external_rss.php
@@ -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++) {
+ $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 < $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
+ $this->info_box_contents["$href"]="$title";
+ $this->info_box_contents[$i][0] = array('align' => 'left',
+ 'logo' => 'object_rss',
+ 'text' => $title,
+ 'url' => $href);
+ }
+
+
+ }
+ }
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
-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();
- $rss = fetch_rss( @constant("EXTERNAL_RSS_URLRSS_" . $site) );
- for($i = 0; $i < 5 ; $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',
- 'logo' => 'object_rss',
- 'text' => $title,
- 'url' => $href);
- }
- new infoBox($info_box_head, $info_box_contents);
}
?>
diff --git a/htdocs/includes/boxes/box_factures.php b/htdocs/includes/boxes/box_factures.php
index a38750d494a..4157ea8cce3 100644
--- a/htdocs/includes/boxes/box_factures.php
+++ b/htdocs/includes/boxes/box_factures.php
@@ -27,47 +27,63 @@
\brief Module de génération de l'affichage de la box factures
*/
-if ($user->rights->facture->lire)
-{
+include_once("./includes/boxes/modules_boxes.php");
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les 5 dernières factures clients enregistrées");
- $info_box_contents = array();
+class box_factures extends ModeleBoxes {
- $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";
- if($user->societe_id)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ if ($user->rights->facture->lire)
+ {
+ $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";
+ if($user->societe_id)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ $i++;
+ }
+ }
+
+ }
}
- $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
- $sql .= $db->plimit(5, 0);
-
- $result = $db->query($sql);
-
- if ($result)
+
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
- $i++;
- }
+ parent::showBox($this->info_box_head, $this->info_box_contents);
}
-
- new infoBox($info_box_head, $info_box_contents);
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_factures_fourn.php b/htdocs/includes/boxes/box_factures_fourn.php
index cf0ce3d2854..a48bd04f32e 100644
--- a/htdocs/includes/boxes/box_factures_fourn.php
+++ b/htdocs/includes/boxes/box_factures_fourn.php
@@ -28,48 +28,62 @@
\version $Revision$
*/
+include_once("./includes/boxes/modules_boxes.php");
-if ($user->rights->facture->lire)
-{
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les 5 dernières factures fournisseurs enregistrées");
+class box_factures_fourn extends ModeleBoxes {
- $info_box_contents = array();
+ var $info_box_head = array();
+ var $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)
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ $this->info_box_head = array('text' => "Les $max dernières factures fournisseurs enregistrées");
+
+ if ($user->rights->facture->lire)
+ {
+ $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)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ $i++;
+ }
+ }
+ }
}
- $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
- $sql .= $db->plimit(5, 0);
-
- $result = $db->query($sql);
-
- if ($result)
+
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
- $i++;
- }
+ parent::showBox($this->info_box_head, $this->info_box_contents);
}
-
- new infoBox($info_box_head, $info_box_contents);
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_factures_fourn_imp.php b/htdocs/includes/boxes/box_factures_fourn_imp.php
index 01e97b71d7e..a3626c66f46 100644
--- a/htdocs/includes/boxes/box_factures_fourn_imp.php
+++ b/htdocs/includes/boxes/box_factures_fourn_imp.php
@@ -27,48 +27,63 @@
\version $Revision$
*/
-if ($user->rights->facture->lire)
-{
- $nbtoshow=5;
-
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les $nbtoshow plus anciennes factures fournisseurs impayées");
+include_once("./includes/boxes/modules_boxes.php");
- $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 AND f.paye=0 AND fk_statut = 1";
- if($user->societe_id)
+class box_factures_fourn_imp extends ModeleBoxes {
+
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ if ($user->rights->facture->lire)
+ {
+ $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";
+ if($user->societe_id)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+
+ $i++;
+ }
+ }
+
+ }
}
- $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
- $sql .= $db->plimit(5, 0);
-
- $result = $db->query($sql);
- if ($result)
+
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
-
- $i++;
- }
+ parent::showBox($this->info_box_head, $this->info_box_contents);
}
-
- new infoBox($info_box_head, $info_box_contents);
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_factures_imp.php b/htdocs/includes/boxes/box_factures_imp.php
index c8c61cbf1c7..68129af532b 100644
--- a/htdocs/includes/boxes/box_factures_imp.php
+++ b/htdocs/includes/boxes/box_factures_imp.php
@@ -27,48 +27,62 @@
\brief Module de génération de l'affichage de la box factures impayees
*/
-if ($user->rights->facture->lire)
-{
- $nbtoshow=5;
-
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les $nbtoshow plus anciennes factures clients impayées");
+include_once("./includes/boxes/modules_boxes.php");
- $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)
+class box_factures_imp extends ModeleBoxes {
+
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ $this->info_box_head = array('text' => "Les $max plus anciennes factures clients impayées");
+
+ if ($user->rights->facture->lire)
+ {
+ $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)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+
+ $i++;
+ }
+ }
+ }
}
- $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
- $sql .= $db->plimit($nbtoshow, 0);
-
- $result = $db->query($sql);
- if ($result)
+
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
-
- $i++;
- }
+ parent::showBox($this->info_box_head, $this->info_box_contents);
}
-
- new infoBox($info_box_head, $info_box_contents);
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_fournisseurs.php b/htdocs/includes/boxes/box_fournisseurs.php
index 0f878325a35..c1dd0220b05 100644
--- a/htdocs/includes/boxes/box_fournisseurs.php
+++ b/htdocs/includes/boxes/box_fournisseurs.php
@@ -26,40 +26,57 @@
\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();
-$sql = "SELECT s.nom,s.idp";
-$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur = 1";
-if ($user->societe_id > 0)
-{
- $sql .= " AND s.idp = $user->societe_id";
-}
-$sql .= " ORDER BY s.datec DESC ";
-$sql .= $db->plimit(5, 0);
+class box_fournisseurs extends ModeleBoxes {
-$result = $db->query($sql);
+ var $info_box_head = array();
+ var $info_box_contents = array();
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $info_box_contents[$i][0] = array('align' => 'left',
- 'logo' => 'object_company',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ 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";
+ if ($user->societe_id > 0)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY s.datec DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $i++;
+ }
+ }
- $i++;
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
?>
diff --git a/htdocs/includes/boxes/box_osc_client.php b/htdocs/includes/boxes/box_osc_client.php
index 20062769caf..c6010f12ab3 100644
--- a/htdocs/includes/boxes/box_osc_client.php
+++ b/htdocs/includes/boxes/box_osc_client.php
@@ -21,39 +21,54 @@
*
*/
-/*!
+/**
\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");
-
-$info_box_contents = array();
+include_once("./includes/boxes/modules_boxes.php");
-$sql = "SELECT count(*) as cus FROM ".DB_NAME_OSC.".customers";
+class box_osc_clients extends ModeleBoxes {
-$result = $db->query($sql);
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $info_box_contents[$i][0] = array('align' => 'center',
- 'logo' => 'object_product',
- 'text' => $objp->cus,
- 'url' => DOL_URL_ROOT."/boutique/client/index.php");
- $i++;
+ global $user, $langs, $db;
+
+ $this->info_box_head = array('text' => "Nombre de client");
+
+ $sql = "SELECT count(*) as cus FROM ".DB_NAME_OSC.".customers";
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $this->info_box_contents[$i][0] = array('align' => 'center',
+ 'logo' => 'object_product',
+ 'text' => $objp->cus,
+ 'url' => DOL_URL_ROOT."/boutique/client/index.php");
+ $i++;
+ }
+ }
+
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
-
?>
diff --git a/htdocs/includes/boxes/box_produits.php b/htdocs/includes/boxes/box_produits.php
index 24c0f9a891a..f174e2c0c41 100644
--- a/htdocs/includes/boxes/box_produits.php
+++ b/htdocs/includes/boxes/box_produits.php
@@ -27,38 +27,57 @@
\brief Module de génération de l'affichage de la box produits
*/
-if ($user->rights->produit->lire)
-{
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les 5 derniers produits/services enregistrés");
+include_once("./includes/boxes/modules_boxes.php");
- $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);
-
- $result = $db->query($sql);
+class box_produits extends ModeleBoxes {
- if ($result)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $num = $db->num_rows();
- $i = 0;
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => price($objp->price));
- $i++;
- }
- }
- new infoBox($info_box_head, $info_box_contents);
+ global $user, $langs, $db;
+
+ $this->info_box_head = array('text' => "Les $max derniers produits/services enregistrés");
+
+ if ($user->rights->produit->lire)
+ {
+ $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($max, 0);
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'right',
+ 'text' => price($objp->price));
+ $i++;
+ }
+ }
+ else {
+ dolibarr_print_error($db);
+ }
+ }
+ }
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_propales.php b/htdocs/includes/boxes/box_propales.php
index f3dee35b1b9..15ce1b1df5f 100644
--- a/htdocs/includes/boxes/box_propales.php
+++ b/htdocs/includes/boxes/box_propales.php
@@ -27,46 +27,63 @@
\brief Module de génération de l'affichage de la box propales
*/
-if ($user->rights->propale->lire)
-{
+include_once("./includes/boxes/modules_boxes.php");
- $info_box_head = array();
- $info_box_head[] = array('text' => "Les 5 dernières propositions");
- $info_box_contents = array();
+class box_propales extends ModeleBoxes {
- $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";
- if($user->societe_id)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $sql .= " AND s.idp = $user->societe_id";
+ global $user, $langs, $db;
+
+ if ($user->rights->propale->lire)
+ {
+ $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";
+ if($user->societe_id)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY p.datep DESC, p.ref DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ $i++;
+ }
+ }
+
+ }
}
- $sql .= " ORDER BY p.datep DESC, p.ref DESC ";
- $sql .= $db->plimit(5, 0);
-
- $result = $db->query($sql);
- if ($result)
+ function showBox()
{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
-
- $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',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
- $i++;
- }
- }
- new infoBox($info_box_head, $info_box_contents);
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
+
?>
diff --git a/htdocs/includes/boxes/box_prospect.php b/htdocs/includes/boxes/box_prospect.php
index 4b4f3f89976..58e927d2a70 100644
--- a/htdocs/includes/boxes/box_prospect.php
+++ b/htdocs/includes/boxes/box_prospect.php
@@ -27,40 +27,58 @@
\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");
-$sql = "SELECT s.nom,s.idp";
-$sql .= " FROM ".MAIN_DB_PREFIX."societe as s WHERE s.client = 2";
-if ($user->societe_id > 0)
-{
- $sql .= " AND s.idp = $user->societe_id";
-}
-$sql .= " ORDER BY s.datec DESC ";
-$sql .= $db->plimit(5, 0);
-$result = $db->query($sql);
+class box_prospect extends ModeleBoxes {
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ var $info_box_head = array();
+ var $info_box_contents = array();
+
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $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);
+ 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";
+ if ($user->societe_id > 0)
+ {
+ $sql .= " AND s.idp = $user->societe_id";
+ }
+ $sql .= " ORDER BY s.datec DESC ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $i++;
+ }
+ }
- $i++;
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
?>
diff --git a/htdocs/includes/boxes/box_services_vendus.php b/htdocs/includes/boxes/box_services_vendus.php
index 24bca727ea1..d8c9b030fbd 100644
--- a/htdocs/includes/boxes/box_services_vendus.php
+++ b/htdocs/includes/boxes/box_services_vendus.php
@@ -27,49 +27,62 @@
\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();
-$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 ";
+class box_services_vendus extends ModeleBoxes {
-/*
- *
- */
-$sql .= $db->plimit(5, 0);
+ var $info_box_head = array();
+ var $info_box_contents = array();
-$result = $db->query($sql);
-
-if ($result)
-{
- $num = $db->num_rows();
-
- $i = 0;
-
- while ($i < $num)
+ function loadBox($max=5)
{
- $objp = $db->fetch_object($result);
-
- $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);
+ global $user, $langs, $db;
- $info_box_contents[$i][1] = array('align' => 'left',
- 'text' => $objp->nom,
- 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+ $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";
+ $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 ";
+ $sql .= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+
+ $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);
+
+ $this->info_box_contents[$i][1] = array('align' => 'left',
+ 'text' => $objp->nom,
+ 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
+
+ $i++;
+ }
+ }
- $i++;
}
+
+ function showBox()
+ {
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
+
}
-new infoBox($info_box_head, $info_box_contents);
?>
diff --git a/htdocs/includes/boxes/modules_boxes.php b/htdocs/includes/boxes/modules_boxes.php
new file mode 100644
index 00000000000..769f3adf9d9
--- /dev/null
+++ b/htdocs/includes/boxes/modules_boxes.php
@@ -0,0 +1,117 @@
+
+ *
+ * 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 '";
+ }
+
+}
+
+
+?>
diff --git a/htdocs/index.php b/htdocs/index.php
index 44b511d317d..e7f3b89b79a 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -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 "
\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 '';
-
for ($ii=0, $ni=sizeof($boxes); $ii<$ni; $ii++)
{
- if ($ii % 2 == 0)
- {
- print "\n";
- }
-
+ if ($ii % $NBCOLS == 0) print "
\n";
print '| ';
- include($boxes[$ii]);
+
+ // Affichage boite ii
+ include_once("./includes/boxes/".$boxes[$ii].".php");
+ $box=new $boxes[$ii]();
+ $box->loadBox();
+ $box->showBox();
+
print " | ";
-
- if ( ($ii -1) / 3 == 0)
- {
- print "
\n";
- }
+ if ($ii % $NBCOLS == ($NBCOLS-1)) print "\n";
}
-
+if ($ii % $NBCOLS == ($NBCOLS-1)) print "\n";
print "
";
+
$db->close();
llxFooter("Dernière modification $Date$ révision $Revision$");
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index a7e90a042f0..69cb0fb63f4 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -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");