diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 602cde69163..56e5071a250 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -168,10 +168,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; + StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); if ($num > 0) { @@ -253,10 +250,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("ProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); if ($num > 0) { @@ -335,10 +329,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("SupplierProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); if ($num > 0) { @@ -422,10 +413,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("DraftOrders").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); if ($num > 0) { @@ -727,9 +715,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -831,9 +817,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 74916ec62e1..7feb9aa8655 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8670,3 +8670,65 @@ function currentToken() { return $_SESSION['token']; } + +/** + * Start a table with headers and a optinal clickable number + * (don't forget to close the table with a HTML TABLE and a HTML DIV element) + * + * @param string|array $headers The header(s) of the table (headers inside a array are automatic translated) + * @param integer $emptyRows (optional) The count of empty rows after the first header (use this instead of empty headers) + * @param integer $number (optional) The number that is shown right after the first header + * @param string $internalLink (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @return void + */ +function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +{ + global $langs; + + print '
'; + print '
'.$langs->trans("OrdersOpened").' '.$num.'
'; + print ''; + + print $emptyRows < 1 ? ''; + + if(!is_array($headers) || count($headers) < 2) + { + print ''; + return; + } + + foreach(array_slice($headers, 1) as $header) + { + print ''; + } + + print ''; +}
' : ''; + + print is_array($headers) ? $langs->trans($headers[0]) : $headers; + + if($number > -1) + { + // extra space between the first header and the number + print ' '; + } + + if(!empty($internalLink)) + { + print ''; + } + + if($number > -1) + { + print ''.$number.''; + } + + if(!empty($internalLink)) + { + print ''; + } + + print '
'; + print print $langs->trans($header); + print '