diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 56e5071a250..511fb606a4e 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -168,7 +169,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); + StartSimpleTableHeader("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -250,7 +251,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); + StartSimpleTableHeader("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -329,7 +330,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftOrders", "commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -413,7 +414,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -503,16 +504,19 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $num = $db->num_rows($resql); $i = 0; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastCustomersOrProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + else + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + if ($num) { while ($i < $num) @@ -570,12 +574,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $num = $db->num_rows($result); $i = 0; - print '
'; - print '
'; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); - else print $langs->trans("BoxTitleLastModifiedCustomers", $max); - print ''.$langs->trans("FullList").'
'; - print ''; - print ''; - print ''; - print ''; + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + if ($num) { while ($i < $num && $i < $max) @@ -650,12 +650,11 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD if ($resql) { $num = $db->num_rows($resql); - + if ($num > 0) { - print '
'; - print '
'.$langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)).''.$langs->trans("FullList").'
'; - print ''; + StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); + $i = 0; $staticcontrat = new Contrat($db); @@ -715,7 +714,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); + StartSimpleTableHeader("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -817,7 +816,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); + StartSimpleTableHeader("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); $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 7feb9aa8655..2bc5d8eea53 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8675,58 +8675,70 @@ function currentToken() * 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") + * @param string $header The first left header of the table (automatic translated) + * @param string $link (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") + * @param integer $emptyRows (optional) The count of empty rows after the first header + * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" * @return void */ -function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) { global $langs; print '
'; print '
'.$langs->trans("LastContracts", 5).'
'; print ''; - + print $emptyRows < 1 ? ''; - if(!is_array($headers) || count($headers) < 2) + if ($number < 0 && !empty($link)) { - print ''; - return; - } + print ''; }
' : ''; - print is_array($headers) ? $langs->trans($headers[0]) : $headers; + print $langs->trans($header); - if($number > -1) + if ($number > -1) { // extra space between the first header and the number print ' '; } - if(!empty($internalLink)) + if (!empty($link)) { - print ''; + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } } - if($number > -1) + if ($number > -1) { print ''.$number.''; } - if(!empty($internalLink)) + if (!empty($link)) { print ''; } print '
'; - foreach(array_slice($headers, 1) as $header) - { - print ''; - print print $langs->trans($header); + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } + + print $langs->trans("FullList"); + print ''; print '