From 42293089a03f361b53a9be5d9c06165df25e0f6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 30 Aug 2016 20:16:58 +0200 Subject: [PATCH] Fix several fix into tab management of tasks --- htdocs/projet/tasks/contact.php | 4 +- htdocs/projet/tasks/document.php | 4 +- htdocs/projet/tasks/note.php | 4 +- htdocs/projet/tasks/time.php | 92 +++++++++++++++++++++++--------- 4 files changed, 73 insertions(+), 31 deletions(-) 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 '<table class="border" width="100%">'; // Ref - print '<tr><td width="30%">'; + print '<tr><td class="titlefield">'; print $langs->trans("Ref"); print '</td><td>'; // Define a complementary filter for search of next/prev ref. @@ -255,7 +255,7 @@ if ($id > 0 || ! empty($ref)) $linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; // Ref - print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'; + print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td colspan="3">'; 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 '<table class="border" width="100%">'; // Ref - print '<tr><td width="30%">'; + print '<tr><td class="titlefield">'; print $langs->trans("Ref"); print '</td><td>'; // Define a complementary filter for search of next/prev ref. @@ -198,7 +198,7 @@ if ($object->id > 0) print '<table class="border" width="100%">'; // Ref - print '<tr><td width="30%">'; + print '<tr><td class="titlefield">'; print $langs->trans("Ref"); print '</td><td colspan="3">'; 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 '<table class="border" width="100%">'; // Ref - print '<tr><td width="30%">'; + print '<tr><td class="titlefield">'; print $langs->trans("Ref"); print '</td><td>'; // Define a complementary filter for search of next/prev ref. @@ -172,7 +172,7 @@ if ($object->id > 0) $linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; // Ref - print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'; 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 '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; // Ref print '<tr><td class="titlefield">'; @@ -291,19 +306,22 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_print_date($projectstatic->date_end,'day'); print '</td></tr>'; - // Budget - print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,0,0,0,$conf->currency); - print '</td></tr>'; - - // 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 '<tr><td>'.$langs->trans("Budget").'</td><td>'; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,0,0,0,$conf->currency); + print '</td></tr>'; + + // 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 '</table>'; dol_fiche_end(); @@ -312,7 +330,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* * Actions */ - if (empty($id)) + if (empty($id) && empty($ref)) { print '<div class="tabsAction">'; @@ -353,7 +371,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; // Ref - print '<tr><td width="30%">'; + print '<tr><td class="titlefield">'; print $langs->trans("Ref"); print '</td><td colspan="3">'; 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 '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="updateline">'; - print '<input type="hidden" name="id" value="'.$object->id.'">'; + print '<input type="hidden" name="id" value="'.$id.'">'; + print '<input type="hidden" name="projectid" value="'.$projectidforalltimes.'">'; print '<input type="hidden" name="withproject" value="'.$withproject.'">'; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td width="100">'.$langs->trans("Date").'</td>'; + if (! $id && ! $ref) // Not a dedicated task + { + print '<td>'.$langs->trans("Task").'</td>'; + } print '<td>'.$langs->trans("By").'</td>'; print '<td align="left">'.$langs->trans("Note").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; @@ -553,6 +581,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '<td> </td>'; print "</tr>\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 '</td>'; + // Task + if (! $id && ! $ref) // Not a dedicated task + { + print '<td class="nowrap">'; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print '</td>'; + } + // User print '<td>'; 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; -- GitLab