36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56@phan-var-force ?string $uploaddir
60$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61if (isModEnabled(
'eventorganization')) {
62 $langsLoad[] =
'eventorganization';
65$langs->loadLangs($langsLoad);
67$action =
GETPOST(
'action',
'alpha');
68$massaction =
GETPOST(
'massaction',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$cancel =
GETPOST(
'cancel',
'alpha');
71$toselect =
GETPOST(
'toselect',
'array');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
73$backtopage =
GETPOST(
'backtopage',
'alpha');
74$optioncss =
GETPOST(
'optioncss',
'alpha');
75$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
136$projectstatic =
new Project($db);
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
142$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
145if ($id > 0 || $ref) {
153if (!$user->hasRight(
'projet',
'lire')) {
162 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
163 $search_user = $user->id;
173if (
GETPOST(
'cancel',
'alpha')) {
176if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
180$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
181$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
186include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
189if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
194 $search_duration =
'';
195 $search_date_startday =
'';
196 $search_date_startmonth =
'';
197 $search_date_startyear =
'';
198 $search_date_endday =
'';
199 $search_date_endmonth =
'';
200 $search_date_endyear =
'';
201 $search_date_start =
'';
202 $search_date_end =
'';
203 $search_task_ref =
'';
204 $search_company =
'';
205 $search_company_alias =
'';
206 $search_project_ref =
'';
207 $search_project_label =
'';
208 $search_task_label =
'';
210 $search_valuebilled =
'';
211 $search_product_ref =
'';
213 $search_array_options = array();
214 $search_timespent_starthour =
'';
215 $search_timespent_startmin =
'';
216 $search_timespent_endhour =
'';
217 $search_timespent_endmin =
'';
221if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
222 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
223 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
224 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
225 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
229 $langs->load(
"errors");
230 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
239 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
240 $action =
'createtime';
250 if (empty(
$object->project->status)) {
251 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
252 $action =
'createtime';
263 $object->timespent_withhour = 1;
266 $object->timespent_withhour = 0;
271 $result =
$object->addTimeSpent($user);
282 $action =
'createtime';
286if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
287 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
288 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
304 $object->fetch($id_temp, $ref);
306 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
310 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
312 $object->timespent_withhour = 1;
313 } elseif (!empty($timespent_date)) {
314 $object->timespent_date = $timespent_date;
315 $object->timespent_withhour = 0;
323 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
324 $result =
$object->updateTimeSpent($user);
337 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
341 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
344 $object->timespent_withhour = 1;
345 } elseif (!empty($timespent_date)) {
346 $object->timespent_date = $timespent_date;
347 $object->timespent_datehour = $timespent_date;
348 $object->timespent_withhour = 0;
356 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
357 $result =
$object->updateTimeSpent($user);
372if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
375 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
376 $result =
$object->delTimeSpent($user);
379 $langs->load(
"errors");
390if (!empty($project_ref) && !empty($withproject)) {
391 if ($projectstatic->fetch(0, $project_ref) > 0) {
392 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
393 if (count($tasksarray) > 0) {
394 $id = $tasksarray[0]->id;
396 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
403$projectidforalltimes = 0;
405 $projectidforalltimes =
GETPOSTINT(
'projectid');
407 $result = $projectstatic->fetch($projectidforalltimes);
408 if (!empty($projectstatic->socid)) {
409 $projectstatic->fetch_thirdparty();
411 $res = $projectstatic->fetch_optionals();
412} elseif (
GETPOST(
'project_ref',
'alpha')) {
413 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
414 $projectidforalltimes = $projectstatic->id;
418 $result = $projectstatic->fetch(
$object->fk_project);
421$allprojectforuser = 0;
422if ($id <= 0 && $projectidforalltimes == 0) {
423 $allprojectforuser = $user->id;
426if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
427 if (!empty($projectstatic->socid)) {
428 $projectstatic->fetch_thirdparty();
431 if (!($projectstatic->thirdparty->id > 0)) {
432 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
434 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
435 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
436 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
438 $tmpinvoice =
new Facture($db);
439 $tmptimespent =
new Task($db);
440 $tmpproduct =
new Product($db);
441 $fuser =
new User($db);
446 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
449 $prodDurationHoursBase = 1.0;
450 $product_data_cache = array();
452 $tmpproduct->fetch($idprod);
458 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
459 if ($prodDurationHoursBase < 0) {
461 $langs->load(
"errors");
465 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
467 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
468 $txtva = $dataforprice[
'tva_tx'];
469 $localtax1 = $dataforprice[
'localtax1'];
470 $localtax2 = $dataforprice[
'localtax2'];
472 $prodDurationHoursBase = 1;
480 $tmpinvoice->socid = $projectstatic->thirdparty->id;
482 $tmpinvoice->fk_project = $projectstatic->id;
483 $tmpinvoice->cond_reglement_id = $condidproject;
484 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
485 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
488 $tmpinvoice->fetch($invoiceToUse);
490 $result = $tmpinvoice->create($user);
498 if ($generateinvoicemode ==
'onelineperuser') {
499 $arrayoftasks = array();
500 foreach ($toselect as $key => $value) {
502 $object->fetchTimeSpent($value);
503 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
504 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
507 foreach ($arrayoftasks as $userid => $data) {
508 $fuser->fetch($userid);
509 $username = $fuser->getFullName($langs);
511 foreach ($data as $fk_product => $timespent_data) {
513 $qtyhour = $timespent_data[
'timespent'] / 3600;
520 } elseif ($idprod <= 0) {
523 $pu_ht = $fuser->thm;
528 if ($timespent_data[
'timespent']) {
529 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
534 $prodDurationHours = $prodDurationHoursBase;
535 $idprodline = $idprod;
538 $localtax1line = $localtax1;
539 $localtax2line = $localtax2;
542 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
543 if (!array_key_exists($fk_product, $product_data_cache)) {
544 $result = $tmpproduct->fetch($fk_product);
549 $prodDurationHours = $tmpproduct->getProductDurationHours();
550 if ($prodDurationHours < 0) {
552 $langs->load(
"errors");
556 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
558 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
559 $txtvaline = $dataforprice[
'tva_tx'];
560 $localtax1line = $dataforprice[
'localtax1'];
561 $localtax2line = $dataforprice[
'localtax2'];
563 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
565 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
566 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
567 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
568 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
569 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
571 $idprodline = $fk_product;
578 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice").
' - '.$username .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
585 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
586 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
587 $result = $db->query($sql);
595 } elseif ($generateinvoicemode ==
'onelineperperiod') {
596 $arrayoftasks = array();
598 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
599 foreach ($toselect as $key => $value) {
601 $object->fetchTimeSpent($value);
603 $ftask =
new Task($db);
606 $fuser->fetch(
$object->timespent_fk_user);
607 $username = $fuser->getFullName($langs);
609 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
610 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
611 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
614 if (!empty($withdetail)) {
615 if (!empty(
$object->timespent_withhour)) {
622 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
623 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
626 $pu_ht_saved = $pu_ht;
627 foreach ($arrayoftasks as $timespent_id => $value) {
628 $pu_ht = $pu_ht_saved;
629 $userid = $value[
'user'];
633 $qtyhour = $value[
'timespent'] / 3600;
637 if ($value[
'timespent']) {
638 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
643 $prodDurationHours = $prodDurationHoursBase;
644 $idprodline = $idprod;
647 $localtax1line = $localtax1;
648 $localtax2line = $localtax2;
650 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
651 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
652 $result = $tmpproduct->fetch($value[
'fk_product']);
657 $prodDurationHours = $tmpproduct->getProductDurationHours();
658 if ($prodDurationHours < 0) {
660 $langs->load(
"errors");
664 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
666 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
667 $txtvaline = $dataforprice[
'tva_tx'];
668 $localtax1line = $dataforprice[
'localtax1'];
669 $localtax2line = $dataforprice[
'localtax2'];
671 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
673 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
674 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
675 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
676 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
677 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
679 $idprodline = $value[
'fk_product'];
685 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
693 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
694 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
695 $result = $db->query($sql);
702 } elseif ($generateinvoicemode ==
'onelinepertask') {
703 $arrayoftasks = array();
704 foreach ($toselect as $key => $value) {
706 $object->fetchTimeSpent($value);
708 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
709 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
712 foreach ($arrayoftasks as $task_id => $data) {
713 $ftask =
new Task($db);
714 $ftask->fetch($task_id);
716 foreach ($data as $fk_product => $timespent_data) {
717 $qtyhour = $timespent_data[
'timespent'] / 3600;
721 $prodDurationHours = $prodDurationHoursBase;
722 $idprodline = $idprod;
725 $localtax1line = $localtax1;
726 $localtax2line = $localtax2;
728 if (!empty($fk_product) && $fk_product !== $idprod) {
729 if (!array_key_exists($fk_product, $product_data_cache)) {
730 $result = $tmpproduct->fetch($fk_product);
735 $prodDurationHours = $tmpproduct->getProductDurationHours();
736 if ($prodDurationHours < 0) {
738 $langs->load(
"errors");
742 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
744 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
745 $txtvaline = $dataforprice[
'tva_tx'];
746 $localtax1line = $dataforprice[
'localtax1'];
747 $localtax2line = $dataforprice[
'localtax2'];
749 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
751 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
752 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
753 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
754 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
755 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
757 $idprodline = $fk_product;
761 if ($idprodline > 0) {
763 $pu_ht_for_task = $pu_htline;
766 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
768 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
774 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
776 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
782 $lineName = $ftask->ref .
' - ' . $ftask->label;
783 $lineid = $tmpinvoice->addline($lineName, (
float) $pu_ht_for_task, (
float)
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject, $date_start, $date_end, 0, 0, 0,
'HT', 0, 1, -1, 0,
'', 0, 0, 0, $pa_ht);
792 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
793 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
794 $result = $db->query($sql);
807 $urltoinvoice = $tmpinvoice->getNomUrl(0);
808 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
809 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
819if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
820 $langs->load(
'interventions');
822 if (!empty($projectstatic->socid)) {
823 $projectstatic->fetch_thirdparty();
826 if (!($projectstatic->thirdparty->id > 0)) {
827 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
829 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
830 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
831 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
834 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
836 $tmptimespent =
new Task($db);
837 $fuser =
new User($db);
843 $tmpinter->socid = $projectstatic->thirdparty->id;
845 $tmpinter->fk_project = $projectstatic->id;
846 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
849 $tmpinter->fetch($interToUse);
851 $result = $tmpinter->create($user);
859 $arrayoftasks = array();
860 foreach ($toselect as $key => $value) {
862 $object->fetchTimeSpent($value);
865 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
866 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
867 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
868 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
871 foreach ($arrayoftasks as $timespent_id => $value) {
872 $ftask =
new Task($db);
873 $ftask->fetch($value[
'id']);
875 $qtyhour = $value[
'timespent'] / 3600;
879 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
884 $timespent->fetch($timespent_id);
885 $timespent->intervention_id = $tmpinter->id;
886 $timespent->intervention_line_id = $lineid;
887 $result = $timespent->update($user);
897 $urltointer = $tmpinter->getNomUrl(0);
898 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
899 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
916$form =
new Form($db);
919$userstatic =
new User($db);
921$arrayofselected = is_array($toselect) ? $toselect : array();
923$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
924if (!empty($withproject)) {
925 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
929llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
931if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
935 if ($projectidforalltimes > 0) {
936 $result = $projectstatic->fetch($projectidforalltimes);
937 if (!empty($projectstatic->socid)) {
938 $projectstatic->fetch_thirdparty();
940 $res = $projectstatic->fetch_optionals();
941 } elseif (
$object->fetch($id, $ref) >= 0) {
942 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
945 $result = $projectstatic->fetch(
$object->fk_project);
946 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
947 $projectstatic->fetchComments();
949 if (!empty($projectstatic->socid)) {
950 $projectstatic->fetch_thirdparty();
952 $res = $projectstatic->fetch_optionals();
954 $object->project = clone $projectstatic;
957 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
958 $linktocreatetime =
'';
960 if ($projectstatic->id > 0) {
963 if (empty($id) || $tab ==
'timespent') {
970 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
972 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
974 $param .=
'&search_user=' . ((int) $search_user);
977 $param .=
'&search_month=' . ((int) $search_month);
980 $param .=
'&search_year=' . ((int) $search_year);
985 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
987 $morehtmlref =
'<div class="refidno">';
989 $morehtmlref .= $projectstatic->title;
991 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
992 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
994 $morehtmlref .=
'</div>';
997 if (!$user->hasRight(
'projet',
'all',
'lire')) {
998 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
999 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1002 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1004 print
'<div class="fichecenter">';
1005 print
'<div class="fichehalfleft">';
1006 print
'<div class="underbanner clearboth"></div>';
1008 print
'<table class="border tableforfield centpercent">';
1012 print
'<tr><td class="tdtop">';
1013 print $langs->trans(
"Usage");
1017 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1018 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1019 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1023 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1024 $htmltext = $langs->trans(
"ProjectFollowTasks");
1025 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1029 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"' :
'')) .
'"> ';
1030 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1031 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1034 if (isModEnabled(
'eventorganization')) {
1035 print
'<input type="checkbox" disabled name="usage_organize_event"' . (GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_organize_event ?
' checked="checked"' :
'')) .
'"> ';
1036 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1037 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1043 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1044 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1045 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1050 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1052 print($start ? $start :
'?');
1055 print($end ? $end :
'?');
1056 if ($projectstatic->hasDelay()) {
1062 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1063 if ($projectstatic->public) {
1064 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1065 print $langs->trans(
'SharedProject');
1067 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1068 print $langs->trans(
'PrivateProject');
1076 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1082 print
'<div class="fichehalfright">';
1083 print
'<div class="underbanner clearboth"></div>';
1085 print
'<table class="border tableforfield centpercent">';
1088 if (isModEnabled(
'category')) {
1089 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1090 print $form->showCategories($projectstatic->id,
'project', 1);
1095 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1096 if ($projectstatic->description) {
1097 print
'<tr><td class="nottitleforfield" colspan="2">';
1098 print
'<div class="longmessagecut">';
1109 print
'<div class="clearboth"></div>';
1119 $linktocreatetimeBtnStatus = 0;
1120 $linktocreatetimeUrl =
'';
1121 $linktocreatetimeHelpText =
'';
1122 if ($user->hasRight(
'projet',
'time')) {
1123 if ($projectstatic->public || $userRead > 0) {
1124 $linktocreatetimeBtnStatus = 1;
1126 if (!empty($projectidforalltimes)) {
1128 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1129 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1132 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1133 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1136 $linktocreatetimeBtnStatus = -2;
1137 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1140 $linktocreatetimeBtnStatus = -2;
1141 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1144 $paramsbutton = array(
'morecss' =>
'reposition');
1145 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1148 $massactionbutton =
'';
1149 $arrayofmassactions = array();
1151 if ($projectstatic->id > 0) {
1153 if ($projectstatic->usage_bill_time) {
1154 $arrayofmassactions = array(
1155 'generateinvoice' => $langs->trans(
"GenerateBill"),
1159 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1160 $langs->load(
"interventions");
1161 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1165 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1166 $arrayofmassactions = array();
1168 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1173 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1175 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1177 if ($action ==
'deleteline') {
1178 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1179 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1182 $param = ($withproject ?
'&withproject=1' :
'');
1183 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1184 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1186 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1187 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1188 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1190 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1196 if (empty($withproject)) {
1197 $morehtmlref .=
'<div class="refidno">';
1198 $morehtmlref .= $langs->trans(
"Project") .
': ';
1199 $morehtmlref .= $projectstatic->getNomUrl(1);
1200 $morehtmlref .=
'<br>';
1203 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1204 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1205 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1207 $morehtmlref .=
'</div>';
1210 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1212 print
'<div class="fichecenter">';
1213 print
'<div class="fichehalfleft">';
1215 print
'<div class="underbanner clearboth"></div>';
1216 print
'<table class="border centpercent tableforfield">';
1219 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1220 if (
$object->fk_task_parent > 0) {
1221 $tasktmp =
new Task($db);
1222 $tasktmp->fetch(
$object->fk_task_parent);
1223 print $tasktmp->getNomUrl(1);
1228 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1230 print($start ? $start :
'?');
1233 print($end ? $end :
'?');
1240 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1241 if (
$object->planned_workload) {
1249 print
'<div class="fichehalfright">';
1251 print
'<div class="underbanner clearboth"></div>';
1252 print
'<table class="border tableforfield centpercent">';
1255 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1260 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1261 if (
$object->planned_workload) {
1262 $tmparray =
$object->getSummaryOfTimeSpent();
1263 if ($tmparray[
'total_duration'] > 0) {
1264 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1269 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1280 print
'<div class="clearboth"></div>';
1284 if ($action ==
'deleteline') {
1285 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1286 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1291 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1293 $hookmanager->initHooks(array(
'tasktimelist'));
1297 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1299 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($projectstatic->id > 0 ?
'projectid=' . $projectstatic->id : (
$object->id > 0 ?
"id=" .
$object->id :
'')) .
'&lineid=' .
GETPOSTINT(
'lineid') . ($withproject ?
'&withproject=1' :
'') .
"&contextpage=" . urlencode($contextpage);
1300 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1304 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1305 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1306 if (empty($reshook)) {
1307 $formconfirm .= $hookmanager->resPrint;
1308 } elseif ($reshook > 0) {
1309 $formconfirm = $hookmanager->resPrint;
1316 $arrayfields = array();
1317 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1318 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1319 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1320 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1321 if (! empty($allprojectforuser)) {
1322 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1323 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1325 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1326 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1328 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1329 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1330 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1331 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1333 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1334 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int) isModEnabled(
"salaries"));
1335 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' =>
'1',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1337 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1342 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1343 $param .=
'&contextpage=' . urlencode($contextpage);
1345 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1346 $param .=
'&limit='.((int) $limit);
1348 if ($search_month > 0) {
1349 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1351 if ($search_year > 0) {
1352 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1354 if (!empty($search_user)) {
1355 $param .=
'&search_user='.urlencode($search_user);
1357 if ($search_task_ref !=
'') {
1358 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1360 if ($search_company !=
'') {
1361 $param .=
'&$search_company=' . urlencode($search_company);
1363 if ($search_company_alias !=
'') {
1364 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1366 if ($search_project_ref !=
'') {
1367 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1369 if ($search_project_label !=
'') {
1370 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1372 if ($search_task_label !=
'') {
1373 $param .=
'&search_task_label=' . urlencode($search_task_label);
1375 if ($search_note !=
'') {
1376 $param .=
'&search_note=' . urlencode($search_note);
1378 if ($search_duration !=
'') {
1379 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1381 if ($optioncss !=
'') {
1382 $param .=
'&optioncss=' . urlencode($optioncss);
1384 if ($search_date_startday) {
1385 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1387 if ($search_date_startmonth) {
1388 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1390 if ($search_date_startyear) {
1391 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1393 if ($search_date_endday) {
1394 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1396 if ($search_date_endmonth) {
1397 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1399 if ($search_date_endyear) {
1400 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1402 if ($search_timespent_starthour) {
1403 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1405 if ($search_timespent_startmin) {
1406 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1408 if ($search_timespent_endhour) {
1409 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1411 if ($search_timespent_endmin) {
1412 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1416 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1418 $param .=
'&id=' . urlencode((
string) ($id));
1421 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1424 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1427 $parameters = array(
'param' => &$param);
1428 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1429 $param .= $hookmanager->resPrint;
1431 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1432 if ($optioncss !=
'') {
1433 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1435 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1436 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1437 if ($action ==
'editline') {
1438 print
'<input type="hidden" name="action" value="updateline">';
1439 } elseif ($action ==
'splitline') {
1440 print
'<input type="hidden" name="action" value="updatesplitline">';
1441 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1442 print
'<input type="hidden" name="action" value="addtimespent">';
1443 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1444 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1445 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1446 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1448 print
'<input type="hidden" name="action" value="list">';
1450 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1451 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1453 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1454 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1455 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1456 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1457 print
'<input type="hidden" name="page_y" value="">';
1460 if ($massaction ==
'generateinvoice') {
1461 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1462 print
'<table class="noborder centerpercent">';
1464 print
'<td class="titlefield">';
1465 print $langs->trans(
'DateInvoice');
1468 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1474 print $langs->trans(
'Mode');
1478 'onelineperuser' =>
'OneLinePerUser',
1479 'onelinepertask' =>
'OneLinePerTask',
1480 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1482 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1483 print
"\n" .
'<script type="text/javascript">';
1485 $(document).ready(function () {
1486 setDetailVisibility();
1487 $("#generateinvoicemode").change(function() {
1488 setDetailVisibility();
1490 function setDetailVisibility() {
1491 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1492 if (generateinvoicemode=="onelineperperiod") {
1493 $("#detail_time_duration").show();
1495 $("#detail_time_duration").hide();
1500 print
'</script>' .
"\n";
1501 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1505 if (isModEnabled(
"service")) {
1508 print $langs->trans(
'ServiceToUseOnLines');
1511 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1516 print
'<td class="titlefield">';
1517 print $langs->trans(
'InvoiceToUse');
1520 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1524 print
'<td class="titlefield">';
1525 print $langs->trans(
"CustomerRelativeDiscount");
1528 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1531 print
'<tr class="newinvoicedetail">';
1532 print
'<td class="titlefield">';
1533 print $langs->trans(
"PaymentConditions");
1536 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1550 print
'<div class="center">';
1551 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1552 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1556 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1557 print
'<div class="center">';
1558 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1562 } elseif ($massaction ==
'generateinter') {
1564 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1566 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1568 print
'<table class="noborder centpercent">';
1570 print
'<td class="titlefield">';
1571 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1575 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1580 print
'<div class="center">';
1581 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1582 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1586 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1587 print
'<div class="center">';
1588 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1595 $parameters = array(
1596 'toselect' => $toselect,
1597 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1600 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1604 print $hookmanager->resPrint;
1612 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1613 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1615 $sql =
"SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,";
1616 $sql .=
" t.fk_product, t.invoice_line_id,";
1617 $sql .=
" pt.ref, pt.label, pt.fk_projet, pt.billable,";
1618 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1619 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1620 $sql .=
" p.fk_soc,s.name_alias,";
1621 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1622 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1623 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1627 $parameters = array();
1628 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1629 $sql .= $hookmanager->resPrint;
1630 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1634 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1635 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1636 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1637 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1638 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1639 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1640 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1641 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1642 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1645 $parameters = array();
1646 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1647 $sql .= $hookmanager->resPrint;
1648 $sql .=
" WHERE elementtype = 'task'";
1649 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1650 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1654 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1655 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1657 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1659 $sql .=
" AND t.fk_element =".((int)
$object->id);
1660 } elseif (!empty($projectidforalltimes)) {
1662 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1663 } elseif (!empty($allprojectforuser)) {
1665 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1666 $search_user = $user->id;
1668 if ($search_user > 0) {
1669 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1676 if ($search_task_ref) {
1679 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1680 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1682 if ($search_company) {
1685 if ($search_company_alias) {
1689 if ($search_project_ref) {
1692 if ($search_project_label) {
1695 if ($search_task_label) {
1698 if ($search_user > 0) {
1701 if (!empty($search_product_ref)) {
1704 if ($search_valuebilled ==
'1') {
1705 $sql .=
' AND t.invoice_id > 0';
1707 if ($search_valuebilled ==
'0') {
1708 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1711 if ($search_date_start) {
1712 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1714 if ($search_date_end) {
1715 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1718 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1719 if ($search_timespent_starthour || $search_timespent_startmin) {
1720 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1721 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1722 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1725 if ($search_timespent_endhour || $search_timespent_endmin) {
1726 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1727 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1728 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1732 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1735 $extrafieldsobjectkey =
'projet_task';
1736 $extrafieldsobjectprefix =
'efpt.';
1737 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1740 $parameters = array();
1741 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1742 $sql .= $hookmanager->resPrint;
1745 $nbtotalofrecords =
'';
1748 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1749 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1750 $resql = $db->query($sqlforcount);
1752 $objforcount = $db->fetch_object($resql);
1753 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1758 if (($page * $limit) > $nbtotalofrecords) {
1766 $sql .= $db->order($sortfield, $sortorder);
1768 $sql .= $db->plimit($limit + 1, $offset);
1771 $resql = $db->query($sql);
1777 $num = $db->num_rows($resql);
1780 if (!empty($projectidforalltimes)) {
1781 print
'<!-- List of time spent for project -->' .
"\n";
1783 $title = $langs->trans(
"ListTaskTimeUserProject");
1785 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1787 print
'<!-- List of time spent -->' .
"\n";
1789 $title = $langs->trans(
"ListTaskTimeForTask");
1791 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1796 $row = $db->fetch_object($resql);
1808 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1809 print
'<!-- table to add time spent -->' .
"\n";
1811 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1814 print
'<div class="div-table-responsive-no-min">';
1815 print
'<table class="noborder nohover centpercent">';
1817 print
'<tr class="liste_titre">';
1818 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1819 if (!empty($allprojectforuser)) {
1820 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1823 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1825 print
'<td>' . $langs->trans(
"By") .
'</td>';
1826 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1827 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1828 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1832 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1833 print
'<td>'.$langs->trans(
"Product").
'</td>';
1837 $parameters = array(
'mode' =>
'create');
1838 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1839 print $hookmanager->resPrint;
1843 print
'<tr class="oddeven nohover">';
1846 print
'<td class="maxwidthonsmartphone">';
1848 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1851 if (!empty($allprojectforuser)) {
1860 print
'<td class="maxwidthonsmartphone">';
1861 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1866 print
'<td class="maxwidthonsmartphone nowraponall">';
1867 $contactsofproject = $projectstatic->getListContactId(
'internal');
1868 if (count($contactsofproject) > 0) {
1869 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1870 if (in_array($user->id, $contactsofproject)) {
1871 $userid = $user->id;
1873 $userid = $contactsofproject[0];
1876 if ($projectstatic->public) {
1877 $contactsofproject = array();
1879 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1882 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1889 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1893 print
'<td class="nowraponall">';
1894 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1895 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1896 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1898 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1902 print
'<td class="nowrap">';
1903 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1911 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1912 print
'<td class="nowraponall">';
1914 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
1920 $parameters = array(
'mode' =>
'create');
1921 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1922 print $hookmanager->resPrint;
1924 print
'<td class="center">';
1925 $form->buttonsSaveCancel();
1926 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1927 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1936 $moreforfilter =
'';
1938 $parameters = array();
1939 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1940 if (empty($reshook)) {
1941 $moreforfilter .= $hookmanager->resPrint;
1943 $moreforfilter = $hookmanager->resPrint;
1946 if (!empty($moreforfilter)) {
1947 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1948 print $moreforfilter;
1952 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1953 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1954 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1956 print
'<!-- Liste of time spent -->'.
"\n";
1957 print
'<div class="div-table-responsive">';
1958 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1962 print
'<tr class="liste_titre_filter">';
1965 print
'<td class="liste_titre center">';
1966 $searchpicto = $form->showFilterButtons(
'left');
1971 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1972 print
'<td class="liste_titre left">';
1973 print
'<div class="nowrapfordate paddingright">';
1974 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1976 print
'<div class="nowrapfordate">';
1977 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1982 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1983 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1987 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1988 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1991 if (!empty($allprojectforuser)) {
1992 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1993 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1995 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1996 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2000 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2001 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2002 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2004 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2005 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2009 if (!empty($arrayfields[
'author'][
'checked'])) {
2010 print
'<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1),
'search_user', 1, null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth125').
'</td>';
2013 if (!empty($arrayfields[
't.note'][
'checked'])) {
2014 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2017 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2019 print
'<td class="liste_titre right">';
2021 $durationtouse_start =
'';
2022 if ($search_timespent_starthour || $search_timespent_startmin) {
2023 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2025 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
2026 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2029 $durationtouse_end =
'';
2030 if ($search_timespent_endhour || $search_timespent_endmin) {
2031 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2033 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2034 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2040 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2041 print
'<td class="liste_titre right"></td>';
2044 if (!empty($arrayfields[
'value'][
'checked'])) {
2045 print
'<td class="liste_titre"></td>';
2048 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2049 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2053 $extrafieldsobjectkey =
'projet_task';
2054 $extrafieldsobjectprefix =
'ef.';
2055 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2057 $parameters = array(
'arrayfields' => $arrayfields);
2058 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2059 print $hookmanager->resPrint;
2062 print
'<td class="liste_titre center">';
2063 $searchpicto = $form->showFilterButtons();
2067 print
'</tr>' .
"\n";
2075 print
'<tr class="liste_titre">';
2077 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2080 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2081 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2084 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2085 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2088 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2090 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2093 if (!empty($allprojectforuser)) {
2094 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2095 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2098 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2099 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2103 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2104 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2105 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2108 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2109 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2113 if (!empty($arrayfields[
'author'][
'checked'])) {
2114 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2117 if (!empty($arrayfields[
't.note'][
'checked'])) {
2118 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2121 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2122 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2125 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2126 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2130 if (!empty($arrayfields[
'value'][
'checked'])) {
2131 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2134 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2135 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2139 $extrafieldsobjectkey =
'projet_task';
2140 $extrafieldsobjectprefix =
'ef.';
2141 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2143 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2144 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2145 print $hookmanager->resPrint;
2147 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2152 $tasktmp =
new Task($db);
2153 $tmpinvoice =
new Facture($db);
2156 $param .=
'&page='.((int) $page);
2158 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2166 foreach ($tasks as $task_time) {
2172 $invoiced = $task_time->invoice_id ? true :
false;
2174 $date1 = $db->jdate($task_time->element_date);
2175 $date2 = $db->jdate($task_time->element_datehour);
2179 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2183 print
'<td class="center nowraponall">';
2184 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2185 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2186 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2188 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2189 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2190 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2191 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2192 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2196 print
'<a class="reposition editfielda paddingleft" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' .
newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2197 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2201 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2202 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2205 if ($massactionbutton || $massaction) {
2207 if (in_array($task_time->rowid, $arrayofselected)) {
2213 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2214 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2218 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2219 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2233 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2234 print
'<td class="nowrap">';
2235 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2236 if (empty($task_time->element_date_withhour)) {
2237 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2239 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2242 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2251 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2252 print
'<td class="tdoverflowmax125">';
2253 if ($task_time->fk_soc > 0) {
2254 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2255 $tmpsociete =
new Societe($db);
2256 $tmpsociete->fetch($task_time->fk_soc);
2257 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2259 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2261 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2270 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2272 if ($task_time->fk_soc > 0) {
2273 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2274 $tmpsociete =
new Societe($db);
2275 $tmpsociete->fetch($task_time->fk_soc);
2276 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2278 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2280 $valtoshow = $tmpsociete->name_alias;
2282 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2290 if (!empty($allprojectforuser)) {
2292 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2293 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2294 $tmpproject =
new Project($db);
2295 $tmpproject->fetch($task_time->fk_projet);
2296 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2298 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2300 print
'<td class="nowraponall">';
2301 print $tmpproject->getNomUrl(1);
2308 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2309 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2310 $tmpproject =
new Project($db);
2311 $tmpproject->fetch($task_time->fk_projet);
2312 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2314 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2316 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2317 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2320 print $tmpproject->getNomUrl(1,
'', -1);
2330 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2331 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2332 print
'<td class="nowrap">';
2333 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2334 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2336 $tasktmp->id = $task_time->fk_element;
2337 $tasktmp->ref = $task_time->ref;
2338 $tasktmp->label = $task_time->label;
2339 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2346 } elseif ($action !==
'createtime') {
2347 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2351 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2352 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2353 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2354 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2357 $tasktmp->id = $task_time->fk_element;
2358 $tasktmp->ref = $task_time->ref;
2359 $tasktmp->label = $task_time->label;
2360 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2370 if (!empty($arrayfields[
'author'][
'checked'])) {
2371 print
'<td class="tdoverflowmax125">';
2372 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2375 $object->fetch($task_time->fk_element);
2377 $contactsoftask =
$object->getListContactId(
'internal');
2378 if (!in_array($task_time->fk_user, $contactsoftask)) {
2379 $contactsoftask[] = $task_time->fk_user;
2381 if (count($contactsoftask) > 0) {
2382 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2383 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2385 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2388 $userstatic->id = $task_time->fk_user;
2389 $userstatic->lastname = $task_time->lastname;
2390 $userstatic->firstname = $task_time->firstname;
2391 $userstatic->photo = $task_time->photo;
2392 $userstatic->gender = $task_time->gender;
2393 $userstatic->status = $task_time->user_status;
2395 print $userstatic->getNomUrl(-1);
2404 if (!empty($arrayfields[
't.note'][
'checked'])) {
2405 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2406 print
'<td class="small">';
2407 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2410 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2417 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2418 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2422 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2423 print
'<td class="right nowraponall">';
2424 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2425 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2426 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2437 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2438 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2440 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2446 $totalarray[
'totalduration'] = $task_time->element_duration;
2448 $totalarray[
'totalduration'] += $task_time->element_duration;
2453 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2454 print
'<td class="nowraponall">';
2455 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2457 print $form->select_produits($task_time->fk_product,
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
2458 } elseif (!empty($task_time->fk_product)) {
2460 $resultFetch = $product->fetch($task_time->fk_product);
2461 if ($resultFetch < 0) {
2464 print $product->getNomUrl(1);
2474 if (!empty($arrayfields[
'value'][
'checked'])) {
2475 $langs->load(
"salaries");
2476 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2478 print
'<td class="nowraponall right">';
2479 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2480 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2505 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2506 print
'<td class="center">';
2508 if ($projectstatic->usage_bill_time) {
2509 if ($task_time->invoice_id) {
2510 $result = $tmpinvoice->fetch($task_time->invoice_id);
2512 if ($user->hasRight(
'facture',
'lire')) {
2513 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2514 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2516 print $tmpinvoice->getNomUrl(1);
2517 if (!empty($task_time->invoice_line_id)) {
2519 $invoiceLine->fetch($task_time->invoice_line_id);
2520 if (!empty($invoiceLine->id)) {
2521 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2522 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2527 print $langs->trans(
"Yes");
2532 if (intval($task_time->billable) == 1) {
2533 print $langs->trans(
"No");
2535 print $langs->trans(
"Disabled");
2539 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2550 $extrafieldsobjectkey =
'projet_task';
2551 $extrafieldsobjectprefix =
'ef.';
2552 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2555 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2556 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2557 print $hookmanager->resPrint;
2561 print
'<td class="center nowraponall">';
2562 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2563 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2564 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2566 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2567 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2568 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2569 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2570 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2574 print
'<a class="reposition editfielda paddingleft" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' .
newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2575 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2579 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2580 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2583 if ($massactionbutton || $massaction) {
2585 if (in_array($task_time->rowid, $arrayofselected)) {
2591 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2592 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2596 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2597 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2615 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2616 print
'<!-- first line -->';
2617 print
'<tr class="oddeven">';
2625 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2626 print
'<td class="nowrap">';
2627 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2628 if (empty($task_time->element_date_withhour)) {
2629 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2631 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2634 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2640 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2641 print
'<td class="nowrap">';
2646 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2647 print
'<td class="nowrap">';
2652 if (!empty($allprojectforuser)) {
2653 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2654 print
'<td class="nowrap">';
2660 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2661 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2662 print
'<td class="nowrap">';
2663 $tasktmp->id = $task_time->fk_element;
2664 $tasktmp->ref = $task_time->ref;
2665 $tasktmp->label = $task_time->label;
2666 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2672 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2673 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2674 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2681 if (!empty($arrayfields[
'author'][
'checked'])) {
2682 print
'<td class="nowraponall">';
2683 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2685 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2688 $contactsoftask =
$object->getListContactId(
'internal');
2689 if (!in_array($task_time->fk_user, $contactsoftask)) {
2690 $contactsoftask[] = $task_time->fk_user;
2692 if (count($contactsoftask) > 0) {
2693 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2694 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2696 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2699 $userstatic->id = $task_time->fk_user;
2700 $userstatic->lastname = $task_time->lastname;
2701 $userstatic->firstname = $task_time->firstname;
2702 $userstatic->photo = $task_time->photo;
2703 $userstatic->status = $task_time->user_status;
2704 print $userstatic->getNomUrl(-1);
2710 if (!empty($arrayfields[
't.note'][
'checked'])) {
2711 print
'<td class="tdoverflowmax300">';
2712 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2713 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2718 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2719 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2723 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2724 print
'<td class="right">';
2725 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2726 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2727 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2735 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2736 print
'<td class="nowraponall tdoverflowmax125">';
2741 if (!empty($arrayfields[
'value'][
'checked'])) {
2742 print
'<td class="right">';
2743 print
'<span class="amount">';
2744 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2745 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2751 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2752 print
'<td class="right">';
2753 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2754 if (isset($task_time->total_ht)) {
2755 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2762 $extrafieldsobjectkey =
'projet_task';
2763 $extrafieldsobjectprefix =
'ef.';
2764 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2767 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2768 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2769 print $hookmanager->resPrint;
2773 print
'<td class="center nowraponall">';
2782 print
'<!-- second line --><tr class="oddeven">';
2786 print
'<td class="center nowraponall">';
2791 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2792 print
'<td class="nowraponall">';
2793 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2794 if (empty($task_time->element_date_withhour)) {
2795 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2797 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2800 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2806 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2812 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2818 if (!empty($allprojectforuser)) {
2819 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2826 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2827 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2828 print
'<td class="nowraponall">';
2829 $tasktmp->id = $task_time->fk_element;
2830 $tasktmp->ref = $task_time->ref;
2831 $tasktmp->label = $task_time->label;
2832 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2838 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2839 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2840 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2847 if (!empty($arrayfields[
'author'][
'checked'])) {
2848 print
'<td class="nowraponall tdoverflowmax100">';
2849 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2851 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2854 $contactsoftask =
$object->getListContactId(
'internal');
2855 if (!in_array($task_time->fk_user, $contactsoftask)) {
2856 $contactsoftask[] = $task_time->fk_user;
2858 if (count($contactsoftask) > 0) {
2859 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2860 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2862 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2865 $userstatic->id = $task_time->fk_user;
2866 $userstatic->lastname = $task_time->lastname;
2867 $userstatic->firstname = $task_time->firstname;
2868 $userstatic->photo = $task_time->photo;
2869 $userstatic->status = $task_time->user_status;
2870 print $userstatic->getNomUrl(-1);
2876 if (!empty($arrayfields[
't.note'][
'checked'])) {
2877 print
'<td class="small tdoverflowmax300"">';
2878 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2879 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2884 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2885 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2889 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2890 print
'<td class="right">';
2891 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2892 print
'<input type="hidden" name="old_duration_2" value="0">';
2893 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2901 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2902 print
'<td class="nowraponall tdoverflowmax125">';
2907 if (!empty($arrayfields[
'value'][
'checked'])) {
2908 print
'<td class="right">';
2909 print
'<span class="amount nowraponall">';
2911 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2918 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2919 print
'<td class="right">';
2920 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2921 if (isset($task_time->total_ht)) {
2922 print
'<span class="amount nowraponall">';
2923 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2931 $extrafieldsobjectkey =
'projet_task';
2932 $extrafieldsobjectprefix =
'ef.';
2933 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2936 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2937 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2938 print $hookmanager->resPrint;
2942 print
'<td class="center nowraponall">';
2955 print
'<tr class="liste_total">';
2960 if ($num < $limit && empty($offset)) {
2961 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2963 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2977 if (!count($tasks)) {
2978 $totalnboffields = 1;
2979 foreach ($arrayfields as $value) {
2980 if (!empty($value[
'checked'])) {
2984 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2985 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2989 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2990 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2991 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
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...
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.