diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 2cafcc707d0..6ddb10c40ed 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -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); } } diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 95c538e58b6..edcc64b8f94 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -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(); diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 29ecd776066..b0a7fa92d62 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -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) ? '('.$nbEvent.')' : ''); } - 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); } } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index db51155b39d..4be5f19aa0d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -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 .= ''; // Owner - $out .= ''; + $out .= ''; + $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 .= ''; // Type $out .= ''; $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; } diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index d3dc21febee..712735c0328 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -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) ? '('.$nbEvent.')' : ''); } - 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 : ''); } } diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index a6df0bac866..3bfeda941b0 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -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); } diff --git a/htdocs/projet/agenda.php b/htdocs/projet/agenda.php index 9b9d53ef6df..9456df8ff7b 100644 --- a/htdocs/projet/agenda.php +++ b/htdocs/projet/agenda.php @@ -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); } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index fd9da7099d8..9dbcb742990 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -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();