From 8522faea7f86f000bf9d31f0ea043a24c1e59165 Mon Sep 17 00:00:00 2001 From: altairis Date: Wed, 20 Nov 2019 10:15:46 +0100 Subject: [PATCH 1/5] add conf --- htdocs/conf/conf.php | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 htdocs/conf/conf.php diff --git a/htdocs/conf/conf.php b/htdocs/conf/conf.php new file mode 100644 index 00000000000..bfadb6d5c55 --- /dev/null +++ b/htdocs/conf/conf.php @@ -0,0 +1,51 @@ + Date: Fri, 22 Nov 2019 15:14:32 +0100 Subject: [PATCH 2/5] remove conf --- htdocs/conf/conf.php | 51 -------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 htdocs/conf/conf.php diff --git a/htdocs/conf/conf.php b/htdocs/conf/conf.php deleted file mode 100644 index bfadb6d5c55..00000000000 --- a/htdocs/conf/conf.php +++ /dev/null @@ -1,51 +0,0 @@ - Date: Fri, 22 Nov 2019 15:14:55 +0100 Subject: [PATCH 3/5] allow time consumed to be linked to another task --- htdocs/projet/tasks/time.php | 102 +++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 29 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 0f9e9fb6357..c534789c812 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Christophe Battarel * * 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 @@ -225,34 +226,70 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel if (!$error) { - $object->fetch($id, $ref); - // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - - $object->timespent_id = $_POST["lineid"]; - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += $_POST["new_durationmin"] * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered - { - $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); - $object->timespent_withhour = 1; - } - else + if ($_POST['taskid'] != $id) { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + $id = $_POST['taskid']; + + $object->fetchTimeSpent(GETPOST('lineid', 'int')); + // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) + $result = $object->delTimeSpent($user); + + $object->fetch($id); + $object->timespent_note = $_POST["timespent_note_line"]; + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + $object->timespent_withhour = 1; + } + else + { + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + } + $object->timespent_fk_user = $_POST["userid_line"]; + $result = $object->addTimeSpent($user); + if ($result >= 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } } - $object->timespent_fk_user = $_POST["userid_line"]; + else + { + $object->fetch($id, $ref); + // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - $result = $object->updateTimeSpent($user); - if ($result >= 0) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; + $object->timespent_id = $_POST["lineid"]; + $object->timespent_note = $_POST["timespent_note_line"]; + $object->timespent_old_duration = $_POST["old_duration"]; + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += $_POST["new_durationmin"] * 60; // We store duration in seconds + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + $object->timespent_withhour = 1; + } + else + { + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + } + $object->timespent_fk_user = $_POST["userid_line"]; + + $result = $object->updateTimeSpent($user); + if ($result >= 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } } } else @@ -1195,10 +1232,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; - $tasktmp->id = $task_time->fk_task; - $tasktmp->ref = $task_time->ref; - $tasktmp->label = $task_time->label; - print $tasktmp->getNomUrl(1, 'withproject', 'time'); + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + $formproject->selectTasks(-1, GETPOST('taskid', 'int')?GETPOST('taskid', 'int'):$task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + } + else + { + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + } print ''; if (!$i) $totalarray['nbfield']++; } From 7f24d1fe407941af8545d726e6a98205f8874e46 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Nov 2019 14:18:09 +0000 Subject: [PATCH 4/5] Fixing style errors. --- htdocs/projet/tasks/time.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index c534789c812..9fb95609cb6 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -229,11 +229,11 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel if ($_POST['taskid'] != $id) { $id = $_POST['taskid']; - + $object->fetchTimeSpent(GETPOST('lineid', 'int')); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) $result = $object->delTimeSpent($user); - + $object->fetch($id); $object->timespent_note = $_POST["timespent_note_line"]; $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds @@ -259,7 +259,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel $error++; } } - else + else { $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) From eddc38e37f77ef85778ddfb4d5bfa6e0181d51d6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 15 Jan 2020 13:18:25 +0000 Subject: [PATCH 5/5] Fixing style errors. --- htdocs/projet/tasks/time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 779bd6ac2fd..efaaa5b75ca 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -235,8 +235,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel $result = $object->delTimeSpent($user); $object->fetch($id, $ref); - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; + $object->timespent_note = $_POST["timespent_note_line"]; + $object->timespent_old_duration = $_POST["old_duration"]; $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered