dolibarr  16.0.5
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)) $object->description = GETPOST('description', "alphanohtml");
104  else $object->description = GETPOST('description', "restricthtml");
105  $object->fk_task_parent = $task_parent;
106  $object->planned_workload = $planned_workload;
107  $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
108  $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
109  $object->progress = price2num(GETPOST('progress', 'alphanohtml'));
110  $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml'));
111 
112  // Fill array 'array_options' with data from add form
113  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
114  if ($ret < 0) {
115  $error++;
116  }
117 
118  if (!$error) {
119  $result = $object->update($user);
120  if ($result < 0) {
121  setEventMessages($object->error, $object->errors, 'errors');
122  $action = 'edit';
123  }
124  } else {
125  $action = 'edit';
126  }
127  } else {
128  $action = 'edit';
129  }
130 }
131 
132 if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) {
133  $result = $projectstatic->fetch($object->fk_project);
134  $projectstatic->fetch_thirdparty();
135 
136  if ($object->delete($user) > 0) {
137  header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : ''));
138  exit;
139  } else {
140  setEventMessages($object->error, $object->errors, 'errors');
141  $action = '';
142  }
143 }
144 
145 // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
146 if (!empty($project_ref) && !empty($withproject)) {
147  if ($projectstatic->fetch('', $project_ref) > 0) {
148  $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
149  if (count($tasksarray) > 0) {
150  $id = $tasksarray[0]->id;
151  } else {
152  header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
153  }
154  }
155 }
156 
157 // Build doc
158 if ($action == 'builddoc' && $user->rights->projet->creer) {
159  // Save last template used to generate document
160  if (GETPOST('model')) {
161  $object->setDocModel($user, GETPOST('model', 'alpha'));
162  }
163 
164  $outputlangs = $langs;
165  if (GETPOST('lang_id', 'aZ09')) {
166  $outputlangs = new Translate("", $conf);
167  $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
168  }
169  $result = $object->generateDocument($object->model_pdf, $outputlangs);
170  if ($result <= 0) {
171  setEventMessages($object->error, $object->errors, 'errors');
172  $action = '';
173  }
174 }
175 
176 // Delete file in doc form
177 if ($action == 'remove_file' && $user->rights->projet->creer) {
178  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
179 
180  $langs->load("other");
181  $upload_dir = $conf->project->dir_output;
182  $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file'));
183 
184  $ret = dol_delete_file($file);
185  if ($ret) {
186  setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
187  } else {
188  setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
189  }
190 }
191 
192 
193 /*
194  * View
195  */
196 
197 llxHeader('', $langs->trans("Task"));
198 
199 $form = new Form($db);
200 $formother = new FormOther($db);
201 $formfile = new FormFile($db);
202 
203 if ($id > 0 || !empty($ref)) {
204  $res = $object->fetch_optionals();
205  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) {
206  $object->fetchComments();
207  }
208 
209  $result = $projectstatic->fetch($object->fk_project);
210  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
211  $projectstatic->fetchComments();
212  }
213  if (!empty($projectstatic->socid)) {
214  $projectstatic->fetch_thirdparty();
215  }
216 
217  $object->project = clone $projectstatic;
218 
219  //$userWrite = $projectstatic->restrictedProjectArea($user, 'write');
220 
221  if (!empty($withproject)) {
222  // Tabs for project
223  $tab = 'tasks';
224  $head = project_prepare_head($projectstatic);
225  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
226 
227  $param = ($mode == 'mine' ? '&mode=mine' : '');
228 
229  // Project card
230 
231  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
232 
233  $morehtmlref = '<div class="refidno">';
234  // Title
235  $morehtmlref .= $projectstatic->title;
236  // Thirdparty
237  if (!empty($projectstatic->thirdparty->id) &&$projectstatic->thirdparty->id > 0) {
238  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project');
239  }
240  $morehtmlref .= '</div>';
241 
242  // Define a complementary filter for search of next/prev ref.
243  if (empty($user->rights->projet->all->lire)) {
244  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
245  $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
246  }
247 
248  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
249 
250  print '<div class="fichecenter">';
251  print '<div class="fichehalfleft">';
252  print '<div class="underbanner clearboth"></div>';
253 
254  print '<table class="border tableforfield centpercent">';
255 
256  // Usage
257  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
258  print '<tr><td class="tdtop">';
259  print $langs->trans("Usage");
260  print '</td>';
261  print '<td>';
262  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
263  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
264  $htmltext = $langs->trans("ProjectFollowOpportunity");
265  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
266  print '<br>';
267  }
268  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
269  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
270  $htmltext = $langs->trans("ProjectFollowTasks");
271  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
272  print '<br>';
273  }
274  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
275  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"' : '')).'"> ';
276  $htmltext = $langs->trans("ProjectBillTimeDescription");
277  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
278  print '<br>';
279  }
280  if (isModEnabled('eventorganization')) {
281  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"' : '')).'"> ';
282  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
283  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
284  }
285  print '</td></tr>';
286  }
287 
288  // Visibility
289  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
290  if ($projectstatic->public) {
291  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
292  print $langs->trans('SharedProject');
293  } else {
294  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
295  print $langs->trans('PrivateProject');
296  }
297  print '</td></tr>';
298 
299  // Date start - end
300  print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
301  $start = dol_print_date($projectstatic->date_start, 'day');
302  print ($start ? $start : '?');
303  $end = dol_print_date($projectstatic->date_end, 'day');
304  print ' - ';
305  print ($end ? $end : '?');
306  if ($projectstatic->hasDelay()) {
307  print img_warning("Late");
308  }
309  print '</td></tr>';
310 
311  // Budget
312  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
313  if (strcmp($projectstatic->budget_amount, '')) {
314  print '<span class="amount">'.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
315  }
316  print '</td></tr>';
317 
318  // Other attributes
319  $cols = 2;
320  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
321 
322  print '</table>';
323 
324  print '</div>';
325 
326  print '<div class="fichehalfright">';
327  print '<div class="underbanner clearboth"></div>';
328 
329  print '<table class="border tableforfield centpercent">';
330 
331  // Description
332  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
333  print nl2br($projectstatic->description);
334  print '</td></tr>';
335 
336  // Categories
337  if (isModEnabled('categorie')) {
338  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
339  print $form->showCategories($projectstatic->id, 'project', 1);
340  print "</td></tr>";
341  }
342 
343  print '</table>';
344 
345  print '</div>';
346  print '</div>';
347 
348  print '<div class="clearboth"></div>';
349 
350  print dol_get_fiche_end();
351 
352  print '<br>';
353  }
354 
355  /*
356  * Actions
357  */
358  /*print '<div class="tabsAction">';
359 
360  if ($user->rights->projet->all->creer || $user->rights->projet->creer)
361  {
362  if ($projectstatic->public || $userWrite > 0)
363  {
364  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
365  }
366  else
367  {
368  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
369  }
370  }
371  else
372  {
373  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
374  }
375 
376  print '</div>';
377  */
378 
379  // To verify role of users
380  //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
381  //$arrayofuseridoftask=$object->getListContactId('internal');
382 
383  $head = task_prepare_head($object);
384 
385  if ($action == 'edit' && $user->rights->projet->creer) {
386  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
387  print '<input type="hidden" name="token" value="'.newToken().'">';
388  print '<input type="hidden" name="action" value="update">';
389  print '<input type="hidden" name="withproject" value="'.$withproject.'">';
390  print '<input type="hidden" name="id" value="'.$object->id.'">';
391 
392  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', '');
393 
394  print '<table class="border centpercent">';
395 
396  // Ref
397  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
398  print '<td><input class="minwidth100" name="taskref" value="'.$object->ref.'"></td></tr>';
399 
400  // Label
401  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
402  print '<td><input class="minwidth500" name="label" value="'.$object->label.'"></td></tr>';
403 
404  // Project
405  if (empty($withproject)) {
406  print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
407  print $projectstatic->getNomUrl(1);
408  print '</td></tr>';
409 
410  // Third party
411  print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
412  if ($projectstatic->thirdparty->id) {
413  print $projectstatic->thirdparty->getNomUrl(1);
414  } else {
415  print '&nbsp;';
416  }
417  print '</td></tr>';
418  }
419 
420  // Task parent
421  print '<tr><td>'.$langs->trans("ChildOfProjectTask").'</td><td>';
422  print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id);
423  print '</td></tr>';
424 
425  // Date start
426  print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
427  print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0);
428  print '</td></tr>';
429 
430  // Date end
431  print '<tr><td>'.$langs->trans("Deadline").'</td><td>';
432  print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0);
433  print '</td></tr>';
434 
435  // Planned workload
436  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
437  print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text');
438  print '</td></tr>';
439 
440  // Progress declared
441  print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
442  print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1);
443  print '</td></tr>';
444 
445  // Description
446  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
447  print '<td>';
448 
449  if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
450  print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$object->description.'</textarea>';
451  } else {
452  // WYSIWYG editor
453  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
454  $cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
455  if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
456  $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
457  }
458  $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
459  print $doleditor->Create();
460  }
461  print '</td></tr>';
462 
463  print '<tr><td>'.$langs->trans("Budget").'</td>';
464  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>';
465  print '</tr>';
466 
467  // Other options
468  $parameters = array();
469  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
470  print $hookmanager->resPrint;
471  if (empty($reshook)) {
472  print $object->showOptionals($extrafields, 'edit');
473  }
474 
475  print '</table>';
476 
477  print dol_get_fiche_end();
478 
479  print $form->buttonsSaveCancel("Modify");
480 
481  print '</form>';
482  } else {
483  /*
484  * Fiche tache en mode visu
485  */
486  $param = ($withproject ? '&withproject=1' : '');
487  $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>' : '';
488 
489  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
490 
491  if ($action == 'delete') {
492  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
493  }
494 
495  if (!GETPOST('withproject') || empty($projectstatic->id)) {
496  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
497  $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
498  } else {
499  $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
500  }
501 
502  $morehtmlref = '';
503 
504  // Project
505  if (empty($withproject)) {
506  $morehtmlref .= '<div class="refidno">';
507  $morehtmlref .= $langs->trans("Project").': ';
508  $morehtmlref .= $projectstatic->getNomUrl(1);
509  $morehtmlref .= '<br>';
510 
511  // Third party
512  $morehtmlref .= $langs->trans("ThirdParty").': ';
513  if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
514  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
515  }
516  $morehtmlref .= '</div>';
517  }
518 
519  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
520 
521  print '<div class="fichecenter">';
522  print '<div class="fichehalfleft">';
523 
524  print '<div class="underbanner clearboth"></div>';
525  print '<table class="border centpercent tableforfield">';
526 
527  // Task parent
528  print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
529  if ($object->fk_task_parent > 0) {
530  $tasktmp = new Task($db);
531  $tasktmp->fetch($object->fk_task_parent);
532  print $tasktmp->getNomUrl(1);
533  }
534  print '</td></tr>';
535 
536  // Date start - Date end
537  print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("Deadline").'</td><td colspan="3">';
538  $start = dol_print_date($object->date_start, 'dayhour');
539  print ($start ? $start : '?');
540  $end = dol_print_date($object->date_end, 'dayhour');
541  print ' - ';
542  print ($end ? $end : '?');
543  if ($object->hasDelay()) {
544  print img_warning("Late");
545  }
546  print '</td></tr>';
547 
548  // Planned workload
549  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
550  if ($object->planned_workload != '') {
551  print convertSecondToTime($object->planned_workload, 'allhourmin');
552  }
553  print '</td></tr>';
554 
555  // Description
556  print '<td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
557  print dol_htmlentitiesbr($object->description);
558  print '</td></tr>';
559 
560  print '</table>';
561  print '</div>';
562 
563  print '<div class="fichehalfright">';
564 
565  print '<div class="underbanner clearboth"></div>';
566  print '<table class="border centpercent tableforfield">';
567 
568  // Progress declared
569  print '<tr><td class="titlefield">'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
570  if ($object->progress != '') {
571  print $object->progress.' %';
572  }
573  print '</td></tr>';
574 
575  // Progress calculated
576  print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
577  if ($object->planned_workload != '') {
578  $tmparray = $object->getSummaryOfTimeSpent();
579  if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) {
580  print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';
581  } else {
582  print '0 %';
583  }
584  } else {
585  print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>';
586  }
587  print '</td></tr>';
588 
589  // Budget
590  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
591  if (strcmp($object->budget_amount, '')) {
592  print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
593  }
594  print '</td></tr>';
595 
596  // Other attributes
597  $cols = 3;
598  $parameters = array('socid'=>$socid);
599  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
600 
601  print '</table>';
602 
603  print '</div>';
604 
605  print '</div>';
606  print '<div class="clearboth"></div>';
607 
608  print dol_get_fiche_end();
609  }
610 
611 
612  if ($action != 'edit') {
613  /*
614  * Actions
615  */
616 
617  print '<div class="tabsAction">';
618 
619  $parameters = array();
620  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
621  // modified by hook
622  if (empty($reshook)) {
623  // Modify
624  if ($user->rights->projet->creer) {
625  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Modify').'</a>';
626  } else {
627  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
628  }
629 
630  // Delete
631  if ($user->rights->projet->supprimer) {
632  if (!$object->hasChildren() && !$object->hasTimeSpent()) {
633  print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Delete').'</a>';
634  } else {
635  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>';
636  }
637  } else {
638  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
639  }
640 
641  print '</div>';
642  }
643 
644  print '<div class="fichecenter"><div class="fichehalfleft">';
645  print '<a name="builddoc"></a>'; // ancre
646 
647  /*
648  * Generated documents
649  */
650  $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
651  $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
652  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
653  $genallowed = ($user->rights->projet->lire);
654  $delallowed = ($user->rights->projet->creer);
655 
656  print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
657 
658  print '</div><div class="fichehalfright">';
659 
660  // List of actions on element
661  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
662  $formactions = new FormActions($db);
663  $formactions->showactions($object, 'project_task', 0, 1, '', 10, 'withproject='.$withproject);
664 
665  print '</div></div>';
666  }
667 }
668 
669 // End of page
670 llxFooter();
671 $db->close();
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
Translate
Class to manage translations.
Definition: translate.class.php:30
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
Task
Class to manage tasks.
Definition: task.class.php:37
project_prepare_head
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
dol_banner_tab
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.
Definition: functions.lib.php:2046
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
convertSecondToTime
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:236
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_delete_file
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:1231
$formactions
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.
Definition: agenda_other.php:178
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
task_prepare_head
task_prepare_head($object)
Prepare array with list of tabs.
Definition: project.lib.php:335
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_htmlentitiesbr
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...
Definition: functions.lib.php:6991
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
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...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30