diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 99a8b9a856b..9f647dbeefc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2107,7 +2107,8 @@ class Task extends CommonObjectLine $timespent->element_date = $this->timespent_date; $timespent->element_datehour = $this->timespent_datehour; - $timespent->element_date_withhour = $this->timespent_withhour; + + $timespent->element_date_withhour = $this->timespent_withhour; // 0 or 1 $timespent->element_duration = $this->timespent_duration; if ($this->timespent_fk_user > 0) { $timespent->fk_user = $this->timespent_fk_user; @@ -2118,7 +2119,9 @@ class Task extends CommonObjectLine $timespent->invoice_line_id = $this->timespent_invoicelineid; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if ($timespent->update($user) > 0) { + + $resupdate = $timespent->update($user); + if ($resupdate > 0) { if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_TIMESPENT_MODIFY', $user); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 473714fd644..a1efbe71544 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -33,15 +33,6 @@ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formintervention.class.php'; - /** * @var Conf $conf * @var DoliDB $db @@ -53,6 +44,14 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formintervention.class.php'; ' @phan-var-force ?string $uploaddir '; +require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formintervention.class.php'; // Load translation files required by the page $langsLoad = array('projects', 'bills', 'orders', 'companies'); @@ -72,8 +71,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST('mode', 'alpha'); -$id = GETPOSTINT('id'); -$projectid = GETPOSTINT('projectid'); +$id = GETPOSTINT('id'); // Id of task +$projectid = GETPOSTINT('projectid'); // Id of project +$lineid = GETPOSTINT('lineid'); // Id of time spent line $ref = GETPOST('ref', 'alpha'); $withproject = GETPOSTINT('withproject'); $project_ref = GETPOST('project_ref', 'alpha'); @@ -164,6 +164,7 @@ if ($object->fk_project > 0) { /* * Actions */ + $error = 0; if (GETPOST('cancel', 'alpha')) { @@ -289,11 +290,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); if (!$error) { - if (GETPOSTINT('taskid') != $id) { // GETPOST('taskid') is id of new task - $id_temp = GETPOSTINT('taskid'); // should not overwrite $id + if (GETPOSTINT('taskid') != $id) { // GETPOSTINT('taskid') is the id of new task + $id_temp = GETPOSTINT('taskid'); // should not overwrite $id - - $object->fetchTimeSpent(GETPOSTINT('lineid')); + $object->fetchTimeSpent($lineid); $result = 0; @@ -326,7 +326,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } } } else { - $object->fetch($id, $ref); + $object->fetch($id, $ref); // $object is Task $object->fetchTimeSpent(GETPOSTINT('lineid')); @@ -334,17 +334,21 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_old_duration = GETPOSTINT("old_duration"); $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOSTINT("timelinehour"), GETPOSTINT("timelinemin"), 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); $object->timespent_withhour = 1; } elseif (!empty($timespent_date)) { $object->timespent_date = $timespent_date; + $object->timespent_datehour = $timespent_date; $object->timespent_withhour = 0; } + $object->timespent_fk_user = GETPOSTINT("userid_line"); $object->timespent_fk_product = GETPOSTINT("fk_product"); $object->timespent_invoiceid = GETPOSTINT("invoiceid"); $object->timespent_invoicelineid = GETPOSTINT("invoicelineid"); + $result = 0; if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { @@ -1398,9 +1402,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - if ($id) { - $param .= '&id=' . urlencode((string) ($id)); - } if ($projectid) { $param .= '&projectid=' . urlencode((string) ($projectid)); } @@ -1434,7 +1435,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; print ''; - print ''; print ''; print ''; print ''; @@ -1598,7 +1598,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql = "SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,"; $sql .= " t.fk_product,"; - $sql .= " pt.ref, pt.label, pt.fk_projet,"; + $sql .= " pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; $sql .= " p.fk_soc,s.name_alias,"; @@ -1769,7 +1769,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $i = 0; while ($i < $num) { $row = $db->fetch_object($resql); + $tasks[$i] = $row; + $i++; } $db->free($resql); @@ -2158,6 +2160,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print '