diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index f3f58c17119..6689f966c15 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -194,7 +194,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Ref - print '
'; + print '
'; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -255,7 +255,7 @@ if ($id > 0 || ! empty($ref)) $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; // Ref - print '
'.$langs->trans('Ref').''; + print '
'.$langs->trans('Ref').''; if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 07fda131407..c9a69fc81a4 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -137,7 +137,7 @@ if ($object->id > 0) print ''; // Ref - print '
'; + print '
'; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -198,7 +198,7 @@ if ($object->id > 0) print ''; // Ref - print '
'; + print '
'; print $langs->trans("Ref"); print ''; if (empty($withproject) || empty($projectstatic->id)) diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index e62e58df58b..5d5cb38dbe5 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -117,7 +117,7 @@ if ($object->id > 0) print ''; // Ref - print '
'; + print '
'; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -172,7 +172,7 @@ if ($object->id > 0) $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; // Ref - print '
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; if (empty($withproject) || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8eacca6f09e..09a86e1df58 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('projects'); $id=GETPOST('id','int'); +$projectid=GETPOST('projectid','int'); $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); @@ -45,8 +46,20 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('projecttaskcard','globalcard')); + $object = new Task($db); $projectstatic = new Project($db); +$extrafields_project = new ExtraFields($db); +$extrafields_task = new ExtraFields($db); + +if ($projectid > 0 || ! empty($ref)) +{ + // fetch optionals attributes and labels + $extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); +} +$extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_element); /* @@ -223,12 +236,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { $result=$projectstatic->fetch($projectidforalltimes); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); } elseif ($object->fetch($id, $ref) >= 0) { $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - + $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $object->project = clone $projectstatic; } @@ -247,7 +262,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; - // Budget - print ''; - - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields_project->attribute_label)) + if (! $id && ! $ref) // Not a dedicated task { - print $object->showOptionals($extrafields_project); - } - + // Budget + print ''; + + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$projectstatic,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields_project->attribute_label)) + { + print $projectstatic->showOptionals($extrafields_project); + } + } + print '
'; @@ -291,19 +306,22 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_print_date($projectstatic->date_end,'day'); print '
'.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,0,0,0,$conf->currency); - print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,0,0,0,$conf->currency); + print '
'; dol_fiche_end(); @@ -312,7 +330,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* * Actions */ - if (empty($id)) + if (empty($id) && empty($ref)) { print '
'; @@ -353,7 +371,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $linkback=$withproject?''.$langs->trans("BackToList").'':''; // Ref - print '
'; + print '
'; print $langs->trans("Ref"); print ''; if (! GETPOST('withproject') || empty($projectstatic->id)) @@ -492,16 +510,21 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($projectstatic->id > 0) { - /* + if ($action == 'deleteline') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + } + + /* * List of time spent */ $tasks = array(); - $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm"; - $sql.= ", u.lastname, u.firstname"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_user = u.rowid"; + $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql .= " pt.ref, pt.label,"; + $sql .= " u.lastname, u.firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; $sql .= " ORDER BY t.task_date DESC, t.task_datehour DESC, t.rowid DESC"; @@ -534,15 +557,20 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_print_error($db); } - print '
'; + print ''; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; + if (! $id && ! $ref) // Not a dedicated task + { + print ''; + } print ''; print ''; print ''; @@ -553,6 +581,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print "\n"; + $tasktmp = new Task($db); + $total = 0; $totalvalue = 0; foreach ($tasks as $task_time) @@ -575,10 +605,22 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } print ''; + // Task + if (! $id && ! $ref) // Not a dedicated task + { + print ''; + } + // User print '
'.$langs->trans("Date").''.$langs->trans("Task").''.$langs->trans("By").''.$langs->trans("Note").''.$langs->trans("TimeSpent").' 
'; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print ''; if ($_GET['action'] == 'editline' && $_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;