35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
55$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
56if (isModEnabled(
'eventorganization')) {
57 $langsLoad[] =
'eventorganization';
60$langs->loadLangs($langsLoad);
62$action =
GETPOST(
'action',
'alpha');
63$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$toselect =
GETPOST(
'toselect',
'array');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$optioncss =
GETPOST(
'optioncss',
'alpha');
70$mode =
GETPOST(
'mode',
'alpha');
76$project_ref =
GETPOST(
'project_ref',
'alpha');
82$search_date_startday =
GETPOSTINT(
'search_date_startday');
83$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
84$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
85$search_date_endday =
GETPOSTINT(
'search_date_endday');
86$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
87$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
88$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
89$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
90$search_note =
GETPOST(
'search_note',
'alpha');
91$search_duration =
GETPOST(
'search_duration',
'alpha');
92$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
93$search_task_label =
GETPOST(
'search_task_label',
'alpha');
94$search_user =
GETPOST(
'search_user',
'intcomma');
95$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
96$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
97$search_company =
GETPOST(
'$search_company',
'alpha');
98$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
99$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
100$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
101$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
102$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
103$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
104$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
107$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
108$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
110if (empty($page) || $page == -1) {
113$offset = $limit * $page;
114$pageprev = $page - 1;
115$pagenext = $page + 1;
117 $sortfield =
't.element_date,t.element_datehour,t.rowid';
120 $sortorder =
'DESC,DESC,DESC';
123$childids = $user->getAllChildIds(1);
127$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
131$projectstatic =
new Project($db);
134$extrafields->fetch_name_optionals_label($projectstatic->table_element);
135$extrafields->fetch_name_optionals_label(
$object->table_element);
138if ($id > 0 || $ref) {
146if (!$user->hasRight(
'projet',
'lire')) {
155 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
156 $search_user = $user->id;
166if (
GETPOST(
'cancel',
'alpha')) {
169if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
173$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
174$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
179include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
182if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
187 $search_duration =
'';
189 $search_date_startday =
'';
190 $search_date_startmonth =
'';
191 $search_date_startyear =
'';
192 $search_date_endday =
'';
193 $search_date_endmonth =
'';
194 $search_date_endyear =
'';
195 $search_date_start =
'';
196 $search_date_end =
'';
197 $search_task_ref =
'';
198 $search_company =
'';
199 $search_company_alias =
'';
200 $search_project_ref =
'';
201 $search_project_label =
'';
202 $search_task_label =
'';
204 $search_valuebilled =
'';
205 $search_product_ref =
'';
207 $search_array_options = array();
208 $search_timespent_starthour =
'';
209 $search_timespent_startmin =
'';
210 $search_timespent_endhour =
'';
211 $search_timespent_endmin =
'';
215if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
216 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
217 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
218 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
219 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
223 $langs->load(
"errors");
224 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
234 $action =
'createtime';
244 if (empty(
$object->project->status)) {
245 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
246 $action =
'createtime';
257 $object->timespent_withhour = 1;
264 $result =
$object->addTimeSpent($user);
275 $action =
'createtime';
279if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
280 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
281 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
293 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
294 $result =
$object->delTimeSpent($user);
297 $object->fetch($id_temp, $ref);
299 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
303 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
305 $object->timespent_withhour = 1;
315 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
316 $result =
$object->addTimeSpent($user);
328 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
332 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
334 $object->timespent_withhour = 1;
344 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
345 $result =
$object->updateTimeSpent($user);
360if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
363 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
364 $result =
$object->delTimeSpent($user);
367 $langs->load(
"errors");
378if (!empty($project_ref) && !empty($withproject)) {
379 if ($projectstatic->fetch(0, $project_ref) > 0) {
380 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
381 if (count($tasksarray) > 0) {
382 $id = $tasksarray[0]->id;
384 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
391$projectidforalltimes = 0;
393 $projectidforalltimes =
GETPOSTINT(
'projectid');
395 $result = $projectstatic->fetch($projectidforalltimes);
396 if (!empty($projectstatic->socid)) {
397 $projectstatic->fetch_thirdparty();
399 $res = $projectstatic->fetch_optionals();
400} elseif (
GETPOST(
'project_ref',
'alpha')) {
401 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
402 $projectidforalltimes = $projectstatic->id;
406 $result = $projectstatic->fetch(
$object->fk_project);
409if ($id <= 0 && $projectidforalltimes == 0) {
410 $allprojectforuser = $user->id;
413if ($action ==
'confirm_generateinvoice') {
414 if (!empty($projectstatic->socid)) {
415 $projectstatic->fetch_thirdparty();
418 if (!($projectstatic->thirdparty->id > 0)) {
419 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
421 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
422 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
423 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
425 $tmpinvoice =
new Facture($db);
426 $tmptimespent =
new Task($db);
427 $tmpproduct =
new Product($db);
428 $fuser =
new User($db);
433 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
436 $prodDurationHoursBase = 1.0;
437 $product_data_cache = array();
439 $tmpproduct->fetch($idprod);
445 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
446 if ($prodDurationHoursBase < 0) {
448 $langs->load(
"errors");
452 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
454 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
455 $txtva = $dataforprice[
'tva_tx'];
456 $localtax1 = $dataforprice[
'localtax1'];
457 $localtax2 = $dataforprice[
'localtax2'];
459 $prodDurationHoursBase = 1;
467 $tmpinvoice->socid = $projectstatic->thirdparty->id;
469 $tmpinvoice->fk_project = $projectstatic->id;
470 $tmpinvoice->cond_reglement_id = $condidproject;
471 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
472 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
475 $tmpinvoice->fetch($invoiceToUse);
477 $result = $tmpinvoice->create($user);
485 if ($generateinvoicemode ==
'onelineperuser') {
486 $arrayoftasks = array();
487 foreach ($toselect as $key => $value) {
489 $object->fetchTimeSpent($value);
490 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
491 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
494 foreach ($arrayoftasks as $userid => $data) {
495 $fuser->fetch($userid);
496 $username = $fuser->getFullName($langs);
498 foreach ($data as $fk_product => $timespent_data) {
500 $qtyhour = $timespent_data[
'timespent'] / 3600;
507 } elseif ($idprod <= 0) {
510 $pu_ht = $fuser->thm;
515 if ($timespent_data[
'timespent']) {
516 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
521 $prodDurationHours = $prodDurationHoursBase;
522 $idprodline = $idprod;
525 $localtax1line = $localtax1;
526 $localtax2line = $localtax2;
529 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
530 if (!array_key_exists($fk_product, $product_data_cache)) {
531 $result = $tmpproduct->fetch($fk_product);
536 $prodDurationHours = $tmpproduct->getProductDurationHours();
537 if ($prodDurationHours < 0) {
539 $langs->load(
"errors");
543 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
545 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
546 $txtvaline = $dataforprice[
'tva_tx'];
547 $localtax1line = $dataforprice[
'localtax1'];
548 $localtax2line = $dataforprice[
'localtax2'];
550 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
552 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
553 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
554 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
555 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
556 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
558 $idprodline = $fk_product;
562 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
569 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
570 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
571 $result = $db->query($sql);
579 } elseif ($generateinvoicemode ==
'onelineperperiod') {
580 $arrayoftasks = array();
582 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
583 foreach ($toselect as $key => $value) {
585 $object->fetchTimeSpent($value);
587 $ftask =
new Task($db);
590 $fuser->fetch(
$object->timespent_fk_user);
591 $username = $fuser->getFullName($langs);
593 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
594 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
595 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
598 if (!empty($withdetail)) {
599 if (!empty(
$object->timespent_withhour)) {
606 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
607 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
610 foreach ($arrayoftasks as $timespent_id => $value) {
611 $userid = $value[
'user'];
615 $qtyhour = $value[
'timespent'] / 3600;
619 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
623 $prodDurationHours = $prodDurationHoursBase;
624 $idprodline = $idprod;
627 $localtax1line = $localtax1;
628 $localtax2line = $localtax2;
630 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
631 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
632 $result = $tmpproduct->fetch($value[
'fk_product']);
637 $prodDurationHours = $tmpproduct->getProductDurationHours();
638 if ($prodDurationHours < 0) {
640 $langs->load(
"errors");
644 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
646 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
647 $txtvaline = $dataforprice[
'tva_tx'];
648 $localtax1line = $dataforprice[
'localtax1'];
649 $localtax2line = $dataforprice[
'localtax2'];
651 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
653 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
654 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
655 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
656 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
657 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
659 $idprodline = $value[
'fk_product'];
661 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
669 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
670 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
671 $result = $db->query($sql);
678 } elseif ($generateinvoicemode ==
'onelinepertask') {
679 $arrayoftasks = array();
680 foreach ($toselect as $key => $value) {
682 $object->fetchTimeSpent($value);
684 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
685 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
688 foreach ($arrayoftasks as $task_id => $data) {
689 $ftask =
new Task($db);
690 $ftask->fetch($task_id);
692 foreach ($data as $fk_product => $timespent_data) {
693 $qtyhour = $timespent_data[
'timespent'] / 3600;
697 $prodDurationHours = $prodDurationHoursBase;
698 $idprodline = $idprod;
701 $localtax1line = $localtax1;
702 $localtax2line = $localtax2;
704 if (!empty($fk_product) && $fk_product !== $idprod) {
705 if (!array_key_exists($fk_product, $product_data_cache)) {
706 $result = $tmpproduct->fetch($fk_product);
711 $prodDurationHours = $tmpproduct->getProductDurationHours();
712 if ($prodDurationHours < 0) {
714 $langs->load(
"errors");
718 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
720 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
721 $txtvaline = $dataforprice[
'tva_tx'];
722 $localtax1line = $dataforprice[
'localtax1'];
723 $localtax2line = $dataforprice[
'localtax2'];
725 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
727 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
728 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
729 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
730 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
731 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
733 $idprodline = $fk_product;
737 if ($idprodline > 0) {
739 $pu_ht_for_task = $pu_htline;
742 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
744 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
750 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
752 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
758 $lineName = $ftask->ref .
' - ' . $ftask->label;
759 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0, null, $pa_ht);
768 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
769 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
770 $result = $db->query($sql);
783 $urltoinvoice = $tmpinvoice->getNomUrl(0);
784 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
785 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
795if ($action ==
'confirm_generateinter') {
796 $langs->load(
'interventions');
798 if (!empty($projectstatic->socid)) {
799 $projectstatic->fetch_thirdparty();
802 if (!($projectstatic->thirdparty->id > 0)) {
803 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
805 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
806 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
807 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
810 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
812 $tmptimespent =
new Task($db);
813 $fuser =
new User($db);
819 $tmpinter->socid = $projectstatic->thirdparty->id;
821 $tmpinter->fk_project = $projectstatic->id;
822 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
825 $tmpinter->fetch($interToUse);
827 $result = $tmpinter->create($user);
835 $arrayoftasks = array();
836 foreach ($toselect as $key => $value) {
838 $object->fetchTimeSpent($value);
841 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
842 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
843 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
844 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
847 foreach ($arrayoftasks as $timespent_id => $value) {
848 $ftask =
new Task($db);
849 $ftask->fetch($value[
'id']);
851 $qtyhour = $value[
'timespent'] / 3600;
855 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
860 $urltointer = $tmpinter->getNomUrl(0);
861 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
862 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
879$form =
new Form($db);
882$userstatic =
new User($db);
884$arrayofselected = is_array($toselect) ? $toselect : array();
886$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
887if (!empty($withproject)) {
888 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
892llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
894if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
898 if ($projectidforalltimes > 0) {
899 $result = $projectstatic->fetch($projectidforalltimes);
900 if (!empty($projectstatic->socid)) {
901 $projectstatic->fetch_thirdparty();
903 $res = $projectstatic->fetch_optionals();
904 } elseif (
$object->fetch($id, $ref) >= 0) {
905 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
908 $result = $projectstatic->fetch(
$object->fk_project);
909 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
910 $projectstatic->fetchComments();
912 if (!empty($projectstatic->socid)) {
913 $projectstatic->fetch_thirdparty();
915 $res = $projectstatic->fetch_optionals();
917 $object->project = clone $projectstatic;
920 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
921 $linktocreatetime =
'';
923 if ($projectstatic->id > 0) {
926 if (empty($id) || $tab ==
'timespent') {
933 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
935 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
937 $param .=
'&search_user=' . ((int) $search_user);
940 $param .=
'&search_month=' . ((int) $search_month);
943 $param .=
'&search_year=' . ((int) $search_year);
948 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
950 $morehtmlref =
'<div class="refidno">';
952 $morehtmlref .= $projectstatic->title;
954 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
955 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
957 $morehtmlref .=
'</div>';
960 if (!$user->hasRight(
'projet',
'all',
'lire')) {
961 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
962 $projectstatic->next_prev_filter =
"rowid:IN:(" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0') .
")";
965 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
967 print
'<div class="fichecenter">';
968 print
'<div class="fichehalfleft">';
969 print
'<div class="underbanner clearboth"></div>';
971 print
'<table class="border tableforfield centpercent">';
975 print
'<tr><td class="tdtop">';
976 print $langs->trans(
"Usage");
980 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
981 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
982 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
986 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
987 $htmltext = $langs->trans(
"ProjectFollowTasks");
988 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
992 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"' :
'')) .
'"> ';
993 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
994 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
997 if (isModEnabled(
'eventorganization')) {
998 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"' :
'')) .
'"> ';
999 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1000 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1006 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1007 if ($projectstatic->public) {
1008 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1009 print $langs->trans(
'SharedProject');
1011 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1012 print $langs->trans(
'PrivateProject');
1017 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1018 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1019 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1024 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1026 print($start ? $start :
'?');
1029 print($end ? $end :
'?');
1030 if ($projectstatic->hasDelay()) {
1039 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1045 print
'<div class="fichehalfright">';
1046 print
'<div class="underbanner clearboth"></div>';
1048 print
'<table class="border tableforfield centpercent">';
1051 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1056 if (isModEnabled(
'category')) {
1057 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1058 print $form->showCategories($projectstatic->id,
'project', 1);
1067 print
'<div class="clearboth"></div>';
1077 $linktocreatetimeBtnStatus = 0;
1078 $linktocreatetimeUrl =
'';
1079 $linktocreatetimeHelpText =
'';
1080 if ($user->hasRight(
'projet',
'time')) {
1081 if ($projectstatic->public || $userRead > 0) {
1082 $linktocreatetimeBtnStatus = 1;
1084 if (!empty($projectidforalltimes)) {
1086 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1087 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1090 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1091 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1094 $linktocreatetimeBtnStatus = -2;
1095 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1098 $linktocreatetimeBtnStatus = -2;
1099 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1102 $paramsbutton = array(
'morecss' =>
'reposition');
1103 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1106 $massactionbutton =
'';
1107 $arrayofmassactions = array();
1109 if ($projectstatic->id > 0) {
1111 if ($projectstatic->usage_bill_time) {
1112 $arrayofmassactions = array(
1113 'generateinvoice' => $langs->trans(
"GenerateBill"),
1117 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1118 $langs->load(
"interventions");
1119 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1123 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1124 $arrayofmassactions = array();
1126 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1131 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1133 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1135 if ($action ==
'deleteline') {
1136 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1137 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1140 $param = ($withproject ?
'&withproject=1' :
'');
1141 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1142 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1144 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1145 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1146 $object->next_prev_filter =
"fk_projet:IN:(" . $db->sanitize($projectsListId) .
")";
1148 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1154 if (empty($withproject)) {
1155 $morehtmlref .=
'<div class="refidno">';
1156 $morehtmlref .= $langs->trans(
"Project") .
': ';
1157 $morehtmlref .= $projectstatic->getNomUrl(1);
1158 $morehtmlref .=
'<br>';
1161 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1162 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1163 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1165 $morehtmlref .=
'</div>';
1168 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1170 print
'<div class="fichecenter">';
1171 print
'<div class="fichehalfleft">';
1173 print
'<div class="underbanner clearboth"></div>';
1174 print
'<table class="border centpercent tableforfield">';
1177 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1178 if (
$object->fk_task_parent > 0) {
1179 $tasktmp =
new Task($db);
1180 $tasktmp->fetch(
$object->fk_task_parent);
1181 print $tasktmp->getNomUrl(1);
1186 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1188 print($start ? $start :
'?');
1191 print($end ? $end :
'?');
1198 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1199 if (
$object->planned_workload) {
1207 print
'<div class="fichehalfright">';
1209 print
'<div class="underbanner clearboth"></div>';
1210 print
'<table class="border tableforfield centpercent">';
1213 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1218 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1219 if (
$object->planned_workload) {
1220 $tmparray =
$object->getSummaryOfTimeSpent();
1221 if ($tmparray[
'total_duration'] > 0) {
1222 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1227 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1238 print
'<div class="clearboth"></div>';
1242 if ($action ==
'deleteline') {
1243 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1244 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1249 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1251 $hookmanager->initHooks(array(
'tasktimelist'));
1255 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1257 $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);
1258 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1262 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1263 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1264 if (empty($reshook)) {
1265 $formconfirm .= $hookmanager->resPrint;
1266 } elseif ($reshook > 0) {
1267 $formconfirm = $hookmanager->resPrint;
1274 $arrayfields = array();
1275 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1276 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1277 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1278 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1279 if (! empty($allprojectforuser)) {
1280 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1281 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1283 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1284 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1286 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1287 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1288 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1289 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1291 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1292 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1293 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' => 1,
'enabled' => (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1295 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1298 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1301 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1302 $param .=
'&contextpage=' . urlencode($contextpage);
1304 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1305 $param .=
'&limit='.((int) $limit);
1307 if ($search_month > 0) {
1308 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1310 if ($search_year > 0) {
1311 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1313 if (!empty($search_user)) {
1314 $param .=
'&search_user='.urlencode($search_user);
1316 if ($search_task_ref !=
'') {
1317 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1319 if ($search_company !=
'') {
1320 $param .=
'&$search_company=' . urlencode($search_company);
1322 if ($search_company_alias !=
'') {
1323 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1325 if ($search_project_ref !=
'') {
1326 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1328 if ($search_project_label !=
'') {
1329 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1331 if ($search_task_label !=
'') {
1332 $param .=
'&search_task_label=' . urlencode($search_task_label);
1334 if ($search_note !=
'') {
1335 $param .=
'&search_note=' . urlencode($search_note);
1337 if ($search_duration !=
'') {
1338 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1340 if ($optioncss !=
'') {
1341 $param .=
'&optioncss=' . urlencode($optioncss);
1343 if ($search_date_startday) {
1344 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1346 if ($search_date_startmonth) {
1347 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1349 if ($search_date_startyear) {
1350 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1352 if ($search_date_endday) {
1353 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1355 if ($search_date_endmonth) {
1356 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1358 if ($search_date_endyear) {
1359 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1361 if ($search_timespent_starthour) {
1362 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1364 if ($search_timespent_startmin) {
1365 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1367 if ($search_timespent_endhour) {
1368 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1370 if ($search_timespent_endmin) {
1371 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1379 $param .=
'&id=' . urlencode((
string) ($id));
1382 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1385 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1388 $parameters = array(
'param' => &$param);
1389 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1390 $param .= $hookmanager->resPrint;
1392 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1393 if ($optioncss !=
'') {
1394 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1396 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1397 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1398 if ($action ==
'editline') {
1399 print
'<input type="hidden" name="action" value="updateline">';
1400 } elseif ($action ==
'splitline') {
1401 print
'<input type="hidden" name="action" value="updatesplitline">';
1402 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1403 print
'<input type="hidden" name="action" value="addtimespent">';
1404 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1405 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1406 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1407 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1409 print
'<input type="hidden" name="action" value="list">';
1411 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1412 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1414 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1415 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1416 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1417 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1418 print
'<input type="hidden" name="page_y" value="">';
1421 if ($massaction ==
'generateinvoice') {
1422 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1423 print
'<table class="noborder centerpercent">';
1425 print
'<td class="titlefield">';
1426 print $langs->trans(
'DateInvoice');
1429 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1435 print $langs->trans(
'Mode');
1439 'onelineperuser' =>
'OneLinePerUser',
1440 'onelinepertask' =>
'OneLinePerTask',
1441 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1443 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1444 print
"\n" .
'<script type="text/javascript">';
1446 $(document).ready(function () {
1447 setDetailVisibility();
1448 $("#generateinvoicemode").change(function() {
1449 setDetailVisibility();
1451 function setDetailVisibility() {
1452 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1453 if (generateinvoicemode=="onelineperperiod") {
1454 $("#detail_time_duration").show();
1456 $("#detail_time_duration").hide();
1461 print
'</script>' .
"\n";
1462 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1466 if (isModEnabled(
"service")) {
1469 print $langs->trans(
'ServiceToUseOnLines');
1472 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1477 print
'<td class="titlefield">';
1478 print $langs->trans(
'InvoiceToUse');
1481 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1485 print
'<td class="titlefield">';
1486 print $langs->trans(
"CustomerRelativeDiscount");
1489 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1492 print
'<tr class="newinvoicedetail">';
1493 print
'<td class="titlefield">';
1494 print $langs->trans(
"PaymentConditions");
1497 print $form->getSelectConditionsPaiements($projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1511 print
'<div class="center">';
1512 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1513 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1517 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1518 print
'<div class="center">';
1519 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1523 } elseif ($massaction ==
'generateinter') {
1525 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1527 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1529 print
'<table class="noborder centpercent">';
1531 print
'<td class="titlefield">';
1532 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1536 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1541 print
'<div class="center">';
1542 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1543 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1547 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1548 print
'<div class="center">';
1549 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1556 $parameters = array(
1557 'toselect' => $toselect,
1558 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1561 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1565 print $hookmanager->resPrint;
1573 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1574 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1576 $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,";
1577 $sql .=
" t.fk_product,";
1578 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1579 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1580 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1581 $sql .=
" p.fk_soc,s.name_alias,";
1582 $sql .=
" t.invoice_line_id,";
1583 $sql .=
" pt.billable";
1585 $parameters = array();
1586 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1587 $sql .= $hookmanager->resPrint;
1588 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1592 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1593 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1594 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1595 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1596 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1597 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1598 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1599 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1602 $parameters = array();
1603 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1604 $sql .= $hookmanager->resPrint;
1605 $sql .=
" WHERE elementtype = 'task'";
1606 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1607 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1611 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1612 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1614 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1616 $sql .=
" AND t.fk_element =".((int)
$object->id);
1617 } elseif (!empty($projectidforalltimes)) {
1619 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1620 } elseif (!empty($allprojectforuser)) {
1622 if (empty($search_user)) {
1623 $search_user = $user->id;
1625 if ($search_user > 0) {
1626 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1633 if ($search_task_ref) {
1636 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1637 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1639 if ($search_company) {
1642 if ($search_company_alias) {
1646 if ($search_project_ref) {
1649 if ($search_project_label) {
1652 if ($search_task_label) {
1655 if ($search_user > 0) {
1658 if (!empty($search_product_ref)) {
1661 if ($search_valuebilled ==
'1') {
1662 $sql .=
' AND t.invoice_id > 0';
1664 if ($search_valuebilled ==
'0') {
1665 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1668 if ($search_date_start) {
1669 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1671 if ($search_date_end) {
1672 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1675 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1676 if ($search_timespent_starthour || $search_timespent_startmin) {
1677 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1678 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1679 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1682 if ($search_timespent_endhour || $search_timespent_endmin) {
1683 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1684 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1685 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1689 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1692 $parameters = array();
1693 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1694 $sql .= $hookmanager->resPrint;
1697 $nbtotalofrecords =
'';
1700 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1701 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1702 $resql = $db->query($sqlforcount);
1704 $objforcount = $db->fetch_object($resql);
1705 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1710 if (($page * $limit) > $nbtotalofrecords) {
1718 $sql .= $db->order($sortfield, $sortorder);
1720 $sql .= $db->plimit($limit + 1, $offset);
1723 $resql = $db->query($sql);
1729 $num = $db->num_rows($resql);
1732 if (!empty($projectidforalltimes)) {
1733 print
'<!-- List of time spent for project -->' .
"\n";
1735 $title = $langs->trans(
"ListTaskTimeUserProject");
1737 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1739 print
'<!-- List of time spent -->' .
"\n";
1741 $title = $langs->trans(
"ListTaskTimeForTask");
1743 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1748 $row = $db->fetch_object($resql);
1760 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1761 print
'<!-- table to add time spent -->' .
"\n";
1763 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1766 print
'<div class="div-table-responsive-no-min">';
1767 print
'<table class="noborder nohover centpercent">';
1769 print
'<tr class="liste_titre">';
1770 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1771 if (!empty($allprojectforuser)) {
1772 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1775 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1777 print
'<td>' . $langs->trans(
"By") .
'</td>';
1778 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1779 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1780 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1784 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1785 print
'<td>'.$langs->trans(
"Product").
'</td>';
1789 $parameters = array(
'mode' =>
'create');
1790 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1791 print $hookmanager->resPrint;
1795 print
'<tr class="oddeven nohover">';
1798 print
'<td class="maxwidthonsmartphone">';
1800 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1803 if (!empty($allprojectforuser)) {
1812 print
'<td class="maxwidthonsmartphone">';
1813 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1818 print
'<td class="maxwidthonsmartphone nowraponall">';
1819 $contactsofproject = $projectstatic->getListContactId(
'internal');
1820 if (count($contactsofproject) > 0) {
1821 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1822 if (in_array($user->id, $contactsofproject)) {
1823 $userid = $user->id;
1825 $userid = $contactsofproject[0];
1828 if ($projectstatic->public) {
1829 $contactsofproject = array();
1831 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1834 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1841 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1845 print
'<td class="nowraponall">';
1846 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1847 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1848 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1850 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1854 print
'<td class="nowrap">';
1855 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1863 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1864 print
'<td class="nowraponall">';
1866 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', 0,
'', null, 1);
1872 $parameters = array(
'mode' =>
'create');
1873 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1874 print $hookmanager->resPrint;
1876 print
'<td class="center">';
1877 $form->buttonsSaveCancel();
1878 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1879 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1888 $moreforfilter =
'';
1890 $parameters = array();
1891 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1892 if (empty($reshook)) {
1893 $moreforfilter .= $hookmanager->resPrint;
1895 $moreforfilter = $hookmanager->resPrint;
1898 if (!empty($moreforfilter)) {
1899 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1900 print $moreforfilter;
1904 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1905 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1906 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1908 print
'<div class="div-table-responsive">';
1909 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1913 print
'<tr class="liste_titre_filter">';
1916 print
'<td class="liste_titre center">';
1917 $searchpicto = $form->showFilterButtons(
'left');
1922 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1923 print
'<td class="liste_titre left">';
1924 print
'<div class="nowrapfordate">';
1925 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1927 print
'<div class="nowrapfordate">';
1928 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1933 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1934 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1938 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1939 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1942 if (!empty($allprojectforuser)) {
1943 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1944 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1946 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1947 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1951 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1952 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1953 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1955 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1956 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1960 if (!empty($arrayfields[
'author'][
'checked'])) {
1961 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>';
1964 if (!empty($arrayfields[
't.note'][
'checked'])) {
1965 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1968 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1970 print
'<td class="liste_titre right">';
1972 $durationtouse_start =
'';
1973 if ($search_timespent_starthour || $search_timespent_startmin) {
1974 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1976 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1977 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1980 $durationtouse_end =
'';
1981 if ($search_timespent_endhour || $search_timespent_endmin) {
1982 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1984 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
1985 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1991 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1992 print
'<td class="liste_titre right"></td>';
1995 if (!empty($arrayfields[
'value'][
'checked'])) {
1996 print
'<td class="liste_titre"></td>';
1999 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2000 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2008 $parameters = array(
'arrayfields' => $arrayfields);
2009 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2010 print $hookmanager->resPrint;
2013 print
'<td class="liste_titre center">';
2014 $searchpicto = $form->showFilterButtons();
2018 print
'</tr>' .
"\n";
2021 $totalarray = array();
2022 $totalarray[
'nbfield'] = 0;
2026 print
'<tr class="liste_titre">';
2028 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2029 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2032 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2033 $totalarray[
'nbfield']++;
2035 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2036 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2037 $totalarray[
'nbfield']++;
2039 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2041 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2042 $totalarray[
'nbfield']++;
2044 if (!empty($allprojectforuser)) {
2045 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2047 $totalarray[
'nbfield']++;
2049 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2050 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2051 $totalarray[
'nbfield']++;
2054 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2055 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2056 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2057 $totalarray[
'nbfield']++;
2059 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2060 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2061 $totalarray[
'nbfield']++;
2064 if (!empty($arrayfields[
'author'][
'checked'])) {
2065 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2066 $totalarray[
'nbfield']++;
2068 if (!empty($arrayfields[
't.note'][
'checked'])) {
2069 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2070 $totalarray[
'nbfield']++;
2072 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2073 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2074 $totalarray[
'nbfield']++;
2076 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2077 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2078 $totalarray[
'nbfield']++;
2081 if (!empty($arrayfields[
'value'][
'checked'])) {
2082 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2083 $totalarray[
'nbfield']++;
2085 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2086 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2087 $totalarray[
'nbfield']++;
2094 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2095 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2096 print $hookmanager->resPrint;
2098 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2099 $totalarray[
'nbfield']++;
2103 $tasktmp =
new Task($db);
2104 $tmpinvoice =
new Facture($db);
2107 $param .=
'&page='.((int) $page);
2109 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2113 $savnbfield = $totalarray[
'nbfield'];
2114 $totalarray = array();
2115 $totalarray[
'nbfield'] = 0;
2117 foreach ($tasks as $task_time) {
2123 $invoiced = $task_time->invoice_id ? true :
false;
2125 $date1 = $db->jdate($task_time->element_date);
2126 $date2 = $db->jdate($task_time->element_datehour);
2130 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2134 print
'<td class="center nowraponall">';
2135 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2136 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2137 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2139 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2140 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2141 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2142 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' :
'').
'">';
2143 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2147 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' :
'') .
'">';
2148 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2152 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' :
'').
'">';
2153 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2156 if ($massactionbutton || $massaction) {
2158 if (in_array($task_time->rowid, $arrayofselected)) {
2164 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2165 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2169 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2170 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2179 $totalarray[
'nbfield']++;
2184 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2185 print
'<td class="nowrap">';
2186 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2187 if (empty($task_time->element_date_withhour)) {
2188 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2190 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2193 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2197 $totalarray[
'nbfield']++;
2202 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2203 print
'<td class="tdoverflowmax125">';
2204 if ($task_time->fk_soc > 0) {
2205 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2206 $tmpsociete =
new Societe($db);
2207 $tmpsociete->fetch($task_time->fk_soc);
2208 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2210 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2212 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2216 $totalarray[
'nbfield']++;
2221 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2222 if ($task_time->fk_soc > 0) {
2223 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2224 $tmpsociete =
new Societe($db);
2225 $tmpsociete->fetch($task_time->fk_soc);
2226 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2228 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2230 $valtoshow = $tmpsociete->name_alias;
2232 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2236 $totalarray[
'nbfield']++;
2241 if (!empty($allprojectforuser)) {
2242 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2243 print
'<td class="nowraponall">';
2244 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2245 $tmpproject =
new Project($db);
2246 $tmpproject->fetch($task_time->fk_projet);
2247 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2249 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2251 print $tmpproject->getNomUrl(1);
2254 $totalarray[
'nbfield']++;
2257 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2258 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2259 $tmpproject =
new Project($db);
2260 $tmpproject->fetch($task_time->fk_projet);
2261 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2263 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2265 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2269 $totalarray[
'nbfield']++;
2275 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2276 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2277 print
'<td class="nowrap">';
2278 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2279 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2281 $tasktmp->id = $task_time->fk_element;
2282 $tasktmp->ref = $task_time->ref;
2283 $tasktmp->label = $task_time->label;
2284 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2288 $totalarray[
'nbfield']++;
2291 } elseif ($action !==
'createtime') {
2292 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2296 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2297 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2298 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2302 $totalarray[
'nbfield']++;
2308 if (!empty($arrayfields[
'author'][
'checked'])) {
2309 print
'<td class="minwidth100 tdoverflowmax125">';
2310 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2313 $object->fetch($task_time->fk_element);
2315 $contactsoftask =
$object->getListContactId(
'internal');
2316 if (!in_array($task_time->fk_user, $contactsoftask)) {
2317 $contactsoftask[] = $task_time->fk_user;
2319 if (count($contactsoftask) > 0) {
2320 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2321 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2323 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2326 $userstatic->id = $task_time->fk_user;
2327 $userstatic->lastname = $task_time->lastname;
2328 $userstatic->firstname = $task_time->firstname;
2329 $userstatic->photo = $task_time->photo;
2330 $userstatic->gender = $task_time->gender;
2331 $userstatic->status = $task_time->user_status;
2333 print $userstatic->getNomUrl(-1);
2337 $totalarray[
'nbfield']++;
2342 if (!empty($arrayfields[
't.note'][
'checked'])) {
2343 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2344 print
'<td class="small">';
2345 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2348 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2353 $totalarray[
'nbfield']++;
2355 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2356 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2360 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2361 print
'<td class="right nowraponall">';
2362 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2363 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2364 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2370 $totalarray[
'nbfield']++;
2373 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2375 if (empty($totalarray[
'val'][
't.element_duration'])) {
2376 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2378 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2381 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2383 if (empty($totalarray[
'totalduration'])) {
2384 $totalarray[
'totalduration'] = $task_time->element_duration;
2386 $totalarray[
'totalduration'] += $task_time->element_duration;
2391 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2392 print
'<td class="nowraponall">';
2393 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2395 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', 0,
'',
null, 1);
2396 } elseif (!empty($task_time->fk_product)) {
2398 $resultFetch = $product->fetch($task_time->fk_product);
2399 if ($resultFetch < 0) {
2402 print $product->getNomUrl(1);
2407 $totalarray[
'nbfield']++;
2412 if (!empty($arrayfields[
'value'][
'checked'])) {
2413 $langs->load(
"salaries");
2414 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2416 print
'<td class="nowraponall right">';
2417 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2418 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2422 $totalarray[
'nbfield']++;
2425 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2427 if (empty($totalarray[
'val'][
'value'])) {
2428 $totalarray[
'val'][
'value'] = $value;
2430 $totalarray[
'val'][
'value'] += $value;
2433 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2435 if (empty($totalarray[
'totalvalue'])) {
2436 $totalarray[
'totalvalue'] = $value;
2438 $totalarray[
'totalvalue'] += $value;
2443 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2444 print
'<td class="center">';
2446 if ($projectstatic->usage_bill_time) {
2447 if ($task_time->invoice_id) {
2448 $result = $tmpinvoice->fetch($task_time->invoice_id);
2450 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2451 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2453 print $tmpinvoice->getNomUrl(1);
2454 if (!empty($task_time->invoice_line_id)) {
2456 $invoiceLine->fetch($task_time->invoice_line_id);
2457 if (!empty($invoiceLine->id)) {
2458 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2459 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2466 if (intval($task_time->billable) == 1) {
2467 print $langs->trans(
"No");
2469 print $langs->trans(
"Disabled");
2473 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2478 $totalarray[
'nbfield']++;
2488 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2489 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2490 print $hookmanager->resPrint;
2494 print
'<td class="center nowraponall">';
2495 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2496 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2497 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2499 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2500 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2501 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2502 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' :
'').
'">';
2503 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2507 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' :
'') .
'">';
2508 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2512 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' :
'').
'">';
2513 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2516 if ($massactionbutton || $massaction) {
2518 if (in_array($task_time->rowid, $arrayofselected)) {
2524 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2525 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2529 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2530 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2539 $totalarray[
'nbfield']++;
2548 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2549 print
'<!-- first line -->';
2550 print
'<tr class="oddeven">';
2558 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2559 print
'<td class="nowrap">';
2560 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2561 if (empty($task_time->element_date_withhour)) {
2562 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2564 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2567 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2573 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2574 print
'<td class="nowrap">';
2579 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2580 print
'<td class="nowrap">';
2585 if (!empty($allprojectforuser)) {
2586 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2587 print
'<td class="nowrap">';
2593 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2594 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2595 print
'<td class="nowrap">';
2596 $tasktmp->id = $task_time->fk_element;
2597 $tasktmp->ref = $task_time->ref;
2598 $tasktmp->label = $task_time->label;
2599 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2605 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2606 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2607 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2614 if (!empty($arrayfields[
'author'][
'checked'])) {
2615 print
'<td class="nowraponall">';
2616 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2620 $contactsoftask =
$object->getListContactId(
'internal');
2621 if (!in_array($task_time->fk_user, $contactsoftask)) {
2622 $contactsoftask[] = $task_time->fk_user;
2624 if (count($contactsoftask) > 0) {
2625 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2626 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2628 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2631 $userstatic->id = $task_time->fk_user;
2632 $userstatic->lastname = $task_time->lastname;
2633 $userstatic->firstname = $task_time->firstname;
2634 $userstatic->photo = $task_time->photo;
2635 $userstatic->status = $task_time->user_status;
2636 print $userstatic->getNomUrl(-1);
2642 if (!empty($arrayfields[
't.note'][
'checked'])) {
2643 print
'<td class="tdoverflowmax300">';
2644 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2645 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2650 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2651 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2655 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2656 print
'<td class="right">';
2657 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2658 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2659 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2667 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2668 print
'<td class="nowraponall tdoverflowmax125">';
2673 if (!empty($arrayfields[
'value'][
'checked'])) {
2674 print
'<td class="right">';
2675 print
'<span class="amount">';
2676 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2677 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2683 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2684 print
'<td class="right">';
2685 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2686 if (isset($task_time->total_ht)) {
2687 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2698 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2699 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2700 print $hookmanager->resPrint;
2704 print
'<td class="center nowraponall">';
2713 print
'<!-- second line --><tr class="oddeven">';
2717 print
'<td class="center nowraponall">';
2722 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2723 print
'<td class="nowrap">';
2724 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2725 if (empty($task_time->element_date_withhour)) {
2726 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2728 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2731 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2737 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2738 print
'<td class="nowrap">';
2743 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2744 print
'<td class="nowrap">';
2749 if (!empty($allprojectforuser)) {
2750 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2751 print
'<td class="nowrap">';
2757 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2758 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2759 print
'<td class="nowrap">';
2760 $tasktmp->id = $task_time->fk_element;
2761 $tasktmp->ref = $task_time->ref;
2762 $tasktmp->label = $task_time->label;
2763 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2769 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2770 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2771 print
'<td class="nowrap">';
2778 if (!empty($arrayfields[
'author'][
'checked'])) {
2779 print
'<td class="nowraponall tdoverflowmax100">';
2780 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2784 $contactsoftask =
$object->getListContactId(
'internal');
2785 if (!in_array($task_time->fk_user, $contactsoftask)) {
2786 $contactsoftask[] = $task_time->fk_user;
2788 if (count($contactsoftask) > 0) {
2789 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2790 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2792 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2795 $userstatic->id = $task_time->fk_user;
2796 $userstatic->lastname = $task_time->lastname;
2797 $userstatic->firstname = $task_time->firstname;
2798 $userstatic->photo = $task_time->photo;
2799 $userstatic->status = $task_time->user_status;
2800 print $userstatic->getNomUrl(-1);
2806 if (!empty($arrayfields[
't.note'][
'checked'])) {
2807 print
'<td class="small tdoverflowmax300"">';
2808 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2809 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2814 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2815 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2819 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2820 print
'<td class="right">';
2821 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2822 print
'<input type="hidden" name="old_duration_2" value="0">';
2823 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2831 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2832 print
'<td class="nowraponall tdoverflowmax125">';
2837 if (!empty($arrayfields[
'value'][
'checked'])) {
2838 print
'<td class="right">';
2839 print
'<span class="amount">';
2841 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2847 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2848 print
'<td class="right">';
2849 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2850 if (isset($task_time->total_ht)) {
2851 print
'<span class="amount">';
2852 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2864 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2865 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2866 print $hookmanager->resPrint;
2870 print
'<td class="center nowraponall">';
2882 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2883 print
'<tr class="liste_total">';
2885 while ($i < $totalarray[
'nbfield']) {
2888 if ($num < $limit && empty($offset)) {
2889 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2891 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2893 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2894 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2895 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2896 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2905 if (!count($tasks)) {
2906 $totalnboffields = 1;
2907 foreach ($arrayfields as $value) {
2908 if (!empty($value[
'checked'])) {
2912 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2913 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2917 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2918 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2919 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 ...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
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.
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'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.