Skip to content

Commit

Permalink
Fix pagination when MAIN_DISABLE_FULL_SCANLIST is on
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 15, 2017
1 parent 6aa26e0 commit d14e4db
Show file tree
Hide file tree
Showing 61 changed files with 76 additions and 67 deletions.
2 changes: 1 addition & 1 deletion dev/skeletons/skeleton_list.php
Expand Up @@ -247,7 +247,7 @@ function init_myfunc()
//$sql.= $db->plimit($conf->liste_limit+1, $offset);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/account.php
Expand Up @@ -172,7 +172,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$resql = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/fiscalyear.php
Expand Up @@ -90,7 +90,7 @@
$sql.=$db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/productaccount.php
Expand Up @@ -248,7 +248,7 @@
}
$sql .= $db->order($sortfield, $sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/balance.php
Expand Up @@ -143,7 +143,7 @@

// List

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/list.php
Expand Up @@ -293,7 +293,7 @@

// List

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/listbyaccount.php
Expand Up @@ -162,7 +162,7 @@

// List

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/listbyyear.php
Expand Up @@ -158,7 +158,7 @@
* Mode List
*/

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0);
if ($nbtotalofrecords < 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/lines.php
Expand Up @@ -200,7 +200,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/list.php
Expand Up @@ -220,7 +220,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/expensereport/lines.php
Expand Up @@ -178,7 +178,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/expensereport/list.php
Expand Up @@ -208,7 +208,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/lines.php
Expand Up @@ -182,7 +182,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/list.php
Expand Up @@ -217,7 +217,7 @@
$sql .= $db->order($sortfield, $sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/list.php
Expand Up @@ -250,7 +250,7 @@
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records with no order and no limits
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$resql = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/subscription/list.php
Expand Up @@ -110,7 +110,7 @@
if ($search_amount) $sql.= natural_search('c.subscription', $search_amount, 1);
$sql.= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/type.php
Expand Up @@ -407,7 +407,7 @@
$sql.=" AND datefin < '".$db->idate($now)."'";
}
// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$resql = $db->query($sql);
Expand Down
11 changes: 10 additions & 1 deletion htdocs/admin/tools/listevents.php
Expand Up @@ -174,6 +174,15 @@
if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); }
if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); }
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = '';
/*if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}*/

$sql.= $db->plimit($conf->liste_limit+1, $offset);
//print $sql;
$result = $db->query($sql);
Expand All @@ -195,7 +204,7 @@
$center='<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=purge">'.$langs->trans("Purge").'</a>';
}

print_barre_liste($langs->trans("ListOfSecurityEvents").' ('.$num.')', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, 0, 'setup');
print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup');

if ($action == 'purge')
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/categories/class/api_categories.class.php
Expand Up @@ -209,7 +209,7 @@ function getListForItem($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0,
$sql.= ' AND s.rowid = sub.fk_categorie';
$sql.= ' AND sub.'.$subcol_name.' = '.$item;

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/categories/class/api_deprecated_category.class.php
Expand Up @@ -124,7 +124,7 @@ function getList($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $l
$sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')';
$sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down Expand Up @@ -205,7 +205,7 @@ function getListForItem($type='product', $sortfield = "s.rowid", $sortorder = 'A
$sql.= ' AND s.rowid = sub.fk_categorie';
$sql.= ' AND sub.'.$subcol_name.' = '.$item;

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/listactions.php
Expand Up @@ -245,7 +245,7 @@
if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'";
$sql.= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/rapport/index.php
Expand Up @@ -85,7 +85,7 @@
$sql.= " GROUP BY year, month, df";
$sql.= " ORDER BY year DESC, month DESC, df DESC";

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/mailing/cibles.php
Expand Up @@ -412,7 +412,7 @@
$sql .= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/list.php
Expand Up @@ -333,7 +333,7 @@
$sql.=', p.ref DESC';

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/class/api_deprecated_commande.class.php
Expand Up @@ -139,7 +139,7 @@ function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page =
$sql .= " AND sc.fk_user = ".$search_sale;
}

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/customer.php
Expand Up @@ -97,7 +97,7 @@
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/list.php
Expand Up @@ -560,7 +560,7 @@
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/bank/bankentries.php
Expand Up @@ -502,7 +502,7 @@

$sql.= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
$nbtotalofpages = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/bank/index.php
Expand Up @@ -175,7 +175,7 @@
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
Expand Up @@ -138,7 +138,7 @@ function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page =
$sql .= " AND sc.fk_user = ".$search_sale;
}

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/fiche-rec.php
Expand Up @@ -1575,7 +1575,7 @@
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
}

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/list.php
Expand Up @@ -402,7 +402,7 @@
foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.$sortorder.',';
$sql.= ' f.rowid DESC ';

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/paiement/cheque/list.php
Expand Up @@ -112,7 +112,7 @@
}
$sql.= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/paiement/list.php
Expand Up @@ -186,7 +186,7 @@
}
$sql.= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/list.php
Expand Up @@ -365,7 +365,7 @@
}

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contrat/list.php
Expand Up @@ -288,7 +288,7 @@
$totalnboflines = $db->num_rows($result);
}

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contrat/services.php
Expand Up @@ -236,7 +236,7 @@
if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'";
$sql .= $db->order($sortfield,$sortorder);

$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -3184,7 +3184,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
* @param string $sortorder Order to sort ('' by default)
* @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
* @param int $num Number of records found by select with limit+1
* @param int $totalnboflines Total number of records/lines for all pages (if known). Use a negative value to not show number.
* @param int|string $totalnboflines Total number of records/lines for all pages (if known). Use a negative value of number to not show number. Use '' if unknown.
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
* @param string $morehtml More html to show
Expand All @@ -3193,7 +3193,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
* @param int $hideselectlimit Force to hide select limit
* @return void
*/
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0)
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0)
{
global $conf,$langs;

Expand Down Expand Up @@ -3223,7 +3223,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
print '<td class="nobordernopadding valignmiddle">';
if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath);
print '<div class="titre inline-block">'.$titre;
if (!empty($titre) && $savtotalnboflines >= 0) print ' ('.$totalnboflines.')';
if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print ' ('.$totalnboflines.')';
print '</div></td>';

// Center
Expand Down
2 changes: 1 addition & 1 deletion htdocs/cron/list.php
Expand Up @@ -225,7 +225,7 @@
$sql.= $db->order($sortfield,$sortorder);

// Count total nb of records
$nbtotalofrecords = -1;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
Expand Down

0 comments on commit d14e4db

Please sign in to comment.