diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php
index d34532f15b7..ec6ef3b465e 100644
--- a/htdocs/admin/boxes.php
+++ b/htdocs/admin/boxes.php
@@ -20,7 +20,7 @@
/**
* \file htdocs/admin/boxes.php
- * \brief Page d'administration/configuration des boites
+ * \brief Page to setup boxes
* \version $Id$
*/
@@ -53,7 +53,7 @@ if ($_POST["action"] == 'add')
$sql.= " WHERE fk_user = 0";
$sql.= " AND box_id = ".$_POST["boxid"];
$sql.= " AND position = ".$_POST["pos"];
-
+
$resql = $db->query($sql);
dol_syslog("boxes.php::search if box active sql=".$sql);
if ($resql)
@@ -62,7 +62,7 @@ if ($_POST["action"] == 'add')
if ($num == 0)
{
$db->begin();
-
+
// Si la boite n'est pas deja active, insert with box_order=''
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id";
@@ -75,10 +75,10 @@ if ($_POST["action"] == 'add')
$sql.= ", ''";
$sql.= ", 0";
$sql.= ")";
-
+
dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
-
+
// Remove all personalized setup when a box is activated or disabled
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
@@ -87,7 +87,7 @@ if ($_POST["action"] == 'add')
$db->commit();
}
-
+
Header("Location: boxes.php");
exit;
}
@@ -100,11 +100,11 @@ if ($_POST["action"] == 'add')
if ($_GET["action"] == 'delete')
{
$db->begin();
-
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE rowid=".$_GET["rowid"];
$resql = $db->query($sql);
-
+
// Remove all personalized setup when a box is activated or disabled
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
@@ -117,13 +117,13 @@ if ($_GET["action"] == 'switch')
{
// On permute les valeur du champ box_order des 2 lignes de la table boxes
$db->begin();
-
+
$objfrom=new ModeleBoxes($db);
$objfrom->fetch($_GET["switchfrom"]);
-
+
$objto=new ModeleBoxes($db);
$objto->fetch($_GET["switchto"]);
-
+
if (is_object($objfrom) && is_object($objto))
{
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$objto->box_order."' WHERE rowid=".$objfrom->rowid;
@@ -135,7 +135,7 @@ if ($_GET["action"] == 'switch')
$resultupdateto = $db->query($sql);
if (! $resultupdateto) { dol_print_error($db); }
}
-
+
if ($resultupdatefrom && $resultupdateto)
{
$db->commit();
@@ -180,7 +180,7 @@ if ($resql)
$obj = $db->fetch_object($resql);
$boxes[$obj->position][$obj->box_id]=1;
$i++;
-
+
array_push($actives,$obj->box_id);
if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) $decalage++;
@@ -266,15 +266,15 @@ $var=True;
if ($resql)
{
$html=new Form($db);
-
+
$num = $db->num_rows($resql);
$i = 0;
-
+
// Boucle sur toutes les boites
while ($i < $num)
{
$obj = $db->fetch_object($resql);
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$module = $regs[1];
@@ -285,10 +285,10 @@ if ($resql)
$module=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/includes/boxes/".$module.".php";
}
-
+
include_once(DOL_DOCUMENT_ROOT.$sourcefile);
$box=new $module($db,$obj->note);
-
+
// if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1)
if (in_array($obj->rowid, $actives))
{
@@ -297,7 +297,7 @@ if ($resql)
else
{
$var = ! $var;
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$logo = $box->boximg;
@@ -306,14 +306,14 @@ if ($resql)
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
-
+
print '
';
}
$i++;
}
-
+
$db->free($resql);
}
@@ -365,18 +365,18 @@ if ($resql)
$num = $db->num_rows($resql);
$i = 0;
$var=true;
-
+
$box_order=1;
$foundrupture=1;
-
+
// On lit avec un coup d'avance
$obj = $db->fetch_object($resql);
-
+
while ($obj && $i < $num)
{
$var = ! $var;
$objnext = $db->fetch_object($resql);
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$module = $regs[1];
@@ -387,10 +387,10 @@ if ($resql)
$module=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/includes/boxes/".$module.".php";
}
-
+
include_once(DOL_DOCUMENT_ROOT.$sourcefile);
$box=new $module($db,$obj->note);
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$logo = $box->boximg;
@@ -399,7 +399,7 @@ if ($resql)
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
-
+
print '';
print '| '.img_object("",$logo).' '.$box->boxlabel.' | ';
print '' . ($obj->note?$obj->note:' ') . ' | ';
@@ -416,17 +416,17 @@ if ($resql)
print '';
print ''.img_delete().'';
print ' | ';
-
+
print "
\n";
$i++;
-
+
$box_order++;
-
+
if (! $foundrupture) $objprevious = $obj;
else $box_order=1;
$obj=$objnext;
}
-
+
$db->free($resql);
}
diff --git a/htdocs/boxes.php b/htdocs/boxes.php
index 1522a3ad919..75a906a02ce 100644
--- a/htdocs/boxes.php
+++ b/htdocs/boxes.php
@@ -28,6 +28,149 @@
+/**
+ * \brief Show a HTML Tab with boxes of a particular area including personalized choices of user
+ * \param user User
+ * \param areacode Code of area for pages (0=value for Home page)
+ * \return int <0 if KO, Nb of boxes shown of OK (0 to n)
+ */
+function printBoxesArea($user,$areacode)
+{
+ global $conf,$langs,$db;
+
+ $infobox=new InfoBox($db);
+ $boxarray=$infobox->listboxes($areacode,$user);
+
+ //$boxid_left = array();
+ //$boxid_right = array();
+ if (sizeof($boxarray))
+ {
+ print_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
+ print '';
+ print ''."\n";
+
+ print '';
+
+ // Affichage colonne gauche
+ print '| '."\n";
+
+ print "\n\n";
+ print ' '."\n";
+
+ $ii=0;
+ foreach ($boxarray as $key => $box)
+ {
+ if (preg_match('/^A/i',$box->box_order)) // column A
+ {
+ $ii++;
+ //print 'box_id '.$boxarray[$ii]->box_id.' ';
+ //print 'box_order '.$boxarray[$ii]->box_order.' ';
+ //$boxid_left[$key] = $box->box_id;
+ // Affichage boite key
+ $box->loadBox($conf->box_max_lines);
+ $box->showBox();
+ }
+ }
+
+ // If no box on left, we add an invisible empty box
+ if ($ii==0)
+ {
+ $emptybox=new ModeleBoxes($db);
+ $emptybox->box_id='A';
+ $emptybox->info_box_head=array();
+ $emptybox->info_box_contents=array();
+ $emptybox->showBox(array(),array());
+ }
+
+ print " \n";
+ print "\n";
+
+ print " | \n";
+ // Affichage colonne droite
+ print '';
+
+ print "\n\n";
+ print ' '."\n";
+
+ $ii=0;
+ foreach ($boxarray as $key => $box)
+ {
+ if (preg_match('/^B/i',$box->box_order)) // colonne B
+ {
+ $ii++;
+ //print 'box_id '.$boxarray[$ii]->box_id.' ';
+ //print 'box_order '.$boxarray[$ii]->box_order.' ';
+ //$boxid_right[$key] = $boxarray[$key]->box_id;
+ // Affichage boite key
+ $box->loadBox($conf->box_max_lines);
+ $box->showBox();
+ }
+ }
+
+ // If no box on right, we show add an invisible empty box
+ if ($ii==0)
+ {
+ $emptybox=new ModeleBoxes($db);
+ $emptybox->box_id='B';
+ $emptybox->info_box_head=array();
+ $emptybox->info_box_contents=array();
+ $emptybox->showBox(array(),array());
+ }
+
+ print " \n";
+ print "\n";
+ print " | ";
+ print " \n";
+ print "\n";
+
+ print " |
";
+ print "
";
+
+ if ($conf->use_javascript_ajax)
+ {
+ print "\n";
+ print ''."\n";
+ }
+ }
+
+ return sizeof($boxarray);
+}
+
+
+
/**
* \class InfoBox
* \brief Classe permettant la gestion des boxes sur une page
@@ -80,7 +223,7 @@ class InfoBox
while ($j < $num)
{
$obj = $this->db->fetch_object($result);
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$module = $regs[1];
@@ -91,10 +234,10 @@ class InfoBox
$module=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/includes/boxes/".$module.".php";
}
-
+
include_once(DOL_DOCUMENT_ROOT.$sourcefile);
$box=new $module($db,$obj->note);
-
+
$box->rowid=$obj->rowid;
$box->box_id=$obj->box_id;
$box->position=$obj->position;
@@ -140,7 +283,7 @@ class InfoBox
while ($j < $num)
{
$obj = $this->db->fetch_object($result);
-
+
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$module = $regs[1];
@@ -151,10 +294,10 @@ class InfoBox
$module=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/includes/boxes/".$module.".php";
}
-
+
include_once(DOL_DOCUMENT_ROOT.$sourcefile);
$box=new $module($db,$obj->note);
-
+
$box->rowid=$obj->rowid;
$box->box_id=$obj->box_id;
$box->position=$obj->position;
@@ -287,5 +430,10 @@ class InfoBox
return -1;
}
}
+
}
+
+
+
+
?>
diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
index fd8476434f9..c9851ba42c9 100644
--- a/htdocs/contrat/contrat.class.php
+++ b/htdocs/contrat/contrat.class.php
@@ -5,7 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2008 Raphael Bertrand (Resultic)
* Copyright (C) 2010 Juanjo Menent
- *
+ *
* 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
@@ -1075,12 +1075,16 @@ class Contrat extends CommonObject
if ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4'); }
if ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6'); }
}
- if ($mode == 4)
+ if ($mode == 4 || $mode == 6)
{
$line=new ContratLigne($this->db);
- $text=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed);
- $text.=' '.$langs->trans("Services");
- $text.=': ';
+ $text='';
+ if ($mode == 4)
+ {
+ $text=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed);
+ $text.=' '.$langs->trans("Services");
+ $text.=': ';
+ }
$text.=$this->nbofserviceswait.' '.$line->LibStatut(0,3).' ';
$text.=$this->nbofservicesopened.' '.$line->LibStatut(4,3,0).' ';
$text.=$this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).' ';
diff --git a/htdocs/includes/boxes/box_contracts.php b/htdocs/includes/boxes/box_contracts.php
index e11cd19c049..5e9216d103b 100644
--- a/htdocs/includes/boxes/box_contracts.php
+++ b/htdocs/includes/boxes/box_contracts.php
@@ -46,9 +46,9 @@ class box_contracts extends ModeleBoxes {
function box_contracts()
{
global $langs;
-
+
$langs->load("contracts");
-
+
$this->boxlabel=$langs->trans("BoxLastContracts");
}
@@ -64,15 +64,14 @@ class box_contracts extends ModeleBoxes {
include_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
$contractstatic=new Contrat($db);
-
+
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
-
+
if ($user->rights->contrat->lire)
{
$sql = "SELECT s.nom, s.rowid as socid,";
$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql.= ", ".MAIN_DB_PREFIX."contrat as c";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
@@ -80,52 +79,59 @@ class box_contracts extends ModeleBoxes {
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
$sql.= $db->plimit($max, 0);
-
+
$result = $db->query($sql);
-
+
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
-
+
$i = 0;
-
+
while ($i < $num)
{
$objp = $db->fetch_object($result);
$datec=$db->jdate($objp->datec);
$dateterm=$db->jdate($objp->fin_validite);
$dateclose=$db->jdate($objp->date_cloture);
-
$late = '';
- if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
-
+
+ $contractstatic->statut=$objp->fk_statut;
+ $contractstatic->id=$objp->rowid;
+ $result=$contractstatic->fetch_lignes();
+
+ // fin_validite is no more on contract but on services
+ // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
+
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid);
-
+
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
- 'text' => $objp->ref,
+ 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref
'text2'=> $late,
'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid);
-
+
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);
-
+
$this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => dol_trunc($objp->nom,40),
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);
-
+
$this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day'));
-
- $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"',
- 'text' => $contractstatic->LibStatut($objp->fk_statut,3));
-
+
+ $this->info_box_contents[$i][5] = array('td' => 'align="right" nowrap="nowrap"',
+ 'text' => $contractstatic->getLibStatut(6),
+ 'asis'=>1
+ );
+
$i++;
}
-
+
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContracts"));
}
else
diff --git a/htdocs/includes/boxes/modules_boxes.php b/htdocs/includes/boxes/modules_boxes.php
index b33e166a31d..02653bda5eb 100644
--- a/htdocs/includes/boxes/modules_boxes.php
+++ b/htdocs/includes/boxes/modules_boxes.php
@@ -90,7 +90,7 @@ class ModeleBoxes
/**
- * \brief Methode standard d'affichage des boites
+ * \brief Standard method to show a box (usage by boxes not mandatory, a box can still use its own function)
* \param $head tableau des caracteristiques du titre
* \param $contents tableau des lignes de contenu
*/
@@ -186,7 +186,8 @@ class ModeleBoxes
print '';
// Url
- if (! empty($contents[$i][$j]['url'])) {
+ if (! empty($contents[$i][$j]['url']))
+ {
print '"
print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
@@ -204,13 +205,13 @@ class ModeleBoxes
if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
if ($maxlength) $textewithnotags=dol_trunc($textewithnotags,$maxlength);
- if (preg_match('/^ ';
- if (preg_match('/^ ";
diff --git a/htdocs/index.php b/htdocs/index.php
index ffba410bf95..afbe0e1f319 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -560,140 +560,15 @@ if ($nboflate > 0)
}
print ' | ';
+print '
';
/*
* Show boxes
*/
-$infobox=new InfoBox($db);
-$boxarray=$infobox->listboxes("0",$user); // 0=value for home page
-//$boxid_left = array();
-//$boxid_right = array();
+printBoxesArea($user,"0");
-if (sizeof($boxarray))
-{
- print '
';
- print_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
- print '';
- print ''."\n";
-
- print '';
-
- // Affichage colonne gauche
- print '| '."\n";
-
- print "\n\n";
- print ' '."\n";
-
- $ii=0;
- foreach ($boxarray as $key => $box)
- {
- if (preg_match('/^A/i',$box->box_order)) // column A
- {
- $ii++;
- //print 'box_id '.$boxarray[$ii]->box_id.' ';
- //print 'box_order '.$boxarray[$ii]->box_order.' ';
- //$boxid_left[$key] = $box->box_id;
- // Affichage boite key
- $box->loadBox($conf->box_max_lines);
- $box->showBox();
- }
- }
-
- // If no box on left, we add an invisible empty box
- if ($ii==0)
- {
- $emptybox=new ModeleBoxes($db);
- $emptybox->box_id='A';
- $emptybox->info_box_head=array();
- $emptybox->info_box_contents=array();
- $emptybox->showBox(array(),array());
- }
-
- print " \n";
- print "\n";
-
- print " | \n";
- // Affichage colonne droite
- print '';
-
- print "\n\n";
- print ' '."\n";
-
- $ii=0;
- foreach ($boxarray as $key => $box)
- {
- if (preg_match('/^B/i',$box->box_order)) // colonne B
- {
- $ii++;
- //print 'box_id '.$boxarray[$ii]->box_id.' ';
- //print 'box_order '.$boxarray[$ii]->box_order.' ';
- //$boxid_right[$key] = $boxarray[$key]->box_id;
- // Affichage boite key
- $box->loadBox($conf->box_max_lines);
- $box->showBox();
- }
- }
-
- // If no box on right, we show add an invisible empty box
- if ($ii==0)
- {
- $emptybox=new ModeleBoxes($db);
- $emptybox->box_id='B';
- $emptybox->info_box_head=array();
- $emptybox->info_box_contents=array();
- $emptybox->showBox(array(),array());
- }
-
- print " \n";
- print "\n";
- print " | ";
- print " \n";
- print "\n";
-
- print " |
";
- print "
";
-
- if ($conf->use_javascript_ajax)
- {
- print "\n";
- print ''."\n";
- }
-}
/*