dolibarr  x.y.z
task.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require "../../main.inc.php";
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
36 
37 // Load translation files required by the page
38 $langs->loadlangs(array('projects', 'companies'));
39 
40 $action = GETPOST('action', 'aZ09');
41 $confirm = GETPOST('confirm', 'alpha');
42 
43 $id = GETPOST('id', 'int');
44 $ref = GETPOST("ref", 'alpha', 1); // task ref
45 $taskref = GETPOST("taskref", 'alpha'); // task ref
46 $withproject = GETPOST('withproject', 'int');
47 $project_ref = GETPOST('project_ref', 'alpha');
48 $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : '');
49 
50 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
51 $hookmanager->initHooks(array('projecttaskcard', 'globalcard'));
52 
53 $object = new Task($db);
54 $extrafields = new ExtraFields($db);
55 $projectstatic = new Project($db);
56 
57 // fetch optionals attributes and labels
58 $extrafields->fetch_name_optionals_label($object->table_element);
59 
60 $parameters = array('id'=>$id);
61 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
62 if ($reshook < 0) {
63  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
64 }
65 
66 if ($id > 0 || $ref) {
67  $object->fetch($id, $ref);
68 }
69 
70 // Security check
71 $socid = 0;
72 
73 restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
74 
75 
76 
77 /*
78  * Actions
79  */
80 
81 if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) {
82  $error = 0;
83 
84  if (empty($taskref)) {
85  $error++;
86  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
87  }
88  if (!GETPOST("label")) {
89  $error++;
90  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
91  }
92  if (!$error) {
93  $object->oldcopy = clone $object;
94 
95  $tmparray = explode('_', GETPOST('task_parent'));
96  $task_parent = $tmparray[1];
97  if (empty($task_parent)) {
98  $task_parent = 0; // If task_parent is ''
99  }
100 
101  $object->ref = $taskref ? $taskref : GETPOST("ref", 'alpha', 2);
102  $object->label = GETPOST("label", "alphanohtml");
103  if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
104  $object->description = GETPOST('description', "alphanohtml");
105  } else {
106  $object->description = GETPOST('description', "restricthtml");
107  }
108  $object->fk_task_parent = $task_parent;
109  $object->planned_workload = $planned_workload;
110  $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
111  $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
112  $object->progress = price2num(GETPOST('progress', 'alphanohtml'));
113  $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml'));
114 
115  // Fill array 'array_options' with data from add form
116  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
117  if ($ret < 0) {
118  $error++;
119  }
120 
121  if (!$error) {
122  $result = $object->update($user);
123  if ($result < 0) {
124  setEventMessages($object->error, $object->errors, 'errors');
125  $action = 'edit';
126  }
127  } else {
128  $action = 'edit';
129  }
130  } else {
131  $action = 'edit';
132  }
133 }
134 
135 if ($action == 'confirm_clone' && $confirm == 'yes') {
136  //$clone_contacts = GETPOST('clone_contacts') ? 1 : 0;
137  $clone_prog = GETPOST('clone_prog') ? 1 : 0;
138  $clone_time = GETPOST('clone_time') ? 1 : 0;
139  $clone_affectation = GETPOST('clone_affectation') ? 1 : 0;
140  $clone_change_dt = GETPOST('clone_change_dt') ? 1 : 0;
141  $clone_notes = GETPOST('clone_notes') ? 1 : 0;
142  $clone_file = GETPOST('clone_file') ? 1 : 0;
143  $result = $object->createFromClone($user, $object->id, $object->fk_project, $object->fk_task_parent, $clone_change_dt, $clone_affectation, $clone_time, $clone_file, $clone_notes, $clone_prog);
144  if ($result <= 0) {
145  setEventMessages($object->error, $object->errors, 'errors');
146  } else {
147  // Load new object
148  $newobject = new Task($db);
149  $newobject->fetch($result);
150  $newobject->fetch_optionals();
151  $newobject->fetch_thirdparty(); // Load new object
152  $object = $newobject;
153  $action = '';
154  }
155 }
156 
157 if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) {
158  $result = $projectstatic->fetch($object->fk_project);
159  $projectstatic->fetch_thirdparty();
160 
161  if ($object->delete($user) > 0) {
162  header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : ''));
163  exit;
164  } else {
165  setEventMessages($object->error, $object->errors, 'errors');
166  $action = '';
167  }
168 }
169 
170 // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
171 if (!empty($project_ref) && !empty($withproject)) {
172  if ($projectstatic->fetch('', $project_ref) > 0) {
173  $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
174  if (count($tasksarray) > 0) {
175  $id = $tasksarray[0]->id;
176  } else {
177  header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
178  }
179  }
180 }
181 
182 // Build doc
183 if ($action == 'builddoc' && $user->rights->projet->creer) {
184  // Save last template used to generate document
185  if (GETPOST('model')) {
186  $object->setDocModel($user, GETPOST('model', 'alpha'));
187  }
188 
189  $outputlangs = $langs;
190  if (GETPOST('lang_id', 'aZ09')) {
191  $outputlangs = new Translate("", $conf);
192  $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
193  }
194  $result = $object->generateDocument($object->model_pdf, $outputlangs);
195  if ($result <= 0) {
196  setEventMessages($object->error, $object->errors, 'errors');
197  $action = '';
198  }
199 }
200 
201 // Delete file in doc form
202 if ($action == 'remove_file' && $user->rights->projet->creer) {
203  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
204 
205  $langs->load("other");
206  $upload_dir = $conf->project->dir_output;
207  $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file'));
208 
209  $ret = dol_delete_file($file);
210  if ($ret) {
211  setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
212  } else {
213  setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
214  }
215 }
216 
217 
218 /*
219  * View
220  */
221 $form = new Form($db);
222 $formother = new FormOther($db);
223 $formfile = new FormFile($db);
224 $result = $projectstatic->fetch($object->fk_project);
225 
226 $title = $object->ref;
227 if (!empty($withproject)) {
228  $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
229 }
230 $help_url = '';
231 
232 llxHeader('', $title, $help_url);
233 
234 
235 if ($id > 0 || !empty($ref)) {
236  $res = $object->fetch_optionals();
237  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) {
238  $object->fetchComments();
239  }
240 
241 
242  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
243  $projectstatic->fetchComments();
244  }
245  if (!empty($projectstatic->socid)) {
246  $projectstatic->fetch_thirdparty();
247  }
248 
249  $object->project = clone $projectstatic;
250 
251  //$userWrite = $projectstatic->restrictedProjectArea($user, 'write');
252 
253  if (!empty($withproject)) {
254  // Tabs for project
255  $tab = 'tasks';
256  $head = project_prepare_head($projectstatic);
257  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
258 
259  $param = ($mode == 'mine' ? '&mode=mine' : '');
260 
261  // Project card
262 
263  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
264 
265  $morehtmlref = '<div class="refidno">';
266  // Title
267  $morehtmlref .= $projectstatic->title;
268  // Thirdparty
269  if (!empty($projectstatic->thirdparty->id) &&$projectstatic->thirdparty->id > 0) {
270  $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
271  }
272  $morehtmlref .= '</div>';
273 
274  // Define a complementary filter for search of next/prev ref.
275  if (empty($user->rights->projet->all->lire)) {
276  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
277  $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
278  }
279 
280  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
281 
282  print '<div class="fichecenter">';
283  print '<div class="fichehalfleft">';
284  print '<div class="underbanner clearboth"></div>';
285 
286  print '<table class="border tableforfield centpercent">';
287 
288  // Usage
289  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
290  print '<tr><td class="tdtop">';
291  print $langs->trans("Usage");
292  print '</td>';
293  print '<td>';
294  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
295  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
296  $htmltext = $langs->trans("ProjectFollowOpportunity");
297  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
298  print '<br>';
299  }
300  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
301  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
302  $htmltext = $langs->trans("ProjectFollowTasks");
303  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
304  print '<br>';
305  }
306  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
307  print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
308  $htmltext = $langs->trans("ProjectBillTimeDescription");
309  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
310  print '<br>';
311  }
312  if (isModEnabled('eventorganization')) {
313  print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> ';
314  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
315  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
316  }
317  print '</td></tr>';
318  }
319 
320  // Visibility
321  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
322  if ($projectstatic->public) {
323  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
324  print $langs->trans('SharedProject');
325  } else {
326  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
327  print $langs->trans('PrivateProject');
328  }
329  print '</td></tr>';
330 
331  // Budget
332  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
333  if (strcmp($projectstatic->budget_amount, '')) {
334  print '<span class="amount">'.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
335  }
336  print '</td></tr>';
337 
338  // Date start - end project
339  print '<tr><td>'.$langs->trans("Dates").'</td><td>';
340  $start = dol_print_date($projectstatic->date_start, 'day');
341  print ($start ? $start : '?');
342  $end = dol_print_date($projectstatic->date_end, 'day');
343  print ' - ';
344  print ($end ? $end : '?');
345  if ($projectstatic->hasDelay()) {
346  print img_warning("Late");
347  }
348  print '</td></tr>';
349 
350  // Other attributes
351  $cols = 2;
352  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
353 
354  print '</table>';
355 
356  print '</div>';
357 
358  print '<div class="fichehalfright">';
359  print '<div class="underbanner clearboth"></div>';
360 
361  print '<table class="border tableforfield centpercent">';
362 
363  // Description
364  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
365  print nl2br($projectstatic->description);
366  print '</td></tr>';
367 
368  // Categories
369  if (isModEnabled('categorie')) {
370  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
371  print $form->showCategories($projectstatic->id, 'project', 1);
372  print "</td></tr>";
373  }
374 
375  print '</table>';
376 
377  print '</div>';
378  print '</div>';
379 
380  print '<div class="clearboth"></div>';
381 
382  print dol_get_fiche_end();
383 
384  print '<br>';
385  }
386 
387  /*
388  * Actions
389  */
390  /*print '<div class="tabsAction">';
391 
392  if ($user->rights->projet->all->creer || $user->rights->projet->creer)
393  {
394  if ($projectstatic->public || $userWrite > 0)
395  {
396  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
397  }
398  else
399  {
400  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
401  }
402  }
403  else
404  {
405  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
406  }
407 
408  print '</div>';
409  */
410 
411  // To verify role of users
412  //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
413  //$arrayofuseridoftask=$object->getListContactId('internal');
414 
415  if ($action == 'clone') {
416  $formquestion = array(
417  'text' => $langs->trans("ConfirmClone"),
418  //array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
419  array('type' => 'checkbox', 'name' => 'clone_change_dt', 'label' => $langs->trans("CloneChanges"), 'value' => true),
420  array('type' => 'checkbox', 'name' => 'clone_affectation', 'label' => $langs->trans("CloneAffectation"), 'value' => true),
421  array('type' => 'checkbox', 'name' => 'clone_prog', 'label' => $langs->trans("CloneProgression"), 'value' => true),
422  array('type' => 'checkbox', 'name' => 'clone_time', 'label' => $langs->trans("CloneTimes"), 'value' => true),
423  array('type' => 'checkbox', 'name' => 'clone_file', 'label' => $langs->trans("CloneFile"), 'value' => true),
424 
425  );
426 
427  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneTask"), "confirm_clone", $formquestion, '', 1, 300, 590);
428  }
429 
430 
431  $head = task_prepare_head($object);
432 
433  if ($action == 'edit' && $user->rights->projet->creer) {
434  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
435  print '<input type="hidden" name="token" value="'.newToken().'">';
436  print '<input type="hidden" name="action" value="update">';
437  print '<input type="hidden" name="withproject" value="'.$withproject.'">';
438  print '<input type="hidden" name="id" value="'.$object->id.'">';
439 
440  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', '');
441 
442  print '<table class="border centpercent">';
443 
444  // Ref
445  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
446  print '<td><input class="minwidth100" name="taskref" value="'.$object->ref.'"></td></tr>';
447 
448  // Label
449  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
450  print '<td><input class="minwidth500" name="label" value="'.$object->label.'"></td></tr>';
451 
452  // Project
453  if (empty($withproject)) {
454  print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
455  print $projectstatic->getNomUrl(1);
456  print '</td></tr>';
457 
458  // Third party
459  print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
460  if ($projectstatic->thirdparty->id) {
461  print $projectstatic->thirdparty->getNomUrl(1);
462  } else {
463  print '&nbsp;';
464  }
465  print '</td></tr>';
466  }
467 
468  // Task parent
469  print '<tr><td>'.$langs->trans("ChildOfProjectTask").'</td><td>';
470  $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id);
471  print '</td></tr>';
472 
473  // Date start
474  print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
475  print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0);
476  print '</td></tr>';
477 
478  // Date end
479  print '<tr><td>'.$langs->trans("Deadline").'</td><td>';
480  print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0);
481  print '</td></tr>';
482 
483  // Planned workload
484  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
485  print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text');
486  print '</td></tr>';
487 
488  // Progress declared
489  print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
490  print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1);
491  print '</td></tr>';
492 
493  // Description
494  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
495  print '<td>';
496 
497  // WYSIWYG editor
498  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
499  $cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_SOCIETE) ? $conf->global->FCKEDITOR_ENABLE_SOCIETE : 0);
500  if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
501  $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
502  }
503  $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
504  print $doleditor->Create();
505  print '</td></tr>';
506 
507  print '<tr><td>'.$langs->trans("Budget").'</td>';
508  print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : price2num($object->budget_amount)).'"></td>';
509  print '</tr>';
510 
511  // Other options
512  $parameters = array();
513  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
514  print $hookmanager->resPrint;
515  if (empty($reshook)) {
516  print $object->showOptionals($extrafields, 'edit');
517  }
518 
519  print '</table>';
520 
521  print dol_get_fiche_end();
522 
523  print $form->buttonsSaveCancel("Modify");
524 
525  print '</form>';
526  } else {
527  /*
528  * Fiche tache en mode visu
529  */
530  $param = ($withproject ? '&withproject=1' : '');
531  $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>' : '';
532 
533  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
534 
535  if ($action == 'delete') {
536  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
537  }
538 
539  if (!GETPOST('withproject') || empty($projectstatic->id)) {
540  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
541  $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
542  } else {
543  $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
544  }
545 
546  $morehtmlref = '';
547 
548  // Project
549  if (empty($withproject)) {
550  $morehtmlref .= '<div class="refidno">';
551  $morehtmlref .= $langs->trans("Project").': ';
552  $morehtmlref .= $projectstatic->getNomUrl(1);
553  $morehtmlref .= '<br>';
554 
555  // Third party
556  $morehtmlref .= $langs->trans("ThirdParty").': ';
557  if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
558  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
559  }
560  $morehtmlref .= '</div>';
561  }
562 
563  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
564 
565  print '<div class="fichecenter">';
566  print '<div class="fichehalfleft">';
567 
568  print '<div class="underbanner clearboth"></div>';
569  print '<table class="border centpercent tableforfield">';
570 
571  // Task parent
572  print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
573  if ($object->fk_task_parent > 0) {
574  $tasktmp = new Task($db);
575  $tasktmp->fetch($object->fk_task_parent);
576  print $tasktmp->getNomUrl(1);
577  }
578  print '</td></tr>';
579 
580  // Date start - Date end task
581  print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("Deadline").'</td><td colspan="3">';
582  $start = dol_print_date($object->date_start, 'dayhour');
583  print ($start ? $start : '?');
584  $end = dol_print_date($object->date_end, 'dayhour');
585  print ' - ';
586  print ($end ? $end : '?');
587  if ($object->hasDelay()) {
588  print img_warning("Late");
589  }
590  print '</td></tr>';
591 
592  // Planned workload
593  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
594  if ($object->planned_workload != '') {
595  print convertSecondToTime($object->planned_workload, 'allhourmin');
596  }
597  print '</td></tr>';
598 
599  // Description
600  print '<td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
601  print dol_htmlentitiesbr($object->description);
602  print '</td></tr>';
603 
604  print '</table>';
605  print '</div>';
606 
607  print '<div class="fichehalfright">';
608 
609  print '<div class="underbanner clearboth"></div>';
610  print '<table class="border centpercent tableforfield">';
611 
612  // Progress declared
613  print '<tr><td class="titlefield">'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
614  if ($object->progress != '') {
615  print $object->progress.' %';
616  }
617  print '</td></tr>';
618 
619  // Progress calculated
620  print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
621  if ($object->planned_workload != '') {
622  $tmparray = $object->getSummaryOfTimeSpent();
623  if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) {
624  print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';
625  } else {
626  print '0 %';
627  }
628  } else {
629  print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>';
630  }
631  print '</td></tr>';
632 
633  // Budget
634  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
635  if (strcmp($object->budget_amount, '')) {
636  print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
637  }
638  print '</td></tr>';
639 
640  // Other attributes
641  $cols = 3;
642  $parameters = array('socid'=>$socid);
643  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
644 
645  print '</table>';
646 
647  print '</div>';
648 
649  print '</div>';
650  print '<div class="clearboth"></div>';
651 
652  print dol_get_fiche_end();
653  }
654 
655 
656  if ($action != 'edit') {
657  /*
658  * Actions
659  */
660 
661  print '<div class="tabsAction">';
662 
663  $parameters = array();
664  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
665  // modified by hook
666  if (empty($reshook)) {
667  // Modify
668  if ($user->rights->projet->creer) {
669  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Modify').'</a>';
670  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Clone').'</a>';
671  } else {
672  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
673  }
674 
675  // Delete
676  $permissiontodelete = $user->hasRight('projet', 'supprimer');
677  if ($permissiontodelete) {
678  if (!$object->hasChildren() && !$object->hasTimeSpent()) {
679  print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', $permissiontodelete);
680  } else {
681  print dolGetButtonAction($langs->trans("TaskHasChild"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', 0);
682  }
683  } else {
684  print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', $permissiontodelete);
685  }
686 
687  print '</div>';
688  }
689 
690  print '<div class="fichecenter"><div class="fichehalfleft">';
691  print '<a name="builddoc"></a>'; // ancre
692 
693  /*
694  * Generated documents
695  */
696  $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
697  $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
698  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
699  $genallowed = ($user->rights->projet->lire);
700  $delallowed = ($user->rights->projet->creer);
701 
702  print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
703 
704  print '</div><div class="fichehalfright">';
705 
706  // List of actions on element
707  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
708  $formactions = new FormActions($db);
709  $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid;
710  $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject);
711 
712  print '</div></div>';
713  }
714 }
715 
716 // End of page
717 llxFooter();
718 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage a WYSIWYG editor.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage projects.
Class to manage tasks.
Definition: task.class.php:38
Class to manage translations.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition: date.lib.php:238
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
Definition: files.lib.php:1250
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.