diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 924d85c3781..01623e81747 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -105,7 +105,8 @@ $search_date_endyear = GETPOST('search_date_endyear', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_date_end_startday = GETPOST('search_date_end_startday', 'int'); -$search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int'); +$search_date_end_startmonth = GETPOST('se$sql .= $db->plimit($limit + 1, $offset); +arch_date_end_startmonth', 'int'); $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int'); $search_date_end_endday = GETPOST('search_date_end_endday', 'int'); $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); @@ -793,9 +794,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); -$sql .= ', p.ref DESC'; - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -817,7 +815,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= ', p.ref DESC'; +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index a093743b072..8394b948673 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1046,8 +1046,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -1069,7 +1067,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 4a3735a15b2..0014245ee48 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -255,8 +255,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -278,7 +276,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index a3b02dc48bd..b33c2900187 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -266,8 +266,6 @@ if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -289,7 +287,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($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) { diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index c6909129dda..054ef800586 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -117,8 +117,6 @@ if ($search_amount) { } $sql .= dolSqlDateFilter('bc.date_bordereau', 0, $month, $year); -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -140,7 +138,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print "$sql"; $resql = $db->query($sql); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index c88d77eff42..658f2c150f1 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -258,7 +258,6 @@ if (GETPOST("orphelins", "alpha")) { $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } -$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -281,7 +280,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($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) { diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index dfac774d8cf..4906313cad1 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -155,8 +155,6 @@ if ($search_company) { $sql .= natural_search("s.nom", $search_company); } -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -178,7 +176,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 3578fb5ca67..01ef33eea9d 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -114,8 +114,6 @@ if ($search_amount) { $sql .= natural_search("p.amount", $search_amount, 1); } -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -137,7 +135,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index cf8622af8ec..d4ddfa0f31f 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -254,7 +254,6 @@ $sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs. if (isModEnabled('project')) { $sql .= ", p.rowid, p.ref, p.title"; } -$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -277,7 +276,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($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) { diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 0019c54d7dc..19a7cf06740 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -191,7 +191,6 @@ if ($search_status != '' && $search_status >= 0) { } $sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code"; -$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -214,7 +213,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($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) { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index f65152286b7..e8c4174af71 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -626,12 +626,6 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -// Add order -if ($view == "recent") { - $sql .= $db->order("p.datec", "DESC"); -} else { - $sql .= $db->order($sortfield, $sortorder); -} //print $sql; // Count total nb of records @@ -655,7 +649,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +if ($view == "recent") { + $sql .= $db->order("p.datec", "DESC"); +} else { + $sql .= $db->order($sortfield, $sortorder); +} +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); if (!$resql) { diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index c319e8f8b68..e1c31e570cd 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -449,8 +449,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ @@ -471,7 +469,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 814dc16d835..bded18fa597 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -343,8 +343,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -366,7 +364,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 634c4adc72b..7f797d7f96b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -954,8 +954,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -977,7 +975,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 89cbfd29a86..79a3862ae52 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -702,8 +702,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -725,7 +723,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 56766b0f278..10c3c0bae78 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -197,8 +197,6 @@ if ($reshook < 0) { } $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -220,7 +218,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} dol_syslog("fourn/product/list.php:", LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 676ed15cd28..564fb8a2a96 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -359,8 +359,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -382,8 +380,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); - +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 000bb708998..cac761023ef 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -635,8 +635,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } +// Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); -$sql .= $db->plimit($limit + 1, $offset); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} //print $sql; $resql = $db->query($sql);