From d326e59beba5e5d997384f323f6f22c57c55a17e Mon Sep 17 00:00:00 2001
From: pratushraj
Date: Thu, 23 Feb 2023 13:00:31 +0530
Subject: [PATCH 1/2] issue #24014
---
htdocs/projet/class/task.class.php | 9 ++++++---
htdocs/projet/tasks.php | 26 +++++++++++++-------------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 87ab0afdc47..3c58a147d39 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -813,7 +813,7 @@ class Task extends CommonObjectLine
* @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
* @return array Array of tasks
*/
- public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1)
+ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '')
{
global $conf, $hookmanager;
@@ -953,8 +953,11 @@ class Task extends CommonObjectLine
}
}
-
- $sql .= " ORDER BY p.ref, t.rang, t.dateo";
+ if($sortfield && $sortorder) {
+ $sql .= $this->db->order($sortfield, $sortorder);
+ } else {
+ $sql .= " ORDER BY p.ref, t.rang, t.dateo";
+ }
//print $sql;exit;
dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG);
diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php
index ffba37abb7d..22258bd3b18 100644
--- a/htdocs/projet/tasks.php
+++ b/htdocs/projet/tasks.php
@@ -124,12 +124,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_el
// Default sort order (if not yet defined by previous GETPOST)
-if (!$sortfield) {
+/* if (!$sortfield) {
reset($object->fields); $sortfield="t.".key($object->fields);
} // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
if (!$sortorder) {
$sortorder = "ASC";
-}
+} */
// Security check
@@ -848,7 +848,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
$filteronthirdpartyid = $socid;
- $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options);
+ $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options, 0, 1, $sortfield, $sortorder);
// We load also tasks limited to a particular user
$tmpuser = new User($db);
@@ -998,41 +998,41 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print '';
// print '| '.$langs->trans("Project").' | ';
if (!empty($arrayfields['t.ref']['checked'])) {
- print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '');
+ print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], 't.ref', '', $param, '', $sortfield, $sortorder, '');
}
if (!empty($arrayfields['t.label']['checked'])) {
- print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
+ print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", '', $param, '', $sortfield, $sortorder, '');
}
if (!empty($arrayfields['t.description']['checked'])) {
print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
}
if (!empty($arrayfields['t.dateo']['checked'])) {
- print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.datee']['checked'])) {
- print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.planned_workload']['checked'])) {
- print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+ print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
}
if (!empty($arrayfields['t.duration_effective']['checked'])) {
- print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+ print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
}
if (!empty($arrayfields['t.progress_calculated']['checked'])) {
print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
}
if (!empty($arrayfields['t.progress']['checked'])) {
- print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+ print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
}
if (!empty($arrayfields['t.progress_summary']['checked'])) {
print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
}
if ($object->usage_bill_time) {
if (!empty($arrayfields['t.tobill']['checked'])) {
- print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "t.tobill", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.billed']['checked'])) {
- print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "t.billed", '', $param, '', $sortfield, $sortorder, 'right ');
}
}
// Contacts of task, disabled because available by default jsut after
@@ -1043,7 +1043,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
*/
if (!empty($arrayfields['t.budget_amount']['checked'])) {
- print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "t.budget_amount", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['c.assigned']['checked'])) {
From af4228064d95a44e62ac9b4342e0d6955d4f87a4 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Thu, 23 Feb 2023 07:33:16 +0000
Subject: [PATCH 2/2] Fixing style errors.
---
htdocs/projet/class/task.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 3c58a147d39..fea80f6d13a 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -953,7 +953,7 @@ class Task extends CommonObjectLine
}
}
- if($sortfield && $sortorder) {
+ if ($sortfield && $sortorder) {
$sql .= $this->db->order($sortfield, $sortorder);
} else {
$sql .= " ORDER BY p.ref, t.rang, t.dateo";