Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #32791 Lost user and THM when updating task time #32822

Draft
wants to merge 1 commit into
base: 20.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions htdocs/projet/class/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright (C) 2020 Juanjo Menent <[email protected]>
* Copyright (C) 2022 Charlene Benke <[email protected]>
* Copyright (C) 2023 Gauthier VERDOL <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1417,9 +1417,9 @@ public function mergeTimeSpentTask($origin_id, $dest_id)
/**
* Add time spent
*
* @param User $user User object
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int Return integer <=0 if KO, >0 if OK
* @param User $user User object
* @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
* @return int Return integer <=0 if KO, >0 if OK
*/
public function addTimeSpent($user, $notrigger = 0)
{
Expand Down
27 changes: 22 additions & 5 deletions htdocs/projet/tasks/time.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Copyright (C) 2018 Frédéric France <[email protected]>
* Copyright (C) 2019-2021 Christophe Battarel <[email protected]>
* Copyright (C) 2023 Gauthier VERDOL <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
* Copyright (C) 2024 Vincent de Grandpré <[email protected]>
* Copyright (C) 2024 Solution Libre SAS <[email protected]>
*
Expand Down Expand Up @@ -270,6 +270,7 @@

if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $user->hasRight('projet', 'lire')) {
$error = 0;
$db->begin();

if (!GETPOST("new_durationhour") && !GETPOST("new_durationmin")) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors');
Expand Down Expand Up @@ -300,10 +301,21 @@
} else {
$object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear"));
}
$object->timespent_fk_user = GETPOSTINT("userid_line");
$object->timespent_fk_product = GETPOSTINT("fk_product");
$object->timespent_invoiceid = GETPOSTINT("invoiceid");
$object->timespent_invoicelineid = GETPOSTINT("invoicelineid");

// Use fields from existing record or from post (if provided)
if (GETPOST("userid_line") != '') {
$object->timespent_fk_user = GETPOSTINT("userid_line");
}
if (GETPOST("fk_product") != '') {
$object->timespent_fk_product = GETPOSTINT("fk_product");
}
if (GETPOST("invoiceid") != '') {
$object->timespent_invoiceid = GETPOSTINT("invoiceid");
}
if (GETPOST("invoicelineid") != '') {
$object->timespent_invoicelineid = GETPOSTINT("invoicelineid");
}


$result = 0;
if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) {
Expand Down Expand Up @@ -349,6 +361,11 @@
} else {
$action = '';
}
if ($error == 0) {
$db->commit();
} else {
$db->rollback();
}
}

if ($action == 'confirm_deleteline' && $confirm == "yes" && ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer'))) {
Expand Down
Loading