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 .
'/core/lib/project.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
55@phan-var-force ?string $uploaddir
59$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
60if (isModEnabled(
'eventorganization')) {
61 $langsLoad[] =
'eventorganization';
64$langs->loadLangs($langsLoad);
66$action =
GETPOST(
'action',
'alpha');
67$massaction =
GETPOST(
'massaction',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
73$optioncss =
GETPOST(
'optioncss',
'alpha');
74$mode =
GETPOST(
'mode',
'alpha');
80$project_ref =
GETPOST(
'project_ref',
'alpha');
86$search_date_startday =
GETPOSTINT(
'search_date_startday');
87$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
88$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
89$search_date_endday =
GETPOSTINT(
'search_date_endday');
90$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
91$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
92$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
93$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
94$search_note =
GETPOST(
'search_note',
'alpha');
95$search_duration =
GETPOST(
'search_duration',
'alpha');
96$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
97$search_task_label =
GETPOST(
'search_task_label',
'alpha');
98$search_user =
GETPOST(
'search_user',
'intcomma');
99$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
100$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
101$search_company =
GETPOST(
'$search_company',
'alpha');
102$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
103$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
104$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
105$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
106$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
107$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
108$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
111$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
112$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
114if (empty($page) || $page == -1) {
117$offset = $limit * $page;
118$pageprev = $page - 1;
119$pagenext = $page + 1;
121 $sortfield =
't.element_date,t.element_datehour,t.rowid';
124 $sortorder =
'DESC,DESC,DESC';
127$childids = $user->getAllChildIds(1);
131$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
135$projectstatic =
new Project($db);
138$extrafields->fetch_name_optionals_label($projectstatic->table_element);
139$extrafields->fetch_name_optionals_label(
$object->table_element);
142if ($id > 0 || $ref) {
150if (!$user->hasRight(
'projet',
'lire')) {
159 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
160 $search_user = $user->id;
170if (
GETPOST(
'cancel',
'alpha')) {
173if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
177$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
178$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
183include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
186if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
191 $search_duration =
'';
192 $search_date_startday =
'';
193 $search_date_startmonth =
'';
194 $search_date_startyear =
'';
195 $search_date_endday =
'';
196 $search_date_endmonth =
'';
197 $search_date_endyear =
'';
198 $search_date_start =
'';
199 $search_date_end =
'';
200 $search_task_ref =
'';
201 $search_company =
'';
202 $search_company_alias =
'';
203 $search_project_ref =
'';
204 $search_project_label =
'';
205 $search_task_label =
'';
207 $search_valuebilled =
'';
208 $search_product_ref =
'';
210 $search_array_options = array();
211 $search_timespent_starthour =
'';
212 $search_timespent_startmin =
'';
213 $search_timespent_endhour =
'';
214 $search_timespent_endmin =
'';
218if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
219 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
220 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
221 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
222 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
226 $langs->load(
"errors");
227 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
236 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
237 $action =
'createtime';
247 if (empty(
$object->project->status)) {
248 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
249 $action =
'createtime';
260 $object->timespent_withhour = 1;
263 $object->timespent_withhour = 0;
268 $result =
$object->addTimeSpent($user);
279 $action =
'createtime';
283if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
284 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
285 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
301 $object->fetch($id_temp, $ref);
303 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
307 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
309 $object->timespent_withhour = 1;
310 } elseif (!empty($timespent_date)) {
311 $object->timespent_date = $timespent_date;
312 $object->timespent_withhour = 0;
320 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
321 $result =
$object->updateTimeSpent($user);
334 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
338 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
341 $object->timespent_withhour = 1;
342 } elseif (!empty($timespent_date)) {
343 $object->timespent_date = $timespent_date;
344 $object->timespent_datehour = $timespent_date;
345 $object->timespent_withhour = 0;
353 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
354 $result =
$object->updateTimeSpent($user);
369if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
372 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
373 $result =
$object->delTimeSpent($user);
376 $langs->load(
"errors");
387if (!empty($project_ref) && !empty($withproject)) {
388 if ($projectstatic->fetch(0, $project_ref) > 0) {
389 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
390 if (count($tasksarray) > 0) {
391 $id = $tasksarray[0]->id;
393 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
400$projectidforalltimes = 0;
402 $projectidforalltimes =
GETPOSTINT(
'projectid');
404 $result = $projectstatic->fetch($projectidforalltimes);
405 if (!empty($projectstatic->socid)) {
406 $projectstatic->fetch_thirdparty();
408 $res = $projectstatic->fetch_optionals();
409} elseif (
GETPOST(
'project_ref',
'alpha')) {
410 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
411 $projectidforalltimes = $projectstatic->id;
415 $result = $projectstatic->fetch(
$object->fk_project);
418$allprojectforuser = 0;
419if ($id <= 0 && $projectidforalltimes == 0) {
420 $allprojectforuser = $user->id;
423if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
424 if (!empty($projectstatic->socid)) {
425 $projectstatic->fetch_thirdparty();
428 if (!($projectstatic->thirdparty->id > 0)) {
429 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
431 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
432 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
433 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
435 $tmpinvoice =
new Facture($db);
436 $tmptimespent =
new Task($db);
437 $tmpproduct =
new Product($db);
438 $fuser =
new User($db);
443 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
446 $prodDurationHoursBase = 1.0;
447 $product_data_cache = array();
449 $tmpproduct->fetch($idprod);
455 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
456 if ($prodDurationHoursBase < 0) {
458 $langs->load(
"errors");
462 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
464 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
465 $txtva = $dataforprice[
'tva_tx'];
466 $localtax1 = $dataforprice[
'localtax1'];
467 $localtax2 = $dataforprice[
'localtax2'];
469 $prodDurationHoursBase = 1;
477 $tmpinvoice->socid = $projectstatic->thirdparty->id;
479 $tmpinvoice->fk_project = $projectstatic->id;
480 $tmpinvoice->cond_reglement_id = $condidproject;
481 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
482 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
485 $tmpinvoice->fetch($invoiceToUse);
487 $result = $tmpinvoice->create($user);
495 if ($generateinvoicemode ==
'onelineperuser') {
496 $arrayoftasks = array();
497 foreach ($toselect as $key => $value) {
499 $object->fetchTimeSpent($value);
500 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
501 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
504 foreach ($arrayoftasks as $userid => $data) {
505 $fuser->fetch($userid);
506 $username = $fuser->getFullName($langs);
508 foreach ($data as $fk_product => $timespent_data) {
510 $qtyhour = $timespent_data[
'timespent'] / 3600;
517 } elseif ($idprod <= 0) {
520 $pu_ht = $fuser->thm;
525 if ($timespent_data[
'timespent']) {
526 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
531 $prodDurationHours = $prodDurationHoursBase;
532 $idprodline = $idprod;
535 $localtax1line = $localtax1;
536 $localtax2line = $localtax2;
539 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
540 if (!array_key_exists($fk_product, $product_data_cache)) {
541 $result = $tmpproduct->fetch($fk_product);
546 $prodDurationHours = $tmpproduct->getProductDurationHours();
547 if ($prodDurationHours < 0) {
549 $langs->load(
"errors");
553 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
555 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
556 $txtvaline = $dataforprice[
'tva_tx'];
557 $localtax1line = $dataforprice[
'localtax1'];
558 $localtax2line = $dataforprice[
'localtax2'];
560 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
562 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
563 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
564 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
565 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
566 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
568 $idprodline = $fk_product;
572 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject);
579 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
580 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
581 $result = $db->query($sql);
589 } elseif ($generateinvoicemode ==
'onelineperperiod') {
590 $arrayoftasks = array();
592 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
593 foreach ($toselect as $key => $value) {
595 $object->fetchTimeSpent($value);
597 $ftask =
new Task($db);
600 $fuser->fetch(
$object->timespent_fk_user);
601 $username = $fuser->getFullName($langs);
603 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
604 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
605 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
608 if (!empty($withdetail)) {
609 if (!empty(
$object->timespent_withhour)) {
616 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
617 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
620 foreach ($arrayoftasks as $timespent_id => $value) {
621 $userid = $value[
'user'];
625 $qtyhour = $value[
'timespent'] / 3600;
629 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
633 $prodDurationHours = $prodDurationHoursBase;
634 $idprodline = $idprod;
637 $localtax1line = $localtax1;
638 $localtax2line = $localtax2;
640 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
641 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
642 $result = $tmpproduct->fetch($value[
'fk_product']);
647 $prodDurationHours = $tmpproduct->getProductDurationHours();
648 if ($prodDurationHours < 0) {
650 $langs->load(
"errors");
654 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
656 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
657 $txtvaline = $dataforprice[
'tva_tx'];
658 $localtax1line = $dataforprice[
'localtax1'];
659 $localtax2line = $dataforprice[
'localtax2'];
661 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
663 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
664 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
665 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
666 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
667 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
669 $idprodline = $value[
'fk_product'];
671 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject);
679 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
680 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
681 $result = $db->query($sql);
688 } elseif ($generateinvoicemode ==
'onelinepertask') {
689 $arrayoftasks = array();
690 foreach ($toselect as $key => $value) {
692 $object->fetchTimeSpent($value);
694 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
695 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
698 foreach ($arrayoftasks as $task_id => $data) {
699 $ftask =
new Task($db);
700 $ftask->fetch($task_id);
702 foreach ($data as $fk_product => $timespent_data) {
703 $qtyhour = $timespent_data[
'timespent'] / 3600;
707 $prodDurationHours = $prodDurationHoursBase;
708 $idprodline = $idprod;
711 $localtax1line = $localtax1;
712 $localtax2line = $localtax2;
714 if (!empty($fk_product) && $fk_product !== $idprod) {
715 if (!array_key_exists($fk_product, $product_data_cache)) {
716 $result = $tmpproduct->fetch($fk_product);
721 $prodDurationHours = $tmpproduct->getProductDurationHours();
722 if ($prodDurationHours < 0) {
724 $langs->load(
"errors");
728 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
730 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
731 $txtvaline = $dataforprice[
'tva_tx'];
732 $localtax1line = $dataforprice[
'localtax1'];
733 $localtax2line = $dataforprice[
'localtax2'];
735 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
737 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
738 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
739 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
740 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
741 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
743 $idprodline = $fk_product;
747 if ($idprodline > 0) {
749 $pu_ht_for_task = $pu_htline;
752 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
754 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
760 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
762 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
768 $lineName = $ftask->ref .
' - ' . $ftask->label;
769 $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);
778 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
779 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
780 $result = $db->query($sql);
793 $urltoinvoice = $tmpinvoice->getNomUrl(0);
794 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
795 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
805if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
806 $langs->load(
'interventions');
808 if (!empty($projectstatic->socid)) {
809 $projectstatic->fetch_thirdparty();
812 if (!($projectstatic->thirdparty->id > 0)) {
813 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
815 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
816 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
817 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
820 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
822 $tmptimespent =
new Task($db);
823 $fuser =
new User($db);
829 $tmpinter->socid = $projectstatic->thirdparty->id;
831 $tmpinter->fk_project = $projectstatic->id;
832 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
835 $tmpinter->fetch($interToUse);
837 $result = $tmpinter->create($user);
845 $arrayoftasks = array();
846 foreach ($toselect as $key => $value) {
848 $object->fetchTimeSpent($value);
851 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
852 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
853 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
854 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
857 foreach ($arrayoftasks as $timespent_id => $value) {
858 $ftask =
new Task($db);
859 $ftask->fetch($value[
'id']);
861 $qtyhour = $value[
'timespent'] / 3600;
865 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
870 $timespent->fetch($timespent_id);
871 $timespent->intervention_id = $tmpinter->id;
872 $timespent->intervention_line_id = $lineid;
873 $result = $timespent->update($user);
883 $urltointer = $tmpinter->getNomUrl(0);
884 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
885 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
902$form =
new Form($db);
905$userstatic =
new User($db);
907$arrayofselected = is_array($toselect) ? $toselect : array();
909$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
910if (!empty($withproject)) {
911 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
915llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
917if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
921 if ($projectidforalltimes > 0) {
922 $result = $projectstatic->fetch($projectidforalltimes);
923 if (!empty($projectstatic->socid)) {
924 $projectstatic->fetch_thirdparty();
926 $res = $projectstatic->fetch_optionals();
927 } elseif (
$object->fetch($id, $ref) >= 0) {
928 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
931 $result = $projectstatic->fetch(
$object->fk_project);
932 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
933 $projectstatic->fetchComments();
935 if (!empty($projectstatic->socid)) {
936 $projectstatic->fetch_thirdparty();
938 $res = $projectstatic->fetch_optionals();
940 $object->project = clone $projectstatic;
943 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
944 $linktocreatetime =
'';
946 if ($projectstatic->id > 0) {
949 if (empty($id) || $tab ==
'timespent') {
956 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
958 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
960 $param .=
'&search_user=' . ((int) $search_user);
963 $param .=
'&search_month=' . ((int) $search_month);
966 $param .=
'&search_year=' . ((int) $search_year);
971 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
973 $morehtmlref =
'<div class="refidno">';
975 $morehtmlref .= $projectstatic->title;
977 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
978 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
980 $morehtmlref .=
'</div>';
983 if (!$user->hasRight(
'projet',
'all',
'lire')) {
984 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
985 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
988 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
990 print
'<div class="fichecenter">';
991 print
'<div class="fichehalfleft">';
992 print
'<div class="underbanner clearboth"></div>';
994 print
'<table class="border tableforfield centpercent">';
998 print
'<tr><td class="tdtop">';
999 print $langs->trans(
"Usage");
1003 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1004 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1005 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1009 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1010 $htmltext = $langs->trans(
"ProjectFollowTasks");
1011 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1015 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"' :
'')) .
'"> ';
1016 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1017 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1020 if (isModEnabled(
'eventorganization')) {
1021 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"' :
'')) .
'"> ';
1022 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1023 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1029 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1030 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1031 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1036 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1038 print($start ? $start :
'?');
1041 print($end ? $end :
'?');
1042 if ($projectstatic->hasDelay()) {
1048 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1049 if ($projectstatic->public) {
1050 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1051 print $langs->trans(
'SharedProject');
1053 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1054 print $langs->trans(
'PrivateProject');
1062 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1068 print
'<div class="fichehalfright">';
1069 print
'<div class="underbanner clearboth"></div>';
1071 print
'<table class="border tableforfield centpercent">';
1074 if (isModEnabled(
'category')) {
1075 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1076 print $form->showCategories($projectstatic->id,
'project', 1);
1081 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1082 if ($projectstatic->description) {
1083 print
'<tr><td class="nottitleforfield" colspan="2">';
1084 print
'<div class="longmessagecut">';
1095 print
'<div class="clearboth"></div>';
1105 $linktocreatetimeBtnStatus = 0;
1106 $linktocreatetimeUrl =
'';
1107 $linktocreatetimeHelpText =
'';
1108 if ($user->hasRight(
'projet',
'time')) {
1109 if ($projectstatic->public || $userRead > 0) {
1110 $linktocreatetimeBtnStatus = 1;
1112 if (!empty($projectidforalltimes)) {
1114 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1115 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1118 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1119 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1122 $linktocreatetimeBtnStatus = -2;
1123 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1126 $linktocreatetimeBtnStatus = -2;
1127 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1130 $paramsbutton = array(
'morecss' =>
'reposition');
1131 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1134 $massactionbutton =
'';
1135 $arrayofmassactions = array();
1137 if ($projectstatic->id > 0) {
1139 if ($projectstatic->usage_bill_time) {
1140 $arrayofmassactions = array(
1141 'generateinvoice' => $langs->trans(
"GenerateBill"),
1145 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1146 $langs->load(
"interventions");
1147 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1151 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1152 $arrayofmassactions = array();
1154 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1159 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1161 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1163 if ($action ==
'deleteline') {
1164 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1165 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1168 $param = ($withproject ?
'&withproject=1' :
'');
1169 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1170 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1172 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1173 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1174 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1176 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1182 if (empty($withproject)) {
1183 $morehtmlref .=
'<div class="refidno">';
1184 $morehtmlref .= $langs->trans(
"Project") .
': ';
1185 $morehtmlref .= $projectstatic->getNomUrl(1);
1186 $morehtmlref .=
'<br>';
1189 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1190 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1191 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1193 $morehtmlref .=
'</div>';
1196 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1198 print
'<div class="fichecenter">';
1199 print
'<div class="fichehalfleft">';
1201 print
'<div class="underbanner clearboth"></div>';
1202 print
'<table class="border centpercent tableforfield">';
1205 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1206 if (
$object->fk_task_parent > 0) {
1207 $tasktmp =
new Task($db);
1208 $tasktmp->fetch(
$object->fk_task_parent);
1209 print $tasktmp->getNomUrl(1);
1214 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1216 print($start ? $start :
'?');
1219 print($end ? $end :
'?');
1226 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1227 if (
$object->planned_workload) {
1235 print
'<div class="fichehalfright">';
1237 print
'<div class="underbanner clearboth"></div>';
1238 print
'<table class="border tableforfield centpercent">';
1241 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1246 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1247 if (
$object->planned_workload) {
1248 $tmparray =
$object->getSummaryOfTimeSpent();
1249 if ($tmparray[
'total_duration'] > 0) {
1250 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1255 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1266 print
'<div class="clearboth"></div>';
1270 if ($action ==
'deleteline') {
1271 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1272 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1277 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1279 $hookmanager->initHooks(array(
'tasktimelist'));
1283 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1285 $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);
1286 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1290 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1291 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1292 if (empty($reshook)) {
1293 $formconfirm .= $hookmanager->resPrint;
1294 } elseif ($reshook > 0) {
1295 $formconfirm = $hookmanager->resPrint;
1302 $arrayfields = array();
1303 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1304 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1305 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1306 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1307 if (! empty($allprojectforuser)) {
1308 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1309 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1311 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1312 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1314 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1315 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1316 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1317 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1319 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1320 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int) isModEnabled(
"salaries"));
1321 $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));
1323 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1328 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1329 $param .=
'&contextpage=' . urlencode($contextpage);
1331 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1332 $param .=
'&limit='.((int) $limit);
1334 if ($search_month > 0) {
1335 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1337 if ($search_year > 0) {
1338 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1340 if (!empty($search_user)) {
1341 $param .=
'&search_user='.urlencode($search_user);
1343 if ($search_task_ref !=
'') {
1344 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1346 if ($search_company !=
'') {
1347 $param .=
'&$search_company=' . urlencode($search_company);
1349 if ($search_company_alias !=
'') {
1350 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1352 if ($search_project_ref !=
'') {
1353 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1355 if ($search_project_label !=
'') {
1356 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1358 if ($search_task_label !=
'') {
1359 $param .=
'&search_task_label=' . urlencode($search_task_label);
1361 if ($search_note !=
'') {
1362 $param .=
'&search_note=' . urlencode($search_note);
1364 if ($search_duration !=
'') {
1365 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1367 if ($optioncss !=
'') {
1368 $param .=
'&optioncss=' . urlencode($optioncss);
1370 if ($search_date_startday) {
1371 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1373 if ($search_date_startmonth) {
1374 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1376 if ($search_date_startyear) {
1377 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1379 if ($search_date_endday) {
1380 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1382 if ($search_date_endmonth) {
1383 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1385 if ($search_date_endyear) {
1386 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1388 if ($search_timespent_starthour) {
1389 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1391 if ($search_timespent_startmin) {
1392 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1394 if ($search_timespent_endhour) {
1395 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1397 if ($search_timespent_endmin) {
1398 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1406 $param .=
'&id=' . urlencode((
string) ($id));
1409 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1412 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1415 $parameters = array(
'param' => &$param);
1416 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1417 $param .= $hookmanager->resPrint;
1419 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1420 if ($optioncss !=
'') {
1421 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1423 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1424 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1425 if ($action ==
'editline') {
1426 print
'<input type="hidden" name="action" value="updateline">';
1427 } elseif ($action ==
'splitline') {
1428 print
'<input type="hidden" name="action" value="updatesplitline">';
1429 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1430 print
'<input type="hidden" name="action" value="addtimespent">';
1431 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1432 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1433 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1434 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1436 print
'<input type="hidden" name="action" value="list">';
1438 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1439 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1441 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1442 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1443 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1444 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1445 print
'<input type="hidden" name="page_y" value="">';
1448 if ($massaction ==
'generateinvoice') {
1449 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1450 print
'<table class="noborder centerpercent">';
1452 print
'<td class="titlefield">';
1453 print $langs->trans(
'DateInvoice');
1456 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1462 print $langs->trans(
'Mode');
1466 'onelineperuser' =>
'OneLinePerUser',
1467 'onelinepertask' =>
'OneLinePerTask',
1468 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1470 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1471 print
"\n" .
'<script type="text/javascript">';
1473 $(document).ready(function () {
1474 setDetailVisibility();
1475 $("#generateinvoicemode").change(function() {
1476 setDetailVisibility();
1478 function setDetailVisibility() {
1479 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1480 if (generateinvoicemode=="onelineperperiod") {
1481 $("#detail_time_duration").show();
1483 $("#detail_time_duration").hide();
1488 print
'</script>' .
"\n";
1489 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1493 if (isModEnabled(
"service")) {
1496 print $langs->trans(
'ServiceToUseOnLines');
1499 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1504 print
'<td class="titlefield">';
1505 print $langs->trans(
'InvoiceToUse');
1508 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1512 print
'<td class="titlefield">';
1513 print $langs->trans(
"CustomerRelativeDiscount");
1516 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1519 print
'<tr class="newinvoicedetail">';
1520 print
'<td class="titlefield">';
1521 print $langs->trans(
"PaymentConditions");
1524 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1538 print
'<div class="center">';
1539 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1540 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1544 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1545 print
'<div class="center">';
1546 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1550 } elseif ($massaction ==
'generateinter') {
1552 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1554 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1556 print
'<table class="noborder centpercent">';
1558 print
'<td class="titlefield">';
1559 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1563 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1568 print
'<div class="center">';
1569 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1570 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1574 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1575 print
'<div class="center">';
1576 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1583 $parameters = array(
1584 'toselect' => $toselect,
1585 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1588 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1592 print $hookmanager->resPrint;
1600 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1601 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1603 $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,";
1604 $sql .=
" t.fk_product,";
1605 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1606 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1607 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1608 $sql .=
" p.fk_soc,s.name_alias,";
1609 $sql .=
" t.invoice_line_id,";
1610 $sql .=
" pt.billable";
1612 $parameters = array();
1613 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1614 $sql .= $hookmanager->resPrint;
1615 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1619 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1620 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1621 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1622 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1623 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1624 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1625 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1626 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1629 $parameters = array();
1630 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1631 $sql .= $hookmanager->resPrint;
1632 $sql .=
" WHERE elementtype = 'task'";
1633 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1634 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1638 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1639 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1641 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1643 $sql .=
" AND t.fk_element =".((int)
$object->id);
1644 } elseif (!empty($projectidforalltimes)) {
1646 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1647 } elseif (!empty($allprojectforuser)) {
1649 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1650 $search_user = $user->id;
1652 if ($search_user > 0) {
1653 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1660 if ($search_task_ref) {
1663 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1664 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1666 if ($search_company) {
1669 if ($search_company_alias) {
1673 if ($search_project_ref) {
1676 if ($search_project_label) {
1679 if ($search_task_label) {
1682 if ($search_user > 0) {
1685 if (!empty($search_product_ref)) {
1688 if ($search_valuebilled ==
'1') {
1689 $sql .=
' AND t.invoice_id > 0';
1691 if ($search_valuebilled ==
'0') {
1692 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1695 if ($search_date_start) {
1696 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1698 if ($search_date_end) {
1699 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1702 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1703 if ($search_timespent_starthour || $search_timespent_startmin) {
1704 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1705 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1706 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1709 if ($search_timespent_endhour || $search_timespent_endmin) {
1710 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1711 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1712 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1716 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1719 $parameters = array();
1720 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1721 $sql .= $hookmanager->resPrint;
1724 $nbtotalofrecords =
'';
1727 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1728 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1729 $resql = $db->query($sqlforcount);
1731 $objforcount = $db->fetch_object($resql);
1732 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1737 if (($page * $limit) > $nbtotalofrecords) {
1745 $sql .= $db->order($sortfield, $sortorder);
1747 $sql .= $db->plimit($limit + 1, $offset);
1750 $resql = $db->query($sql);
1756 $num = $db->num_rows($resql);
1759 if (!empty($projectidforalltimes)) {
1760 print
'<!-- List of time spent for project -->' .
"\n";
1762 $title = $langs->trans(
"ListTaskTimeUserProject");
1764 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1766 print
'<!-- List of time spent -->' .
"\n";
1768 $title = $langs->trans(
"ListTaskTimeForTask");
1770 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1775 $row = $db->fetch_object($resql);
1787 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1788 print
'<!-- table to add time spent -->' .
"\n";
1790 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1793 print
'<div class="div-table-responsive-no-min">';
1794 print
'<table class="noborder nohover centpercent">';
1796 print
'<tr class="liste_titre">';
1797 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1798 if (!empty($allprojectforuser)) {
1799 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1802 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1804 print
'<td>' . $langs->trans(
"By") .
'</td>';
1805 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1806 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1807 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1811 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1812 print
'<td>'.$langs->trans(
"Product").
'</td>';
1816 $parameters = array(
'mode' =>
'create');
1817 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1818 print $hookmanager->resPrint;
1822 print
'<tr class="oddeven nohover">';
1825 print
'<td class="maxwidthonsmartphone">';
1827 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1830 if (!empty($allprojectforuser)) {
1839 print
'<td class="maxwidthonsmartphone">';
1840 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1845 print
'<td class="maxwidthonsmartphone nowraponall">';
1846 $contactsofproject = $projectstatic->getListContactId(
'internal');
1847 if (count($contactsofproject) > 0) {
1848 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1849 if (in_array($user->id, $contactsofproject)) {
1850 $userid = $user->id;
1852 $userid = $contactsofproject[0];
1855 if ($projectstatic->public) {
1856 $contactsofproject = array();
1858 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1861 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1868 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1872 print
'<td class="nowraponall">';
1873 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1874 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1875 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1877 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1881 print
'<td class="nowrap">';
1882 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1890 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1891 print
'<td class="nowraponall">';
1893 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);
1899 $parameters = array(
'mode' =>
'create');
1900 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1901 print $hookmanager->resPrint;
1903 print
'<td class="center">';
1904 $form->buttonsSaveCancel();
1905 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1906 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1915 $moreforfilter =
'';
1917 $parameters = array();
1918 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1919 if (empty($reshook)) {
1920 $moreforfilter .= $hookmanager->resPrint;
1922 $moreforfilter = $hookmanager->resPrint;
1925 if (!empty($moreforfilter)) {
1926 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1927 print $moreforfilter;
1931 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1932 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1933 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1935 print
'<!-- Liste of time spent -->'.
"\n";
1936 print
'<div class="div-table-responsive">';
1937 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1941 print
'<tr class="liste_titre_filter">';
1944 print
'<td class="liste_titre center">';
1945 $searchpicto = $form->showFilterButtons(
'left');
1950 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1951 print
'<td class="liste_titre left">';
1952 print
'<div class="nowrapfordate paddingright">';
1953 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1955 print
'<div class="nowrapfordate">';
1956 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1961 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1962 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1966 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1967 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1970 if (!empty($allprojectforuser)) {
1971 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1972 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1974 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1975 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1979 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1980 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1981 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1983 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1984 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1988 if (!empty($arrayfields[
'author'][
'checked'])) {
1989 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>';
1992 if (!empty($arrayfields[
't.note'][
'checked'])) {
1993 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1996 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1998 print
'<td class="liste_titre right">';
2000 $durationtouse_start =
'';
2001 if ($search_timespent_starthour || $search_timespent_startmin) {
2002 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2004 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
2005 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2008 $durationtouse_end =
'';
2009 if ($search_timespent_endhour || $search_timespent_endmin) {
2010 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2012 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2013 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2019 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2020 print
'<td class="liste_titre right"></td>';
2023 if (!empty($arrayfields[
'value'][
'checked'])) {
2024 print
'<td class="liste_titre"></td>';
2027 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2028 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2036 $parameters = array(
'arrayfields' => $arrayfields);
2037 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2038 print $hookmanager->resPrint;
2041 print
'<td class="liste_titre center">';
2042 $searchpicto = $form->showFilterButtons();
2046 print
'</tr>' .
"\n";
2054 print
'<tr class="liste_titre">';
2056 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2059 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2060 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2063 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2064 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2067 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2069 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2072 if (!empty($allprojectforuser)) {
2073 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2074 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2077 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2078 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2082 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2083 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2084 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2087 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2088 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2092 if (!empty($arrayfields[
'author'][
'checked'])) {
2093 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2096 if (!empty($arrayfields[
't.note'][
'checked'])) {
2097 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2100 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2101 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2104 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2105 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2109 if (!empty($arrayfields[
'value'][
'checked'])) {
2110 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2113 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2114 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2122 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2123 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2124 print $hookmanager->resPrint;
2126 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2131 $tasktmp =
new Task($db);
2132 $tmpinvoice =
new Facture($db);
2135 $param .=
'&page='.((int) $page);
2137 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2145 foreach ($tasks as $task_time) {
2151 $invoiced = $task_time->invoice_id ? true :
false;
2153 $date1 = $db->jdate($task_time->element_date);
2154 $date2 = $db->jdate($task_time->element_datehour);
2158 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2162 print
'<td class="center nowraponall">';
2163 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2164 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2165 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2167 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2168 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2169 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2170 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' :
'').
'">';
2171 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2175 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' :
'') .
'">';
2176 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2180 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' :
'').
'">';
2181 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2184 if ($massactionbutton || $massaction) {
2186 if (in_array($task_time->rowid, $arrayofselected)) {
2192 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2193 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2197 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2198 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2212 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2213 print
'<td class="nowrap">';
2214 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2215 if (empty($task_time->element_date_withhour)) {
2216 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2218 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2221 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2230 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2231 print
'<td class="tdoverflowmax125">';
2232 if ($task_time->fk_soc > 0) {
2233 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2234 $tmpsociete =
new Societe($db);
2235 $tmpsociete->fetch($task_time->fk_soc);
2236 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2238 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2240 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2249 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2251 if ($task_time->fk_soc > 0) {
2252 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2253 $tmpsociete =
new Societe($db);
2254 $tmpsociete->fetch($task_time->fk_soc);
2255 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2257 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2259 $valtoshow = $tmpsociete->name_alias;
2261 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2269 if (!empty($allprojectforuser)) {
2271 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2272 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2273 $tmpproject =
new Project($db);
2274 $tmpproject->fetch($task_time->fk_projet);
2275 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2277 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2279 print
'<td class="nowraponall">';
2280 print $tmpproject->getNomUrl(1);
2287 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2288 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2289 $tmpproject =
new Project($db);
2290 $tmpproject->fetch($task_time->fk_projet);
2291 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2293 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2295 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2296 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2299 print $tmpproject->getNomUrl(1,
'', -1);
2309 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2310 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2311 print
'<td class="nowrap">';
2312 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2313 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2315 $tasktmp->id = $task_time->fk_element;
2316 $tasktmp->ref = $task_time->ref;
2317 $tasktmp->label = $task_time->label;
2318 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2325 } elseif ($action !==
'createtime') {
2326 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2330 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2331 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2332 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2333 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
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', -1);
2349 if (!empty($arrayfields[
'author'][
'checked'])) {
2350 print
'<td class="tdoverflowmax125">';
2351 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2354 $object->fetch($task_time->fk_element);
2356 $contactsoftask =
$object->getListContactId(
'internal');
2357 if (!in_array($task_time->fk_user, $contactsoftask)) {
2358 $contactsoftask[] = $task_time->fk_user;
2360 if (count($contactsoftask) > 0) {
2361 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2362 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2364 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2367 $userstatic->id = $task_time->fk_user;
2368 $userstatic->lastname = $task_time->lastname;
2369 $userstatic->firstname = $task_time->firstname;
2370 $userstatic->photo = $task_time->photo;
2371 $userstatic->gender = $task_time->gender;
2372 $userstatic->status = $task_time->user_status;
2374 print $userstatic->getNomUrl(-1);
2383 if (!empty($arrayfields[
't.note'][
'checked'])) {
2384 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2385 print
'<td class="small">';
2386 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2389 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2396 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2397 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2401 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2402 print
'<td class="right nowraponall">';
2403 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2404 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2405 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2416 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2417 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2419 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2425 $totalarray[
'totalduration'] = $task_time->element_duration;
2427 $totalarray[
'totalduration'] += $task_time->element_duration;
2432 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2433 print
'<td class="nowraponall">';
2434 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2436 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);
2437 } elseif (!empty($task_time->fk_product)) {
2439 $resultFetch = $product->fetch($task_time->fk_product);
2440 if ($resultFetch < 0) {
2443 print $product->getNomUrl(1);
2453 if (!empty($arrayfields[
'value'][
'checked'])) {
2454 $langs->load(
"salaries");
2455 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2457 print
'<td class="nowraponall right">';
2458 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2459 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2484 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2485 print
'<td class="center">';
2487 if ($projectstatic->usage_bill_time) {
2488 if ($task_time->invoice_id) {
2489 $result = $tmpinvoice->fetch($task_time->invoice_id);
2491 if ($user->hasRight(
'facture',
'lire')) {
2492 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2493 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2495 print $tmpinvoice->getNomUrl(1);
2496 if (!empty($task_time->invoice_line_id)) {
2498 $invoiceLine->fetch($task_time->invoice_line_id);
2499 if (!empty($invoiceLine->id)) {
2500 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2501 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2506 print $langs->trans(
"Yes");
2511 if (intval($task_time->billable) == 1) {
2512 print $langs->trans(
"No");
2514 print $langs->trans(
"Disabled");
2518 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2533 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2534 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2535 print $hookmanager->resPrint;
2539 print
'<td class="center nowraponall">';
2540 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2541 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2542 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2544 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2545 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2546 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2547 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' :
'').
'">';
2548 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2552 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' :
'') .
'">';
2553 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2557 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' :
'').
'">';
2558 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2561 if ($massactionbutton || $massaction) {
2563 if (in_array($task_time->rowid, $arrayofselected)) {
2569 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2570 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2574 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2575 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2593 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2594 print
'<!-- first line -->';
2595 print
'<tr class="oddeven">';
2603 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2604 print
'<td class="nowrap">';
2605 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2606 if (empty($task_time->element_date_withhour)) {
2607 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2609 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2612 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2618 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2619 print
'<td class="nowrap">';
2624 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2625 print
'<td class="nowrap">';
2630 if (!empty($allprojectforuser)) {
2631 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2632 print
'<td class="nowrap">';
2638 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2639 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2640 print
'<td class="nowrap">';
2641 $tasktmp->id = $task_time->fk_element;
2642 $tasktmp->ref = $task_time->ref;
2643 $tasktmp->label = $task_time->label;
2644 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2650 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2651 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2652 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2659 if (!empty($arrayfields[
'author'][
'checked'])) {
2660 print
'<td class="nowraponall">';
2661 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2663 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2666 $contactsoftask =
$object->getListContactId(
'internal');
2667 if (!in_array($task_time->fk_user, $contactsoftask)) {
2668 $contactsoftask[] = $task_time->fk_user;
2670 if (count($contactsoftask) > 0) {
2671 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2672 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2674 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2677 $userstatic->id = $task_time->fk_user;
2678 $userstatic->lastname = $task_time->lastname;
2679 $userstatic->firstname = $task_time->firstname;
2680 $userstatic->photo = $task_time->photo;
2681 $userstatic->status = $task_time->user_status;
2682 print $userstatic->getNomUrl(-1);
2688 if (!empty($arrayfields[
't.note'][
'checked'])) {
2689 print
'<td class="tdoverflowmax300">';
2690 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2691 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2696 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2697 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2701 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2702 print
'<td class="right">';
2703 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2704 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2705 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2713 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2714 print
'<td class="nowraponall tdoverflowmax125">';
2719 if (!empty($arrayfields[
'value'][
'checked'])) {
2720 print
'<td class="right">';
2721 print
'<span class="amount">';
2722 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2723 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2729 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2730 print
'<td class="right">';
2731 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2732 if (isset($task_time->total_ht)) {
2733 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2744 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2745 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2746 print $hookmanager->resPrint;
2750 print
'<td class="center nowraponall">';
2759 print
'<!-- second line --><tr class="oddeven">';
2763 print
'<td class="center nowraponall">';
2768 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2769 print
'<td class="nowraponall">';
2770 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2771 if (empty($task_time->element_date_withhour)) {
2772 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2774 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2777 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2783 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2789 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2795 if (!empty($allprojectforuser)) {
2796 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2803 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2804 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2805 print
'<td class="nowraponall">';
2806 $tasktmp->id = $task_time->fk_element;
2807 $tasktmp->ref = $task_time->ref;
2808 $tasktmp->label = $task_time->label;
2809 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2815 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2816 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2817 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2824 if (!empty($arrayfields[
'author'][
'checked'])) {
2825 print
'<td class="nowraponall tdoverflowmax100">';
2826 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2828 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2831 $contactsoftask =
$object->getListContactId(
'internal');
2832 if (!in_array($task_time->fk_user, $contactsoftask)) {
2833 $contactsoftask[] = $task_time->fk_user;
2835 if (count($contactsoftask) > 0) {
2836 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2837 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2839 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2842 $userstatic->id = $task_time->fk_user;
2843 $userstatic->lastname = $task_time->lastname;
2844 $userstatic->firstname = $task_time->firstname;
2845 $userstatic->photo = $task_time->photo;
2846 $userstatic->status = $task_time->user_status;
2847 print $userstatic->getNomUrl(-1);
2853 if (!empty($arrayfields[
't.note'][
'checked'])) {
2854 print
'<td class="small tdoverflowmax300"">';
2855 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2856 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2861 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2862 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2866 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2867 print
'<td class="right">';
2868 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2869 print
'<input type="hidden" name="old_duration_2" value="0">';
2870 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2878 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2879 print
'<td class="nowraponall tdoverflowmax125">';
2884 if (!empty($arrayfields[
'value'][
'checked'])) {
2885 print
'<td class="right">';
2886 print
'<span class="amount nowraponall">';
2888 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2895 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2896 print
'<td class="right">';
2897 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2898 if (isset($task_time->total_ht)) {
2899 print
'<span class="amount nowraponall">';
2900 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2912 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2913 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2914 print $hookmanager->resPrint;
2918 print
'<td class="center nowraponall">';
2931 print
'<tr class="liste_total">';
2936 if ($num < $limit && empty($offset)) {
2937 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2939 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2953 if (!count($tasks)) {
2954 $totalnboffields = 1;
2955 foreach ($arrayfields as $value) {
2956 if (!empty($value[
'checked'])) {
2960 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2961 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2965 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2966 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2967 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.