From ed52dd963668a6311a912554ee239c6e187f2d92 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Fri, 19 Jul 2013 15:29:40 +0200
Subject: [PATCH] New: A more responsive desgin for statistic box of home page
 Qual: Hook for statistics now match specifications.

---
 ChangeLog                               |  15 +-
 htdocs/core/class/hookmanager.class.php |   3 +-
 htdocs/index.php                        | 252 +++++++++++++-----------
 htdocs/theme/amarok/style.css.php       |  20 +-
 htdocs/theme/auguria/style.css.php      |  19 ++
 htdocs/theme/bureau2crea/style.css.php  |  23 ++-
 htdocs/theme/cameleo/style.css.php      |  19 ++
 htdocs/theme/eldy/style.css.php         |  19 ++
 8 files changed, 239 insertions(+), 131 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0375d554b22..c028d285b35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,12 +29,12 @@ For users:
 - New: Can add an event automatically when a projet is create. 
 - New: Add option MAIN_GENERATE_DOCUMENT_WITH_PICTURE.
 - New: Add option excludethirdparties and onlythirdparties into merge pdf scripts.
+- New : [ task #925 ] Add ODT document generation for Tasks in project module.
+- New : [ task #924 ] Add numbering rule on task.
+- New : [ task #165 ] Add import/export of multiprices.
+- New: Add Maghreb regions and departments.
+- New: A more responsive desgin for statistic box of home page.
 - Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
-- New : [ task #925 ] Add ODT document generation for Tasks in project module
-- New : [ task #924 ] Add numbering rule on task
-- New : [ task #165 ] Add import/export of multiprices
-- New: Add Maghreb regions and departments
- 
 
 
 For translators:
@@ -55,6 +55,7 @@ For developers:
   key to use a specific language file.
 - New: Make some changes to allow usage of several alternative $dolibarr_main_url_root variables.
   Fix also several bugs with old code. 
+- Qual: All nowrap properties are now using CSS class nowrap. 
 
 WARNING: This may create regression for some external modules, but was necessary to make
 Dolibarr better:
@@ -65,8 +66,8 @@ If your action class for hook was returning a string or an array, instead your m
 set $actionclassinstance->results (to return array) 
 or $actionclassinstance->resprints (to return string)
 to return same thing. The return value must be replaced by a "return 0";
-Goal is to fix old compatibility code that does not match hook
-specification: http://wiki.dolibarr.org/index.php/Hooks_system   
+Goal is to fix old compatibility code that does not match hook specifications: 
+ http://wiki.dolibarr.org/index.php/Hooks_system   
 
 - Some methods object->addline used a first parameter that was object->id, some not. Of course
 this was not a good pratice, since object->id is already known so no need to provide it as 
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index e41334a30e0..bd13cc238b1 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -131,7 +131,8 @@ class HookManager
         // Define type of hook ('output', 'returnvalue' or 'addreplace'). 'addreplace' should be type for all hooks. 'output' and 'returnvalue' are deprecated.
         $hooktype='output';
         if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue';	// pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win.
-        if (in_array($method,array('doActions','formObjectOptions','moveUploadedFile','pdf_writelinedesc','paymentsupplierinvoices','printSearchForm', 'formattachOptions', 'formBuilddocLineOptions'))) $hooktype='addreplace';
+        if (in_array($method,array('addStatisticLine','doActions','formObjectOptions','moveUploadedFile','pdf_writelinedesc','paymentsupplierinvoices',
+        							'printSearchForm', 'formattachOptions', 'formBuilddocLineOptions'))) $hooktype='addreplace';
 
         // Loop on each hook to qualify modules that declared context
         $modulealreadyexecuted=array();
diff --git a/htdocs/index.php b/htdocs/index.php
index 6108985a0b6..adb35c29f4d 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -109,7 +109,7 @@ $langs->load("orders");
 $langs->load("contracts");
 
 //print memory_get_usage();
-if ($user->societe_id == 0)
+if (empty($user->societe_id))
 {
     print '<br>';
     print '<table class="noborder" width="100%">';
@@ -117,132 +117,146 @@ if ($user->societe_id == 0)
     print '<th class="liste_titre" colspan="2">'.$langs->trans("DolibarrStateBoard").'</th>';
     print '<th class="liste_titre" align="right">&nbsp;</th>';
     print '</tr>';
+    print '<tr><td colspan="3">';
 
     $var=true;
 
-    // Condition to be checked for each display line dashboard
-    $conditions=array(
-    ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
-    ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
-    ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
-    ! empty($conf->adherent->enabled) && $user->rights->adherent->lire,
-    ! empty($conf->product->enabled) && $user->rights->produit->lire,
-    ! empty($conf->service->enabled) && $user->rights->service->lire,
-    ! empty($conf->propal->enabled) && $user->rights->propale->lire,
-    ! empty($conf->commande->enabled) && $user->rights->commande->lire,
-    ! empty($conf->facture->enabled) && $user->rights->facture->lire,
-    ! empty($conf->contrat->enabled) && $user->rights->contrat->activer);
-    // Class file containing the method load_state_board for each line
-    $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
-    DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php",
-    DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php",
-    DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
-    DOL_DOCUMENT_ROOT."/product/class/product.class.php",
-    DOL_DOCUMENT_ROOT."/product/class/service.class.php",
-    DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
-    DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
-    DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
-    DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
-    // Name class containing the method load_state_board for each line
-    $classes=array('Client',
-                   'Prospect',
-                   'Fournisseur',
-                   'Adherent',
-                   'Product',
-                   'Service',
-				   'Propal',
-				   'Commande',
-				   'Facture',
-                   'Contrat');
-    // Cle array returned by the method load_state_board for each line
-    $keys=array('customers',
-                'prospects',
-                'suppliers',
-                'members',
-                'products',
-                'services',
-				'proposals',
-				'orders',
-				'invoices',
-				'Contracts');
-    // Dashboard Icon lines
-    $icons=array('company',
-                 'company',
-                 'company',
-                 'user',
-                 'product',
-                 'service',
-				 'propal',
-				 'order',
-				 'bill',
-				 'order');
-    // Translation keyword
-    $titres=array("ThirdPartyCustomersStats",
-                  "ThirdPartyProspectsStats",
-                  "Suppliers",
-                  "Members",
-                  "Products",
-                  "Services",
-                  "CommercialProposals",
-                  "CustomersOrders",
-                  "BillsCustomers",
-                  "Contracts");
-    // Dashboard Link lines
-    $links=array(DOL_URL_ROOT.'/comm/list.php',
-    DOL_URL_ROOT.'/comm/prospect/list.php',
-    DOL_URL_ROOT.'/fourn/liste.php',
-    DOL_URL_ROOT.'/adherents/liste.php?statut=1&mainmenu=members',
-    DOL_URL_ROOT.'/product/liste.php?type=0&mainmenu=products',
-    DOL_URL_ROOT.'/product/liste.php?type=1&mainmenu=products',
-    DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial',
-    DOL_URL_ROOT.'/commande/liste.php?mainmenu=commercial',
-    DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
-    DOL_URL_ROOT.'/contrat/liste.php');
-    // Translation lang files
-    $langfile=array("companies",
-                    "prospects",
-                    "suppliers",
-                    "members",
-                    "products",
-                    "produts",
-                    "propal",
-                    "orders",
-                    "bills",
-					"contracts");
-
-
-    // Loop and displays each line of table
-    foreach ($keys as $key=>$val)
-    {
-        if ($conditions[$key])
-        {
-            $classe=$classes[$key];
-            // Search in cache if load_state_board is already realized
-            if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe]))
-            {
-            	include_once $includes[$key];	// Loading a class cost around 1Mb
-
-                $board=new $classe($db);
-                $board->load_state_board($user);
-                $boardloaded[$classe]=$board;
-            }
-            else $board=$boardloaded[$classe];
-
-            $var=!$var;
-            if ($langfile[$key]) $langs->load($langfile[$key]);
-            $title=$langs->trans($titres[$key]);
-            print '<tr '.$bc[$var].'><td width="16">'.img_object($title,$icons[$key]).'</td>';
-            print '<td>'.$title.'</td>';
-            print '<td align="right"><a href="'.$links[$key].'">'.$board->nb[$val].'</a></td>';
-            print '</tr>';
-        }
-    }
-
     $object=new stdClass();
     $parameters=array();
     $action='';
     $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
 
+    if (empty($reshook))
+    {
+	    // Condition to be checked for each display line dashboard
+	    $conditions=array(
+	    ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
+	    ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
+	    ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
+	    ! empty($conf->adherent->enabled) && $user->rights->adherent->lire,
+	    ! empty($conf->product->enabled) && $user->rights->produit->lire,
+	    ! empty($conf->service->enabled) && $user->rights->service->lire,
+	    ! empty($conf->propal->enabled) && $user->rights->propale->lire,
+	    ! empty($conf->commande->enabled) && $user->rights->commande->lire,
+	    ! empty($conf->facture->enabled) && $user->rights->facture->lire,
+	    ! empty($conf->contrat->enabled) && $user->rights->contrat->activer);
+	    // Class file containing the method load_state_board for each line
+	    $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
+	    DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php",
+	    DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php",
+	    DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
+	    DOL_DOCUMENT_ROOT."/product/class/product.class.php",
+	    DOL_DOCUMENT_ROOT."/product/class/service.class.php",
+	    DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
+	    DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
+	    DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
+	    DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
+	    // Name class containing the method load_state_board for each line
+	    $classes=array('Client',
+	                   'Prospect',
+	                   'Fournisseur',
+	                   'Adherent',
+	                   'Product',
+	                   'Service',
+					   'Propal',
+					   'Commande',
+					   'Facture',
+	                   'Contrat');
+	    // Cle array returned by the method load_state_board for each line
+	    $keys=array('customers',
+	                'prospects',
+	                'suppliers',
+	                'members',
+	                'products',
+	                'services',
+					'proposals',
+					'orders',
+					'invoices',
+					'Contracts');
+	    // Dashboard Icon lines
+	    $icons=array('company',
+	                 'company',
+	                 'company',
+	                 'user',
+	                 'product',
+	                 'service',
+					 'propal',
+					 'order',
+					 'bill',
+					 'order');
+	    // Translation keyword
+	    $titres=array("ThirdPartyCustomersStats",
+	                  "ThirdPartyProspectsStats",
+	                  "Suppliers",
+	                  "Members",
+	                  "Products",
+	                  "Services",
+	                  "CommercialProposals",
+	                  "CustomersOrders",
+	                  "BillsCustomers",
+	                  "Contracts");
+	    // Dashboard Link lines
+	    $links=array(DOL_URL_ROOT.'/comm/list.php',
+	    DOL_URL_ROOT.'/comm/prospect/list.php',
+	    DOL_URL_ROOT.'/fourn/liste.php',
+	    DOL_URL_ROOT.'/adherents/liste.php?statut=1&mainmenu=members',
+	    DOL_URL_ROOT.'/product/liste.php?type=0&mainmenu=products',
+	    DOL_URL_ROOT.'/product/liste.php?type=1&mainmenu=products',
+	    DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial',
+	    DOL_URL_ROOT.'/commande/liste.php?mainmenu=commercial',
+	    DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
+	    DOL_URL_ROOT.'/contrat/liste.php');
+	    // Translation lang files
+	    $langfile=array("companies",
+	                    "prospects",
+	                    "suppliers",
+	                    "members",
+	                    "products",
+	                    "produts",
+	                    "propal",
+	                    "orders",
+	                    "bills",
+						"contracts");
+
+
+	    // Loop and displays each line of table
+	    foreach ($keys as $key=>$val)
+	    {
+	        if ($conditions[$key])
+	        {
+	            $classe=$classes[$key];
+	            // Search in cache if load_state_board is already realized
+	            if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe]))
+	            {
+	            	include_once $includes[$key];	// Loading a class cost around 1Mb
+
+	                $board=new $classe($db);
+	                $board->load_state_board($user);
+	                $boardloaded[$classe]=$board;
+	            }
+	            else $board=$boardloaded[$classe];
+
+	            $var=!$var;
+	            if ($langfile[$key]) $langs->load($langfile[$key]);
+	            $title=$langs->trans($titres[$key]);
+	            /*print '<tr '.$bc[$var].'><td width="16">'.img_object($title,$icons[$key]).'</td>';
+	            print '<td>'.$title.'</td>';
+	            print '<td align="right"><a href="'.$links[$key].'">'.$board->nb[$val].'</a></td>';
+	            print '</tr>';
+	            */
+	            print '<div class="boxstats">';
+	            print '<a href="'.$links[$key].'" class="nobold nounderline">';
+	            print img_object($title,$icons[$key]).' '.$title.'<br>';
+	            print '</a>';
+	            print '<a href="'.$links[$key].'">';
+	            print $board->nb[$val];
+	            print '</div>';
+	            print '</a>';
+	        }
+	    }
+    }
+
+    print '</td></tr>';
     print '</table>';
 }
 
diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php
index 2866da54411..e8b168f4507 100755
--- a/htdocs/theme/amarok/style.css.php
+++ b/htdocs/theme/amarok/style.css.php
@@ -333,7 +333,12 @@ th .button {
 .nowrap {
 	white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
 }
-
+.nobold {
+	font-weight: normal !important;
+}
+.nounderline {
+    text-decoration: none;
+}
 
 .blockvmenubookmarks .menu_contenu {
 	background-color: transparent;
@@ -1298,6 +1303,19 @@ tr.impair table.nobordernopadding td, tr.pair table.nobordernopadding td { paddi
  *  Boxes
  */
 
+.boxstats {
+    <?php print "float: ".$left.";\n"; ?>
+    margin: 4px;
+    padding: 4px;
+	/*-moz-box-shadow: 4px 4px 4px #DDD;
+    -webkit-box-shadow: 4px 4px 4px #DDD;
+    box-shadow: 4px 4px 4px #DDD;
+    margin-bottom: 8px !important;*/
+    border: 1px solid #AAA;
+    text-align: center;
+    border-radius: 5px;
+}
+
 .boxtable {
 	-moz-box-shadow:2px 4px 2px #cccccc;
 	-webkit-box-shadow:2px 4px 2px #cccccc;
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 3e0390b91c0..e2d8523a5b2 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -219,6 +219,12 @@ div.inline-block
 .nowrap {
 	white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
 }
+.nobold {
+	font-weight: normal !important;
+}
+.nounderline {
+    text-decoration: none;
+}
 
 
 /* ============================================================================== */
@@ -1432,6 +1438,19 @@ div.tabBar .noborder {
  *  Boxes
  */
 
+.boxstats {
+    <?php print "float: ".$left.";\n"; ?>
+    margin: 4px;
+    padding: 4px;
+	/*-moz-box-shadow: 4px 4px 4px #DDD;
+    -webkit-box-shadow: 4px 4px 4px #DDD;
+    box-shadow: 4px 4px 4px #DDD;
+    margin-bottom: 8px !important;*/
+    border: 1px solid #AAA;
+    text-align: center;
+    border-radius: 5px;
+}
+
 .boxtable {
 -moz-box-shadow: 4px 4px 4px #CCC;
 -webkit-box-shadow: 4px 4px 4px #CCC;
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index 7de1adf9cdb..bc4a8bde676 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -246,9 +246,13 @@ div.inline-block
 .nowrap {
 	white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
 }
-/*.dolibarrcombobox {
-	height: 22px;
-}*/
+.nobold {
+	font-weight: normal !important;
+}
+.nounderline {
+    text-decoration: none;
+}
+
 
 /* ============================================================================== */
 /* Styles to hide objects                                                         */
@@ -1570,6 +1574,19 @@ tr.pair td.nohover {
  *  Boxes
  */
 
+.boxstats {
+    <?php print "float: ".$left.";\n"; ?>
+    margin: 4px;
+    padding: 4px;
+	/*-moz-box-shadow: 4px 4px 4px #DDD;
+    -webkit-box-shadow: 4px 4px 4px #DDD;
+    box-shadow: 4px 4px 4px #DDD;
+    margin-bottom: 8px !important;*/
+    border: 1px solid #AAA;
+    text-align: center;
+    border-radius: 5px;
+}
+
 .box {
 	padding-right: 0px;
 	padding-left: 0px;
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index 316d8515158..9d4e3bef96a 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -224,6 +224,12 @@ div.inline-block
 .nowrap {
 	white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
 }
+.nobold {
+	font-weight: normal !important;
+}
+.nounderline {
+    text-decoration: none;
+}
 
 
 /* ============================================================================== */
@@ -1558,6 +1564,19 @@ border: 0px;
  *  Boxes
  */
 
+.boxstats {
+    <?php print "float: ".$left.";\n"; ?>
+    margin: 4px;
+    padding: 4px;
+	/*-moz-box-shadow: 4px 4px 4px #DDD;
+    -webkit-box-shadow: 4px 4px 4px #DDD;
+    box-shadow: 4px 4px 4px #DDD;
+    margin-bottom: 8px !important;*/
+    border: 1px solid #AAA;
+    text-align: center;
+    border-radius: 5px;
+}
+
 .box {
 	padding-right: 0px;
 	padding-left: 0px;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 8a49ac69e3b..130a6fa8706 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -381,6 +381,12 @@ th .button {
 .nowrap {
 	white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
 }
+.nobold {
+	font-weight: normal !important;
+}
+.nounderline {
+    text-decoration: none;
+}
 
 
 /* ============================================================================== */
@@ -1818,6 +1824,19 @@ div.tabBar .noborder {
  *  Boxes
  */
 
+.boxstats {
+    <?php print "float: ".$left.";\n"; ?>
+    margin: 3px;
+    padding: 3px;
+	/*-moz-box-shadow: 4px 4px 4px #DDD;
+    -webkit-box-shadow: 4px 4px 4px #DDD;
+    box-shadow: 4px 4px 4px #DDD;
+    margin-bottom: 8px !important;*/
+    border: 1px solid #AAA;
+    text-align: center;
+    border-radius: 5px;
+}
+
 .boxtable {
     -moz-box-shadow: 4px 4px 4px #DDD;
     -webkit-box-shadow: 4px 4px 4px #DDD;
-- 
GitLab