30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40 $langs->loadLangs(array(
'projects',
'bills',
'orders'));
42 $action =
GETPOST(
'action',
'alpha');
43 $massaction =
GETPOST(
'massaction',
'alpha');
44 $confirm =
GETPOST(
'confirm',
'alpha');
45 $cancel =
GETPOST(
'cancel',
'alpha');
46 $toselect =
GETPOST(
'toselect',
'array');
47 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
48 $backtopage =
GETPOST(
'backtopage',
'alpha');
49 $optioncss =
GETPOST(
'optioncss',
'alpha');
52 $projectid =
GETPOST(
'projectid',
'int');
54 $withproject =
GETPOST(
'withproject',
'int');
55 $project_ref =
GETPOST(
'project_ref',
'alpha');
58 $search_day =
GETPOST(
'search_day',
'int');
59 $search_month =
GETPOST(
'search_month',
'int');
60 $search_year =
GETPOST(
'search_year',
'int');
61 $search_datehour =
'';
62 $search_datewithhour =
'';
63 $search_note =
GETPOST(
'search_note',
'alpha');
64 $search_duration =
GETPOST(
'search_duration',
'int');
65 $search_value =
GETPOST(
'search_value',
'int');
66 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
67 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
68 $search_user =
GETPOST(
'search_user',
'int');
69 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
76 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
77 $sortfield =
GETPOST(
"sortfield",
'alpha');
78 $sortorder =
GETPOST(
"sortorder",
'alpha');
80 if (empty($page) || $page == -1) { $page = 0; }
81 $offset = $limit * $page;
82 $pageprev = $page - 1;
83 $pagenext = $page + 1;
84 if (!$sortfield) $sortfield =
't.task_date,t.task_datehour,t.rowid';
85 if (!$sortorder) $sortorder =
'DESC,DESC,DESC';
89 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
91 $object =
new Task($db);
92 $projectstatic =
new Project($db);
94 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
95 $extrafields->fetch_name_optionals_label($object->table_element);
102 if (
GETPOST(
'cancel',
'alpha')) { $action =
''; }
103 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice') { $massaction =
''; }
105 $parameters = array(
'socid'=>$socid,
'projectid'=>$projectid);
106 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
107 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
109 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
112 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
118 $search_datehour =
'';
119 $search_datewithhour =
'';
121 $search_duration =
'';
123 $search_date_creation =
'';
124 $search_date_update =
'';
125 $search_task_ref =
'';
126 $search_task_label =
'';
128 $search_valuebilled =
'';
130 $search_array_options = array();
134 if ($action ==
'addtimespent' && $user->rights->projet->lire)
138 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
139 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
140 if (empty($timespent_durationhour) && empty($timespent_durationmin))
142 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")), null,
'errors');
145 if (empty($_POST[
"userid"]))
147 $langs->load(
"errors");
148 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'), null,
'errors');
156 $object->fetch($id, $ref);
160 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")), null,
'errors');
161 $action =
'createtime';
164 $object->fetch(
GETPOST(
'taskid',
'int'));
170 $object->fetch_projet();
172 if (empty($object->project->statut))
174 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"), null,
'errors');
175 $action =
'createtime';
178 $object->timespent_note = $_POST[
"timespent_note"];
179 if (
GETPOST(
'progress',
'int') > 0) $object->progress =
GETPOST(
'progress',
'int');
180 $object->timespent_duration = $_POST[
"timespent_durationhour"] * 60 * 60;
181 $object->timespent_duration += ($_POST[
"timespent_durationmin"] ? $_POST[
"timespent_durationmin"] : 0) * 60;
185 $object->timespent_withhour = 1;
189 $object->timespent_fk_user = $_POST[
"userid"];
190 $result = $object->addTimeSpent($user);
201 if (empty($id)) $action =
'createtime';
202 else $action =
'createtime';
206 if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire)
212 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")), null,
'errors');
218 if (
GETPOST(
'taskid',
'int') != $id)
220 $id =
GETPOST(
'taskid',
'int');
222 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
224 $result = $object->delTimeSpent($user);
226 $object->fetch($id, $ref);
227 $object->timespent_note = $_POST[
"timespent_note_line"];
228 $object->timespent_old_duration = $_POST[
"old_duration"];
229 $object->timespent_duration = $_POST[
"new_durationhour"] * 60 * 60;
230 $object->timespent_duration += ($_POST[
"new_durationmin"] ? $_POST[
"new_durationmin"] : 0) * 60;
231 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0)
234 $object->timespent_withhour = 1;
238 $object->timespent_fk_user = $_POST[
"userid_line"];
239 $result = $object->addTimeSpent($user);
248 $object->fetch($id, $ref);
251 $object->timespent_id = $_POST[
"lineid"];
252 $object->timespent_note = $_POST[
"timespent_note_line"];
253 $object->timespent_old_duration = $_POST[
"old_duration"];
254 $object->timespent_duration = $_POST[
"new_durationhour"] * 60 * 60;
255 $object->timespent_duration += ($_POST[
"new_durationmin"] ? $_POST[
"new_durationmin"] : 0) * 60;
256 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0)
259 $object->timespent_withhour = 1;
263 $object->timespent_fk_user = $_POST[
"userid_line"];
265 $result = $object->updateTimeSpent($user);
279 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->rights->projet->lire)
281 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
283 $result = $object->delTimeSpent($user);
287 $langs->load(
"errors");
297 if (!empty($project_ref) && !empty($withproject))
299 if ($projectstatic->fetch(0, $project_ref) > 0)
301 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
302 if (count($tasksarray) > 0)
304 $id = $tasksarray[0]->id;
306 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
313 $projectidforalltimes = 0;
314 if (
GETPOST(
'projectid',
'int') > 0)
316 $projectidforalltimes =
GETPOST(
'projectid',
'int');
318 $result = $projectstatic->fetch($projectidforalltimes);
319 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
320 $res = $projectstatic->fetch_optionals();
321 } elseif (
GETPOST(
'project_ref',
'alpha'))
323 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
324 $projectidforalltimes = $projectstatic->id;
329 $result = $projectstatic->fetch($object->fk_project);
332 if ($action ==
'confirm_generateinvoice')
334 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
336 if (!($projectstatic->thirdparty->id > 0)) {
337 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"), null,
'errors');
339 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
340 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
341 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
343 $tmpinvoice =
new Facture($db);
344 $tmptimespent =
new Task($db);
345 $tmpproduct =
new Product($db);
346 $fuser =
new User($db);
349 $idprod =
GETPOST(
'productid',
'int');
350 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
351 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
353 $prodDurationHours = 1.0;
356 $tmpproduct->fetch($idprod);
357 if ($tmpproduct->duration_unit ==
'i')
358 $prodDurationHours = 1. / 60;
359 if ($tmpproduct->duration_unit ==
'h')
360 $prodDurationHours = 1.;
361 if ($tmpproduct->duration_unit ==
'd')
362 $prodDurationHours = 24.;
363 if ($tmpproduct->duration_unit ==
'w')
364 $prodDurationHours = 24. * 7;
365 if ($tmpproduct->duration_unit ==
'm')
366 $prodDurationHours = 24. * 30;
367 if ($tmpproduct->duration_unit ==
'y')
368 $prodDurationHours = 24. * 365;
369 $prodDurationHours *= $tmpproduct->duration_value;
371 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
373 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
374 $txtva = $dataforprice[
'tva_tx'];
375 $localtax1 = $dataforprice[
'localtax1'];
376 $localtax2 = $dataforprice[
'localtax2'];
384 $tmpinvoice->socid = $projectstatic->thirdparty->id;
385 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
386 $tmpinvoice->fk_project = $projectstatic->id;
389 $tmpinvoice->fetch($invoiceToUse);
391 $result = $tmpinvoice->create($user);
401 if ($generateinvoicemode ==
'onelineperuser') {
402 $arrayoftasks = array();
403 foreach ($toselect as $key => $value)
406 $object->fetchTimeSpent($value);
407 $arrayoftasks[$object->timespent_fk_user][
'timespent'] += $object->timespent_duration;
408 $arrayoftasks[$object->timespent_fk_user][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
411 foreach ($arrayoftasks as $userid => $value)
413 $fuser->fetch($userid);
415 $username = $fuser->getFullName($langs);
418 $qtyhour = $value[
'timespent'] / 3600;
419 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
424 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
428 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username).
' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
431 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.$lineid.
', invoice_id = '.$tmpinvoice->id;
432 $sql .=
' WHERE rowid in ('.join(
',', $toselect).
') AND fk_user = '.$userid;
433 $result = $db->query($sql);
441 } elseif ($generateinvoicemode ==
'onelineperperiod') {
442 $arrayoftasks = array();
443 foreach ($toselect as $key => $value)
446 $object->fetchTimeSpent($value);
447 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
448 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
449 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
450 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
453 foreach ($arrayoftasks as $timespent_id => $value)
455 $userid = $value[
'user'];
456 $fuser->fetch($userid);
458 $username = $fuser->getFullName($langs);
461 $qtyhour = $value[
'timespent'] / 3600;
462 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
467 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
471 $lineid = $tmpinvoice->addline($value[
'note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
474 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.$lineid.
', invoice_id = '.$tmpinvoice->id;
475 $sql .=
' WHERE rowid in ('.join(
',', $toselect).
') AND fk_user = '.$userid;
476 $result = $db->query($sql);
484 } elseif ($generateinvoicemode ==
'onelinepertask') {
485 $arrayoftasks = array();
486 foreach ($toselect as $key => $value)
489 $object->fetchTimeSpent($value);
491 $arrayoftasks[$object->id][
'timespent'] += $object->timespent_duration;
492 $arrayoftasks[$object->id][
'totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm;
495 foreach ($arrayoftasks as $task_id => $value)
497 $ftask =
new Task($db);
498 $ftask->fetch($task_id);
500 $qtyhour = $value[
'timespent'] / 3600;
501 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
506 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
510 $lineName = $ftask->ref.
' - '.$ftask->label;
511 $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
514 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.$lineid.
', invoice_id = '.$tmpinvoice->id;
515 $sql .=
' WHERE rowid in ('.join(
',', $toselect).
')';
516 $result = $db->query($sql);
529 $urltoinvoice = $tmpinvoice->getNomUrl(0);
530 setEventMessages($langs->trans(
"InvoiceGeneratedFromTimeSpent", $urltoinvoice), null,
'mesgs');
545 $arrayofselected = is_array($toselect) ? $toselect : array();
549 $form =
new Form($db);
552 $userstatic =
new User($db);
554 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
559 if ($projectidforalltimes > 0)
561 $result = $projectstatic->fetch($projectidforalltimes);
562 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
563 $res = $projectstatic->fetch_optionals();
564 } elseif ($object->fetch($id, $ref) >= 0)
566 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) $object->fetchComments();
567 $result = $projectstatic->fetch($object->fk_project);
568 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
569 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
570 $res = $projectstatic->fetch_optionals();
572 $object->project = clone $projectstatic;
575 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
576 $linktocreatetime =
'';
578 if ($projectstatic->id > 0)
583 if (empty($id) || $tab ==
'timespent') $tab =
'timespent';
587 print dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
589 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
593 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
595 $morehtmlref =
'<div class="refidno">';
597 $morehtmlref .= $projectstatic->title;
599 if ($projectstatic->thirdparty->id > 0)
601 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
603 $morehtmlref .=
'</div>';
606 if (!$user->rights->projet->all->lire)
608 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
609 $projectstatic->next_prev_filter =
" rowid in (".(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
612 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
614 print '<div class="fichecenter">';
615 print '<div class="fichehalfleft">';
616 print '<div class="underbanner clearboth"></div>';
618 print '<table class="border tableforfield centpercent">';
621 print '<tr><td class="tdtop">';
622 print $langs->trans(
"Usage");
625 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
627 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
628 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
629 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
632 if (empty($conf->global->PROJECT_HIDE_TASKS))
634 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
635 $htmltext = $langs->trans(
"ProjectFollowTasks");
636 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
639 if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
641 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"' :
'')).
'"> ';
642 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
643 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
649 print '<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
650 if ($projectstatic->public)
print $langs->trans(
'SharedProject');
651 else print $langs->trans(
'PrivateProject');
655 print '<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
657 print ($start ? $start :
'?');
660 print ($end ? $end :
'?');
665 print '<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
666 if (strcmp($projectstatic->budget_amount,
''))
print price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
676 print '<div class="fichehalfright">';
677 print '<div class="ficheaddleft">';
678 print '<div class="underbanner clearboth"></div>';
680 print '<table class="border tableforfield" width="100%">';
683 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
684 print nl2br($projectstatic->description);
688 if ($conf->categorie->enabled) {
689 print '<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
690 print $form->showCategories($projectstatic->id,
'project', 1);
700 print '<div class="clearboth"></div>';
708 $linktocreatetimeBtnStatus = 0;
709 $linktocreatetimeUrl =
'';
710 $linktocreatetimeHelpText =
'';
711 if ($user->rights->projet->all->lire || $user->rights->projet->lire)
713 if ($projectstatic->public || $userRead > 0)
715 $linktocreatetimeBtnStatus = 1;
717 if (!empty($projectidforalltimes))
719 $backtourl =
$_SERVER[
'PHP_SELF'].
'?projectid='.$projectstatic->id.($withproject ?
'&withproject=1' :
'');
720 $linktocreatetimeUrl =
$_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').
'&projectid='.$projectstatic->id.
'&action=createtime'.$param.
'&backtopage='.urlencode($backtourl);
723 $backtourl =
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.($withproject ?
'&withproject=1' :
'');
724 $linktocreatetimeUrl =
$_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').($object->id > 0 ?
'&id='.$object->id :
'&projectid='.$projectstatic->id).
'&action=createtime'.$param.
'&backtopage='.urlencode($backtourl);
727 $linktocreatetimeBtnStatus = -2;
728 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
732 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus);
735 $massactionbutton =
'';
736 if ($projectstatic->usage_bill_time)
738 $arrayofmassactions = array(
739 'generateinvoice'=>$langs->trans(
"GenerateBill"),
743 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice'))) $arrayofmassactions = array();
744 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
748 if (empty($projectidforalltimes))
753 if ($action ==
'deleteline')
755 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
"lineid",
'int').($withproject ?
'&withproject=1' :
''), $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_delete",
'',
'', 1);
758 $param = ($withproject ?
'&withproject=1' :
'');
759 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
761 if (!
GETPOST(
'withproject') || empty($projectstatic->id))
763 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
764 $object->next_prev_filter =
" fk_projet in (".$projectsListId.
")";
765 }
else $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
770 if (empty($withproject))
772 $morehtmlref .=
'<div class="refidno">';
773 $morehtmlref .= $langs->trans(
"Project").
': ';
774 $morehtmlref .= $projectstatic->getNomUrl(1);
775 $morehtmlref .=
'<br>';
778 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
779 if (is_object($projectstatic->thirdparty)) {
780 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
782 $morehtmlref .=
'</div>';
785 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
787 print '<div class="fichecenter">';
788 print '<div class="fichehalfleft">';
790 print '<div class="underbanner clearboth"></div>';
791 print '<table class="border tableforfield centpercent">';
794 print '<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
796 print ($start ? $start :
'?');
799 print ($end ? $end :
'?');
804 print '<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
805 if ($object->planned_workload)
814 print '<div class="fichehalfright"><div class="ficheaddleft">';
816 print '<div class="underbanner clearboth"></div>';
817 print '<table class="border tableforfield centpercent">';
820 print '<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td>';
821 print $object->progress !=
'' ? $object->progress.
' %' :
'';
825 print '<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td>';
826 if ($object->planned_workload)
828 $tmparray = $object->getSummaryOfTimeSpent();
829 if ($tmparray[
'total_duration'] > 0)
print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
831 }
else print '<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
842 print '<div class="clearboth"></div>';
848 if ($projectstatic->id > 0)
850 if ($action ==
'deleteline' && !empty($projectidforalltimes))
852 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
'lineid',
'int').($withproject ?
'&withproject=1' :
''), $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_delete",
'',
'', 1);
856 $hookmanager->initHooks(array(
'tasktimelist'));
859 $arrayfields = array();
860 $arrayfields[
't.task_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
861 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
863 $arrayfields[
't.task_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
864 $arrayfields[
't.task_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
866 $arrayfields[
'author'] = array(
'label'=>$langs->trans(
"By"),
'checked'=>1);
867 $arrayfields[
't.note'] = array(
'label'=>$langs->trans(
"Note"),
'checked'=>1);
868 $arrayfields[
't.task_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
869 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
870 $arrayfields[
'valuebilled'] = array(
'label'=>$langs->trans(
"Billed"),
'checked'=>1,
'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time));
872 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
877 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
878 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
879 if ($search_month > 0) $param .=
'&search_month='.urlencode($search_month);
880 if ($search_year > 0) $param .=
'&search_year='.urlencode($search_year);
881 if ($search_user > 0) $param .=
'&search_user='.urlencode($search_user);
882 if ($search_task_ref !=
'') $param .=
'&search_task_ref='.urlencode($search_task_ref);
883 if ($search_task_label !=
'') $param .=
'&search_task_label='.urlencode($search_task_label);
884 if ($search_note !=
'') $param .=
'&search_note='.urlencode($search_note);
885 if ($search_duration !=
'') $param .=
'&search_field2='.urlencode($search_duration);
886 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
891 if ($id) $param .=
'&id='.urlencode($id);
892 if ($projectid) $param .=
'&projectid='.urlencode($projectid);
893 if ($withproject) $param .=
'&withproject='.urlencode($withproject);
895 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
896 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
897 print '<input type="hidden" name="token" value="'.newToken().
'">';
898 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
899 if ($action ==
'editline')
print '<input type="hidden" name="action" value="updateline">';
900 elseif ($action ==
'splitline')
print '<input
type="hidden"
name="action" value="updatesplitline">';
901 elseif ($action == 'createtime' && $user->rights->projet->lire)
print '<input
type="hidden"
name="action" value="addtimespent">';
902 elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire)
print '<input
type="hidden"
name="action" value="confirm_generateinvoice">';
904 print '<input
type="hidden"
name="sortfield" value="'.$sortfield.'">';
905 print '<input
type="hidden"
name="sortorder" value="'.$sortorder.'">';
908 print '<input
type="hidden"
name="projectid" value="'.$projectidforalltimes.'">';
909 print '<input
type="hidden"
name="withproject" value="'.$withproject.'">';
913 if ($massaction == 'generateinvoice')
915 print '<input type="hidden" name="massaction" value="confirm_createbills">';
917 if ($projectstatic->thirdparty->id > 0) {
918 print '<table class="noborder" width="100%" >';
920 print '<td class="titlefield">';
921 print $langs->trans(
'DateInvoice');
924 print $form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
930 print $langs->trans(
'Mode');
934 'onelineperuser'=>
'OneLinePerUser',
935 'onelinepertask'=>
'OneLinePerTask',
936 'onelineperperiod'=>
'OneLinePerPeriod',
938 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
942 if ($conf->service->enabled)
946 print $langs->trans(
'ServiceToUseOnLines');
949 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
955 print '<td class="titlefield">';
956 print $langs->trans(
'InvoiceToUse');
959 $form->selectInvoice(
'invoice',
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
973 print '<div class="center">';
974 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'GenerateBill').
'"> ';
975 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
979 print '<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateInvoice").
'</div>';
980 print '<div class="center">';
981 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
992 $sql =
"SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,";
993 $sql .=
" pt.ref, pt.label,";
994 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
995 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut";
996 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
997 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
998 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture,";
999 $sql .=
" ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"user as u";
1000 $sql .=
" WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
1001 if (empty($projectidforalltimes)) $sql .=
" AND t.fk_task =".$object->id;
1002 else $sql .=
" AND pt.fk_projet IN (".$projectidforalltimes.
")";
1003 if ($search_note) $sql .=
natural_search(
't.note', $search_note);
1004 if ($search_task_ref) $sql .=
natural_search(
'pt.ref', $search_task_ref);
1005 if ($search_task_label) $sql .=
natural_search(
'pt.label', $search_task_label);
1006 if ($search_user > 0) $sql .=
natural_search(
't.fk_user', $search_user);
1007 if ($search_valuebilled ==
'1') $sql .=
' AND t.invoice_id > 0';
1008 if ($search_valuebilled ==
'0') $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1009 $sql .=
dolSqlDateFilter(
't.task_datehour', $search_day, $search_month, $search_year);
1010 $sql .= $db->order($sortfield, $sortorder);
1013 $nbtotalofrecords =
'';
1014 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
1016 $resql = $db->query($sql);
1017 $nbtotalofrecords = $db->num_rows(
$resql);
1018 if (($page * $limit) > $nbtotalofrecords)
1025 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
1027 $num = $nbtotalofrecords;
1029 $sql .= $db->plimit($limit + 1, $offset);
1031 $resql = $db->query($sql);
1038 $num = $db->num_rows(
$resql);
1043 if (!empty($projectidforalltimes))
1045 print '<!-- List of time spent for project -->'.
"\n";
1047 $title = $langs->trans(
"ListTaskTimeUserProject");
1049 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1051 print '<!-- List of time spent for project -->'.
"\n";
1053 $title = $langs->trans(
"ListTaskTimeForTask");
1055 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1061 $row = $db->fetch_object(
$resql);
1073 if ($action ==
'createtime' && $user->rights->projet->lire)
1075 print '<!-- table to add time spent -->'.
"\n";
1076 if (!empty($id))
print '<input type="hidden" name="taskid" value="'.$id.
'">';
1078 print '<div class="div-table-responsive-no-min">';
1079 print '<table class="noborder nohover centpercent">';
1081 print '<tr class="liste_titre">';
1082 print '<td>'.$langs->trans(
"Date").
'</td>';
1083 if (empty($id))
print '<td>'.$langs->trans(
"Task").
'</td>';
1084 print '<td>'.$langs->trans(
"By").
'</td>';
1085 print '<td>'.$langs->trans(
"Note").
'</td>';
1086 print '<td>'.$langs->trans(
"NewTimeSpent").
'</td>';
1087 print '<td>'.$langs->trans(
"ProgressDeclared").
'</td>';
1088 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT))
1095 print '<tr class="oddeven nohover">';
1098 print '<td class="maxwidthonsmartphone">';
1101 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1108 print '<td class="maxwidthonsmartphone">';
1109 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
1114 print '<td class="maxwidthonsmartphone nowraponall">';
1115 $contactsofproject = $projectstatic->getListContactId(
'internal');
1116 if (count($contactsofproject) > 0)
1119 if (in_array($user->id, $contactsofproject)) $userid = $user->id;
1120 else $userid = $contactsofproject[0];
1122 if ($projectstatic->public) $contactsofproject = array();
1123 print $form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'maxwidth250');
1126 print img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).
' '.$langs->trans(
'FirstAddRessourceToAllocateTime');
1133 print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.
'">'.($_POST[
'timespent_note'] ? $_POST[
'timespent_note'] :
'').
'</textarea>';
1138 $durationtouse = ($_POST[
'timespent_duration'] ? $_POST[
'timespent_duration'] :
'');
1141 $durationtouse = (
GETPOST(
'timespent_durationhour') * 3600 +
GETPOST(
'timespent_durationmin') * 60);
1143 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1147 print '<td class="nowrap">';
1148 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1152 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT))
1158 print '<td class="center">';
1159 print '<input type="submit" name="save" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort" value="'.$langs->trans(
"Add").
'">';
1160 print '<input type="submit" name="cancel" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1169 $moreforfilter =
'';
1171 $parameters = array();
1172 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1173 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
1174 else $moreforfilter = $hookmanager->resPrint;
1176 if (!empty($moreforfilter))
1178 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1179 print $moreforfilter;
1183 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
1184 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1185 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1187 print '<div class="div-table-responsive">';
1188 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1191 print '<tr class="liste_titre_filter">';
1193 if (!empty($arrayfields[
't.task_date'][
'checked']))
1195 print
'<td class="liste_titre">';
1196 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.
'">';
1197 print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.
'">';
1198 $formother->select_year($search_year,
'search_year', 1, 20, 5);
1201 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1203 if (!empty($arrayfields[
't.task_ref'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1204 if (!empty($arrayfields[
't.task_label'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1207 if (!empty($arrayfields[
'author'][
'checked'])) print
'<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1),
'search_user', 1, null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250').
'</td>';
1209 if (!empty($arrayfields[
't.note'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).
'"></td>';
1211 if (!empty($arrayfields[
't.task_duration'][
'checked'])) print
'<td class="liste_titre right"></td>';
1213 if (!empty($arrayfields[
'value'][
'checked'])) print
'<td class="liste_titre"></td>';
1215 if (!empty($arrayfields[
'valuebilled'][
'checked'])) print
'<td class="liste_titre center">'.$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1).
'</td>';
1222 $parameters = array(
'arrayfields'=>$arrayfields);
1223 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1224 print $hookmanager->resPrint;
1226 print
'<td class="liste_titre center">';
1227 $searchpicto = $form->showFilterButtons();
1232 print
'<tr class="liste_titre">';
1233 if (!empty($arrayfields[
't.task_date'][
'checked']))
print_liste_field_titre($arrayfields[
't.task_date'][
'label'],
$_SERVER[
'PHP_SELF'],
't.task_date,t.task_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
1234 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1236 if (!empty($arrayfields[
't.task_ref'][
'checked']))
print_liste_field_titre($arrayfields[
't.task_ref'][
'label'],
$_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
1237 if (!empty($arrayfields[
't.task_label'][
'checked']))
print_liste_field_titre($arrayfields[
't.task_label'][
'label'],
$_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
1239 if (!empty($arrayfields[
'author'][
'checked']))
print_liste_field_titre($arrayfields[
'author'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1240 if (!empty($arrayfields[
't.note'][
'checked']))
print_liste_field_titre($arrayfields[
't.note'][
'label'],
$_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
1241 if (!empty($arrayfields[
't.task_duration'][
'checked']))
print_liste_field_titre($arrayfields[
't.task_duration'][
'label'],
$_SERVER[
'PHP_SELF'],
't.task_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
1242 if (!empty($arrayfields[
'value'][
'checked']))
print_liste_field_titre($arrayfields[
'value'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1243 if (!empty($arrayfields[
'valuebilled'][
'checked']))
print_liste_field_titre($arrayfields[
'valuebilled'][
'label'],
$_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ');
1249 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1250 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1251 print $hookmanager->resPrint;
1255 $tasktmp =
new Task($db);
1256 $tmpinvoice =
new Facture($db);
1260 $childids = $user->getAllChildIds();
1264 $totalarray = array();
1265 foreach ($tasks as $task_time)
1267 if ($i >= $limit)
break;
1269 print
'<tr class="oddeven">';
1271 $date1 = $db->jdate($task_time->task_date);
1272 $date2 = $db->jdate($task_time->task_datehour);
1275 if (!empty($arrayfields[
't.task_date'][
'checked']))
1277 print
'<td class="nowrap">';
1278 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1280 if (empty($task_time->task_date_withhour))
1282 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1283 }
else print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1285 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1288 if (!$i) $totalarray[
'nbfield']++;
1292 if (!empty($arrayfields[
't.task_ref'][
'checked']))
1294 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1296 print
'<td class="nowrap">';
1297 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1299 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_task,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
1301 $tasktmp->id = $task_time->fk_task;
1302 $tasktmp->ref = $task_time->ref;
1303 $tasktmp->label = $task_time->label;
1304 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1307 if (!$i) $totalarray[
'nbfield']++;
1310 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1314 if (!empty($arrayfields[
't.task_label'][
'checked']))
1316 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1318 print
'<td class="nowrap">';
1319 print $task_time->label;
1321 if (!$i) $totalarray[
'nbfield']++;
1326 if (!empty($arrayfields[
'author'][
'checked']))
1328 print
'<td class="nowrap">';
1329 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1331 if (empty($object->id)) $object->fetch($id);
1332 $contactsoftask = $object->getListContactId(
'internal');
1333 if (!in_array($task_time->fk_user, $contactsoftask)) {
1334 $contactsoftask[] = $task_time->fk_user;
1336 if (count($contactsoftask) > 0) {
1337 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1338 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
1340 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1343 $userstatic->id = $task_time->fk_user;
1344 $userstatic->lastname = $task_time->lastname;
1345 $userstatic->firstname = $task_time->firstname;
1346 $userstatic->photo = $task_time->photo;
1347 $userstatic->statut = $task_time->user_status;
1348 print $userstatic->getNomUrl(-1);
1351 if (!$i) $totalarray[
'nbfield']++;
1355 if (!empty($arrayfields[
't.note'][
'checked']))
1357 print
'<td class="left">';
1358 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1360 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.
'">'.$task_time->note.
'</textarea>';
1365 if (!$i) $totalarray[
'nbfield']++;
1366 } elseif ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1368 print
'<input type="hidden" name="timespent_note_line" value="'.$task_time->note.
'">';
1372 if (!empty($arrayfields[
't.task_duration'][
'checked']))
1374 print
'<td class="right">';
1375 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid)
1377 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
1378 print $form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
1383 if (!$i) $totalarray[
'nbfield']++;
1384 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.task_duration';
1385 $totalarray[
'val'][
't.task_duration'] += $task_time->task_duration;
1386 if (!$i) $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
1387 $totalarray[
'totalduration'] += $task_time->task_duration;
1391 if (!empty($arrayfields[
'value'][
'checked']))
1393 print
'<td class="nowraponall right">';
1394 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
1395 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
1397 if (!$i) $totalarray[
'nbfield']++;
1398 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
1399 $totalarray[
'val'][
'value'] += $value;
1400 if (!$i) $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
1401 $totalarray[
'totalvalue'] += $value;
1405 if (!empty($arrayfields[
'valuebilled'][
'checked']))
1407 print
'<td class="center">';
1408 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT))
1410 if ($projectstatic->usage_bill_time)
1412 if ($task_time->invoice_id)
1414 $result = $tmpinvoice->fetch($task_time->invoice_id);
1417 print $tmpinvoice->getNomUrl(1);
1420 print $langs->trans(
"No");
1423 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
1427 if (!$i) $totalarray[
'nbfield']++;
1436 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'i'=>$i,
'totalarray'=>&$totalarray);
1437 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1438 print $hookmanager->resPrint;
1441 print
'<td class="center nowraponall">';
1442 if (($action ==
'editline' || $action ==
'splitline') && $_GET[
'lineid'] == $task_time->rowid)
1444 print
'<input type="hidden" name="lineid" value="'.$_GET[
'lineid'].
'">';
1445 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
1447 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1448 } elseif ($user->rights->projet->lire || $user->rights->projet->all->creer)
1450 if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer)
1452 if ($conf->MAIN_FEATURES_LEVEL >= 2)
1455 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_task.
'&action=splitline&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1461 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_task.
'&action=editline&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1466 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_task.
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1467 print
img_delete(
'default',
'class="pictodelete paddingleft"');
1470 if ($massactionbutton || $massaction)
1473 if (in_array($task_time->rowid, $arrayofselected)) $selected = 1;
1475 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1480 if (!$i) $totalarray[
'nbfield']++;
1487 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1489 print
'<tr class="oddeven">';
1492 if (!empty($arrayfields[
't.task_date'][
'checked']))
1494 print
'<td class="nowrap">';
1495 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1497 if (empty($task_time->task_date_withhour))
1499 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1500 }
else print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1502 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1508 if (!empty($arrayfields[
't.task_ref'][
'checked']))
1510 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1512 print
'<td class="nowrap">';
1513 $tasktmp->id = $task_time->fk_task;
1514 $tasktmp->ref = $task_time->ref;
1515 $tasktmp->label = $task_time->label;
1516 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1522 if (!empty($arrayfields[
't.task_label'][
'checked']))
1524 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1527 print $task_time->label;
1533 if (!empty($arrayfields[
'author'][
'checked']))
1536 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1538 if (empty($object->id)) $object->fetch($id);
1539 $contactsoftask = $object->getListContactId(
'internal');
1540 if (!in_array($task_time->fk_user, $contactsoftask)) {
1541 $contactsoftask[] = $task_time->fk_user;
1543 if (count($contactsoftask) > 0) {
1544 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1545 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
1547 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1550 $userstatic->id = $task_time->fk_user;
1551 $userstatic->lastname = $task_time->lastname;
1552 $userstatic->firstname = $task_time->firstname;
1553 $userstatic->photo = $task_time->photo;
1554 $userstatic->statut = $task_time->user_status;
1555 print $userstatic->getNomUrl(-1);
1561 if (!empty($arrayfields[
't.note'][
'checked']))
1563 print
'<td class="left">';
1564 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1566 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.
'">'.$task_time->note.
'</textarea>';
1571 } elseif ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1573 print
'<input type="hidden" name="timespent_note_line" value="'.$task_time->note.
'">';
1577 if (!empty($arrayfields[
't.task_duration'][
'checked']))
1579 print
'<td class="right">';
1580 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1582 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
1583 print $form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
1591 if (!empty($arrayfields[
'value'][
'checked']))
1593 print
'<td class="right">';
1594 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
1595 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
1600 if (!empty($arrayfields[
'valuebilled'][
'checked']))
1602 print
'<td class="right">';
1603 $valuebilled =
price2num($task_time->total_ht,
'', 1);
1604 if (isset($task_time->total_ht)) print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
1614 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time);
1615 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1616 print $hookmanager->resPrint;
1619 print
'<td class="center nowraponall">';
1627 print
'<tr class="oddeven">';
1630 if (!empty($arrayfields[
't.task_date'][
'checked']))
1632 print
'<td class="nowrap">';
1633 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1635 if (empty($task_time->task_date_withhour))
1637 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
1638 }
else print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
1640 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1646 if (!empty($arrayfields[
't.task_ref'][
'checked']))
1648 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1650 print
'<td class="nowrap">';
1651 $tasktmp->id = $task_time->fk_task;
1652 $tasktmp->ref = $task_time->ref;
1653 $tasktmp->label = $task_time->label;
1654 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1660 if (!empty($arrayfields[
't.task_label'][
'checked']))
1662 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes))
1664 print
'<td class="nowrap">';
1665 print $task_time->label;
1671 if (!empty($arrayfields[
'author'][
'checked']))
1674 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1676 if (empty($object->id)) $object->fetch($id);
1677 $contactsoftask = $object->getListContactId(
'internal');
1678 if (!in_array($task_time->fk_user, $contactsoftask)) {
1679 $contactsoftask[] = $task_time->fk_user;
1681 if (count($contactsoftask) > 0) {
1682 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1683 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
1685 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1688 $userstatic->id = $task_time->fk_user;
1689 $userstatic->lastname = $task_time->lastname;
1690 $userstatic->firstname = $task_time->firstname;
1691 $userstatic->photo = $task_time->photo;
1692 $userstatic->statut = $task_time->user_status;
1693 print $userstatic->getNomUrl(-1);
1699 if (!empty($arrayfields[
't.note'][
'checked']))
1701 print
'<td class="left">';
1702 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1704 print
'<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_2.
'">'.$task_time->note.
'</textarea>';
1709 } elseif ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1711 print
'<input type="hidden" name="timespent_note_line_2" value="'.$task_time->note.
'">';
1715 if (!empty($arrayfields[
't.task_duration'][
'checked']))
1717 print
'<td class="right">';
1718 if ($action ==
'splitline' && $_GET[
'lineid'] == $task_time->rowid)
1720 print
'<input type="hidden" name="old_duration_2" value="0">';
1721 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
1729 if (!empty($arrayfields[
'value'][
'checked']))
1731 print
'<td class="right">';
1733 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
1738 if (!empty($arrayfields[
'valuebilled'][
'checked']))
1740 print
'<td class="right">';
1741 $valuebilled =
price2num($task_time->total_ht,
'', 1);
1742 if (isset($task_time->total_ht)) print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
1752 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time);
1753 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1754 print $hookmanager->resPrint;
1757 print
'<td class="center nowraponall">';
1768 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield']))
1770 print
'<tr class="liste_total">';
1772 while ($i < $totalarray[
'nbfield'])
1777 if ($num < $limit && empty($offset)) print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
1778 else print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
1779 } elseif ($totalarray[
'totaldurationfield'] == $i) print '<td class="right">'.
convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';
1780 elseif ($totalarray['totalvaluefield'] == $i) print '<td class="right">'.
price($totalarray['totalvalue']).'</td>';
1782 else print '<td></td>';
1789 $totalnboffields = 1;
1790 foreach ($arrayfields as $value)
1792 if ($value[
'checked']) $totalnboffields++;
1794 print
'<tr class="oddeven"><td colspan="'.$totalnboffields.
'">';
1795 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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...
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Class to manage products or services.
Class to manage Dolibarr users.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
$conf db name
Only used if Module[ID]Name translation string is not found.
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.
img_error($titlealt= 'default')
Show error logo.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) Si ...
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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 ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
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.
Class to manage invoices.
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
img_split($titlealt= 'default', $other= 'class="pictosplit"')
Show split logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.