dolibarr/htdocs/projet/tasks/task.php

663 lines
23 KiB
PHP
Raw Normal View History

2005-08-21 14:39:11 +02:00
<?php
2012-04-18 11:16:15 +02:00
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
2018-09-09 11:25:59 +02:00
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2005-08-21 14:39:11 +02:00
/**
* \file htdocs/projet/tasks/task.php
2012-04-18 11:16:15 +02:00
* \ingroup project
2011-09-14 14:47:51 +02:00
* \brief Page of a project task
*/
2005-08-21 14:39:11 +02:00
2018-07-26 11:57:25 +02:00
require "../../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
2005-08-21 14:39:11 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
$langs->loadlangs(array('projects', 'companies'));
2013-07-17 18:45:58 +02:00
$id=GETPOST('id', 'int');
$ref=GETPOST("ref", 'alpha', 1); // task ref
$taskref=GETPOST("taskref", 'alpha'); // task ref
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$withproject=GETPOST('withproject', 'int');
$project_ref=GETPOST('project_ref', 'alpha');
$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) : '');
2010-01-29 10:55:00 +01:00
// Security check
$socid=0;
//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.
2012-04-18 11:16:15 +02:00
if (! $user->rights->projet->lire) accessforbidden();
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('projecttaskcard','globalcard'));
2012-04-18 11:16:15 +02:00
$object = new Task($db);
$extrafields = new ExtraFields($db);
2012-04-18 11:16:15 +02:00
$projectstatic = new Project($db);
2005-08-21 14:39:11 +02:00
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2018-04-09 07:06:20 +02:00
$parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2018-04-09 07:06:20 +02:00
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2009-01-12 10:53:45 +01:00
/*
* Actions
*/
2009-01-12 10:53:45 +01:00
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
2010-01-29 10:55:00 +01:00
{
$error=0;
2016-07-09 13:58:46 +02:00
if (empty($taskref))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
}
2010-01-29 10:55:00 +01:00
if (empty($_POST["label"]))
{
$error++;
2015-10-17 17:09:34 +02:00
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
2010-01-29 10:55:00 +01:00
}
if (! $error)
{
$object->fetch($id, $ref);
$object->oldcopy = clone $object;
$tmparray=explode('_', $_POST['task_parent']);
2010-02-01 10:21:52 +01:00
$task_parent=$tmparray[1];
if (empty($task_parent)) $task_parent = 0; // If task_parent is ''
2010-01-29 10:55:00 +01:00
$object->ref = $taskref?$taskref:GETPOST("ref", 'alpha', 2);
2012-04-18 11:16:15 +02:00
$object->label = $_POST["label"];
$object->description = $_POST['description'];
$object->fk_task_parent = $task_parent;
$object->planned_workload = $planned_workload;
$object->date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']);
$object->date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']);
2012-04-18 11:16:15 +02:00
$object->progress = $_POST['progress'];
2010-01-29 10:55:00 +01:00
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
2015-02-26 14:25:30 +01:00
if ($ret < 0) $error++;
2015-02-26 14:25:30 +01:00
if (! $error)
{
2015-02-26 14:25:30 +01:00
$result=$object->update($user);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
2015-02-26 14:25:30 +01:00
}
}
2010-01-29 10:55:00 +01:00
}
else
{
$action='edit';
2010-01-29 10:55:00 +01:00
}
}
2012-04-18 11:16:15 +02:00
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer)
2009-01-12 10:53:45 +01:00
{
if ($object->fetch($id, $ref) >= 0)
2009-01-12 10:53:45 +01:00
{
$result=$projectstatic->fetch($object->fk_project);
$projectstatic->fetch_thirdparty();
2009-01-12 10:53:45 +01:00
2012-04-18 11:16:15 +02:00
if ($object->delete($user) > 0)
2009-01-12 10:53:45 +01:00
{
2018-02-26 21:16:40 +01:00
header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject?'&withproject=1':''));
2009-01-12 10:53:45 +01:00
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
2012-04-18 11:16:15 +02:00
$action='';
2009-01-12 10:53:45 +01:00
}
}
}
2012-04-18 11:16:15 +02:00
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
if (! empty($project_ref) && ! empty($withproject))
{
if ($projectstatic->fetch('', $project_ref) > 0)
2012-04-18 11:16:15 +02:00
{
$tasksarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
if (count($tasksarray) > 0)
{
$id=$tasksarray[0]->id;
}
else
{
2012-08-31 05:58:38 +02:00
header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode)?'':'&mode='.$mode));
2012-04-18 11:16:15 +02:00
}
}
}
2013-07-17 18:45:58 +02:00
// Build doc
if ($action == 'builddoc' && $user->rights->projet->creer)
{
$object->fetch($id, $ref);
// Save last template used to generate document
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha'));
2013-07-17 18:45:58 +02:00
$outputlangs = $langs;
if (GETPOST('lang_id', 'aZ09'))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
}
$result= $object->generateDocument($object->modelpdf, $outputlangs);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
2013-07-17 18:45:58 +02:00
}
}
// Delete file in doc form
if ($action == 'remove_file' && $user->rights->projet->creer)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if ($object->fetch($id, $ref) >= 0 )
2013-07-17 18:45:58 +02:00
{
$langs->load("other");
$upload_dir = $conf->projet->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret=dol_delete_file($file);
2015-12-17 14:14:44 +01:00
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
2013-07-17 18:45:58 +02:00
}
}
2008-08-26 00:14:58 +02:00
/*
* View
2017-11-16 23:11:49 +01:00
*/
2005-08-21 14:39:11 +02:00
2012-07-28 17:34:21 +02:00
llxHeader('', $langs->trans("Task"));
2005-08-21 14:39:11 +02:00
$form = new Form($db);
2010-01-28 12:08:11 +01:00
$formother = new FormOther($db);
2013-07-17 18:45:58 +02:00
$formfile = new FormFile($db);
2009-01-12 10:53:45 +01:00
2012-04-18 11:16:15 +02:00
if ($id > 0 || ! empty($ref))
2005-08-21 14:39:11 +02:00
{
if ($object->fetch($id, $ref) > 0)
2005-08-21 14:39:11 +02:00
{
2018-02-21 14:48:25 +01:00
$res=$object->fetch_optionals();
if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
2012-04-18 11:16:15 +02:00
$result=$projectstatic->fetch($object->fk_project);
if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = clone $projectstatic;
$userWrite = $projectstatic->restrictedProjectArea($user, 'write');
2012-04-18 11:16:15 +02:00
if (! empty($withproject))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($projectstatic);
2018-03-06 21:51:43 +01:00
dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project'), 0, '', '');
$param=($mode=='mine'?'&mode=mine':'');
2016-10-18 12:16:12 +02:00
// Project card
2017-06-07 10:55:39 +02:00
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2016-10-18 12:16:12 +02:00
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
2017-06-07 10:55:39 +02:00
if ($projectstatic->thirdparty->id > 0)
2016-10-18 12:16:12 +02:00
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")";
2016-10-18 12:16:12 +02:00
}
2017-06-07 10:55:39 +02:00
2017-01-20 10:27:37 +01:00
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
2017-06-07 10:55:39 +02:00
2019-09-01 01:40:51 +02:00
print '<table class="border tableforfield centpercent">';
// Usage
print '<tr><td class="tdtop">';
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha')!=''?' checked="checked"':'') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha')!=''?' checked="checked"':'') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (! empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
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"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
}
print '</td></tr>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($projectstatic->date_start, 'day');
print ($start?$start:'?');
$end = dol_print_date($projectstatic->date_end, 'day');
print ' - ';
print ($end?$end:'?');
if ($projectstatic->hasDelay()) print img_warning("Late");
2016-10-18 12:16:12 +02:00
print '</td></tr>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
2016-10-18 12:16:12 +02:00
print '</td></tr>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>';
2017-09-17 20:05:36 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
2017-06-07 10:55:39 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Categories
if($conf->categorie->enabled) {
2019-02-23 22:24:26 +01:00
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id, 'project', 1);
2016-10-18 12:16:12 +02:00
print "</td></tr>";
}
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>';
print '</div>';
print '</div>';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="clearboth"></div>';
2017-06-07 10:55:39 +02:00
dol_fiche_end();
2017-04-05 14:48:24 +02:00
print '<br>';
}
/*
* Actions
*/
/*print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
{
if ($projectstatic->public || $userWrite > 0)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
}
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
}
print '</div>';
*/
// To verify role of users
2012-04-18 11:16:15 +02:00
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$object->getListContactId('internal');
2012-04-18 11:16:15 +02:00
$head=task_prepare_head($object);
if ($action == 'edit' && $user->rights->projet->creer)
{
2010-01-29 10:55:00 +01:00
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
2010-01-28 12:08:11 +01:00
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2010-01-29 10:55:00 +01:00
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
2012-04-18 11:16:15 +02:00
print '<input type="hidden" name="id" value="'.$object->id.'">';
2018-03-06 21:51:43 +01:00
dol_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', '');
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2010-01-28 12:08:11 +01:00
// Ref
2016-07-09 13:58:46 +02:00
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
2017-11-22 21:19:40 +01:00
print '<td><input class="minwidth100" name="taskref" value="'.$object->ref.'"></td></tr>';
2010-01-28 12:08:11 +01:00
// Label
2016-07-09 13:58:46 +02:00
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
2017-11-22 21:19:40 +01:00
print '<td><input class="minwidth500" name="label" value="'.$object->label.'"></td></tr>';
// Project
if (empty($withproject))
{
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
print '</td></tr>';
// Third party
2014-05-09 13:39:10 +02:00
print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
}
// Task parent
2017-11-16 23:11:49 +01:00
print '<tr><td>'.$langs->trans("ChildOfProjectTask").'</td><td>';
print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin?0:1), 0, 0, 0, $object->id);
2010-02-01 10:21:52 +01:00
print '</td></tr>';
2010-01-28 12:08:11 +01:00
// Date start
2010-01-29 10:55:00 +01:00
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
2018-09-09 11:25:59 +02:00
print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0);
2010-01-28 12:08:11 +01:00
print '</td></tr>';
2010-01-28 12:08:11 +01:00
// Date end
2010-01-29 10:55:00 +01:00
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
2018-09-09 11:25:59 +02:00
print $form->selectDate($object->date_end?$object->date_end:-1, 'datee', 1, 1, 0, '', 1, 0);
2010-01-28 12:08:11 +01:00
print '</td></tr>';
// Planned workload
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text');
2013-05-13 17:08:36 +02:00
print '</td></tr>';
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1);
2010-01-28 12:08:11 +01:00
print '</td></tr>';
2010-01-28 12:08:11 +01:00
// Description
2017-01-22 12:13:32 +01:00
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
2010-01-29 10:55:00 +01:00
print '<td>';
2017-03-14 14:06:55 +01:00
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$object->description.'</textarea>';
2010-01-28 12:08:11 +01:00
print '</td></tr>';
// Other options
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager->resPrint;
2018-04-13 13:28:48 +02:00
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
}
2010-01-29 10:55:00 +01:00
print '</table>';
2014-12-04 11:53:44 +01:00
dol_fiche_end();
2019-02-23 22:24:26 +01:00
print '<div class="center">';
2011-09-14 14:47:51 +02:00
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Modify").'"> &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
2011-09-14 14:47:51 +02:00
2010-01-29 10:55:00 +01:00
print '</form>';
}
else
{
2010-01-28 12:08:11 +01:00
/*
* Fiche tache en mode visu
*/
$param=($withproject?'&withproject=1':'');
2017-06-07 10:55:39 +02:00
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>':'';
2018-03-06 21:51:43 +01:00
dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
if ($action == 'delete')
2010-01-28 12:08:11 +01:00
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
2010-01-28 12:08:11 +01:00
}
2009-01-15 00:36:51 +01:00
2017-04-05 14:48:24 +02:00
if (! GETPOST('withproject') || empty($projectstatic->id))
{
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
2017-04-05 14:48:24 +02:00
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
$morehtmlref='';
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Project
if (empty($withproject))
{
$morehtmlref.='<div class="refidno">';
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
2017-07-13 14:32:49 +02:00
if (!empty($projectstatic->thirdparty)) {
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
}
2017-05-18 12:12:36 +02:00
$morehtmlref.='</div>';
}
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
2017-06-07 10:55:39 +02:00
2017-03-23 16:10:38 +01:00
print '<div class="fichecenter">';
2017-09-17 20:05:36 +02:00
print '<div class="fichehalfleft">';
2017-06-07 10:55:39 +02:00
print '<div class="underbanner clearboth"></div>';
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2017-11-16 19:41:31 +01:00
// Task parent
print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
if ($object->fk_task_parent > 0)
{
$tasktmp=new Task($db);
$tasktmp->fetch($object->fk_task_parent);
print $tasktmp->getNomUrl(1);
}
print '</td></tr>';
2017-04-05 14:48:24 +02:00
// Date start - Date end
print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td colspan="3">';
$start = dol_print_date($object->date_start, 'dayhour');
2017-04-05 14:48:24 +02:00
print ($start?$start:'?');
$end = dol_print_date($object->date_end, 'dayhour');
2017-04-05 14:48:24 +02:00
print ' - ';
print ($end?$end:'?');
if ($object->hasDelay()) print img_warning("Late");
2010-01-28 12:08:11 +01:00
print '</td></tr>';
// Planned workload
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
if ($object->planned_workload != '')
{
print convertSecondToTime($object->planned_workload, 'allhourmin');
}
2013-05-13 17:08:36 +02:00
print '</td></tr>';
2017-09-17 20:05:36 +02:00
// Description
print '<td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
print nl2br($object->description);
print '</td></tr>';
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2017-09-17 20:05:36 +02:00
// Progress declared
2017-09-17 20:05:36 +02:00
print '<tr><td class="titlefield">'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
if ($object->progress != '')
{
print $object->progress.' %';
}
print '</td></tr>';
// Progress calculated
print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
if ($object->planned_workload != '')
{
$tmparray=$object->getSummaryOfTimeSpent();
2015-03-18 11:04:50 +01:00
if ($tmparray['total_duration'] > 0 && ! empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';
else print '0 %';
}
2017-09-17 20:05:36 +02:00
else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>';
2010-01-28 12:08:11 +01:00
print '</td></tr>';
2017-06-07 16:44:04 +02:00
// Other attributes
$cols = 3;
2019-02-17 20:08:52 +01:00
$parameters=array('socid'=>$socid);
2017-06-07 16:44:04 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
2011-09-14 14:47:51 +02:00
print '</table>';
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
print '</div>';
2017-09-17 20:05:36 +02:00
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
2017-06-07 10:55:39 +02:00
2014-12-04 11:53:44 +01:00
dol_fiche_end();
2011-09-14 14:47:51 +02:00
}
2016-04-30 01:01:32 +02:00
if ($action != 'edit')
2011-09-14 14:47:51 +02:00
{
/*
* Actions
*/
2017-06-07 10:55:39 +02:00
print '<div class="tabsAction">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if (empty($reshook))
{
2016-04-27 22:19:38 +02:00
// Modify
if ($user->rights->projet->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;withproject='.$withproject.'">'.$langs->trans('Modify').'</a>';
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
2016-04-27 22:19:38 +02:00
}
2017-06-07 10:55:39 +02:00
2016-04-27 22:19:38 +02:00
// Delete
if ($user->rights->projet->supprimer)
2016-04-27 22:19:38 +02:00
{
if (! $object->hasChildren() && ! $object->hasTimeSpent())
{
2019-10-20 11:59:21 +02:00
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>';
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>';
}
2016-04-27 22:19:38 +02:00
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
2016-04-27 22:19:38 +02:00
}
2017-06-07 10:55:39 +02:00
2016-04-27 22:19:38 +02:00
print '</div>';
}
2017-06-07 10:55:39 +02:00
2016-10-24 11:27:39 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
2017-06-07 10:55:39 +02:00
/*
* Documents generes
*/
$filename=dol_sanitizeFileName($projectstatic->ref). "/". dol_sanitizeFileName($object->ref);
$filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref). "/" .dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=($user->rights->projet->lire);
$delallowed=($user->rights->projet->creer);
print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf);
2016-10-24 11:27:39 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
2017-06-07 10:55:39 +02:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject);
2016-10-24 11:27:39 +02:00
print '</div></div></div>';
2009-07-28 15:37:28 +02:00
}
2005-08-21 14:39:11 +02:00
}
}
2018-08-15 12:48:13 +02:00
// End of page
llxFooter();
$db->close();