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