diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 39962377a14..953a1bbb965 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -48,10 +48,15 @@ $langs->loadLangs(array('companies', 'donations')); // Get parameters $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'donationlist'; -$toselect = GETPOST('toselect', 'array'); -$optioncss = GETPOST('optioncss', 'alpha'); -$mode = GETPOST('mode', 'alpha'); +$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...) +$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut' $type = GETPOST('type', 'aZ'); @@ -145,16 +150,54 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_all = ""; - $search_ref = ""; - $search_company = ""; - $search_thirdparty = ""; - $search_name = ""; - $search_amount = ""; - $search_status = ''; +$parameters = array('arrayfields' => &$arrayfields); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +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'] = ''; + } + } + + $search_all = ""; + $search_ref = ""; + $search_company = ""; + $search_thirdparty = ""; + $search_name = ""; + $search_amount = ""; + $search_status = ''; + $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 + } + + // Mass actions + $objectclass = 'Don'; + $objectlabel = 'Don'; + $uploaddir = $conf->don->dir_output; + + global $error; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // You can add more action here + // if ($action == 'xxx' && $permissiontoxxx) ... +} + + /* * View @@ -253,7 +296,7 @@ $num = $db->num_rows($resql); if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); + header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id)); exit; } @@ -293,6 +336,9 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($groupby != '') { + $param .= '&groupby='.urlencode($groupby); +} if ($search_status && $search_status != -1) { $param .= '&search_status='.urlencode($search_status); } @@ -308,6 +354,12 @@ if ($search_name) { if ($search_amount) { $param .= '&search_amount='.urlencode($search_amount); } +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array('param' => &$param); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( @@ -324,7 +376,6 @@ if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predel } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - print '
'."\n"; + + llxFooter(); $db->close();