diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 48167edcc1d..6a6089d7e1e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -191,7 +191,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } } -if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire) +if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cancel"] && $user->rights->projet->lire) { $error=0; @@ -318,6 +318,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } $userWrite = $projectstatic->restrictedProjectArea($user,'write'); + $linktocreatetime = ''; if ($projectstatic->id > 0) { @@ -425,6 +426,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); print '
'; + } // Link to create time //if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) @@ -436,12 +438,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project { $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':''); - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } else // We are on tab 'Time Spent' of task { $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':''); - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } } else @@ -454,7 +456,6 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $linktocreatetime = ''.$langs->trans('AddTime').''; } //} - } } if (empty($projectidforalltimes)) @@ -859,6 +860,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; if ($action == 'editline') print ''; + elseif ($action == 'splitline') print ''; else print ''; print ''; print ''; @@ -972,7 +974,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.task_date']['checked'])) { print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { if (empty($task_time->task_date_withhour)) { @@ -1019,7 +1021,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['author']['checked'])) { print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { if (empty($object->id)) $object->fetch($id); $contactsoftask=$object->getListContactId('internal'); @@ -1050,7 +1052,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.note']['checked'])) { print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print ''; } @@ -1061,12 +1063,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; if (! $i) $totalarray['nbfield']++; } + elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } // Time spent if (! empty($arrayfields['t.task_duration']['checked'])) { print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print ''; print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); @@ -1117,7 +1123,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Action column print ''; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid) { print ''; print ''; @@ -1128,8 +1134,15 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) { - //$param = ($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'.($withproject?'&withproject=1':''); - print ' '; + if ($conf->MAIN_FEATURES_LEVEL >= 2) + { + print ' '; + print 'rowid.$param.'">'; + print img_split(); + print ''; + } + + print ' '; print 'rowid.$param.'">'; print img_edit(); print ''; @@ -1145,6 +1158,304 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print "\n"; + // Add line to split + + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + + // Date + if (! empty($arrayfields['t.task_date']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { + print $form->selectDate(($date2?$date2:$date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); + } + else print $form->selectDate(($date2?$date2:$date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } + else + { + print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); + } + print ''; + } + + // Task ref + if (! empty($arrayfields['t.task_ref']['checked'])) + { + 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'); + print ''; + } + } + + // Task label + if (! empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + print $task_time->label; + print ''; + } + } + + // User + if (! empty($arrayfields['author']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask=$object->getListContactId('internal'); + if (!in_array($task_time->fk_user,$contactsoftask)) { + $contactsoftask[]=$task_time->fk_user; + } + if (count($contactsoftask)>0) { + print img_object('','user','class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); + }else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; + print $userstatic->getNomUrl(-1); + } + print ''; + } + + // Note + if (! empty($arrayfields['t.note']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + + // Time spent + if (! empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); + } + else + { + print convertSecondToTime($task_time->task_duration,'allhourmin'); + } + print ''; + } + + // Value spent + if (! empty($arrayfields['value']['checked'])) + { + print ''; + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + } + + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) + { + print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + } + + /* + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + */ + + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; + print ''; + + print "\n"; + + + // Line for second dispatching + + print ''; + + // Date + if (! empty($arrayfields['t.task_date']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { + print $form->selectDate(($date2?$date2:$date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); + } + else print $form->selectDate(($date2?$date2:$date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); + } + else + { + print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); + } + print ''; + } + + // Task ref + if (! empty($arrayfields['t.task_ref']['checked'])) + { + 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'); + print ''; + } + } + + // Task label + if (! empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + print $task_time->label; + print ''; + } + } + + // User + if (! empty($arrayfields['author']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask=$object->getListContactId('internal'); + if (!in_array($task_time->fk_user,$contactsoftask)) { + $contactsoftask[]=$task_time->fk_user; + } + if (count($contactsoftask)>0) { + print img_object('','user','class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user,'userid_line_2',0,'',0,'',$contactsoftask); + }else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; + print $userstatic->getNomUrl(-1); + } + print ''; + } + + // Note + if (! empty($arrayfields['t.note']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + + // Time spent + if (! empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration_2',0,0,'text'); + } + else + { + print convertSecondToTime($task_time->task_duration,'allhourmin'); + } + print ''; + } + + // Value spent + if (! empty($arrayfields['value']['checked'])) + { + print ''; + $value = 0; + print price($value, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + } + + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) + { + print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + } + + /* + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + */ + + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; + print ''; + + print "\n"; + } + $i++; }