Fix select of product and last date in list of time spent

This commit is contained in:
Laurent Destailleur 2026-01-06 10:25:39 +01:00
parent 925381937a
commit 7f73d92dc8
2 changed files with 44 additions and 31 deletions

View file

@ -891,6 +891,8 @@ MyDashboard=My Dashboard
Deductible=Deductible
from=from
toward=toward
fromhour=from
tohour=to
Access=Access
SelectAction=Select action
SelectTargetUser=Select target user/employee

View file

@ -1309,10 +1309,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
$arrayfields['author'] = array('label' => $langs->trans("By"), 'checked' => '1');
$arrayfields['t.note'] = array('label' => $langs->trans("Note"), 'checked' => '1');
$arrayfields['t.tms'] = array('label' => $langs->trans("DateModification"), 'checked' => '0');
if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => '1');
}
$arrayfields['t.element_duration'] = array('label' => $langs->trans("Duration"), 'checked' => '1');
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => '0', 'enabled' => (string) (int) (((getDolGlobalInt('PROJECT_HIDE_TASKS') || !getDolGlobalInt('PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
$arrayfields['value'] = array('label' => $langs->trans("Value"), 'checked' => '1', 'enabled' => (string) (int) isModEnabled("salaries"));
$arrayfields['valuebilled'] = array('label' => $langs->trans("Billed"), 'checked' => '1', 'enabled' => (string) (int) (((getDolGlobalInt('PROJECT_HIDE_TASKS') || !getDolGlobalInt('PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
// Extra fields
@ -1600,7 +1602,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
$sql = "SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,";
$sql .= " t.fk_product, t.import_key, t.datec, t.tms";
$sql .= " t.fk_product, t.import_key, t.datec, t.tms,";
$sql .= " pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet,";
$sql .= " u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
$sql .= " il.fk_facture as invoice_id, inv.fk_statut,";
@ -1998,6 +2000,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.note']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' . dol_escape_htmltag($search_note) . '"></td>';
}
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Duration
if (!empty($arrayfields['t.element_duration']['checked'])) {
// Duration - Time spent
@ -2007,7 +2013,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_timespent_starthour || $search_timespent_startmin) {
$durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
}
print '<div class="nowraponall">' . $langs->trans('from') . ' ';
print '<div class="nowraponall"><span class="opacitymedium">' . $langs->trans('fromhour') . '</span> ';
print $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text', 0, 1);
print '</div>';
@ -2015,7 +2021,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_timespent_endhour || $search_timespent_endmin) {
$durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
}
print '<div class="nowraponall">' . $langs->trans('to') . ' ';
print '<div class="nowraponall"><span class="opacitymedium">' . $langs->trans('tohour') . '</span> ';
print $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text', 0, 1);
print '</div>';
@ -2023,11 +2029,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Product
if (!empty($arrayfields['t.fk_product']['checked'])) {
print '<td class="liste_titre right"></td>';
}
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="liste_titre right"></td>';
print '<td class="liste_titre"></td>';
}
// Value in main currency
if (!empty($arrayfields['value']['checked'])) {
@ -2107,6 +2109,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['t.tms']['checked'])) {
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], 't.tms', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['t.element_duration']['checked'])) {
print_liste_field_titre($arrayfields['t.element_duration']['label'], $_SERVER['PHP_SELF'], 't.element_duration', '', $param, '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
@ -2115,10 +2121,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['t.tms']['checked'])) {
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], 't.tms', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['value']['checked'])) {
print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
@ -2414,7 +2416,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<input type="hidden" name="timespent_note_line" value="' . dol_escape_htmltag($task_time->note, 0, 1) . '">';
}
// Time spent
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="nowraponall">';
print dol_print_date($task_time->tms, 'dayhour');
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Time spent - Duration
if (!empty($arrayfields['t.element_duration']['checked'])) {
print '<td class="right nowraponall">';
if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) {
@ -2466,13 +2478,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="nowraponall">';
print dol_print_date($task_time->tms, 'dayhour');
print '</td>';
}
// Value spent
if (!empty($arrayfields['value']['checked'])) {
$langs->load("salaries");
@ -2504,7 +2509,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// Billed
// Value billed
if (!empty($arrayfields['valuebilled']['checked'])) {
print '<td class="center">'; // invoice_id and invoice_line_id
if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
@ -2718,7 +2723,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 . '" value="' . dol_escape_htmltag($task_time->note, 0, 1) . '">';
}
// Time spent
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="nowraponall">';
print '</td>';
}
// Time spent - duration
if (!empty($arrayfields['t.element_duration']['checked'])) {
print '<td class="right">';
if ($action == 'splitline' && GETPOSTINT('lineid') == $task_time->rowid) {
@ -2883,7 +2894,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<input type="hidden" name="timespent_note_line_2" value="' . dol_escape_htmltag($task_time->note, 0, 1) . '">';
}
// Time spent
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="nowraponall">';
print dol_print_date($task_time->tms, 'dayhour');
print '</td>';
}
// Time spent - duration
if (!empty($arrayfields['t.element_duration']['checked'])) {
print '<td class="right">';
if ($action == 'splitline' && GETPOSTINT('lineid') == $task_time->rowid) {
@ -2901,14 +2919,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '</td>';
}
// Last modification
if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="nowraponall">';
print dol_print_date($task_time->tms, 'dayhour');
print '</td>';
}
// Value spent
// Value spent - duration
if (!empty($arrayfields['value']['checked'])) {
print '<td class="right">';
print '<span class="amount nowraponall">';