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