Merge pull request #12499 from altatof/updtask
NEW : allow time consumed to be linked to another task
This commit is contained in:
commit
2177116f83
@ -4,7 +4,8 @@
|
|||||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||||
|
* Copyright (C) 2019 Christophe Battarel <christophe@altairis.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -225,34 +226,71 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel
|
|||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$object->fetch($id, $ref);
|
if ($_POST['taskid'] != $id)
|
||||||
// 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"));
|
$id = $_POST['taskid'];
|
||||||
$object->timespent_withhour = 1;
|
|
||||||
|
$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, $ref);
|
||||||
|
$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
|
||||||
|
{
|
||||||
|
$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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear"));
|
$object->fetch($id, $ref);
|
||||||
}
|
// TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids))
|
||||||
$object->timespent_fk_user = $_POST["userid_line"];
|
|
||||||
|
|
||||||
$result = $object->updateTimeSpent($user);
|
$object->timespent_id = $_POST["lineid"];
|
||||||
if ($result >= 0)
|
$object->timespent_note = $_POST["timespent_note_line"];
|
||||||
{
|
$object->timespent_old_duration = $_POST["old_duration"];
|
||||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
$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
|
||||||
else
|
if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans($object->error), null, 'errors');
|
$object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear"));
|
||||||
$error++;
|
$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
|
else
|
||||||
@ -1301,19 +1339,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Task ref
|
// Task ref
|
||||||
if (!empty($arrayfields['t.task_ref']['checked']))
|
if (!empty($arrayfields['t.task_ref']['checked']))
|
||||||
{
|
{
|
||||||
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task
|
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task
|
||||||
{
|
{
|
||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
$tasktmp->id = $task_time->fk_task;
|
if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid)
|
||||||
$tasktmp->ref = $task_time->ref;
|
{
|
||||||
$tasktmp->label = $task_time->label;
|
$formproject->selectTasks(-1, GETPOST('taskid', 'int')?GETPOST('taskid', 'int'):$task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, '');
|
||||||
print $tasktmp->getNomUrl(1, 'withproject', 'time');
|
}
|
||||||
print '</td>';
|
else
|
||||||
if (!$i) $totalarray['nbfield']++;
|
{
|
||||||
}
|
$tasktmp->id = $task_time->fk_task;
|
||||||
}
|
$tasktmp->ref = $task_time->ref;
|
||||||
|
$tasktmp->label = $task_time->label;
|
||||||
|
print $tasktmp->getNomUrl(1, 'withproject', 'time');
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Task label
|
// Task label
|
||||||
if (!empty($arrayfields['t.task_label']['checked']))
|
if (!empty($arrayfields['t.task_label']['checked']))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user