mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
Add helper function for table headers with numbers
This commit is contained in:
@@ -168,10 +168,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
|
||||
$total = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("ProposalsDraft").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
|
||||
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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").' <a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
|
||||
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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("DraftOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
|
||||
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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").' <a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
|
||||
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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?search_status=1"><span class="badge">'.$num.'</span></th></tr>';
|
||||
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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><th class="liste_titre" colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=1"><span class="badge">'.$num.'</span></th></tr>';
|
||||
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)
|
||||
|
||||
@@ -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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print $emptyRows < 1 ? '<th>' : '<th colspan="'.($emptyRows + 1).'">';
|
||||
|
||||
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 '<a href="'.DOL_URL_ROOT.'/'.$internalLink.'?'.$arguments.'">';
|
||||
}
|
||||
|
||||
if($number > -1)
|
||||
{
|
||||
print '<span class="badge">'.$number.'</span>';
|
||||
}
|
||||
|
||||
if(!empty($internalLink))
|
||||
{
|
||||
print '</a>';
|
||||
}
|
||||
|
||||
print '</th>';
|
||||
|
||||
if(!is_array($headers) || count($headers) < 2)
|
||||
{
|
||||
print '</tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(array_slice($headers, 1) as $header)
|
||||
{
|
||||
print '<th>';
|
||||
print print $langs->trans($header);
|
||||
print '</th>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user