diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b44abce662d..4acafa49b00 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1014,7 +1014,8 @@ print "\n"; $i = 0; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $maxinloop) { $obj = $db->fetch_object($resql); $datefin = $db->jdate($obj->datefin); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 45fbc99b816..4cd21775ae7 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -502,7 +502,8 @@ print "\n"; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($result); $subscription->ref = $obj->crowid; @@ -546,7 +547,7 @@ while ($i < min($num, $limit)) { } // Output Kanban print $subscription->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print ''; print ''; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index a6179f93417..5b0fd0bd105 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1723,7 +1723,7 @@ if ($resql) { $objectstatic->author = $userstatic->getNomUrl(1); $objectstatic->fk_project = $projectstatic->getNomUrl(1); print $objectstatic->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print ''; print ''; } diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index bc2c2528d07..073e9de9a15 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -574,6 +574,7 @@ $total = array(); $found = 0; $i = 0; $lastcurrencycode = ''; +$imaxinloop = ($limit ? min($num, $limit) : $num); foreach ($accounts as $key => $type) { if ($i >= $limit) { @@ -600,7 +601,7 @@ foreach ($accounts as $key => $type) { } // Output Kanban print $objecttmp->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print ''; print ''; } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 204ea92041f..d72238e3fe6 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -85,9 +85,10 @@ $search_type_id = GETPOST('search_type_id', 'int'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -174,6 +175,14 @@ $result = restrictedArea($user, 'banque', '', '', ''); * Actions */ +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -183,6 +192,23 @@ if ($reshook < 0) { if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $toselect = array(); + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } } /* @@ -282,7 +308,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { 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 paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -296,520 +322,526 @@ if ($limit) { } $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - // Direct jump if only one record found - if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); - exit; - } +$num = $db->num_rows($resql); - // must be place behind the last "header(...)" call - llxHeader('', $langs->trans("VariousPayments")); +// Direct jump if only one record found +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); + exit; +} - $i = 0; - $total = 0; +// must be place behind the last "header(...)" call +llxHeader('', $langs->trans("VariousPayments")); - $param = ''; - 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='.urlencode($limit); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_label) { - $param .= '&search_label='.urlencode($search_label); - } - if ($search_datep_start) { - $param .= '&search_datep_start='.urlencode($search_datep_start); - } - if ($search_datep_end) { - $param .= '&search_datep_end='.urlencode($search_datep_end); - } - if ($search_datev_start) { - $param .= '&search_datev_start='.urlencode($search_datev_start); - } - if ($search_datev_end) { - $param .= '&search_datev_end='.urlencode($search_datev_end); - } - if ($search_type_id > 0) { - $param .= '&search_type_id='.urlencode($search_type_id); - } - if ($search_amount_deb) { - $param .= '&search_amount_deb='.urlencode($search_amount_deb); - } - if ($search_amount_cred) { - $param .= '&search_amount_cred='.urlencode($search_amount_cred); - } - if ($search_bank_account > 0) { - $param .= '&search_account='.urlencode($search_bank_account); - } - if ($search_accountancy_account > 0) { - $param .= '&search_accountancy_account='.urlencode($search_accountancy_account); - } - if ($search_accountancy_subledger > 0) { - $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } +$i = 0; +$total = 0; - $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'; - if (!empty($socid)) { - $url .= '&socid='.urlencode($socid); - } - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier); +$param = ''; +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='.urlencode($limit); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_label) { + $param .= '&search_label='.urlencode($search_label); +} +if ($search_datep_start) { + $param .= '&search_datep_start='.urlencode($search_datep_start); +} +if ($search_datep_end) { + $param .= '&search_datep_end='.urlencode($search_datep_end); +} +if ($search_datev_start) { + $param .= '&search_datev_start='.urlencode($search_datev_start); +} +if ($search_datev_end) { + $param .= '&search_datev_end='.urlencode($search_datev_end); +} +if ($search_type_id > 0) { + $param .= '&search_type_id='.urlencode($search_type_id); +} +if ($search_amount_deb) { + $param .= '&search_amount_deb='.urlencode($search_amount_deb); +} +if ($search_amount_cred) { + $param .= '&search_amount_cred='.urlencode($search_amount_cred); +} +if ($search_bank_account > 0) { + $param .= '&search_account='.urlencode($search_bank_account); +} +if ($search_accountancy_account > 0) { + $param .= '&search_accountancy_account='.urlencode($search_accountancy_account); +} +if ($search_accountancy_subledger > 0) { + $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} - print '
'."\n"; + // End of page llxFooter(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 23c7d87f87a..5f9d0c507d3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1928,7 +1928,7 @@ if ($resql) { $userstatic->fetch($obj->fk_user_author); $facturestatic->fk_user_author = $userstatic->getNomUrl(1); print $facturestatic->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print ''; print ''; } diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 23fd1186e0e..dbd3bdafdbf 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -28,15 +28,19 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page $langs->load("compta"); +$limit = GETPOST('limit', 'int'); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } + $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt = GETPOST("localTaxType", 'int'); $mode = GETPOST('mode', 'alpha'); + /* * View */ @@ -80,8 +84,9 @@ if ($result) { print '