FIX Pagination on related item pages

This commit is contained in:
Laurent Destailleur 2018-07-05 15:53:28 +02:00
parent 0138b0e0b7
commit 0587e73272
7 changed files with 175 additions and 178 deletions

View File

@ -49,11 +49,13 @@ $hookmanager->initHooks(array('productstatsorder'));
$mesg = ''; $mesg = '';
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
@ -112,7 +114,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product,$socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -142,24 +144,21 @@ if ($id > 0 || ! empty($ref))
$sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')';
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND c.fk_soc = ".$socid; if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->order($sortfield, $sortorder);
//Calcul total qty and amount for global if full scan list //Calcul total qty and amount for global if full scan list
$total_ht=0; $total_ht=0;
$total_qty=0; $total_qty=0;
$totalrecords=0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { // Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { $totalofrecords = $db->num_rows($result);
$totalrecords = $db->num_rows($result);
while ($objp = $db->fetch_object($result)) {
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
}
}
} }
$sql.= $db->plimit($conf->liste_limit +1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -172,6 +171,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;search_month='.$search_month; $option .= '&amp;search_month='.$search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year='.$search_year; $option .= '&amp;search_year='.$search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER ['PHP_SELF'] . '?id='.$product->id.'" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER ['PHP_SELF'] . '?id='.$product->id.'" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -183,7 +183,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,''); print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - ';
@ -211,20 +211,22 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var=True; while ($i < min($num, $limit))
while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
$orderstatic->id=$objp->commandeid;
$orderstatic->ref=$objp->ref;
$orderstatic->ref_client=$objp->ref_client;
$societestatic->fetch($objp->socid);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$orderstatic->id=$objp->commandeid;
$orderstatic->ref=$objp->ref;
$orderstatic->ref_client=$objp->ref_client;
print $orderstatic->getNomUrl(1); print $orderstatic->getNomUrl(1);
print "</td>\n"; print "</td>\n";
$societestatic->fetch($objp->socid);
print '<td>'.$societestatic->getNomUrl(1).'</td>'; print '<td>'.$societestatic->getNomUrl(1).'</td>';
print "<td>".$objp->code_client."</td>\n"; print "<td>".$objp->code_client."</td>\n";
print '<td align="center">'; print '<td align="center">';
@ -234,15 +236,11 @@ if ($id > 0 || ! empty($ref))
print '<td align="right">'.$orderstatic->LibStatut($objp->statut,$objp->facture,5).'</td>'; print '<td align="right">'.$orderstatic->LibStatut($objp->statut,$objp->facture,5).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="3"></td>'; print '<td colspan="3"></td>';
print '<td align="center">'.$total_qty.'</td>'; print '<td align="center">'.$total_qty.'</td>';
print '<td align="right">'.price($total_ht).'</td>'; print '<td align="right">'.price($total_ht).'</td>';

View File

@ -119,7 +119,7 @@ if ($id > 0 || ! empty($ref)) {
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product, $socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -153,24 +153,21 @@ if ($id > 0 || ! empty($ref)) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
if ($socid) if ($socid)
$sql .= " AND c.fk_soc = " . $socid; $sql .= " AND c.fk_soc = " . $socid;
$sql .= " ORDER BY $sortfield $sortorder "; $sql.= $db->order($sortfield, $sortorder);
// Calcul total qty and amount for global if full scan list // Calcul total qty and amount for global if full scan list
$total_ht = 0; $total_ht = 0;
$total_qty = 0; $total_qty = 0;
$totalrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { // Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { $totalofrecords = $db->num_rows($result);
$totalrecords = $db->num_rows($result);
while ( $objp = $db->fetch_object($result) ) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
}
} }
$sql .= $db->plimit($conf->liste_limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
@ -182,6 +179,7 @@ if ($id > 0 || ! empty($ref)) {
$option .= '&amp;search_month=' . $search_month; $option .= '&amp;search_month=' . $search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year=' . $search_year; $option .= '&amp;search_year=' . $search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -193,7 +191,7 @@ if ($id > 0 || ! empty($ref)) {
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - ';
@ -219,20 +217,24 @@ if ($id > 0 || ! empty($ref)) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
if ($num > 0) { if ($num > 0)
$var = True; {
while ( $i < $num && $i < $conf->liste_limit ) { while ($i < min($num, $limit))
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var;
print '<tr ' . $bc[$var] . '>'; $total_ht+=$objp->total_ht;
print '<td>'; $total_qty+=$objp->qty;
$supplierorderstatic->id = $objp->commandeid; $supplierorderstatic->id = $objp->commandeid;
$supplierorderstatic->ref = $objp->ref; $supplierorderstatic->ref = $objp->ref;
$supplierorderstatic->statut = $objp->statut; $supplierorderstatic->statut = $objp->statut;
$societestatic->fetch($objp->socid);
print '<tr class="oddeven">';
print '<td>';
print $supplierorderstatic->getNomUrl(1); print $supplierorderstatic->getNomUrl(1);
print "</td>\n"; print "</td>\n";
$societestatic->fetch($objp->socid);
print '<td>' . $societestatic->getNomUrl(1) . '</td>'; print '<td>' . $societestatic->getNomUrl(1) . '</td>';
print "<td>" . $objp->code_client . "</td>\n"; print "<td>" . $objp->code_client . "</td>\n";
print '<td align="center">'; print '<td align="center">';
@ -241,16 +243,12 @@ if ($id > 0 || ! empty($ref)) {
print '<td align="right">' . price($objp->total_ht) . "</td>\n"; print '<td align="right">' . price($objp->total_ht) . "</td>\n";
print '<td align="right">' . $supplierorderstatic->getLibStatut(4) . '</td>'; print '<td align="right">' . $supplierorderstatic->getLibStatut(4) . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i++;
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="3"></td>'; print '<td colspan="3"></td>';
print '<td align="center">' . $total_qty . '</td>'; print '<td align="center">' . $total_qty . '</td>';
print '<td align="right">' . price($total_ht) . '</td>'; print '<td align="right">' . price($total_ht) . '</td>';

View File

@ -46,11 +46,13 @@ $hookmanager->initHooks(array('productstatscontract'));
$mesg = ''; $mesg = '';
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
@ -102,7 +104,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product,$socid); $nboflines = show_stats_for_company($product,$socid);
print "</table>"; print "</table>";
@ -133,7 +135,20 @@ if ($id > 0 || ! empty($ref))
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql.= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client";
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($conf->liste_limit +1, $offset);
//Calcul total qty and amount for global if full scan list
$total_ht=0;
$total_qty=0;
// Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$totalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -145,6 +160,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;search_month=' . $search_month; $option .= '&amp;search_month=' . $search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year=' . $search_year; $option .= '&amp;search_year=' . $search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -156,7 +172,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,0,''); print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
$i = 0; $i = 0;
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
@ -177,8 +193,7 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var=True; while ($i < min($num, $limit))
while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);

View File

@ -50,15 +50,18 @@ $hookmanager->initHooks(array('productstatsinvoice'));
$showmessage=GETPOST('showmessage'); $showmessage=GETPOST('showmessage');
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef"; if (! $sortfield) $sortfield="f.datef";
$search_month = GETPOST('search_month', 'aplha'); $search_month = GETPOST('search_month', 'aplha');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
@ -129,7 +132,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
$nboflines = show_stats_for_company($product,$socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -164,25 +167,19 @@ if ($id > 0 || ! empty($ref))
if ($socid) $sql.= " AND f.fk_soc = ".$socid; if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
//Calcul total qty and amount for global if full scan list // Calcul total qty and amount for global if full scan list
$total_ht=0; $total_ht=0;
$total_qty=0; $total_qty=0;
$totalrecords=0;
// Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
if ($result) $totalofrecords = $db->num_rows($result);
{
$totalrecords = $db->num_rows($result);
while ($objp = $db->fetch_object($result))
{
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
}
}
} }
$sql.= $db->plimit($conf->liste_limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -194,7 +191,8 @@ if ($id > 0 || ! empty($ref))
if (! empty($search_month)) if (! empty($search_month))
$option .= '&amp;search_month='.$search_month; $option .= '&amp;search_month='.$search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year='.$search_year; $option .= '&amp;search_year='.$search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER ['PHP_SELF'] . '?id='.$product->id.'" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER ['PHP_SELF'] . '?id='.$product->id.'" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -206,7 +204,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&amp;id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,''); print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"],"&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - ';
@ -234,11 +232,13 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var=True; while ($i < min($num, $limit))
while ($i < min($num,$conf->liste_limit))
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
$invoicestatic->id=$objp->facid; $invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber; $invoicestatic->ref=$objp->facnumber;
$societestatic->fetch($objp->socid); $societestatic->fetch($objp->socid);
@ -257,15 +257,11 @@ if ($id > 0 || ! empty($ref))
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'</td>'; print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="3"></td>'; print '<td colspan="3"></td>';
print '<td align="center">'.$total_qty.'</td>'; print '<td align="center">'.$total_qty.'</td>';
print '<td align="right">'.price($total_ht).'</td>'; print '<td align="right">'.price($total_ht).'</td>';

View File

@ -51,11 +51,13 @@ $hookmanager->initHooks(array('productstatssupplyinvoice'));
$mesg = ''; $mesg = '';
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int'); $page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder = "DESC"; if (! $sortorder) $sortorder = "DESC";
@ -114,7 +116,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product, $socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -149,19 +151,16 @@ if ($id > 0 || ! empty($ref))
// Calcul total qty and amount for global if full scan list // Calcul total qty and amount for global if full scan list
$total_ht = 0; $total_ht = 0;
$total_qty = 0; $total_qty = 0;
$totalrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { // Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { $totalofrecords = $db->num_rows($result);
$totalrecords = $db->num_rows($result);
while ( $objp = $db->fetch_object($result) ) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
}
} }
$sql .= $db->plimit($conf->liste_limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -174,6 +173,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;search_month=' . $search_month; $option .= '&amp;search_month=' . $search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year=' . $search_year; $option .= '&amp;search_year=' . $search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -185,7 +185,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - ';
@ -213,19 +213,21 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var = True; while ($i < min($num, $limit))
while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var;
print '<tr ' . $bc[$var] . '>'; $total_ht+=$objp->total_ht;
print '<td>'; $total_qty+=$objp->qty;
$supplierinvoicestatic->id = $objp->facid; $supplierinvoicestatic->id = $objp->facid;
$supplierinvoicestatic->ref = $objp->facnumber; $supplierinvoicestatic->ref = $objp->facnumber;
$societestatic->fetch($objp->socid);
print '<tr class="oddeven">';
print '<td>';
print $supplierinvoicestatic->getNomUrl(1); print $supplierinvoicestatic->getNomUrl(1);
print "</td>\n"; print "</td>\n";
$societestatic->fetch($objp->socid);
print '<td>' . $societestatic->getNomUrl(1) . '</td>'; print '<td>' . $societestatic->getNomUrl(1) . '</td>';
print "<td>" . $objp->code_client . "</td>\n"; print "<td>" . $objp->code_client . "</td>\n";
print '<td align="center">'; print '<td align="center">';
@ -234,16 +236,12 @@ if ($id > 0 || ! empty($ref))
print '<td align="right">' . price($objp->total_ht) . "</td>\n"; print '<td align="right">' . price($objp->total_ht) . "</td>\n";
print '<td align="right">' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . '</td>'; print '<td align="right">' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i++;
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="3"></td>'; print '<td colspan="3"></td>';
print '<td align="center">' . $total_qty . '</td>'; print '<td align="center">' . $total_qty . '</td>';
print '<td align="right">' . price($total_ht) . '</td>'; print '<td align="right">' . price($total_ht) . '</td>';

View File

@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product, $socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref))
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
if ($socid) if ($socid)
$sql .= " AND p.fk_soc = " . $socid; $sql .= " AND p.fk_soc = " . $socid;
$sql .= " ORDER BY $sortfield $sortorder "; $sql.= $db->order($sortfield, $sortorder);
// Calcul total qty and amount for global if full scan list // Calcul total qty and amount for global if full scan list
$total_ht = 0; $total_ht = 0;
$total_qty = 0; $total_qty = 0;
$totalrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { // Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { $totalofrecords = $db->num_rows($result);
$totalrecords = $db->num_rows($result);
while ( $objp = $db->fetch_object($result) ) {
$total_ht += $objp->amount;
$total_qty += $objp->qty;
}
}
} }
$sql .= $db->plimit($conf->liste_limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -178,6 +175,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;search_month=' . $search_month; $option .= '&amp;search_month=' . $search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year=' . $search_year; $option .= '&amp;search_year=' . $search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - ';
@ -216,20 +214,22 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var = True; while ($i < min($num, $limit))
while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var;
print '<tr ' . $bc[$var] . '>'; $total_ht+=$objp->amount;
print '<td>'; $total_qty+=$objp->qty;
$propalstatic->id=$objp->propalid; $propalstatic->id=$objp->propalid;
$propalstatic->ref=$objp->ref; $propalstatic->ref=$objp->ref;
$propalstatic->ref_client=$objp->ref_client; $propalstatic->ref_client=$objp->ref_client;
print $propalstatic->getNomUrl(1);
print "</td>\n";
$societestatic->fetch($objp->socid); $societestatic->fetch($objp->socid);
print '<tr class="oddeven">';
print '<td>';
print $propalstatic->getNomUrl(1);
print "</td>\n";
print '<td>'.$societestatic->getNomUrl(1).'</td>'; print '<td>'.$societestatic->getNomUrl(1).'</td>';
print '<td align="center">'; print '<td align="center">';
print dol_print_date($db->jdate($objp->datep), 'dayhour') . "</td>"; print dol_print_date($db->jdate($objp->datep), 'dayhour') . "</td>";
@ -237,17 +237,13 @@ if ($id > 0 || ! empty($ref))
print '<td align="right">' . price($objp->amount) . '</td>' . "\n"; print '<td align="right">' . price($objp->amount) . '</td>' . "\n";
print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>'; print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i++;
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="2"></td>'; print '<td colspan="2"></td>';
print '<td align="center">' . $total_qty . '</td>'; print '<td align="center">' . $total_qty . '</td>';
print '<td align="right">' . price($total_ht) . '</td>'; print '<td align="right">' . price($total_ht) . '</td>';

View File

@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
show_stats_for_company($product, $socid); $nboflines = show_stats_for_company($product, $socid);
print "</table>"; print "</table>";
@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref))
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
if ($socid) if ($socid)
$sql .= " AND p.fk_soc = " . $socid; $sql .= " AND p.fk_soc = " . $socid;
$sql .= " ORDER BY $sortfield $sortorder "; $sql.= $db->order($sortfield, $sortorder);
// Calcul total qty and amount for global if full scan list // Calcul total qty and amount for global if full scan list
$total_ht = 0; $total_ht = 0;
$total_qty = 0; $total_qty = 0;
$totalrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { // Count total nb of records
$totalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { $totalofrecords = $db->num_rows($result);
$totalrecords = $db->num_rows($result);
while ( $objp = $db->fetch_object($result) ) {
$total_ht += $objp->amount;
$total_qty += $objp->qty;
}
}
} }
$sql .= $db->plimit($conf->liste_limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -178,6 +175,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;search_month=' . $search_month; $option .= '&amp;search_month=' . $search_month;
if (! empty($search_year)) if (! empty($search_year))
$option .= '&amp;search_year=' . $search_year; $option .= '&amp;search_year=' . $search_year;
if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit);
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n"; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" name="search_form">' . "\n";
if (! empty($sortfield)) if (! empty($sortfield))
@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref))
$option .= '&amp;page=' . $page; $option .= '&amp;page=' . $page;
} }
print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit);
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print '<div class="divsearchfield">'; print '<div class="divsearchfield">';
print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - ';
@ -216,19 +214,21 @@ if ($id > 0 || ! empty($ref))
if ($num > 0) if ($num > 0)
{ {
$var = True; while ($i < min($num, $limit))
while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var;
print '<tr ' . $bc[$var] . '>'; $total_ht+=$objp->amount;
print '<td>'; $total_qty+=$objp->qty;
$propalstatic->id=$objp->propalid; $propalstatic->id=$objp->propalid;
$propalstatic->ref=$objp->ref; $propalstatic->ref=$objp->ref;
print $propalstatic->getNomUrl(1);
print "</td>\n";
$societestatic->fetch($objp->socid); $societestatic->fetch($objp->socid);
print '<tr class="oddeven">';
print '<td>';
print $propalstatic->getNomUrl(1);
print "</td>\n";
print '<td>'.$societestatic->getNomUrl(1).'</td>'; print '<td>'.$societestatic->getNomUrl(1).'</td>';
print '<td align="center">'; print '<td align="center">';
print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . "</td>"; print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . "</td>";
@ -236,17 +236,13 @@ if ($id > 0 || ! empty($ref))
print '<td align="right">' . price($objp->amount) . '</td>' . "\n"; print '<td align="right">' . price($objp->amount) . '</td>' . "\n";
print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>'; print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i++;
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
} }
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>' . $langs->trans('Total') . '</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td colspan="2"></td>'; print '<td colspan="2"></td>';
print '<td align="center">' . $total_qty . '</td>'; print '<td align="center">' . $total_qty . '</td>';
print '<td align="right">' . price($total_ht) . '</td>'; print '<td align="right">' . price($total_ht) . '</td>';