dolibarr  13.0.2
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 $id = GETPOST('id', 'int');
41 $ref = GETPOST("ref", 'alpha', 1); // task ref
42 $taskref = GETPOST("taskref", 'alpha'); // task ref
43 $action = GETPOST('action', 'aZ09');
44 $confirm = GETPOST('confirm', 'alpha');
45 $withproject = GETPOST('withproject', 'int');
46 $project_ref = GETPOST('project_ref', 'alpha');
47 $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) : '');
48 
49 // Security check
50 $socid = 0;
51 //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
52 if (!$user->rights->projet->lire) accessforbidden();
53 
54 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
55 $hookmanager->initHooks(array('projecttaskcard', 'globalcard'));
56 
57 $object = new Task($db);
58 $extrafields = new ExtraFields($db);
59 $projectstatic = new Project($db);
60 
61 // fetch optionals attributes and labels
62 $extrafields->fetch_name_optionals_label($object->table_element);
63 
64 $parameters = array('id'=>$id);
65 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
66 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
67 
68 /*
69  * Actions
70  */
71 
72 if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
73 {
74  $error = 0;
75 
76  if (empty($taskref))
77  {
78  $error++;
79  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
80  }
81  if (empty($_POST["label"]))
82  {
83  $error++;
84  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
85  }
86  if (!$error)
87  {
88  $object->fetch($id, $ref);
89  $object->oldcopy = clone $object;
90 
91  $tmparray = explode('_', $_POST['task_parent']);
92  $task_parent = $tmparray[1];
93  if (empty($task_parent)) $task_parent = 0; // If task_parent is ''
94 
95  $object->ref = $taskref ? $taskref : GETPOST("ref", 'alpha', 2);
96  $object->label = GETPOST("label", "alphanohtml");
97  $object->description = GETPOST('description', "alphanohtml");
98  $object->fk_task_parent = $task_parent;
99  $object->planned_workload = $planned_workload;
100  $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
101  $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
102  $object->progress = price2num(GETPOST('progress', 'alphanohtml'));
103 
104  // Fill array 'array_options' with data from add form
105  $ret = $extrafields->setOptionalsFromPost(null, $object);
106  if ($ret < 0) $error++;
107 
108  if (!$error)
109  {
110  $result = $object->update($user);
111  if ($result < 0)
112  {
113  setEventMessages($object->error, $object->errors, 'errors');
114  }
115  }
116  } else {
117  $action = 'edit';
118  }
119 }
120 
121 if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer)
122 {
123  if ($object->fetch($id, $ref) >= 0)
124  {
125  $result = $projectstatic->fetch($object->fk_project);
126  $projectstatic->fetch_thirdparty();
127 
128  if ($object->delete($user) > 0)
129  {
130  header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : ''));
131  exit;
132  } else {
133  setEventMessages($object->error, $object->errors, 'errors');
134  $action = '';
135  }
136  }
137 }
138 
139 // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
140 if (!empty($project_ref) && !empty($withproject))
141 {
142  if ($projectstatic->fetch('', $project_ref) > 0)
143  {
144  $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
145  if (count($tasksarray) > 0)
146  {
147  $id = $tasksarray[0]->id;
148  } else {
149  header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
150  }
151  }
152 }
153 
154 // Build doc
155 if ($action == 'builddoc' && $user->rights->projet->creer)
156 {
157  $object->fetch($id, $ref);
158 
159  // Save last template used to generate document
160  if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha'));
161 
162  $outputlangs = $langs;
163  if (GETPOST('lang_id', 'aZ09'))
164  {
165  $outputlangs = new Translate("", $conf);
166  $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
167  }
168  $result = $object->generateDocument($object->model_pdf, $outputlangs);
169  if ($result <= 0)
170  {
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 {
179  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
180 
181  if ($object->fetch($id, $ref) >= 0)
182  {
183  $langs->load("other");
184  $upload_dir = $conf->projet->dir_output;
185  $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file'));
186 
187  $ret = dol_delete_file($file);
188  if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
189  else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
190  }
191 }
192 
193 
194 /*
195  * View
196  */
197 
198 llxHeader('', $langs->trans("Task"));
199 
200 $form = new Form($db);
201 $formother = new FormOther($db);
202 $formfile = new FormFile($db);
203 
204 if ($id > 0 || !empty($ref))
205 {
206  if ($object->fetch($id, $ref) > 0)
207  {
208  $res = $object->fetch_optionals();
209  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
210 
211  $result = $projectstatic->fetch($object->fk_project);
212  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
213  if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
214 
215  $object->project = clone $projectstatic;
216 
217  //$userWrite = $projectstatic->restrictedProjectArea($user, 'write');
218 
219  if (!empty($withproject))
220  {
221  // Tabs for project
222  $tab = 'tasks';
223  $head = project_prepare_head($projectstatic);
224  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
225 
226  $param = ($mode == 'mine' ? '&mode=mine' : '');
227 
228  // Project card
229 
230  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
231 
232  $morehtmlref = '<div class="refidno">';
233  // Title
234  $morehtmlref .= $projectstatic->title;
235  // Thirdparty
236  if ($projectstatic->thirdparty->id > 0)
237  {
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 (!$user->rights->projet->all->lire)
244  {
245  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
246  $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
247  }
248 
249  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
250 
251  print '<div class="fichecenter">';
252  print '<div class="fichehalfleft">';
253  print '<div class="underbanner clearboth"></div>';
254 
255  print '<table class="border tableforfield centpercent">';
256 
257  // Usage
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  {
264  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
265  $htmltext = $langs->trans("ProjectFollowOpportunity");
266  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
267  print '<br>';
268  }
269  if (empty($conf->global->PROJECT_HIDE_TASKS))
270  {
271  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
272  $htmltext = $langs->trans("ProjectFollowTasks");
273  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
274  print '<br>';
275  }
276  if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
277  {
278  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"' : '')).'"> ';
279  $htmltext = $langs->trans("ProjectBillTimeDescription");
280  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
281  print '<br>';
282  }
283  print '</td></tr>';
284 
285  // Visibility
286  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
287  if ($projectstatic->public) print $langs->trans('SharedProject');
288  else print $langs->trans('PrivateProject');
289  print '</td></tr>';
290 
291  // Date start - end
292  print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
293  $start = dol_print_date($projectstatic->date_start, 'day');
294  print ($start ? $start : '?');
295  $end = dol_print_date($projectstatic->date_end, 'day');
296  print ' - ';
297  print ($end ? $end : '?');
298  if ($projectstatic->hasDelay()) print img_warning("Late");
299  print '</td></tr>';
300 
301  // Budget
302  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
303  if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
304  print '</td></tr>';
305 
306  // Other attributes
307  $cols = 2;
308  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
309 
310  print '</table>';
311 
312  print '</div>';
313 
314  print '<div class="fichehalfright">';
315  print '<div class="ficheaddleft">';
316  print '<div class="underbanner clearboth"></div>';
317 
318  print '<table class="border centpercent">';
319 
320  // Description
321  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
322  print nl2br($projectstatic->description);
323  print '</td></tr>';
324 
325  // Categories
326  if ($conf->categorie->enabled) {
327  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
328  print $form->showCategories($projectstatic->id, 'project', 1);
329  print "</td></tr>";
330  }
331 
332  print '</table>';
333 
334  print '</div>';
335  print '</div>';
336  print '</div>';
337 
338  print '<div class="clearboth"></div>';
339 
341 
342  print '<br>';
343  }
344 
345  /*
346  * Actions
347  */
348  /*print '<div class="tabsAction">';
349 
350  if ($user->rights->projet->all->creer || $user->rights->projet->creer)
351  {
352  if ($projectstatic->public || $userWrite > 0)
353  {
354  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
355  }
356  else
357  {
358  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
359  }
360  }
361  else
362  {
363  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
364  }
365 
366  print '</div>';
367  */
368 
369  // To verify role of users
370  //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
371  //$arrayofuseridoftask=$object->getListContactId('internal');
372 
373  $head = task_prepare_head($object);
374 
375  if ($action == 'edit' && $user->rights->projet->creer)
376  {
377  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
378  print '<input type="hidden" name="token" value="'.newToken().'">';
379  print '<input type="hidden" name="action" value="update">';
380  print '<input type="hidden" name="withproject" value="'.$withproject.'">';
381  print '<input type="hidden" name="id" value="'.$object->id.'">';
382 
383  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', '');
384 
385  print '<table class="border centpercent">';
386 
387  // Ref
388  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
389  print '<td><input class="minwidth100" name="taskref" value="'.$object->ref.'"></td></tr>';
390 
391  // Label
392  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
393  print '<td><input class="minwidth500" name="label" value="'.$object->label.'"></td></tr>';
394 
395  // Project
396  if (empty($withproject))
397  {
398  print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
399  print $projectstatic->getNomUrl(1);
400  print '</td></tr>';
401 
402  // Third party
403  print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
404  if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
405  else print '&nbsp;';
406  print '</td></tr>';
407  }
408 
409  // Task parent
410  print '<tr><td>'.$langs->trans("ChildOfProjectTask").'</td><td>';
411  print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id);
412  print '</td></tr>';
413 
414  // Date start
415  print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
416  print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0);
417  print '</td></tr>';
418 
419  // Date end
420  print '<tr><td>'.$langs->trans("Deadline").'</td><td>';
421  print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0);
422  print '</td></tr>';
423 
424  // Planned workload
425  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
426  print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text');
427  print '</td></tr>';
428 
429  // Progress declared
430  print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
431  print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1);
432  print '</td></tr>';
433 
434  // Description
435  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
436  print '<td>';
437  print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$object->description.'</textarea>';
438  print '</td></tr>';
439 
440  // Other options
441  $parameters = array();
442  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
443  print $hookmanager->resPrint;
444  if (empty($reshook))
445  {
446  print $object->showOptionals($extrafields, 'edit');
447  }
448 
449  print '</table>';
450 
451  print dol_get_fiche_end();
452 
453  print '<div class="center">';
454  print '<input type="submit" class="button" name="update" value="'.$langs->trans("Modify").'"> &nbsp; ';
455  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
456  print '</div>';
457 
458  print '</form>';
459  } else {
460  /*
461  * Fiche tache en mode visu
462  */
463  $param = ($withproject ? '&withproject=1' : '');
464  $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>' : '';
465 
466  print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
467 
468  if ($action == 'delete')
469  {
470  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
471  }
472 
473  if (!GETPOST('withproject') || empty($projectstatic->id))
474  {
475  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
476  $object->next_prev_filter = " fk_projet in (".$projectsListId.")";
477  } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
478 
479  $morehtmlref = '';
480 
481  // Project
482  if (empty($withproject))
483  {
484  $morehtmlref .= '<div class="refidno">';
485  $morehtmlref .= $langs->trans("Project").': ';
486  $morehtmlref .= $projectstatic->getNomUrl(1);
487  $morehtmlref .= '<br>';
488 
489  // Third party
490  $morehtmlref .= $langs->trans("ThirdParty").': ';
491  if (!empty($projectstatic->thirdparty)) {
492  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
493  }
494  $morehtmlref .= '</div>';
495  }
496 
497  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
498 
499  print '<div class="fichecenter">';
500  print '<div class="fichehalfleft">';
501 
502  print '<div class="underbanner clearboth"></div>';
503  print '<table class="border centpercent tableforfield">';
504 
505  // Task parent
506  print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
507  if ($object->fk_task_parent > 0)
508  {
509  $tasktmp = new Task($db);
510  $tasktmp->fetch($object->fk_task_parent);
511  print $tasktmp->getNomUrl(1);
512  }
513  print '</td></tr>';
514 
515  // Date start - Date end
516  print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("Deadline").'</td><td colspan="3">';
517  $start = dol_print_date($object->date_start, 'dayhour');
518  print ($start ? $start : '?');
519  $end = dol_print_date($object->date_end, 'dayhour');
520  print ' - ';
521  print ($end ? $end : '?');
522  if ($object->hasDelay()) print img_warning("Late");
523  print '</td></tr>';
524 
525  // Planned workload
526  print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
527  if ($object->planned_workload != '')
528  {
529  print convertSecondToTime($object->planned_workload, 'allhourmin');
530  }
531  print '</td></tr>';
532 
533  // Description
534  print '<td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
535  print nl2br($object->description);
536  print '</td></tr>';
537 
538  print '</table>';
539  print '</div>';
540 
541  print '<div class="fichehalfright"><div class="ficheaddleft">';
542 
543  print '<div class="underbanner clearboth"></div>';
544  print '<table class="border centpercent tableforfield">';
545 
546  // Progress declared
547  print '<tr><td class="titlefield">'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
548  if ($object->progress != '')
549  {
550  print $object->progress.' %';
551  }
552  print '</td></tr>';
553 
554  // Progress calculated
555  print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
556  if ($object->planned_workload != '')
557  {
558  $tmparray = $object->getSummaryOfTimeSpent();
559  if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';
560  else print '0 %';
561  } else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>';
562  print '</td></tr>';
563 
564  // Other attributes
565  $cols = 3;
566  $parameters = array('socid'=>$socid);
567  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
568 
569  print '</table>';
570 
571  print '</div>';
572  print '</div>';
573 
574  print '</div>';
575  print '<div class="clearboth"></div>';
576 
577  print dol_get_fiche_end();
578  }
579 
580 
581  if ($action != 'edit')
582  {
583  /*
584  * Actions
585  */
586 
587  print '<div class="tabsAction">';
588 
589  $parameters = array();
590  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
591  // modified by hook
592  if (empty($reshook))
593  {
594  // Modify
595  if ($user->rights->projet->creer)
596  {
597  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;withproject='.$withproject.'">'.$langs->trans('Modify').'</a>';
598  } else {
599  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
600  }
601 
602  // Delete
603  if ($user->rights->projet->supprimer)
604  {
605  if (!$object->hasChildren() && !$object->hasTimeSpent())
606  {
607  print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>';
608  } else {
609  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>';
610  }
611  } else {
612  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
613  }
614 
615  print '</div>';
616  }
617 
618  print '<div class="fichecenter"><div class="fichehalfleft">';
619  print '<a name="builddoc"></a>'; // ancre
620 
621  /*
622  * Documents generes
623  */
624  $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
625  $filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
626  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
627  $genallowed = ($user->rights->projet->lire);
628  $delallowed = ($user->rights->projet->creer);
629 
630  print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
631 
632  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
633 
634  // List of actions on element
635  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
636  $formactions = new FormActions($db);
637  $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid;
638  $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject);
639 
640  print '</div></div></div>';
641  }
642  }
643 }
644 
645 // End of page
646 llxFooter();
647 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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...
Class to manage building of HTML components.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Classe permettant la generation de composants html autre Only common components are here...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
Definition: files.lib.php:1144
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
project_prepare_head(Project $project)
Prepare array with list of tabs.
Definition: project.lib.php:36
print
Draft customers invoices.
Definition: index.php:89
Class to manage tasks.
Definition: task.class.php:35
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
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:180
task_prepare_head($object)
Prepare array with list of tabs.