diff --git a/htdocs/index.php b/htdocs/index.php index d50b5248fab..9151ead38b8 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -514,47 +514,55 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'project' => array( 'groupName' => 'Projects', + 'globalStatsKey' => 'projects', 'stats' => array('project', 'project_task'), ), 'propal' => array( 'groupName' => 'Proposals', + 'globalStatsKey' => 'proposals', 'stats' => array('propal_opened', 'propal_signed'), ), 'commande' => array( 'groupName' => 'Orders', + 'globalStatsKey' => 'orders', 'stats' => array('commande'), ), 'facture' => array( 'groupName' => 'Invoices', + 'globalStatsKey' => 'invoices', 'stats' => array('facture'), ), 'contrat' => array( 'groupName' => 'Contracts', + 'globalStatsKey' => 'Contracts', 'stats' => array('contrat_inactive', 'contrat_active'), ), 'supplier_proposal' => array( 'groupName' => 'SupplierProposals', + 'globalStatsKey' => 'askprice', 'stats' => array('supplier_proposal_opened', 'supplier_proposal_signed'), ), 'order_supplier' => array( 'groupName' => 'SuppliersOrders', + 'globalStatsKey' => 'supplier_orders', 'stats' => array('order_supplier'), ), 'invoice_supplier' => array( 'groupName' => 'BillsSuppliers', + 'globalStatsKey' => 'supplier_invoices', 'stats' => array('invoice_supplier'), ), @@ -567,18 +575,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'Adherent' => array( 'groupName' => 'Members', + 'globalStatsKey' => 'members', 'stats' => array('Adherent'), ), 'ExpenseReport' => array( 'groupName' => 'ExpenseReport', + 'globalStatsKey' => 'expensereports', 'stats' => array('ExpenseReport'), ), 'Holiday' => array( 'groupName' => 'Holidays', + 'globalStatsKey' => 'holidays', 'stats' => array('Holiday'), ), @@ -672,12 +683,46 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { if (!empty($boards)) { $groupName = $langs->trans($groupElement['groupName']); $groupKeyLowerCase = strtolower($groupKey); + $nbTotalForGroup = 0; + + // global stats + $globalStatsKey = false; + if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])){ // can be filled by hook + $globalStatsKey = $groupElement['globalStatsKey']; + $groupElement['globalStats'] = array(); + + if(in_array($globalStatsKey, $keys)) + { + // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links + $keyIndex = array_search($globalStatsKey, $keys); + + $classe=$classes[$keyIndex]; + if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) + { + $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey]?$boardloaded[$classe]->nb[$globalStatsKey]:0; + $nbTotal = doubleval($groupElement['globalStats']['total']); + if($nbTotal>=10000){ $nbTotal = round($nbTotal/1000 , 2) .'k'; } + $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; + $groupElement['globalStats']['total'] = $nbTotal; + $groupElement['globalStats']['link'] = $links[$keyIndex]; + } + } + } + $openedDashBoard .= '