27 require
"../../main.inc.php";
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
38 $langs->loadlangs(array(
'projects',
'companies'));
41 $ref =
GETPOST(
"ref",
'alpha', 1);
42 $taskref =
GETPOST(
"taskref",
'alpha');
43 $action =
GETPOST(
'action',
'aZ09');
44 $confirm =
GETPOST(
'confirm',
'alpha');
45 $withproject =
GETPOST(
'withproject',
'int');
46 $project_ref =
GETPOST(
'project_ref',
'alpha');
47 $planned_workload = ((
GETPOST(
'planned_workloadhour',
'int') !=
'' ||
GETPOST(
'planned_workloadmin',
'int') !=
'') ? (
GETPOST(
'planned_workloadhour',
'int') > 0 ?
GETPOST(
'planned_workloadhour',
'int') * 3600 : 0) + (
GETPOST(
'planned_workloadmin',
'int') > 0 ?
GETPOST(
'planned_workloadmin',
'int') * 60 : 0) :
'');
55 $hookmanager->initHooks(array(
'projecttaskcard',
'globalcard'));
57 $object =
new Task($db);
59 $projectstatic =
new Project($db);
62 $extrafields->fetch_name_optionals_label($object->table_element);
64 $parameters = array(
'id'=>$id);
65 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
66 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
72 if ($action ==
'update' && !$_POST[
"cancel"] && $user->rights->projet->creer)
79 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")), null,
'errors');
81 if (empty($_POST[
"label"]))
84 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")), null,
'errors');
88 $object->fetch($id, $ref);
89 $object->oldcopy = clone $object;
91 $tmparray = explode(
'_', $_POST[
'task_parent']);
92 $task_parent = $tmparray[1];
93 if (empty($task_parent)) $task_parent = 0;
95 $object->ref = $taskref ? $taskref :
GETPOST(
"ref",
'alpha', 2);
96 $object->label =
GETPOST(
"label",
"alphanohtml");
97 $object->description =
GETPOST(
'description',
"alphanohtml");
98 $object->fk_task_parent = $task_parent;
99 $object->planned_workload = $planned_workload;
100 $object->date_start =
dol_mktime(
GETPOST(
'dateohour',
'int'),
GETPOST(
'dateomin',
'int'), 0,
GETPOST(
'dateomonth',
'int'),
GETPOST(
'dateoday',
'int'),
GETPOST(
'dateoyear',
'int'));
101 $object->date_end =
dol_mktime(
GETPOST(
'dateehour',
'int'),
GETPOST(
'dateemin',
'int'), 0,
GETPOST(
'dateemonth',
'int'),
GETPOST(
'dateeday',
'int'),
GETPOST(
'dateeyear',
'int'));
105 $ret = $extrafields->setOptionalsFromPost(null, $object);
106 if ($ret < 0) $error++;
110 $result = $object->update($user);
121 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->rights->projet->supprimer)
123 if ($object->fetch($id, $ref) >= 0)
125 $result = $projectstatic->fetch($object->fk_project);
126 $projectstatic->fetch_thirdparty();
128 if ($object->delete($user) > 0)
130 header(
'Location: '.DOL_URL_ROOT.
'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ?
'&withproject=1' :
''));
140 if (!empty($project_ref) && !empty($withproject))
142 if ($projectstatic->fetch(
'', $project_ref) > 0)
144 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
145 if (count($tasksarray) > 0)
147 $id = $tasksarray[0]->id;
149 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ?
'' :
'&mode='.$mode));
155 if ($action ==
'builddoc' && $user->rights->projet->creer)
157 $object->fetch($id, $ref);
160 if (
GETPOST(
'model')) $object->setDocModel($user,
GETPOST(
'model',
'alpha'));
162 $outputlangs = $langs;
163 if (
GETPOST(
'lang_id',
'aZ09'))
166 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
168 $result = $object->generateDocument($object->model_pdf, $outputlangs);
177 if ($action ==
'remove_file' && $user->rights->projet->creer)
179 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
181 if ($object->fetch($id, $ref) >= 0)
183 $langs->load(
"other");
184 $upload_dir = $conf->projet->dir_output;
200 $form =
new Form($db);
204 if ($id > 0 || !empty($ref))
206 if ($object->fetch($id, $ref) > 0)
208 $res = $object->fetch_optionals();
209 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) $object->fetchComments();
211 $result = $projectstatic->fetch($object->fk_project);
212 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
213 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
215 $object->project = clone $projectstatic;
219 if (!empty($withproject))
224 print dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'), 0,
'',
'');
226 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
230 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
232 $morehtmlref =
'<div class="refidno">';
234 $morehtmlref .= $projectstatic->title;
236 if ($projectstatic->thirdparty->id > 0)
238 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
240 $morehtmlref .=
'</div>';
243 if (!$user->rights->projet->all->lire)
245 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
246 $projectstatic->next_prev_filter =
" rowid in (".(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
249 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
251 print '<div class="fichecenter">';
252 print '<div class="fichehalfleft">';
253 print '<div class="underbanner clearboth"></div>';
255 print '<table class="border tableforfield centpercent">';
258 print '<tr><td class="tdtop">';
259 print $langs->trans(
"Usage");
262 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
264 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
265 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
266 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
269 if (empty($conf->global->PROJECT_HIDE_TASKS))
271 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
272 $htmltext = $langs->trans(
"ProjectFollowTasks");
273 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
276 if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
278 print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_bill_time ?
' checked="checked"' :
'')).
'"> ';
279 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
280 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
286 print '<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
287 if ($projectstatic->public)
print $langs->trans(
'SharedProject');
288 else print $langs->trans(
'PrivateProject');
292 print '<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
294 print ($start ? $start :
'?');
297 print ($end ? $end :
'?');
302 print '<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
303 if (strcmp($projectstatic->budget_amount,
''))
print price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
314 print '<div class="fichehalfright">';
315 print '<div class="ficheaddleft">';
316 print '<div class="underbanner clearboth"></div>';
318 print '<table class="border centpercent">';
321 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
322 print nl2br($projectstatic->description);
326 if ($conf->categorie->enabled) {
327 print '<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
328 print $form->showCategories($projectstatic->id,
'project', 1);
338 print '<div class="clearboth"></div>';
375 if ($action ==
'edit' && $user->rights->projet->creer)
377 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
378 print '<input type="hidden" name="token" value="'.newToken().
'">';
379 print '<input type="hidden" name="action" value="update">';
380 print '<input type="hidden" name="withproject" value="'.$withproject.
'">';
381 print '<input type="hidden" name="id" value="'.$object->id.
'">';
385 print '<table class="border centpercent">';
388 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
389 print
'<td><input class="minwidth100" name="taskref" value="'.$object->ref.
'"></td></tr>';
392 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td>';
393 print
'<td><input class="minwidth500" name="label" value="'.$object->label.
'"></td></tr>';
396 if (empty($withproject))
398 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td colspan="3">';
399 print $projectstatic->getNomUrl(1);
403 print
'<td>'.$langs->trans(
"ThirdParty").
'</td><td colspan="3">';
404 if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
410 print
'<tr><td>'.$langs->trans(
"ChildOfProjectTask").
'</td><td>';
411 print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id,
'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id);
415 print
'<tr><td>'.$langs->trans(
"DateStart").
'</td><td>';
416 print $form->selectDate($object->date_start,
'dateo', 1, 1, 0,
'', 1, 0);
420 print
'<tr><td>'.$langs->trans(
"Deadline").
'</td><td>';
421 print $form->selectDate($object->date_end ? $object->date_end : -1,
'datee', 1, 1, 0,
'', 1, 0);
425 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
426 print $form->select_duration(
'planned_workload', $object->planned_workload, 0,
'text');
430 print
'<tr><td>'.$langs->trans(
"ProgressDeclared").
'</td><td>';
431 print $formother->select_percent($object->progress,
'progress', 0, 5, 0, 100, 1);
435 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
437 print
'<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.
'">'.$object->description.
'</textarea>';
441 $parameters = array();
442 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
443 print $hookmanager->resPrint;
446 print $object->showOptionals($extrafields,
'edit');
453 print
'<div class="center">';
454 print
'<input type="submit" class="button" name="update" value="'.$langs->trans(
"Modify").
'"> ';
455 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
463 $param = ($withproject ?
'&withproject=1' :
'');
464 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'&restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>' :
'';
466 print
dol_get_fiche_head($head,
'task_task', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
468 if ($action ==
'delete')
470 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$_GET[
"id"].
'&withproject='.$withproject, $langs->trans(
"DeleteATask"), $langs->trans(
"ConfirmDeleteATask"),
"confirm_delete");
473 if (!
GETPOST(
'withproject') || empty($projectstatic->id))
475 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
476 $object->next_prev_filter =
" fk_projet in (".$projectsListId.
")";
477 }
else $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
482 if (empty($withproject))
484 $morehtmlref .=
'<div class="refidno">';
485 $morehtmlref .= $langs->trans(
"Project").
': ';
486 $morehtmlref .= $projectstatic->getNomUrl(1);
487 $morehtmlref .=
'<br>';
490 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
491 if (!empty($projectstatic->thirdparty)) {
492 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
494 $morehtmlref .=
'</div>';
497 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
499 print
'<div class="fichecenter">';
500 print
'<div class="fichehalfleft">';
502 print
'<div class="underbanner clearboth"></div>';
503 print
'<table class="border centpercent tableforfield">';
506 print
'<tr><td>'.$langs->trans(
"ChildOfTask").
'</td><td>';
507 if ($object->fk_task_parent > 0)
509 $tasktmp =
new Task($db);
510 $tasktmp->fetch($object->fk_task_parent);
511 print $tasktmp->getNomUrl(1);
516 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"Deadline").
'</td><td colspan="3">';
518 print ($start ? $start :
'?');
521 print ($end ? $end :
'?');
522 if ($object->hasDelay()) print
img_warning(
"Late");
526 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td colspan="3">';
527 if ($object->planned_workload !=
'')
534 print
'<td class="tdtop">'.$langs->trans(
"Description").
'</td><td colspan="3">';
535 print nl2br($object->description);
541 print
'<div class="fichehalfright"><div class="ficheaddleft">';
543 print
'<div class="underbanner clearboth"></div>';
544 print
'<table class="border centpercent tableforfield">';
547 print
'<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td colspan="3">';
548 if ($object->progress !=
'')
550 print $object->progress.
' %';
555 print
'<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td colspan="3">';
556 if ($object->planned_workload !=
'')
558 $tmparray = $object->getSummaryOfTimeSpent();
559 if ($tmparray[
'total_duration'] > 0 && !empty($object->planned_workload)) print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
561 }
else print
'<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
566 $parameters = array(
'socid'=>$socid);
567 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
575 print
'<div class="clearboth"></div>';
581 if ($action !=
'edit')
587 print
'<div class="tabsAction">';
589 $parameters = array();
590 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
595 if ($user->rights->projet->creer)
597 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&withproject='.$withproject.
'">'.$langs->trans(
'Modify').
'</a>';
599 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
'Modify').
'</a>';
603 if ($user->rights->projet->supprimer)
605 if (!$object->hasChildren() && !$object->hasTimeSpent())
607 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&withproject='.$withproject.
'">'.$langs->trans(
'Delete').
'</a>';
609 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"TaskHasChild").
'">'.$langs->trans(
'Delete').
'</a>';
612 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
'Delete').
'</a>';
618 print
'<div class="fichecenter"><div class="fichehalfleft">';
619 print
'<a name="builddoc"></a>';
626 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
627 $genallowed = ($user->rights->projet->lire);
628 $delallowed = ($user->rights->projet->creer);
630 print $formfile->showdocuments(
'project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
632 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
635 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
637 $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid;
638 $formactions->showactions($object,
'task', $defaultthirdpartyid, 1,
'', 10,
'withproject='.$withproject);
640 print
'</div></div></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
project_prepare_head(Project $project)
Prepare array with list of tabs.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
convertSecondToTime($iSecond, $format= 'all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
task_prepare_head($object)
Prepare array with list of tabs.