36require
'../../main.inc.php';
46@phan-var-force ?string $uploaddir
48require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
52require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
53require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
59$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61 $langsLoad[] =
'eventorganization';
64$langs->loadLangs($langsLoad);
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array:int');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
73$optioncss =
GETPOST(
'optioncss',
'alpha');
74$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
136$projectstatic =
new Project($db);
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
143if ($id > 0 || $ref) {
152if (!$user->hasRight(
'projet',
'lire')) {
161 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
162 $search_user = $user->id;
173if (
GETPOST(
'cancel',
'alpha')) {
176if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
180$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
181$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
186include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
189if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
194 $search_duration =
'';
195 $search_date_startday =
'';
196 $search_date_startmonth =
'';
197 $search_date_startyear =
'';
198 $search_date_endday =
'';
199 $search_date_endmonth =
'';
200 $search_date_endyear =
'';
201 $search_date_start =
'';
202 $search_date_end =
'';
203 $search_task_ref =
'';
204 $search_company =
'';
205 $search_company_alias =
'';
206 $search_project_ref =
'';
207 $search_project_label =
'';
208 $search_task_label =
'';
210 $search_valuebilled =
'';
211 $search_product_ref =
'';
213 $search_array_options = array();
214 $search_timespent_starthour =
'';
215 $search_timespent_startmin =
'';
216 $search_timespent_endhour =
'';
217 $search_timespent_endmin =
'';
221if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
222 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
223 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
224 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
225 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
229 $langs->load(
"errors");
230 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
239 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
240 $action =
'createtime';
250 if (empty(
$object->project->status)) {
251 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
252 $action =
'createtime';
263 $object->timespent_withhour = 1;
266 $object->timespent_withhour = 0;
271 $result =
$object->addTimeSpent($user);
282 $action =
'createtime';
286if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
287 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
288 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
299 $object->fetchTimeSpent($lineid);
303 $object->fetch($id_temp, $ref);
305 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
309 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
311 $object->timespent_withhour = 1;
312 } elseif (!empty($timespent_date)) {
313 $object->timespent_date = $timespent_date;
314 $object->timespent_withhour = 0;
317 if (GETPOSTISSET(
"userid_line")) {
325 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
326 $result =
$object->updateTimeSpent($user);
339 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
344 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
347 $object->timespent_withhour = 1;
348 } elseif (!empty($timespent_date)) {
349 $object->timespent_date = $timespent_date;
350 $object->timespent_datehour = $timespent_date;
351 $object->timespent_withhour = 0;
355 if (GETPOSTISSET(
"userid_line")) {
364 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
365 $result =
$object->updateTimeSpent($user);
380if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
383 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
384 $result =
$object->delTimeSpent($user);
387 $langs->load(
"errors");
398if (!empty($project_ref) && !empty($withproject)) {
399 if ($projectstatic->fetch(0, $project_ref) > 0) {
400 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
401 if (count($tasksarray) > 0) {
402 $id = $tasksarray[0]->id;
404 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
411$projectidforalltimes = 0;
413 $projectidforalltimes =
GETPOSTINT(
'projectid');
415 $result = $projectstatic->fetch($projectidforalltimes);
416 if (!empty($projectstatic->socid)) {
417 $projectstatic->fetch_thirdparty();
419 $res = $projectstatic->fetch_optionals();
420} elseif (
GETPOST(
'project_ref',
'alpha')) {
421 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
422 $projectidforalltimes = $projectstatic->id;
426 $result = $projectstatic->fetch(
$object->fk_project);
429$allprojectforuser = 0;
431if ($id <= 0 && $projectidforalltimes == 0) {
432 $allprojectforuser = $user->id;
435if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
436 if (!empty($projectstatic->socid)) {
437 $projectstatic->fetch_thirdparty();
440 if (!($projectstatic->thirdparty->id > 0)) {
441 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
443 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
444 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
445 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
447 $tmpinvoice =
new Facture($db);
448 $tmptimespent =
new Task($db);
449 $tmpproduct =
new Product($db);
450 $fuser =
new User($db);
457 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
460 $prodDurationHoursBase = 1.0;
461 $product_data_cache = array();
463 $tmpproduct->fetch($idprod);
469 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
470 if ($prodDurationHoursBase < 0) {
472 $langs->load(
"errors");
476 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
478 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
479 $txtva = $dataforprice[
'tva_tx'];
480 $localtax1 =
get_localtax($txtva, 1, $projectstatic->thirdparty);
481 $localtax2 =
get_localtax($txtva, 2, $projectstatic->thirdparty);
483 $prodDurationHoursBase = 1;
491 $tmpinvoice->socid = $projectstatic->thirdparty->id;
493 $tmpinvoice->fk_project = $projectstatic->id;
494 $tmpinvoice->cond_reglement_id = $condidproject;
495 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
496 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
499 $tmpinvoice->fetch($invoiceToUse);
501 $result = $tmpinvoice->create($user);
509 if ($generateinvoicemode ==
'onelineperuser') {
510 $arrayoftasks = array();
511 foreach ($toselect as $key => $value) {
513 $object->fetchTimeSpent($value);
514 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
515 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
518 foreach ($arrayoftasks as $userid => $data) {
519 $fuser->fetch($userid);
520 $username = $fuser->getFullName($langs);
522 foreach ($data as $fk_product => $timespent_data) {
524 $qtyhour = $timespent_data[
'timespent'] / 3600;
525 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
531 } elseif ($idprod <= 0) {
534 $pu_ht = $fuser->thm;
539 if ($timespent_data[
'timespent']) {
540 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
545 $prodDurationHours = $prodDurationHoursBase;
546 $idprodline = $idprod;
549 $localtax1line = $localtax1;
550 $localtax2line = $localtax2;
553 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
554 if (!array_key_exists($fk_product, $product_data_cache)) {
555 $result = $tmpproduct->fetch($fk_product);
560 $prodDurationHours = $tmpproduct->getProductDurationHours();
561 if ($prodDurationHours < 0) {
563 $langs->load(
"errors");
567 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
569 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
570 $txtvaline = $dataforprice[
'tva_tx'];
571 $localtax1line = $dataforprice[
'localtax1'];
572 $localtax2line = $dataforprice[
'localtax2'];
574 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
576 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
577 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
578 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
579 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
580 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
582 $idprodline = $fk_product;
589 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice").
' - '.$username .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
596 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
597 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
598 $result = $db->query($sql);
606 } elseif ($generateinvoicemode ==
'onelineperperiod') {
607 $arrayoftasks = array();
609 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
610 foreach ($toselect as $key => $value) {
612 $object->fetchTimeSpent($value);
614 $ftask =
new Task($db);
617 $fuser->fetch(
$object->timespent_fk_user);
618 $username = $fuser->getFullName($langs);
620 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
621 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
622 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
625 if (!empty($withdetail)) {
626 if (!empty(
$object->timespent_withhour)) {
633 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
634 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
637 foreach ($arrayoftasks as $timespent_id => $value) {
638 $userid = $value[
'user'];
642 $qtyhour = $value[
'timespent'] / 3600;
646 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
650 $prodDurationHours = $prodDurationHoursBase;
651 $idprodline = $idprod;
654 $localtax1line = $localtax1;
655 $localtax2line = $localtax2;
657 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
658 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
659 $result = $tmpproduct->fetch($value[
'fk_product']);
664 $prodDurationHours = $tmpproduct->getProductDurationHours();
665 if ($prodDurationHours < 0) {
667 $langs->load(
"errors");
671 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
673 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
674 $txtvaline = $dataforprice[
'tva_tx'];
675 $localtax1line = $dataforprice[
'localtax1'];
676 $localtax2line = $dataforprice[
'localtax2'];
678 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
680 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
681 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
682 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
683 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
684 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
686 $idprodline = $value[
'fk_product'];
692 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
700 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
701 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
702 $result = $db->query($sql);
709 } elseif ($generateinvoicemode ==
'onelinepertask') {
710 $arrayoftasks = array();
711 foreach ($toselect as $key => $value) {
713 $object->fetchTimeSpent($value);
715 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
716 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
719 foreach ($arrayoftasks as $task_id => $data) {
720 $ftask =
new Task($db);
721 $ftask->fetch($task_id);
723 foreach ($data as $fk_product => $timespent_data) {
724 $qtyhour = $timespent_data[
'timespent'] / 3600;
725 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
728 $prodDurationHours = $prodDurationHoursBase;
729 $idprodline = $idprod;
732 $localtax1line = $localtax1;
733 $localtax2line = $localtax2;
735 if (!empty($fk_product) && $fk_product !== $idprod) {
736 if (!array_key_exists($fk_product, $product_data_cache)) {
737 $result = $tmpproduct->fetch($fk_product);
742 $prodDurationHours = $tmpproduct->getProductDurationHours();
743 if ($prodDurationHours < 0) {
745 $langs->load(
"errors");
749 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
751 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
752 $txtvaline = $dataforprice[
'tva_tx'];
753 $localtax1line = $dataforprice[
'localtax1'];
754 $localtax2line = $dataforprice[
'localtax2'];
756 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
758 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
759 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
760 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
761 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
762 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
764 $idprodline = $fk_product;
768 if ($idprodline > 0) {
770 $pu_ht_for_task = $pu_htline;
773 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
775 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
781 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
783 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
789 $lineName = $ftask->ref .
' - ' . $ftask->label;
790 $lineid = $tmpinvoice->addline($lineName, (
float) $pu_ht_for_task, (
float)
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject, $date_start, $date_end, 0, 0, 0,
'HT', 0, 1, -1, 0,
'', 0, 0, 0, $pa_ht);
799 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
800 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
801 $result = $db->query($sql);
814 $urltoinvoice = $tmpinvoice->getNomUrl(0);
815 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
816 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
826if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
827 $langs->load(
'interventions');
829 if (!empty($projectstatic->socid)) {
830 $projectstatic->fetch_thirdparty();
833 if (!($projectstatic->thirdparty->id > 0)) {
834 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
836 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
837 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
838 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
841 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
843 $tmptimespent =
new Task($db);
844 $fuser =
new User($db);
850 $tmpinter->socid = $projectstatic->thirdparty->id;
852 $tmpinter->fk_project = $projectstatic->id;
853 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
856 $tmpinter->fetch($interToUse);
858 $result = $tmpinter->create($user);
866 $arrayoftasks = array();
867 foreach ($toselect as $key => $value) {
869 $object->fetchTimeSpent($value);
872 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
873 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
874 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
875 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
878 foreach ($arrayoftasks as $timespent_id => $value) {
879 $ftask =
new Task($db);
880 $ftask->fetch($value[
'id']);
882 $qtyhour = $value[
'timespent'] / 3600;
883 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
886 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
891 $timespent->fetch($timespent_id);
892 $timespent->intervention_id = $tmpinter->id;
893 $timespent->intervention_line_id = $lineid;
894 $result = $timespent->update($user);
904 $urltointer = $tmpinter->getNomUrl(0);
905 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
906 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
923$form =
new Form($db);
926$userstatic =
new User($db);
928$arrayofselected = is_array($toselect) ? $toselect : array();
930$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
931if (!empty($withproject)) {
932 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
936llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
939$param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
941 $param .=
'&search_user=' . ((int) $search_user);
944 $param .=
'&search_month=' . ((int) $search_month);
947 $param .=
'&search_year=' . ((int) $search_year);
951if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
953 if ($projectidforalltimes > 0) {
954 $result = $projectstatic->fetch($projectidforalltimes);
955 if (!empty($projectstatic->socid)) {
956 $projectstatic->fetch_thirdparty();
958 $res = $projectstatic->fetch_optionals();
959 } elseif (
$object->fetch($id, $ref) > 0) {
963 $result = $projectstatic->fetch(
$object->fk_project);
964 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
965 $projectstatic->fetchComments();
967 if (!empty($projectstatic->socid)) {
968 $projectstatic->fetch_thirdparty();
970 $res = $projectstatic->fetch_optionals();
972 $object->project = clone $projectstatic;
975 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
976 $linktocreatetime =
'';
978 if ($projectstatic->id > 0) {
981 if (empty($id) || $tab ==
'timespent') {
988 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
992 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
994 $morehtmlref =
'<div class="refidno">';
996 $morehtmlref .= $projectstatic->title;
998 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
999 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
1001 $morehtmlref .=
'</div>';
1004 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1005 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
1006 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1009 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1011 print
'<div class="fichecenter">';
1012 print
'<div class="fichehalfleft">';
1013 print
'<div class="underbanner clearboth"></div>';
1015 print
'<table class="border tableforfield centpercent">';
1019 print
'<tr><td class="tdtop">';
1020 print $langs->trans(
"Usage");
1024 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1025 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1026 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1030 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1031 $htmltext = $langs->trans(
"ProjectFollowTasks");
1032 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1036 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"' :
'')) .
'"> ';
1037 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1038 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1042 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"' :
'')) .
'"> ';
1043 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1044 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1050 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1051 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1052 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency) .
'</span>';
1057 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1059 print($start ? $start :
'?');
1062 print($end ? $end :
'?');
1063 if ($projectstatic->hasDelay()) {
1069 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1070 if ($projectstatic->public) {
1071 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1072 print $langs->trans(
'SharedProject');
1074 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1075 print $langs->trans(
'PrivateProject');
1083 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1089 print
'<div class="fichehalfright">';
1090 print
'<div class="underbanner clearboth"></div>';
1092 print
'<table class="border tableforfield centpercent">';
1096 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1097 print $form->showCategories($projectstatic->id,
'project', 1);
1102 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1103 if ($projectstatic->description) {
1104 print
'<tr><td class="nottitleforfield" colspan="2">';
1105 print
'<div class="longmessagecut">';
1116 print
'<div class="clearboth"></div>';
1124 $linktocreatetimeBtnStatus = 0;
1125 $linktocreatetimeUrl =
'';
1126 $linktocreatetimeHelpText =
'';
1127 if ($user->hasRight(
'projet',
'time')) {
1128 if ($projectstatic->public || $userRead > 0) {
1129 $linktocreatetimeBtnStatus = 1;
1131 if (!empty($projectidforalltimes)) {
1133 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1134 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1137 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1138 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1141 $linktocreatetimeBtnStatus = -2;
1142 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1145 $linktocreatetimeBtnStatus = -2;
1146 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1149 $paramsbutton = array(
'morecss' =>
'reposition');
1150 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1153 $massactionbutton =
'';
1154 $arrayofmassactions = array();
1156 if ($projectstatic->id > 0) {
1158 if ($projectstatic->usage_bill_time) {
1159 $arrayofmassactions = array(
1160 'generateinvoice' => $langs->trans(
"GenerateBill"),
1164 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1165 $langs->load(
"interventions");
1166 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1169 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1170 $arrayofmassactions = array();
1172 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1179 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1181 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1183 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
1184 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1186 if ($action ==
'deleteline') {
1187 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . $param;
1188 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1191 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1192 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1193 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1195 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1201 if (empty($withproject)) {
1202 $morehtmlref .=
'<div class="refidno">';
1203 $morehtmlref .= $langs->trans(
"Project") .
': ';
1204 $morehtmlref .= $projectstatic->getNomUrl(1);
1205 $morehtmlref .=
'<br>';
1208 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1209 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1210 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1212 $morehtmlref .=
'</div>';
1215 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1217 print
'<div class="fichecenter">';
1218 print
'<div class="fichehalfleft">';
1220 print
'<div class="underbanner clearboth"></div>';
1221 print
'<table class="border centpercent tableforfield">';
1224 print
'<tr><td>' . $langs->trans(
"ParentTask") .
'</td><td>';
1225 if (
$object->fk_task_parent > 0) {
1226 $tasktmp =
new Task($db);
1227 $tasktmp->fetch(
$object->fk_task_parent);
1228 print $tasktmp->getNomUrl(1);
1233 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1235 print($start ? $start :
'?');
1238 print($end ? $end :
'?');
1245 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1246 if (
$object->planned_workload) {
1254 print
'<div class="fichehalfright">';
1256 print
'<div class="underbanner clearboth"></div>';
1257 print
'<table class="border tableforfield centpercent">';
1260 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1265 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1266 if (
$object->planned_workload) {
1267 $tmparray =
$object->getSummaryOfTimeSpent();
1268 if ($tmparray[
'total_duration'] > 0) {
1269 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1274 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1285 print
'<div class="clearboth"></div>';
1289 if ($action ==
'deleteline') {
1290 $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).$param;
1291 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1296 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1297 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1298 if (empty($reshook)) {
1299 $formconfirm .= $hookmanager->resPrint;
1300 } elseif ($reshook > 0) {
1301 $formconfirm = $hookmanager->resPrint;
1305 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1307 $hookmanager->initHooks(array(
'tasktimelist'));
1313 $arrayfields = array();
1314 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1315 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1316 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1317 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1318 if (! empty($allprojectforuser)) {
1319 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1320 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1322 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1323 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1325 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1326 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1327 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1328 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1330 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1331 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int)
isModEnabled(
"salaries"));
1332 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' =>
'1',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1334 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1339 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1340 $param .=
'&contextpage=' . urlencode($contextpage);
1342 if ($limit > 0 && $limit != $conf->liste_limit) {
1343 $param .=
'&limit='.((int) $limit);
1346 $param .=
'&id='.((int) $id);
1348 if ($search_month > 0) {
1349 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1351 if ($search_year > 0) {
1352 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1354 if (!empty($search_user)) {
1355 $param .=
'&search_user='.urlencode($search_user);
1357 if ($search_task_ref !=
'') {
1358 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1360 if ($search_company !=
'') {
1361 $param .=
'&search_company=' . urlencode($search_company);
1363 if ($search_company_alias !=
'') {
1364 $param .=
'&search_company_alias=' . urlencode($search_company_alias);
1366 if ($search_project_ref !=
'') {
1367 $param .=
'&search_project_ref=' . urlencode($search_project_ref);
1369 if ($search_project_label !=
'') {
1370 $param .=
'&search_project_label=' . urlencode($search_project_label);
1372 if ($search_task_label !=
'') {
1373 $param .=
'&search_task_label=' . urlencode($search_task_label);
1375 if ($search_note !=
'') {
1376 $param .=
'&search_note=' . urlencode($search_note);
1378 if ($search_duration !=
'') {
1379 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1381 if ($optioncss !=
'') {
1382 $param .=
'&optioncss=' . urlencode($optioncss);
1384 if ($search_date_startday) {
1385 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1387 if ($search_date_startmonth) {
1388 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1390 if ($search_date_startyear) {
1391 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1393 if ($search_date_endday) {
1394 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1396 if ($search_date_endmonth) {
1397 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1399 if ($search_date_endyear) {
1400 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1402 if ($search_timespent_starthour) {
1403 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1405 if ($search_timespent_startmin) {
1406 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1408 if ($search_timespent_endhour) {
1409 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1411 if ($search_timespent_endmin) {
1412 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1419 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1422 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1425 $parameters = array(
'param' => &$param);
1426 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1427 $param .= $hookmanager->resPrint;
1429 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1430 if ($optioncss !=
'') {
1431 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1433 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1434 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1435 if ($action ==
'editline') {
1436 print
'<input type="hidden" name="action" value="updateline">';
1437 } elseif ($action ==
'splitline') {
1438 print
'<input type="hidden" name="action" value="updatesplitline">';
1439 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1440 print
'<input type="hidden" name="action" value="addtimespent">';
1441 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1442 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1443 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1444 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1446 print
'<input type="hidden" name="action" value="list">';
1448 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1449 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1453 print
'<input type="hidden" name="id" value="' . ((int) $id) .
'">';
1454 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1455 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1456 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1457 print
'<input type="hidden" name="page_y" value="">';
1460 if ($massaction ==
'generateinvoice') {
1461 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1462 print
'<table class="noborder centerpercent">';
1464 print
'<td class="titlefield">';
1465 print $langs->trans(
'DateInvoice');
1468 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1474 print $langs->trans(
'Mode');
1478 'onelineperuser' =>
'OneLinePerUser',
1479 'onelinepertask' =>
'OneLinePerTask',
1480 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1482 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1483 print
"\n" .
'<script type="text/javascript">';
1485 $(document).ready(function () {
1486 setDetailVisibility();
1487 $("#generateinvoicemode").change(function() {
1488 setDetailVisibility();
1490 function setDetailVisibility() {
1491 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1492 if (generateinvoicemode=="onelineperperiod") {
1493 $("#detail_time_duration").show();
1495 $("#detail_time_duration").hide();
1500 print
'</script>' .
"\n";
1501 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1508 print $langs->trans(
'ServiceToUseOnLines');
1511 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1516 print
'<td class="titlefield">';
1517 print $langs->trans(
'InvoiceToUse');
1520 print $form->selectInvoiceForTimeProject($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1524 print
'<td class="titlefield">';
1525 print $langs->trans(
"CustomerRelativeDiscount");
1528 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1531 print
'<tr class="newinvoicedetail">';
1532 print
'<td class="titlefield">';
1533 print $langs->trans(
"PaymentConditions");
1536 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1550 print
'<div class="center">';
1551 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1552 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1556 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1557 print
'<div class="center">';
1558 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1562 } elseif ($massaction ==
'generateinter') {
1564 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1566 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1568 print
'<table class="noborder centpercent">';
1570 print
'<td class="titlefield">';
1571 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1575 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1580 print
'<div class="center">';
1581 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1582 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1586 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1587 print
'<div class="center">';
1588 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1595 $parameters = array(
1596 'toselect' => $toselect,
1597 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1600 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1604 print $hookmanager->resPrint;
1612 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1613 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1616 if ($projectstatic->usage_bill_time) {
1617 $arrayfields[
'valuebilled'][
'checked'] = 1;
1620 $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,";
1621 $sql .=
" t.fk_product,";
1622 $sql .=
" pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet,";
1623 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1624 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1625 $sql .=
" p.fk_soc,s.name_alias,";
1626 $sql .=
" t.invoice_line_id,";
1627 $sql .=
" pt.billable";
1629 $parameters = array();
1630 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1631 $sql .= $hookmanager->resPrint;
1632 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1636 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1637 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1638 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1639 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1640 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1641 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1642 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1643 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1646 $parameters = array();
1647 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1648 $sql .= $hookmanager->resPrint;
1649 $sql .=
" WHERE elementtype = 'task'";
1650 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1651 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1655 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1656 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1658 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1660 $sql .=
" AND t.fk_element =".((int)
$object->id);
1661 } elseif (!empty($projectidforalltimes)) {
1663 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1664 } elseif (!empty($allprojectforuser)) {
1666 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1667 $search_user = $user->id;
1669 if ($search_user > 0) {
1670 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1677 if ($search_task_ref) {
1680 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1681 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1683 if ($search_company) {
1686 if ($search_company_alias) {
1690 if ($search_project_ref) {
1693 if ($search_project_label) {
1696 if ($search_task_label) {
1699 if ($search_user > 0) {
1702 if (!empty($search_product_ref)) {
1705 if ($search_valuebilled ==
'1') {
1706 $sql .=
' AND t.invoice_id > 0';
1708 if ($search_valuebilled ==
'0') {
1709 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1712 if ($search_date_start) {
1713 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1715 if ($search_date_end) {
1716 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1719 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1720 if ($search_timespent_starthour || $search_timespent_startmin) {
1721 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1722 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1723 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1726 if ($search_timespent_endhour || $search_timespent_endmin) {
1727 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1728 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1729 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1733 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1736 $parameters = array();
1737 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1738 $sql .= $hookmanager->resPrint;
1741 $nbtotalofrecords =
'';
1744 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1745 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1746 $resql = $db->query($sqlforcount);
1748 $objforcount = $db->fetch_object($resql);
1749 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1754 if (($page * $limit) > (
int) $nbtotalofrecords) {
1762 $sql .= $db->order($sortfield, $sortorder);
1764 $sql .= $db->plimit($limit + 1, $offset);
1767 $resql = $db->query($sql);
1773 $num = $db->num_rows($resql);
1776 if (!empty($projectidforalltimes)) {
1777 print
'<!-- List of time spent for project -->' .
"\n";
1779 $title = $langs->trans(
"ListTaskTimeUserProject");
1781 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1783 print
'<!-- List of time spent -->' .
"\n";
1785 $title = $langs->trans(
"ListTaskTimeForTask");
1787 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1792 $row = $db->fetch_object($resql);
1806 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1807 print
'<!-- table to add time spent -->' .
"\n";
1809 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1812 print
'<div class="div-table-responsive-no-min">';
1813 print
'<table class="noborder nohover centpercent">';
1815 print
'<tr class="liste_titre">';
1816 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1817 if (!empty($allprojectforuser)) {
1818 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1821 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1823 print
'<td>' . $langs->trans(
"By") .
'</td>';
1824 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1825 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1826 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1830 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1831 print
'<td>'.$langs->trans(
"Product").
'</td>';
1835 $parameters = array(
'mode' =>
'create');
1836 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1837 print $hookmanager->resPrint;
1841 print
'<tr class="oddeven nohover">';
1844 print
'<td class="maxwidthonsmartphone">';
1846 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1849 if (!empty($allprojectforuser)) {
1858 print
'<td class="maxwidthonsmartphone">';
1859 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1864 print
'<td class="maxwidthonsmartphone nowraponall">';
1865 $contactsofproject = $projectstatic->getListContactId(
'internal');
1866 if (count($contactsofproject) > 0) {
1867 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1868 if (in_array($user->id, $contactsofproject)) {
1869 $userid = $user->id;
1871 $userid = $contactsofproject[0];
1874 if ($projectstatic->public) {
1875 $contactsofproject = array();
1877 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1880 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1887 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1891 print
'<td class="nowraponall">';
1892 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1893 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1894 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1896 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1900 print
'<td class="nowrap">';
1901 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1909 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1910 print
'<td class="nowraponall">';
1912 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
1918 $parameters = array(
'mode' =>
'create');
1919 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1920 print $hookmanager->resPrint;
1922 print
'<td class="center">';
1923 $form->buttonsSaveCancel();
1924 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1925 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1934 $moreforfilter =
'';
1936 $parameters = array();
1937 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1938 if (empty($reshook)) {
1939 $moreforfilter .= $hookmanager->resPrint;
1941 $moreforfilter = $hookmanager->resPrint;
1944 if (!empty($moreforfilter)) {
1945 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1946 print $moreforfilter;
1950 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1951 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1952 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1955 if ($projectstatic->usage_bill_time) {
1956 $arrayfields[
'valuebilled'][
'checked'] = 1;
1959 print
'<!-- Liste of time spent -->'.
"\n";
1960 print
'<div class="div-table-responsive">';
1961 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1965 print
'<tr class="liste_titre_filter">';
1968 print
'<td class="liste_titre center">';
1969 $searchpicto = $form->showFilterButtons(
'left');
1974 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1975 print
'<td class="liste_titre left">';
1976 print
'<div class="nowrapfordate paddingright">';
1977 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1979 print
'<div class="nowrapfordate">';
1980 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1985 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1986 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1990 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1991 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1994 if (!empty($allprojectforuser)) {
1995 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1996 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1998 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1999 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2003 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2004 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2005 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2007 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2008 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2012 if (!empty($arrayfields[
'author'][
'checked'])) {
2013 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>';
2016 if (!empty($arrayfields[
't.note'][
'checked'])) {
2017 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2020 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2022 print
'<td class="liste_titre right">';
2024 $durationtouse_start =
'';
2025 if ($search_timespent_starthour || $search_timespent_startmin) {
2026 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2028 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
2029 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2032 $durationtouse_end =
'';
2033 if ($search_timespent_endhour || $search_timespent_endmin) {
2034 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2036 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2037 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2043 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2044 print
'<td class="liste_titre right"></td>';
2047 if (!empty($arrayfields[
'value'][
'checked'])) {
2048 print
'<td class="liste_titre"></td>';
2051 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2052 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2060 $parameters = array(
'arrayfields' => $arrayfields);
2061 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2062 print $hookmanager->resPrint;
2065 print
'<td class="liste_titre center">';
2066 $searchpicto = $form->showFilterButtons();
2070 print
'</tr>' .
"\n";
2078 print
'<tr class="liste_titre">';
2080 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2083 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2084 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2087 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2088 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2091 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2093 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2096 if (!empty($allprojectforuser)) {
2097 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2098 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2101 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2102 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2106 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2107 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2108 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2111 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2112 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2116 if (!empty($arrayfields[
'author'][
'checked'])) {
2117 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2120 if (!empty($arrayfields[
't.note'][
'checked'])) {
2121 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2124 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2125 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2128 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2129 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2133 if (!empty($arrayfields[
'value'][
'checked'])) {
2134 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2137 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2138 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2146 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2147 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2148 print $hookmanager->resPrint;
2150 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2155 $tasktmp =
new Task($db);
2156 $tmpinvoice =
new Facture($db);
2159 $param .=
'&page='.((int) $page);
2161 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2169 foreach ($tasks as $task_time) {
2175 $invoiced = $task_time->invoice_id ? true :
false;
2177 $date1 = $db->jdate($task_time->element_date);
2178 $date2 = $db->jdate($task_time->element_datehour);
2182 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2186 print
'<td class="center nowraponall">';
2187 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2188 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2190 print
'<input type="hidden" name="id" value="' .
$id .
'">';
2192 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2194 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2195 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2196 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2197 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' :
'').
'">';
2198 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2202 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' :
'') .
'">';
2203 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2207 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' :
'').
'">';
2208 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2211 if ($massactionbutton || $massaction) {
2213 if (in_array($task_time->rowid, $arrayofselected)) {
2219 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2220 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2224 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2225 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2239 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2240 print
'<td class="nowrap">';
2241 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2242 if (empty($task_time->element_date_withhour)) {
2243 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2245 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2248 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2257 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2258 print
'<td class="tdoverflowmax125">';
2259 if ($task_time->fk_soc > 0) {
2260 if (empty($conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2261 $tmpsociete =
new Societe($db);
2262 $tmpsociete->fetch($task_time->fk_soc);
2263 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2265 $tmpsociete = $conf->cache[
'thirdparty'][$task_time->fk_soc];
2267 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2276 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2278 if ($task_time->fk_soc > 0) {
2279 if (empty($conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2280 $tmpsociete =
new Societe($db);
2281 $tmpsociete->fetch($task_time->fk_soc);
2282 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2284 $tmpsociete = $conf->cache[
'thirdparty'][$task_time->fk_soc];
2286 $valtoshow = $tmpsociete->name_alias;
2288 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2296 if (!empty($allprojectforuser)) {
2298 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2299 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2300 $tmpproject =
new Project($db);
2301 $tmpproject->fetch($task_time->fk_projet);
2302 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2304 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2306 print
'<td class="nowraponall">';
2307 print $tmpproject->getNomUrl(1);
2314 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2315 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2316 $tmpproject =
new Project($db);
2317 $tmpproject->fetch($task_time->fk_projet);
2318 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2320 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2322 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2323 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2326 print $tmpproject->getNomUrl(1,
'', -1);
2336 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2337 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2338 print
'<td class="nowrap">';
2339 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2340 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2342 $tasktmp->id = $task_time->fk_element;
2343 $tasktmp->ref = $task_time->ref;
2344 $tasktmp->label = $task_time->label;
2345 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2352 } elseif ($action !==
'createtime') {
2353 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2357 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2358 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2359 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2360 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2363 $tasktmp->id = $task_time->fk_element;
2364 $tasktmp->ref = $task_time->ref;
2365 $tasktmp->label = $task_time->label;
2366 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2376 if (!empty($arrayfields[
'author'][
'checked'])) {
2377 print
'<td class="tdoverflowmax125">';
2378 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2381 $object->fetch($task_time->fk_element);
2383 $contactsoftask =
$object->getListContactId(
'internal');
2384 if (!in_array($task_time->fk_user, $contactsoftask)) {
2385 $contactsoftask[] = $task_time->fk_user;
2387 if (count($contactsoftask) > 0) {
2388 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2389 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2391 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2394 $userstatic->id = $task_time->fk_user;
2395 $userstatic->lastname = $task_time->lastname;
2396 $userstatic->firstname = $task_time->firstname;
2397 $userstatic->photo = $task_time->photo;
2398 $userstatic->gender = $task_time->gender;
2399 $userstatic->status = $task_time->user_status;
2401 print $userstatic->getNomUrl(-1);
2410 if (!empty($arrayfields[
't.note'][
'checked'])) {
2411 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2412 print
'<td class="small">';
2413 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2416 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2423 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2424 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2428 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2429 print
'<td class="right nowraponall">';
2430 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2431 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2432 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2443 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2444 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2446 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2452 $totalarray[
'totalduration'] = $task_time->element_duration;
2454 $totalarray[
'totalduration'] += $task_time->element_duration;
2459 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2460 print
'<td class="nowraponall">';
2461 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2463 print $form->select_produits($task_time->fk_product,
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
2464 } elseif (!empty($task_time->fk_product)) {
2466 $resultFetch = $product->fetch($task_time->fk_product);
2467 if ($resultFetch < 0) {
2470 print $product->getNomUrl(1);
2480 if (!empty($arrayfields[
'value'][
'checked'])) {
2481 $langs->load(
"salaries");
2482 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2484 print
'<td class="nowraponall right">';
2485 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2486 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2511 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2512 print
'<td class="center">';
2514 if ($projectstatic->usage_bill_time) {
2515 if ($task_time->invoice_id) {
2516 $result = $tmpinvoice->fetch($task_time->invoice_id);
2518 if ($user->hasRight(
'facture',
'lire')) {
2519 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2520 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2522 print $tmpinvoice->getNomUrl(1);
2523 if (!empty($task_time->invoice_line_id)) {
2525 $invoiceLine->fetch($task_time->invoice_line_id);
2526 if (!empty($invoiceLine->id)) {
2527 print
'<br><span class="small opacitymedium">'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2528 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2534 print $langs->trans(
"Yes");
2539 if (intval($task_time->billable) == 1) {
2540 print $langs->trans(
"No");
2542 print $langs->trans(
"Disabled");
2546 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2561 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2562 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2563 print $hookmanager->resPrint;
2567 print
'<td class="center nowraponall">';
2568 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2569 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2570 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2572 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2573 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2574 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2575 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' :
'').
'">';
2576 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2580 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' :
'') .
'">';
2581 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2585 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' :
'').
'">';
2586 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2589 if ($massactionbutton || $massaction) {
2591 if (in_array($task_time->rowid, $arrayofselected)) {
2597 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2598 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2602 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2603 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2621 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2622 print
'<!-- first line -->';
2623 print
'<tr class="oddeven">';
2631 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2632 print
'<td class="nowrap">';
2633 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2634 if (empty($task_time->element_date_withhour)) {
2635 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2637 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2640 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2646 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2647 print
'<td class="nowrap">';
2652 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2653 print
'<td class="nowrap">';
2658 if (!empty($allprojectforuser)) {
2659 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2660 print
'<td class="nowrap">';
2666 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2667 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2668 print
'<td class="nowrap">';
2669 $tasktmp->id = $task_time->fk_element;
2670 $tasktmp->ref = $task_time->ref;
2671 $tasktmp->label = $task_time->label;
2672 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2678 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2679 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2680 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2687 if (!empty($arrayfields[
'author'][
'checked'])) {
2688 print
'<td class="nowraponall">';
2689 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2691 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2694 $contactsoftask =
$object->getListContactId(
'internal');
2695 if (!in_array($task_time->fk_user, $contactsoftask)) {
2696 $contactsoftask[] = $task_time->fk_user;
2698 if (count($contactsoftask) > 0) {
2699 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2700 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2702 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2705 $userstatic->id = $task_time->fk_user;
2706 $userstatic->lastname = $task_time->lastname;
2707 $userstatic->firstname = $task_time->firstname;
2708 $userstatic->photo = $task_time->photo;
2709 $userstatic->status = $task_time->user_status;
2710 print $userstatic->getNomUrl(-1);
2716 if (!empty($arrayfields[
't.note'][
'checked'])) {
2717 print
'<td class="tdoverflowmax300">';
2718 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2719 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2724 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2725 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2729 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2730 print
'<td class="right">';
2731 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2732 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2733 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2741 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2742 print
'<td class="nowraponall tdoverflowmax125">';
2747 if (!empty($arrayfields[
'value'][
'checked'])) {
2748 print
'<td class="right">';
2749 print
'<span class="amount">';
2750 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2751 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2757 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2758 print
'<td class="right">';
2759 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2760 if (isset($task_time->total_ht)) {
2761 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2772 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2773 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2774 print $hookmanager->resPrint;
2778 print
'<td class="center nowraponall">';
2787 print
'<!-- second line --><tr class="oddeven">';
2791 print
'<td class="center nowraponall">';
2796 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2797 print
'<td class="nowraponall">';
2798 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2799 if (empty($task_time->element_date_withhour)) {
2800 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2802 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2805 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2811 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2817 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2823 if (!empty($allprojectforuser)) {
2824 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2831 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2832 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2833 print
'<td class="nowraponall">';
2834 $tasktmp->id = $task_time->fk_element;
2835 $tasktmp->ref = $task_time->ref;
2836 $tasktmp->label = $task_time->label;
2837 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2843 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2844 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2845 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2852 if (!empty($arrayfields[
'author'][
'checked'])) {
2853 print
'<td class="nowraponall tdoverflowmax100">';
2854 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2856 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2859 $contactsoftask =
$object->getListContactId(
'internal');
2860 if (!in_array($task_time->fk_user, $contactsoftask)) {
2861 $contactsoftask[] = $task_time->fk_user;
2863 if (count($contactsoftask) > 0) {
2864 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2865 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2867 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2870 $userstatic->id = $task_time->fk_user;
2871 $userstatic->lastname = $task_time->lastname;
2872 $userstatic->firstname = $task_time->firstname;
2873 $userstatic->photo = $task_time->photo;
2874 $userstatic->status = $task_time->user_status;
2875 print $userstatic->getNomUrl(-1);
2881 if (!empty($arrayfields[
't.note'][
'checked'])) {
2882 print
'<td class="small tdoverflowmax300"">';
2883 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2884 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2889 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2890 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2894 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2895 print
'<td class="right">';
2896 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2897 print
'<input type="hidden" name="old_duration_2" value="0">';
2898 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2906 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2907 print
'<td class="nowraponall tdoverflowmax125">';
2912 if (!empty($arrayfields[
'value'][
'checked'])) {
2913 print
'<td class="right">';
2914 print
'<span class="amount nowraponall">';
2916 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2923 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2924 print
'<td class="right">';
2925 if (isset($task_time->total_ht)) {
2926 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2927 print
'<span class="amount nowraponall small">';
2928 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2940 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2941 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2942 print $hookmanager->resPrint;
2946 print
'<td class="center nowraponall">';
2959 print
'<tr class="liste_total">';
2964 if ($num < $limit && empty($offset)) {
2965 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2967 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2981 if (!count($tasks)) {
2982 $totalnboffields = 1;
2983 foreach ($arrayfields as $value) {
2984 if (!empty($value[
'checked'])) {
2988 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2989 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2993 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2994 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2995 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
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...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
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...
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.