diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 38c37c1389e..ea072abddf2 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -51,6 +51,7 @@ $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search
+$optioncss = GETPOST('optioncss', 'alpha');
$mode = GETPOST('mode', 'alpha');
$search_name = GETPOST('search_name', 'alpha');
@@ -88,15 +89,15 @@ if (GETPOSTISSET('formfilteraction')) {
}
$searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
-$optioncss = GETPOST('optioncss', 'alpha');
-
+// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$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;
@@ -175,6 +176,7 @@ $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$permissiontoread = $user->rights->contrat->lire;
+$permissiontoadd = $user->rights->contrat->creer;
$permissiontodelete = $user->rights->contrat->supprimer;
@@ -183,7 +185,8 @@ $permissiontodelete = $user->rights->contrat->supprimer;
*/
if (GETPOST('cancel', 'alpha')) {
- $action = 'list'; $massaction = '';
+ $action = 'list';
+ $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
@@ -243,13 +246,15 @@ if (empty($reshook)) {
* View
*/
-$now = dol_now();
$form = new Form($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$socstatic = new Societe($db);
$formcompany = new FormCompany($db);
$contracttmp = new Contrat($db);
+
+$now = dol_now();
+
$title = "";
$sql = 'SELECT';
@@ -272,7 +277,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
+$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
@@ -452,6 +458,7 @@ if (empty($reshook)) {
}
$sql .= $hookmanager->resPrint;
+// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
//$result = $db->query($sql);
@@ -485,8 +492,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$page = 0;
$offset = 0;
}
+ $db->free($resql);
}
+// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
@@ -631,7 +640,7 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i
$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('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer);
-print '
';
+print ''."\n";
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
@@ -1194,8 +1254,8 @@ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortor
$urlsource .= str_replace('&', '&', $param);
$filedir = $diroutputmassaction;
-$genallowed = $user->rights->contrat->lire;
-$delallowed = $user->rights->contrat->lire;
+$genallowed = $permissiontoread;
+$delallowed = $permissiontoadd;
print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 338ad79affb..ef4753c7199 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -343,7 +343,7 @@ if ($search_all) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
/* If a group by is required
@@ -560,10 +560,10 @@ print '';
+print '';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '| ';
+ print ' | ';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print ' | ';
@@ -615,7 +615,7 @@ print $hookmanager->resPrint;
}*/
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '';
+ print ' | ';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print ' | ';
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index 82a56264f1c..e298da2d14c 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -729,10 +729,10 @@ print '';
+print '';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '| ';
+ print ' | ';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print ' | ';
@@ -820,8 +820,8 @@ if (!empty($arrayfields['u.tms']['checked'])) {
}
if (!empty($arrayfields['u.statut']['checked'])) {
// Status
- print '';
- print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75imp maxwidth125 onrightofpage');
+ print ' | ';
+ print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
print ' | ';
}
// Action column