Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into 17.0

This commit is contained in:
Laurent Destailleur 2023-02-23 22:15:44 +01:00
commit c2f79dfd7a
2 changed files with 21 additions and 16 deletions

View File

@ -812,9 +812,11 @@ class Task extends CommonObjectLine
* @param array $search_array_options Array of search * @param array $search_array_options Array of search
* @param int $loadextras Fetch all Extrafields on each task * @param int $loadextras Fetch all Extrafields on each task
* @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @return array Array of tasks * @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; global $conf, $hookmanager;
@ -954,8 +956,11 @@ class Task extends CommonObjectLine
} }
} }
if ($sortfield && $sortorder) {
$sql .= " ORDER BY p.ref, t.rang, t.dateo"; $sql .= $this->db->order($sortfield, $sortorder);
} else {
$sql .= " ORDER BY p.ref, t.rang, t.dateo";
}
//print $sql;exit; //print $sql;exit;
dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG); dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG);

View File

@ -124,12 +124,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_el
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) { /* if (!$sortfield) {
reset($object->fields); $sortfield="t.".key($object->fields); 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. } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
if (!$sortorder) { if (!$sortorder) {
$sortorder = "ASC"; $sortorder = "ASC";
} } */
// Security check // Security check
@ -854,7 +854,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Get list of tasks in tasksarray and taskarrayfiltered // 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). // 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; $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 // We load also tasks limited to a particular user
$tmpuser = new User($db); $tmpuser = new User($db);
@ -1004,41 +1004,41 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
// print '<td>'.$langs->trans("Project").'</td>'; // print '<td>'.$langs->trans("Project").'</td>';
if (!empty($arrayfields['t.ref']['checked'])) { 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'])) { 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'])) { if (!empty($arrayfields['t.description']['checked'])) {
print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
} }
if (!empty($arrayfields['t.dateo']['checked'])) { 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'])) { 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'])) { 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'])) { 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'])) { if (!empty($arrayfields['t.progress_calculated']['checked'])) {
print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
} }
if (!empty($arrayfields['t.progress']['checked'])) { 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'])) { if (!empty($arrayfields['t.progress_summary']['checked'])) {
print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1); print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
} }
if ($object->usage_bill_time) { if ($object->usage_bill_time) {
if (!empty($arrayfields['t.tobill']['checked'])) { 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'])) { 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 // Contacts of task, disabled because available by default jsut after
@ -1049,7 +1049,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
*/ */
if (!empty($arrayfields['t.budget_amount']['checked'])) { 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'])) { if (!empty($arrayfields['c.assigned']['checked'])) {