From ea4ac30b286f8e3da4990cb51a1acbaa3f23298e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Aug 2013 21:39:39 +0200 Subject: [PATCH] Fix: more responsive box --- .../boxes/box_graph_product_distribution.php | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 1080c37caa2..a08c25ff81d 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/core/boxes/box_graph_product_distribution.php.php + * \file htdocs/core/boxes/box_graph_product_distribution.php * \ingroup factures * \brief Box to show graph of invoices per month */ @@ -90,9 +90,15 @@ class box_graph_product_distribution extends ModeleBoxes $showinvoicenb=GETPOST($param_showinvoicenb,'alpha',4); $showpropalnb=GETPOST($param_showpropalnb,'alpha',4); $showordernb=GETPOST($param_showordernb,'alpha',4); + if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } $nowarray=dol_getdate(dol_now(),true); $year=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + + $nbofgraph=0; + if ($showinvoicenb) $nbofgraph++; + if ($showpropalnb) $nbofgraph++; + if ($showordernb) $nbofgraph++; $paramtitle=$langs->trans("Products").'/'.$langs->trans("Services"); if (empty($conf->produit->enabled)) $paramtitle=$langs->trans("Services"); @@ -104,7 +110,7 @@ class box_graph_product_distribution extends ModeleBoxes $mode='customer'; $userid=0; - $WIDTH=(($showinvoicenb && $showpropalnb) || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; + $WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; $HEIGHT='192'; // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) @@ -284,40 +290,45 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); + $stringtoshow.=''; + $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("ForProposals"); + $stringtoshow.=' '.$langs->trans("ForProposals"); $stringtoshow.=' '; - $stringtoshow.=' '.$langs->trans("ForCustomersOrders"); + $stringtoshow.=' '.$langs->trans("ForCustomersOrders"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; $stringtoshow.=''; $stringtoshow.='
'; $stringtoshow.='
'; - //if ($showinvoicenb && $showpropalnb && $showordernb) - //{ + + if ($nbofgraph == 1) + { + if ($showinvoicenb) $stringtoshow.=$px1->show(); + else if ($showpropalnb) $stringtoshow.=$px2->show(); + else $stringtoshow.=$px3->show(); + } + if ($nbofgraph == 2) + { + $stringtoshow.='
'; + if ($showinvoicenb) $stringtoshow.=$px1->show(); + else if ($showpropalnb) $stringtoshow.=$px2->show(); + $stringtoshow.='
'; + if ($showordernb) $stringtoshow.=$px3->show(); + else if ($showpropalnb) $stringtoshow.=$px2->show(); + $stringtoshow.='
'; + } + if ($nbofgraph == 3) + { + $stringtoshow.='
'; + $stringtoshow.=$px1->show(); + $stringtoshow.='
'; + $stringtoshow.=$px2->show(); + $stringtoshow.='
'; $stringtoshow.='
'; - $stringtoshow.='
'; - //} - if ($showinvoicenb) $stringtoshow.=$px1->show(); - //if ($showinvoicenb && $showpropalnb) - //{ - $stringtoshow.='
'; - $stringtoshow.='
'; - //} - if ($showpropalnb) $stringtoshow.=$px2->show(); - //if ($showinvoicenb && $showpropalnb) - //{ - $stringtoshow.='
'; - $stringtoshow.='
'; - //} - if ($showordernb) $stringtoshow.=$px3->show(); - //if ($showinvoicenb && $showpropalnb) - //{ + $stringtoshow.=$px3->show(); $stringtoshow.='
'; - $stringtoshow.='
'; - //} + } $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else