NEW Add filter on agenda event progression on agenda page

This commit is contained in:
Laurent Destailleur 2025-11-18 21:25:02 +01:00
parent b748ffd528
commit bcde1eb545
8 changed files with 305 additions and 104 deletions

View file

@ -30,12 +30,6 @@
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
/**
* @var Conf $conf
* @var DoliDB $db
@ -43,10 +37,33 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'members'));
$action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartyagenda';
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
// Get Parameters
$id = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid');
@ -66,20 +83,9 @@ if (!$sortfield) {
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC';
$sortorder = 'DESC,DESC';
}
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$objcanvas = null;
@ -104,7 +110,7 @@ if ($result > 0) {
* Actions
*/
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
$parameters = array('id' => $id, 'objcanvas' => $objcanvas);
$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');
@ -122,6 +128,7 @@ if (empty($reshook)) {
$actioncode = '';
$search_rowid = '';
$search_agenda_label = '';
$search_complete = '';
}
}
@ -172,6 +179,8 @@ if ($object->id > 0) {
print '</div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
@ -187,7 +196,7 @@ if ($object->id > 0) {
$newcardbutton .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
if (isModEnabled('agenda')) {
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', dolBuildUrl(DOL_URL_ROOT.'/comm/action/card.php', ['action' => 'create', 'backtopage' => dolBuildUrl($_SERVER['PHP_SELF'], ['id' => $object->id, 'origin' => 'member', 'originid' => $id])]));
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', dolBuildUrl(DOL_URL_ROOT.'/comm/action/card.php', ['action' => 'create', 'origin' => 'member', 'originid' => $id, 'backtopage' => dolBuildUrl($_SERVER['PHP_SELF'], ['id' => $object->id, 'origin' => 'member', 'originid' => $id])]));
}
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
@ -195,12 +204,35 @@ if ($object->id > 0) {
$param = '&id='.$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_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
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_member_'.$object->id;
$nbEvent = dol_getcache($cachekey);
@ -210,15 +242,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'
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
}

View file

@ -244,7 +244,7 @@ if (empty($reshook) && (GETPOST('removedassignedresource') || GETPOST('removedas
}
$_SESSION['assignedtoresource'] = json_encode($tmpassignedresourceids);
$donotclearsessionresource = 1;
if ($action == 'add' && $usercancreate) {
$action = 'create';
}
@ -1700,7 +1700,7 @@ if ($action == 'create') {
$percent = 100;
}
}
$formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'minwidth150 maxwidth300');
print $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'minwidth150 maxwidth300', 1);
print '</td></tr>';
if (isModEnabled("societe")) {

View file

@ -32,6 +32,13 @@
// Load Dolibarr environment
require '../main.inc.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
@ -46,14 +53,6 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
// Load translation files required by the page
$langs->loadLangs(array('companies', 'users', 'other', 'commercial'));
@ -87,8 +86,8 @@ if (!empty($canvas)) {
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
}
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
@ -97,6 +96,9 @@ if (GETPOST('actioncode', 'array')) {
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
// Security check
if ($user->socid) {
@ -120,10 +122,10 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) {
$sortfield = 'a.datep, a.id';
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC';
$sortorder = 'DESC,DESC';
}
@ -145,9 +147,11 @@ if (empty($reshook)) {
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
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 = '';
}
}
@ -262,6 +266,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '</div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
@ -285,7 +291,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '');
}
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : ''));
$out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog'));
$out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog'), 'tzuserrel');
}
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
@ -298,21 +304,54 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$param = '&id='.$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_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');
}
print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
// Try to know count of actioncomm from cache
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_contact_'.$object->id;
$nbEvent = dol_getcache($cachekey);
$titlelist = $langs->trans("ActionsOnContact").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
if (!empty($conf->dol_optimize_smallscreen)) {
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
}
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 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'
show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder);
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
}
}

View file

@ -64,9 +64,10 @@ class FormActions
* @param integer $showempty Show an empty line if select is used
* @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
* @param string $morecss More css on select field
* @param int $nooutput 1=No output, return string. 0=Print on output
* @return void
*/
public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100', $nooutput = 0)
{
// phpcs:enable
global $langs, $conf;
@ -79,40 +80,45 @@ class FormActions
);
// +ActionUncomplete
$out = '';
if (!empty($conf->use_javascript_ajax) || $onlyselect) {
//var_dump($selected);
if ($selected == 'done') {
$selected = '100';
}
print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
$out .= '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
if ($showempty) {
print '<option value="-1"'.($selected == '' ? ' selected' : '').'>&nbsp;</option>';
$out .= '<option value="-1"'.($selected == '' ? ' selected' : '').'>&nbsp;</option>';
}
foreach ($listofstatus as $key => $val) {
print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
if ($key == '50' && $onlyselect == 2) {
print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
$out .= '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>';
$out .= $val;
$out .= '</option>';
// Add a choice "Incomplete" at second position
if ($key === 'na' && $onlyselect == 2) {
$out .= '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")." + ".$langs->trans("ActionRunningShort").')</option>';
}
}
print '</select>';
$out .= '</select>';
if ($selected == 0 || $selected == 100) {
$canedit = 0;
}
print ajax_combobox('select'.$htmlname, array(), 0, 0, 'resolve', '-1', $morecss);
$out .= ajax_combobox('select'.$htmlname, array(), 0, 0, 'resolve', '-1', $morecss);
if (empty($onlyselect)) {
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna heightofcombo" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
print '<span class="hideonsmartphone hideifna">%</span>';
$out .= ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna heightofcombo" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
$out .= '<span class="hideonsmartphone hideifna">%</span>';
}
} else {
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
$out .= ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
}
if (!empty($conf->use_javascript_ajax)) {
print "\n";
print '<script nonce="'.getNonce().'" type="text/javascript">';
print "
$out .= "\n";
$out .= '<script nonce="'.getNonce().'" type="text/javascript">';
$out .= "
var htmlname = '".dol_escape_js($htmlname)."';
$(document).ready(function () {
@ -155,6 +161,12 @@ class FormActions
}
</script>\n";
}
if ($nooutput) {
return $out;
} else {
print $out;
}
}

View file

@ -1215,7 +1215,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
*/
function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserlogin = 0)
{
global $user, $conf, $extrafields, $hookmanager;
global $user, $extrafields, $hookmanager;
global $contextpage;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
@ -1802,8 +1802,6 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
*/
function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '')
{
global $user, $conf;
$out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo');
if ($noprint) {
@ -1834,7 +1832,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 $user, $conf, $hookmanager;
global $hookmanager;
global $form;
global $param, $massactionbutton;
@ -1878,6 +1876,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
}
$sortfield_new = implode(',', $sortfield_new_list);
$complete = (string) $filters['search_complete']; // Can be 'na', '0', '50', '100'
$percent = $complete !== '' ? $complete : -1;
if ((string) $complete == '0') {
$percent = '0';
} elseif ((int) $complete == 100) {
$percent = '100';
}
$sql = '';
if (isModEnabled('agenda')) {
@ -2273,7 +2279,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
$out .= '<div class="div-table-responsive-no-min">';
$out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre">';
$out .= '<tr class="liste_titre_filter">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
@ -2303,9 +2309,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
$out .= '<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="' . $filters['search_agenda_label'] . '"></td>';
$out .= '<td class="liste_titre"></td>';
$out .= '<td class="liste_titre"></td>';
// Status
$out .= '<td class="liste_titre">';
$out .= '';
// Status ($percent can be 'na'or < 100 or 100)
$out .= '<td class="liste_titre parentonrightofpage">';
$out .= $formactions->form_select_status_action('formaction', $percent, 1, 'search_complete', 1, 2, 'search_status width100 onrightofpage', 1);
$out .= '</td>';
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
@ -2467,9 +2473,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
$out .= '<td class="tdoverflowmax125" title="' . $labelOfTypeToShowLong . '">';
$out .= $actionstatic->getTypePicto();
//if (empty($conf->dol_optimize_smallscreen)) {
$out .= $labelOfTypeToShow;
//}
$out .= '</td>';
// Title/Label of event
@ -2584,8 +2588,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
*/
function show_subsidiaries($conf, $langs, $db, $object)
{
global $user;
$i = -1;
$sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas, s.status";
@ -2702,7 +2704,7 @@ function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND")
}
/**
* Add Event Type SQL
* Add more SQL filters for event list
*
* @param string $sql $sql modified
* @param string $donetodo donetodo
@ -2719,6 +2721,21 @@ function addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
} elseif ($donetodo == 'done') {
$sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))";
}
if (is_array($filters) && isset($filters['search_complete']) && $filters['search_complete'] === 'na') {
$sql .= " AND a.percent = -1";
}
if (is_array($filters) && isset($filters['search_complete']) && $filters['search_complete'] === '0') {
$sql .= " AND a.percent = 0";
}
if (is_array($filters) && isset($filters['search_complete']) && $filters['search_complete'] === '50') {
$sql .= " AND a.percent > 0 AND a.percent < 100";
}
if (is_array($filters) && isset($filters['search_complete']) && $filters['search_complete'] === 'todo') {
$sql .= " AND a.percent >= 0 AND a.percent < 100";
}
if (is_array($filters) && isset($filters['search_complete']) && $filters['search_complete'] === '100') {
$sql .= " AND a.percent = 100";
}
if (is_array($filters) && !empty($filters['search_agenda_label'])) {
$sql .= natural_search('a.label', $filters['search_agenda_label']);
}

View file

@ -31,13 +31,6 @@
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
/**
* @var Conf $conf
* @var DoliDB $db
@ -45,14 +38,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
// Load translation files required by the page
$langs->load("companies");
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
@ -61,6 +60,9 @@ if (GETPOST('actioncode', 'array')) {
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
$id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
@ -69,9 +71,10 @@ $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 (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;
@ -128,7 +131,9 @@ 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 = '';
}
}
@ -188,6 +193,8 @@ dol_print_object_info($object, 1);
print '</div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
@ -224,10 +231,32 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
$param = '&id='.$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_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
@ -240,15 +269,16 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
$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 = array();
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}

View file

@ -63,16 +63,20 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
}
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$search_dateevent_start = GETPOSTDATE('dateevent_start');
$search_dateevent_end = GETPOSTDATE('dateevent_end');
$hookmanager->initHooks(array('projectcardinfo'));
@ -100,9 +104,11 @@ if ($reshook < 0) {
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
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 = '';
}
@ -112,7 +118,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
*/
$form = new Form($db);
$object = new Project($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
@ -225,6 +230,29 @@ if (!empty($object->id)) {
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_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');
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_project_'.$object->id;
@ -235,13 +263,15 @@ if (!empty($object->id)) {
$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 = array();
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
}

View file

@ -30,12 +30,6 @@
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
/**
* @var Conf $conf
* @var DoliDB $db
@ -43,14 +37,20 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
// Load translation files required by the page
$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal'));
$action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartyagenda';
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (GETPOSTISARRAY('actioncode')) {
$actioncode = GETPOST('actioncode', 'array:alpha', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
@ -60,14 +60,18 @@ if (GETPOST('actioncode', 'array')) {
$search_rowid = GETPOST('search_rowid');
$search_agenda_label = GETPOST('search_agenda_label');
$search_complete = GETPOST('search_complete');
$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) {
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
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;
@ -78,6 +82,15 @@ if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
}
// Initialize a technical objects
$object = new Societe($db);
@ -119,7 +132,9 @@ 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 = '';
}
}
@ -158,6 +173,8 @@ dol_print_object_info($object, 1);
print '</div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
@ -210,6 +227,28 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
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_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
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
@ -221,12 +260,13 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') ||
$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 = array();
$filters['search_agenda_label'] = $search_agenda_label;
$filters['search_rowid'] = $search_rowid;
$filters['search_complete'] = $search_complete; // Can be 'na', '0', '100', '50'
// TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);