From 77973fd2ee1a7251b3c66162cecd64e4fab8a178 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Mar 2023 11:16:00 +0100 Subject: [PATCH] Debug v18 --- htdocs/adherents/type.php | 60 ++++++++++++++++++++------- htdocs/core/class/html.form.class.php | 2 +- htdocs/societe/list.php | 6 +-- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 207acc53e6f..1390c1b4254 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -585,6 +585,9 @@ if ($rowid > 0) { $sql .= " d.datefin,"; $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut as status,"; $sql .= " t.libelle as type, t.subscription, t.amount"; + + $sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid "; $sql .= " AND d.entity IN (".getEntity('adherent').")"; @@ -616,24 +619,32 @@ if ($rowid > 0) { $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; } - $sql .= " ".$db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); if ($resql) { - $nbtotalofrecords = $db->num_rows($result); + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; } else { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } - $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); + // Complete request and execute it with limit + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if ($resql) { @@ -668,6 +679,15 @@ if ($rowid > 0) { } $param = "&rowid=".urlencode($object->id); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); + } if (!empty($status)) { $param .= "&status=".urlencode($status); } @@ -691,12 +711,11 @@ if ($rowid > 0) { print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; } - print '
'; + print ''; print ''; - print ''; + print ''; - print '
'; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); $moreforfilter = ''; @@ -706,6 +725,13 @@ if ($rowid > 0) { // Fields title search print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + } + print ''; print ''; @@ -719,11 +745,15 @@ if ($rowid > 0) { print ' '; - print ''; - print ''; - print '  '; - print ''; - print ''; + print ' '; + + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + print ''; + print '  '; + print ''; + print ''; + } print "\n"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e5c245ab78a..e9a33390226 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9832,8 +9832,8 @@ class Form { $out = '
'; if ($pos == 'left') { - $out .= ''; $out .= ''; + $out .= ''; } else { $out .= ''; $out .= ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 085bc0d2532..e9cff69d90b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1577,7 +1577,7 @@ while ($i < $imaxinloop) { print '>'; // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -1897,7 +1897,7 @@ while ($i < $imaxinloop) { } } // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -1925,7 +1925,7 @@ if ($num == 0) { $colspan++; } } - print ''.$langs->trans("NoRecordFound").''; + print ''.$langs->trans("NoRecordFound").''; } $db->free($resql);