Skip to content

Commit

Permalink
FIX#29901 blocking tasktimesel for nonbillabletime with dblclick enab…
Browse files Browse the repository at this point in the history
…ling 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>
  • Loading branch information
vdegrandpre and eldy authored Nov 21, 2024
1 parent 57d1216 commit 869ee70
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions htdocs/projet/tasks/time.php
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,9 @@ function setDetailVisibility() {
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);

Expand Down Expand Up @@ -2156,7 +2159,18 @@ function setDetailVisibility() {
$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;
}
}
}
}
Expand Down Expand Up @@ -2426,7 +2440,6 @@ function setDetailVisibility() {
}

// 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')) {
Expand Down Expand Up @@ -2506,6 +2519,7 @@ function setDetailVisibility() {
$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"' : '') . '>';
Expand Down

0 comments on commit 869ee70

Please sign in to comment.