FIX#29901 blocking tasktimesel for nonbillabletime with dblclick enabling option (#32023)

* FIX#29901 - Disable task checkbox in list with enable option on dbl-click when aligned in left column ans task not billable

* typo

* Managing $invoiced variable for phpstan

* pre-commit hook correct.

* phpcs

* Update time.php

* Update time.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Vincent de Grandpré 2024-11-21 13:11:58 -05:00 committed by GitHub
parent 57d121664f
commit 869ee70c44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2119,6 +2119,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
break;
}
// Line is invoiced if it has an invoice_id
$invoiced = $task_time->invoice_id ? true : false;
$date1 = $db->jdate($task_time->element_date);
$date2 = $db->jdate($task_time->element_datehour);
@ -2156,7 +2159,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$selected = 1;
}
print '&nbsp;';
print '<input id="cb' . $task_time->rowid . '" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>';
// Disable select if task not billable or already invoiced
$disabled = (intval($task_time->billable) != 1 || $invoiced);
$ctrl = '<input '.($disabled ? 'disabled' : '').' id="cb' . $task_time->rowid . '" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>';
if ($disabled) {
// If disabled, a dbl-click very close outside the control
// will re-enable it, so that user is not blocked if needed.
print '<span id="cbsp'. $task_time->rowid . '">'.$ctrl.'</span>';
print '<script>$("#cbsp' . $task_time->rowid . '").dblclick(()=>{ $("#cb' . $task_time->rowid . '").removeAttr("disabled") })</script>';
} else {
print $ctrl;
}
}
}
}
@ -2426,7 +2440,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Invoiced
$invoiced = false;
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')) {
@ -2506,6 +2519,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$selected = 1;
}
print '&nbsp;';
// Disable select if task not billable or already invoiced
$disabled = (intval($task_time->billable) != 1 || $invoiced);
$ctrl = '<input '.($disabled ? 'disabled' : '').' id="cb' . $task_time->rowid . '" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>';