From 88cd8fface58a2f95cc6c4f6e41320b04879acb4 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 16 Sep 2021 17:53:47 +0200 Subject: [PATCH 1/2] FIX: task time: can't filter by user with pgsql + show error message --- htdocs/projet/tasks/time.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2a4b1d6aeee..7baac31a51a 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1058,7 +1058,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ($search_note) $sql .= natural_search('t.note', $search_note); if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); - if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user); + if ($search_user > 0) $sql .= ' AND t.fk_user = ' . intval($search_user); if ($search_valuebilled == '1') $sql .= ' AND t.invoice_id > 0'; if ($search_valuebilled == '0') $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); @@ -1069,6 +1069,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); + + if (! $resql) { + dol_print_error($db); + exit; + } + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { From 571d130c3cb1e9665da68b2c8a3e38a9cc00a93d Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 17 Sep 2021 10:51:37 +0200 Subject: [PATCH 2/2] FIX: task time: keep on using natural_search --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 7baac31a51a..b29c434963d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1058,7 +1058,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ($search_note) $sql .= natural_search('t.note', $search_note); if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); - if ($search_user > 0) $sql .= ' AND t.fk_user = ' . intval($search_user); + if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user, 2); if ($search_valuebilled == '1') $sql .= ' AND t.invoice_id > 0'; if ($search_valuebilled == '0') $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year);