Debug v23 - filters on agenda pages

This commit is contained in:
Laurent Destailleur 2026-02-12 01:22:01 +01:00
parent f23e6b541a
commit 85ccca6ca3
8 changed files with 132 additions and 20 deletions

View file

@ -61,6 +61,7 @@ if (GETPOSTISARRAY('actioncode')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
@ -129,6 +130,7 @@ if (empty($reshook)) {
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -249,8 +251,9 @@ if ($object->id > 0) {
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
}

View file

@ -97,6 +97,7 @@ if (GETPOSTISARRAY('actioncode')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
@ -152,6 +153,7 @@ if (empty($reshook)) {
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -321,6 +323,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
@ -349,14 +354,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
}
}
// End of page
llxFooter();
$db->close();

View file

@ -62,6 +62,10 @@ if (GETPOST('actioncode', 'array')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
$id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
@ -129,7 +133,10 @@ if (empty($reshook)) {
// 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
$actioncode = '';
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -282,10 +289,35 @@ if ($object->id > 0) {
$param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.$contextpage;
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
$param .= '&limit='.((int) $limit);
}
if ($search_rowid) {
$param .= '&search_rowid='.urlencode($search_rowid);
}
if ($actioncode !== '' && $actioncode !== '-1') {
$param .= '&actioncode='.urlencode($actioncode);
}
if ($search_agenda_label) {
$param .= '&search_agenda_label='.urlencode($search_agenda_label);
}
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
$param .= '&dateevent_startday='.GETPOSTINT('dateevent_startday');
}
if ($search_dateevent_end != '') {
$param .= '&dateevent_endyear='.GETPOSTINT('dateevent_endyear');
$param .= '&dateevent_endmonth='.GETPOSTINT('dateevent_endmonth');
$param .= '&dateevent_endday='.GETPOSTINT('dateevent_endday');
}
// Try to know count of actioncomm from cache
@ -298,14 +330,16 @@ if ($object->id > 0) {
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
}
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 0);
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 0);
// List of all actions
$filters = array();
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
}
}

View file

@ -1834,7 +1834,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = null, $nopr
*/
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
{
global $hookmanager;
global $hookmanager, $user;
global $form;
global $param, $massactionbutton;
@ -1930,6 +1930,17 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
}
}
$canedit = 1;
if (!$user->hasRight('agenda', 'myactions', 'read')) {
$canedit = 0;
}
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$canedit = 0;
}
if (!$user->hasRight('agenda', 'allactions', 'read')) { // If no permission to see all, we show only affected to me
$filters['search_filtert'] = (string) $user->id;
}
// Fields from hook
$parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon);
$reshook = $hookmanager->executeHooks('showActionsDoneListSelect', $parameters); // Note that $action and $object may have been modified by hook
@ -2306,7 +2317,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
$out .= $form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1);
$out .= '</td>';
// Owner
$out .= '<td class="liste_titre"></td>';
$out .= '<td class="liste_titre">';
$out .= $form->select_dolusers(($filters['search_filtert'] > 0 ? $filters['search_filtert'] : ''), 'search_filtert', 1, null, (int) !$canedit, '', '', '0', 0, 0, '', 2, '', 'minwidth100 maxwidth250 widthcentpercentminusx');
$out .= '</td>';
// Type
$out .= '<td class="liste_titre">';
$out .= $formactions->select_type_actions($actioncode, "actioncode", '', getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, (getDolGlobalString('AGENDA_USE_MULTISELECT_TYPE') ? 1 : 0), 1, 'selecttype combolargeelem minwidth100 maxwidth150', 1);
@ -2785,6 +2798,9 @@ function addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
if (is_array($filters) && !empty($filters['search_rowid'])) {
$sql .= natural_search('a.id', $filters['search_rowid'], 1);
}
if (is_array($filters) && !empty($filters['search_filtert'])) {
$sql .= natural_search('a.fk_user_action', $filters['search_filtert'], 1);
}
return $sql;
}

View file

@ -101,8 +101,8 @@ $cancel = GETPOST('cancel');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
@ -111,14 +111,19 @@ if (GETPOST('actioncode', 'array')) {
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
if (empty($page) || $page == -1) {
// 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;
@ -187,7 +192,10 @@ if (empty($reshook)) {
// 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
$actioncode = '';
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -318,6 +326,31 @@ if ($object->id > 0) {
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.((int) $limit);
}
if ($search_rowid) {
$param .= '&search_rowid='.urlencode($search_rowid);
}
if ($actioncode !== '' && $actioncode !== '-1') {
$param .= '&actioncode='.urlencode($actioncode);
}
if ($search_agenda_label) {
$param .= '&search_agenda_label='.urlencode($search_agenda_label);
}
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
$param .= '&dateevent_startday='.GETPOSTINT('dateevent_startday');
}
if ($search_dateevent_end != '') {
$param .= '&dateevent_endyear='.GETPOSTINT('dateevent_endyear');
$param .= '&dateevent_endmonth='.GETPOSTINT('dateevent_endmonth');
$param .= '&dateevent_endday='.GETPOSTINT('dateevent_endday');
}
// Try to know count of actioncomm from cache
$nbEvent = 0;
@ -329,15 +362,16 @@ if ($object->id > 0) {
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
}
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
// List of all actions
$filters = [
'search_agenda_label' => $search_agenda_label,
'search_rowid' => $search_rowid,
];
$filters = array();
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, !empty($object->module) ? $object->module : '');
}
}

View file

@ -61,6 +61,7 @@ if (GETPOSTISARRAY('actioncode')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
@ -134,6 +135,7 @@ if (empty($reshook)) {
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -248,6 +250,9 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
@ -276,8 +281,9 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}

View file

@ -75,6 +75,7 @@ if (GETPOSTISARRAY('actioncode')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
@ -109,6 +110,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
@ -242,6 +244,9 @@ if (!empty($object->id)) {
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
@ -270,8 +275,9 @@ if (!empty($object->id)) {
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with same code than into list.php
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
}

View file

@ -62,6 +62,7 @@ if (GETPOSTISARRAY('actioncode')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_filtert = GETPOSTINT('search_filtert');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
@ -136,6 +137,7 @@ if (empty($reshook)) {
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
$search_filtert = '';
}
}
@ -238,6 +240,9 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
if ($search_complete != '') {
$param .= '&search_complete='.urlencode($search_complete);
}
if ($search_filtert != '') {
$param .= '&search_filtert='.urlencode($search_filtert);
}
if ($search_dateevent_start != '') {
$param .= '&dateevent_startyear='.GETPOSTINT('dateevent_startyear');
$param .= '&dateevent_startmonth='.GETPOSTINT('dateevent_startmonth');
@ -266,6 +271,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
$filters['search_filtert'] = $search_filtert;
// TODO Replace this with the same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
@ -274,4 +280,5 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
// End of page
llxFooter();
$db->close();