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"; if ($optioncss != '') { print ''; @@ -343,13 +394,18 @@ print ''; $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')); -if ($user->hasRight('don', 'creer')) { - $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); -} +$newcardbutton .= dolGetButtonTitleSeparator(); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create', '', $permissiontoadd); // @phan-suppress-next-line PhanPluginSuspiciousParamOrder -print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendDonationRef"; +$modelmail = "don"; +$objecttmp = new Don($db); +$trackid = 'don'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { $setupstring = ''; @@ -361,19 +417,41 @@ if ($search_all) { print '
'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'
'; } +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} +$parameters = array( + 'arrayfields' => &$arrayfields, +); + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup +$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : ''); $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; // Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { +if ($conf->main_checkbox_left_column) { print ''; -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { +// Action column +if (!$conf->main_checkbox_left_column) { print ''; // Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); +if ($conf->main_checkbox_left_column) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder); @@ -454,8 +533,9 @@ print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, $totalarray['nbfield']++; print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); +// Action column +if (!$conf->main_checkbox_left_column) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } print ''."\n"; @@ -467,16 +547,24 @@ $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } $donationstatic->setVarsFromFetchObj($obj); + $donationstatic->id = $obj->rowid; $donationstatic->ref = $obj->rowid; $donationstatic->date = $db->jdate($obj->datedon); $donationstatic->status = $obj->status; + $donationstatic->lastname = $obj->lastname; + $donationstatic->firstname = $obj->firstname; + $object = $donationstatic; $company = new Societe($db); $result = $company->fetch($obj->socid); + if ($mode == 'kanban') { if ($i == 0) { print ''; } } else { - $donationstatic->lastname = $obj->lastname; - $donationstatic->firstname = $obj->firstname; + // Show line of result + $j = 0; + print ''; - // Action - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + // Action column + if ($conf->main_checkbox_left_column) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref @@ -554,20 +653,35 @@ while ($i < $imaxinloop) { // Status print ''; - // Action - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + // Action column + if (empty($conf->main_checkbox_left_column)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ""; + print ''."\n"; } $i++; } -print "
'; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; @@ -413,7 +491,8 @@ $liststatus = array( // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; @@ -428,8 +507,8 @@ $totalarray['nbfield'] = 0; // -------------------------------------------------------------------- print '
'; @@ -506,13 +594,24 @@ while ($i < $imaxinloop) { print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''.$donationstatic->LibStatut($obj->status, 5).''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
"; -print '
'; -print "
\n"; + $db->free($resql); +print ''."\n"; +print ''."\n"; + +print ''."\n"; + + llxFooter(); $db->close();