35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
55$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
56if (isModEnabled(
'eventorganization')) {
57 $langsLoad[] =
'eventorganization';
60$langs->loadLangs($langsLoad);
62$action =
GETPOST(
'action',
'alpha');
63$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$toselect =
GETPOST(
'toselect',
'array');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$optioncss =
GETPOST(
'optioncss',
'alpha');
70$mode =
GETPOST(
'mode',
'alpha');
76$project_ref =
GETPOST(
'project_ref',
'alpha');
82$search_date_startday =
GETPOSTINT(
'search_date_startday');
83$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
84$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
85$search_date_endday =
GETPOSTINT(
'search_date_endday');
86$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
87$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
88$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
89$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
90$search_note =
GETPOST(
'search_note',
'alpha');
91$search_duration =
GETPOST(
'search_duration',
'alpha');
92$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
93$search_task_label =
GETPOST(
'search_task_label',
'alpha');
94$search_user =
GETPOST(
'search_user',
'intcomma');
95$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
96$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
97$search_company =
GETPOST(
'$search_company',
'alpha');
98$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
99$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
100$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
101$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
102$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
103$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
104$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
107$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
108$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
110if (empty($page) || $page == -1) {
113$offset = $limit * $page;
114$pageprev = $page - 1;
115$pagenext = $page + 1;
117 $sortfield =
't.element_date,t.element_datehour,t.rowid';
120 $sortorder =
'DESC,DESC,DESC';
123$childids = $user->getAllChildIds(1);
127$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
131$projectstatic =
new Project($db);
134$extrafields->fetch_name_optionals_label($projectstatic->table_element);
135$extrafields->fetch_name_optionals_label(
$object->table_element);
138if ($id > 0 || $ref) {
146if (!$user->hasRight(
'projet',
'lire')) {
155 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
156 $search_user = $user->id;
166if (
GETPOST(
'cancel',
'alpha')) {
169if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
173$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
174$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
179include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
182if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
187 $search_duration =
'';
188 $search_date_startday =
'';
189 $search_date_startmonth =
'';
190 $search_date_startyear =
'';
191 $search_date_endday =
'';
192 $search_date_endmonth =
'';
193 $search_date_endyear =
'';
194 $search_date_start =
'';
195 $search_date_end =
'';
196 $search_task_ref =
'';
197 $search_company =
'';
198 $search_company_alias =
'';
199 $search_project_ref =
'';
200 $search_project_label =
'';
201 $search_task_label =
'';
203 $search_valuebilled =
'';
204 $search_product_ref =
'';
206 $search_array_options = array();
207 $search_timespent_starthour =
'';
208 $search_timespent_startmin =
'';
209 $search_timespent_endhour =
'';
210 $search_timespent_endmin =
'';
214if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
215 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
216 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
217 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
218 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
222 $langs->load(
"errors");
223 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
233 $action =
'createtime';
243 if (empty(
$object->project->status)) {
244 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
245 $action =
'createtime';
256 $object->timespent_withhour = 1;
259 $object->timespent_withhour = 0;
264 $result =
$object->addTimeSpent($user);
275 $action =
'createtime';
279if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
280 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
281 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
297 $object->fetch($id_temp, $ref);
299 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
303 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
305 $object->timespent_withhour = 1;
306 } elseif (!empty($timespent_date)) {
307 $object->timespent_date = $timespent_date;
308 $object->timespent_withhour = 0;
316 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
317 $result =
$object->updateTimeSpent($user);
330 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
334 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
337 $object->timespent_withhour = 1;
338 } elseif (!empty($timespent_date)) {
339 $object->timespent_date = $timespent_date;
340 $object->timespent_datehour = $timespent_date;
341 $object->timespent_withhour = 0;
349 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
350 $result =
$object->updateTimeSpent($user);
365if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
368 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
369 $result =
$object->delTimeSpent($user);
372 $langs->load(
"errors");
383if (!empty($project_ref) && !empty($withproject)) {
384 if ($projectstatic->fetch(0, $project_ref) > 0) {
385 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
386 if (count($tasksarray) > 0) {
387 $id = $tasksarray[0]->id;
389 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
396$projectidforalltimes = 0;
398 $projectidforalltimes =
GETPOSTINT(
'projectid');
400 $result = $projectstatic->fetch($projectidforalltimes);
401 if (!empty($projectstatic->socid)) {
402 $projectstatic->fetch_thirdparty();
404 $res = $projectstatic->fetch_optionals();
405} elseif (
GETPOST(
'project_ref',
'alpha')) {
406 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
407 $projectidforalltimes = $projectstatic->id;
411 $result = $projectstatic->fetch(
$object->fk_project);
414if ($id <= 0 && $projectidforalltimes == 0) {
415 $allprojectforuser = $user->id;
418if ($action ==
'confirm_generateinvoice') {
419 if (!empty($projectstatic->socid)) {
420 $projectstatic->fetch_thirdparty();
423 if (!($projectstatic->thirdparty->id > 0)) {
424 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
426 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
427 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
428 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
430 $tmpinvoice =
new Facture($db);
431 $tmptimespent =
new Task($db);
432 $tmpproduct =
new Product($db);
433 $fuser =
new User($db);
438 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
441 $prodDurationHoursBase = 1.0;
442 $product_data_cache = array();
444 $tmpproduct->fetch($idprod);
450 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
451 if ($prodDurationHoursBase < 0) {
453 $langs->load(
"errors");
457 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
459 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
460 $txtva = $dataforprice[
'tva_tx'];
461 $localtax1 = $dataforprice[
'localtax1'];
462 $localtax2 = $dataforprice[
'localtax2'];
464 $prodDurationHoursBase = 1;
472 $tmpinvoice->socid = $projectstatic->thirdparty->id;
474 $tmpinvoice->fk_project = $projectstatic->id;
475 $tmpinvoice->cond_reglement_id = $condidproject;
476 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
477 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
480 $tmpinvoice->fetch($invoiceToUse);
482 $result = $tmpinvoice->create($user);
490 if ($generateinvoicemode ==
'onelineperuser') {
491 $arrayoftasks = array();
492 foreach ($toselect as $key => $value) {
494 $object->fetchTimeSpent($value);
495 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
496 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
499 foreach ($arrayoftasks as $userid => $data) {
500 $fuser->fetch($userid);
501 $username = $fuser->getFullName($langs);
503 foreach ($data as $fk_product => $timespent_data) {
505 $qtyhour = $timespent_data[
'timespent'] / 3600;
512 } elseif ($idprod <= 0) {
515 $pu_ht = $fuser->thm;
520 if ($timespent_data[
'timespent']) {
521 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
526 $prodDurationHours = $prodDurationHoursBase;
527 $idprodline = $idprod;
530 $localtax1line = $localtax1;
531 $localtax2line = $localtax2;
534 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
535 if (!array_key_exists($fk_product, $product_data_cache)) {
536 $result = $tmpproduct->fetch($fk_product);
541 $prodDurationHours = $tmpproduct->getProductDurationHours();
542 if ($prodDurationHours < 0) {
544 $langs->load(
"errors");
548 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
550 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
551 $txtvaline = $dataforprice[
'tva_tx'];
552 $localtax1line = $dataforprice[
'localtax1'];
553 $localtax2line = $dataforprice[
'localtax2'];
555 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
557 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
558 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
559 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
560 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
561 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
563 $idprodline = $fk_product;
567 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
574 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
575 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
576 $result = $db->query($sql);
584 } elseif ($generateinvoicemode ==
'onelineperperiod') {
585 $arrayoftasks = array();
587 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
588 foreach ($toselect as $key => $value) {
590 $object->fetchTimeSpent($value);
592 $ftask =
new Task($db);
595 $fuser->fetch(
$object->timespent_fk_user);
596 $username = $fuser->getFullName($langs);
598 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
599 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
600 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
603 if (!empty($withdetail)) {
604 if (!empty(
$object->timespent_withhour)) {
611 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
612 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
615 foreach ($arrayoftasks as $timespent_id => $value) {
616 $userid = $value[
'user'];
620 $qtyhour = $value[
'timespent'] / 3600;
624 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
628 $prodDurationHours = $prodDurationHoursBase;
629 $idprodline = $idprod;
632 $localtax1line = $localtax1;
633 $localtax2line = $localtax2;
635 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
636 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
637 $result = $tmpproduct->fetch($value[
'fk_product']);
642 $prodDurationHours = $tmpproduct->getProductDurationHours();
643 if ($prodDurationHours < 0) {
645 $langs->load(
"errors");
649 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
651 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
652 $txtvaline = $dataforprice[
'tva_tx'];
653 $localtax1line = $dataforprice[
'localtax1'];
654 $localtax2line = $dataforprice[
'localtax2'];
656 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
658 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
659 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
660 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
661 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
662 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
664 $idprodline = $value[
'fk_product'];
666 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
674 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
675 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
676 $result = $db->query($sql);
683 } elseif ($generateinvoicemode ==
'onelinepertask') {
684 $arrayoftasks = array();
685 foreach ($toselect as $key => $value) {
687 $object->fetchTimeSpent($value);
689 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
690 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
693 foreach ($arrayoftasks as $task_id => $data) {
694 $ftask =
new Task($db);
695 $ftask->fetch($task_id);
697 foreach ($data as $fk_product => $timespent_data) {
698 $qtyhour = $timespent_data[
'timespent'] / 3600;
702 $prodDurationHours = $prodDurationHoursBase;
703 $idprodline = $idprod;
706 $localtax1line = $localtax1;
707 $localtax2line = $localtax2;
709 if (!empty($fk_product) && $fk_product !== $idprod) {
710 if (!array_key_exists($fk_product, $product_data_cache)) {
711 $result = $tmpproduct->fetch($fk_product);
716 $prodDurationHours = $tmpproduct->getProductDurationHours();
717 if ($prodDurationHours < 0) {
719 $langs->load(
"errors");
723 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
725 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
726 $txtvaline = $dataforprice[
'tva_tx'];
727 $localtax1line = $dataforprice[
'localtax1'];
728 $localtax2line = $dataforprice[
'localtax2'];
730 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
732 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
733 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
734 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
735 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
736 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
738 $idprodline = $fk_product;
742 if ($idprodline > 0) {
744 $pu_ht_for_task = $pu_htline;
747 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
749 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
755 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
757 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
763 $lineName = $ftask->ref .
' - ' . $ftask->label;
764 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0, null, $pa_ht);
773 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
774 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
775 $result = $db->query($sql);
788 $urltoinvoice = $tmpinvoice->getNomUrl(0);
789 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
790 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
800if ($action ==
'confirm_generateinter') {
801 $langs->load(
'interventions');
803 if (!empty($projectstatic->socid)) {
804 $projectstatic->fetch_thirdparty();
807 if (!($projectstatic->thirdparty->id > 0)) {
808 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
810 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
811 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
812 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
815 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
817 $tmptimespent =
new Task($db);
818 $fuser =
new User($db);
824 $tmpinter->socid = $projectstatic->thirdparty->id;
826 $tmpinter->fk_project = $projectstatic->id;
827 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
830 $tmpinter->fetch($interToUse);
832 $result = $tmpinter->create($user);
840 $arrayoftasks = array();
841 foreach ($toselect as $key => $value) {
843 $object->fetchTimeSpent($value);
846 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
847 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
848 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
849 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
852 foreach ($arrayoftasks as $timespent_id => $value) {
853 $ftask =
new Task($db);
854 $ftask->fetch($value[
'id']);
856 $qtyhour = $value[
'timespent'] / 3600;
860 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
865 $urltointer = $tmpinter->getNomUrl(0);
866 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
867 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
884$form =
new Form($db);
887$userstatic =
new User($db);
889$arrayofselected = is_array($toselect) ? $toselect : array();
891$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
892if (!empty($withproject)) {
893 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
897llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
899if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
903 if ($projectidforalltimes > 0) {
904 $result = $projectstatic->fetch($projectidforalltimes);
905 if (!empty($projectstatic->socid)) {
906 $projectstatic->fetch_thirdparty();
908 $res = $projectstatic->fetch_optionals();
909 } elseif (
$object->fetch($id, $ref) >= 0) {
910 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
913 $result = $projectstatic->fetch(
$object->fk_project);
914 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
915 $projectstatic->fetchComments();
917 if (!empty($projectstatic->socid)) {
918 $projectstatic->fetch_thirdparty();
920 $res = $projectstatic->fetch_optionals();
922 $object->project = clone $projectstatic;
925 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
926 $linktocreatetime =
'';
928 if ($projectstatic->id > 0) {
931 if (empty($id) || $tab ==
'timespent') {
938 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
940 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
942 $param .=
'&search_user=' . ((int) $search_user);
945 $param .=
'&search_month=' . ((int) $search_month);
948 $param .=
'&search_year=' . ((int) $search_year);
953 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
955 $morehtmlref =
'<div class="refidno">';
957 $morehtmlref .= $projectstatic->title;
959 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
960 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
962 $morehtmlref .=
'</div>';
965 if (!$user->hasRight(
'projet',
'all',
'lire')) {
966 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
967 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
970 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
972 print
'<div class="fichecenter">';
973 print
'<div class="fichehalfleft">';
974 print
'<div class="underbanner clearboth"></div>';
976 print
'<table class="border tableforfield centpercent">';
980 print
'<tr><td class="tdtop">';
981 print $langs->trans(
"Usage");
985 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
986 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
987 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
991 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
992 $htmltext = $langs->trans(
"ProjectFollowTasks");
993 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
997 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"' :
'')) .
'"> ';
998 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
999 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1002 if (isModEnabled(
'eventorganization')) {
1003 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"' :
'')) .
'"> ';
1004 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1005 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1011 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1012 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1013 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1018 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1020 print($start ? $start :
'?');
1023 print($end ? $end :
'?');
1024 if ($projectstatic->hasDelay()) {
1030 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1031 if ($projectstatic->public) {
1032 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1033 print $langs->trans(
'SharedProject');
1035 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1036 print $langs->trans(
'PrivateProject');
1044 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1050 print
'<div class="fichehalfright">';
1051 print
'<div class="underbanner clearboth"></div>';
1053 print
'<table class="border tableforfield centpercent">';
1056 if (isModEnabled(
'category')) {
1057 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1058 print $form->showCategories($projectstatic->id,
'project', 1);
1063 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1064 if ($projectstatic->description) {
1065 print
'<tr><td class="nottitleforfield" colspan="2">';
1066 print
'<div class="longmessagecut">';
1077 print
'<div class="clearboth"></div>';
1087 $linktocreatetimeBtnStatus = 0;
1088 $linktocreatetimeUrl =
'';
1089 $linktocreatetimeHelpText =
'';
1090 if ($user->hasRight(
'projet',
'time')) {
1091 if ($projectstatic->public || $userRead > 0) {
1092 $linktocreatetimeBtnStatus = 1;
1094 if (!empty($projectidforalltimes)) {
1096 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1097 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1100 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1101 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1104 $linktocreatetimeBtnStatus = -2;
1105 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1108 $linktocreatetimeBtnStatus = -2;
1109 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1112 $paramsbutton = array(
'morecss' =>
'reposition');
1113 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1116 $massactionbutton =
'';
1117 $arrayofmassactions = array();
1119 if ($projectstatic->id > 0) {
1121 if ($projectstatic->usage_bill_time) {
1122 $arrayofmassactions = array(
1123 'generateinvoice' => $langs->trans(
"GenerateBill"),
1127 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1128 $langs->load(
"interventions");
1129 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1133 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1134 $arrayofmassactions = array();
1136 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1141 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1143 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1145 if ($action ==
'deleteline') {
1146 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1147 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1150 $param = ($withproject ?
'&withproject=1' :
'');
1151 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1152 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1154 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1155 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1156 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1158 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1164 if (empty($withproject)) {
1165 $morehtmlref .=
'<div class="refidno">';
1166 $morehtmlref .= $langs->trans(
"Project") .
': ';
1167 $morehtmlref .= $projectstatic->getNomUrl(1);
1168 $morehtmlref .=
'<br>';
1171 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1172 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1173 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1175 $morehtmlref .=
'</div>';
1178 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1180 print
'<div class="fichecenter">';
1181 print
'<div class="fichehalfleft">';
1183 print
'<div class="underbanner clearboth"></div>';
1184 print
'<table class="border centpercent tableforfield">';
1187 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1188 if (
$object->fk_task_parent > 0) {
1189 $tasktmp =
new Task($db);
1190 $tasktmp->fetch(
$object->fk_task_parent);
1191 print $tasktmp->getNomUrl(1);
1196 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1198 print($start ? $start :
'?');
1201 print($end ? $end :
'?');
1208 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1209 if (
$object->planned_workload) {
1217 print
'<div class="fichehalfright">';
1219 print
'<div class="underbanner clearboth"></div>';
1220 print
'<table class="border tableforfield centpercent">';
1223 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1228 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1229 if (
$object->planned_workload) {
1230 $tmparray =
$object->getSummaryOfTimeSpent();
1231 if ($tmparray[
'total_duration'] > 0) {
1232 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1237 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1248 print
'<div class="clearboth"></div>';
1252 if ($action ==
'deleteline') {
1253 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1254 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1259 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1261 $hookmanager->initHooks(array(
'tasktimelist'));
1265 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1267 $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);
1268 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1272 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1273 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1274 if (empty($reshook)) {
1275 $formconfirm .= $hookmanager->resPrint;
1276 } elseif ($reshook > 0) {
1277 $formconfirm = $hookmanager->resPrint;
1284 $arrayfields = array();
1285 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1286 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1287 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1288 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1289 if (! empty($allprojectforuser)) {
1290 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1291 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1293 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1294 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1296 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1297 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1298 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1299 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1301 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1302 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1303 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' => 1,
'enabled' => (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1305 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1308 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1311 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1312 $param .=
'&contextpage=' . urlencode($contextpage);
1314 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1315 $param .=
'&limit='.((int) $limit);
1317 if ($search_month > 0) {
1318 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1320 if ($search_year > 0) {
1321 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1323 if (!empty($search_user)) {
1324 $param .=
'&search_user='.urlencode($search_user);
1326 if ($search_task_ref !=
'') {
1327 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1329 if ($search_company !=
'') {
1330 $param .=
'&$search_company=' . urlencode($search_company);
1332 if ($search_company_alias !=
'') {
1333 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1335 if ($search_project_ref !=
'') {
1336 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1338 if ($search_project_label !=
'') {
1339 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1341 if ($search_task_label !=
'') {
1342 $param .=
'&search_task_label=' . urlencode($search_task_label);
1344 if ($search_note !=
'') {
1345 $param .=
'&search_note=' . urlencode($search_note);
1347 if ($search_duration !=
'') {
1348 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1350 if ($optioncss !=
'') {
1351 $param .=
'&optioncss=' . urlencode($optioncss);
1353 if ($search_date_startday) {
1354 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1356 if ($search_date_startmonth) {
1357 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1359 if ($search_date_startyear) {
1360 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1362 if ($search_date_endday) {
1363 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1365 if ($search_date_endmonth) {
1366 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1368 if ($search_date_endyear) {
1369 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1371 if ($search_timespent_starthour) {
1372 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1374 if ($search_timespent_startmin) {
1375 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1377 if ($search_timespent_endhour) {
1378 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1380 if ($search_timespent_endmin) {
1381 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1389 $param .=
'&id=' . urlencode((
string) ($id));
1392 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1395 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1398 $parameters = array(
'param' => &$param);
1399 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1400 $param .= $hookmanager->resPrint;
1402 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1403 if ($optioncss !=
'') {
1404 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1406 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1407 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1408 if ($action ==
'editline') {
1409 print
'<input type="hidden" name="action" value="updateline">';
1410 } elseif ($action ==
'splitline') {
1411 print
'<input type="hidden" name="action" value="updatesplitline">';
1412 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1413 print
'<input type="hidden" name="action" value="addtimespent">';
1414 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1415 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1416 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1417 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1419 print
'<input type="hidden" name="action" value="list">';
1421 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1422 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1424 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1425 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1426 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1427 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1428 print
'<input type="hidden" name="page_y" value="">';
1431 if ($massaction ==
'generateinvoice') {
1432 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1433 print
'<table class="noborder centerpercent">';
1435 print
'<td class="titlefield">';
1436 print $langs->trans(
'DateInvoice');
1439 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1445 print $langs->trans(
'Mode');
1449 'onelineperuser' =>
'OneLinePerUser',
1450 'onelinepertask' =>
'OneLinePerTask',
1451 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1453 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1454 print
"\n" .
'<script type="text/javascript">';
1456 $(document).ready(function () {
1457 setDetailVisibility();
1458 $("#generateinvoicemode").change(function() {
1459 setDetailVisibility();
1461 function setDetailVisibility() {
1462 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1463 if (generateinvoicemode=="onelineperperiod") {
1464 $("#detail_time_duration").show();
1466 $("#detail_time_duration").hide();
1471 print
'</script>' .
"\n";
1472 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1476 if (isModEnabled(
"service")) {
1479 print $langs->trans(
'ServiceToUseOnLines');
1482 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1487 print
'<td class="titlefield">';
1488 print $langs->trans(
'InvoiceToUse');
1491 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1495 print
'<td class="titlefield">';
1496 print $langs->trans(
"CustomerRelativeDiscount");
1499 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1502 print
'<tr class="newinvoicedetail">';
1503 print
'<td class="titlefield">';
1504 print $langs->trans(
"PaymentConditions");
1507 print $form->getSelectConditionsPaiements($projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1521 print
'<div class="center">';
1522 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1523 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1527 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1528 print
'<div class="center">';
1529 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1533 } elseif ($massaction ==
'generateinter') {
1535 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1537 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1539 print
'<table class="noborder centpercent">';
1541 print
'<td class="titlefield">';
1542 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1546 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1551 print
'<div class="center">';
1552 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1553 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1557 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1558 print
'<div class="center">';
1559 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1566 $parameters = array(
1567 'toselect' => $toselect,
1568 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1571 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1575 print $hookmanager->resPrint;
1583 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1584 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1586 $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,";
1587 $sql .=
" t.fk_product,";
1588 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1589 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1590 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1591 $sql .=
" p.fk_soc,s.name_alias,";
1592 $sql .=
" t.invoice_line_id,";
1593 $sql .=
" pt.billable";
1595 $parameters = array();
1596 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1597 $sql .= $hookmanager->resPrint;
1598 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1602 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1603 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1604 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1605 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1606 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1607 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1608 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1609 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1612 $parameters = array();
1613 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1614 $sql .= $hookmanager->resPrint;
1615 $sql .=
" WHERE elementtype = 'task'";
1616 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1617 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1621 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1622 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1624 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1626 $sql .=
" AND t.fk_element =".((int)
$object->id);
1627 } elseif (!empty($projectidforalltimes)) {
1629 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1630 } elseif (!empty($allprojectforuser)) {
1632 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1633 $search_user = $user->id;
1635 if ($search_user > 0) {
1636 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1643 if ($search_task_ref) {
1646 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1647 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1649 if ($search_company) {
1652 if ($search_company_alias) {
1656 if ($search_project_ref) {
1659 if ($search_project_label) {
1662 if ($search_task_label) {
1665 if ($search_user > 0) {
1668 if (!empty($search_product_ref)) {
1671 if ($search_valuebilled ==
'1') {
1672 $sql .=
' AND t.invoice_id > 0';
1674 if ($search_valuebilled ==
'0') {
1675 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1678 if ($search_date_start) {
1679 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1681 if ($search_date_end) {
1682 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1685 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1686 if ($search_timespent_starthour || $search_timespent_startmin) {
1687 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1688 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1689 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1692 if ($search_timespent_endhour || $search_timespent_endmin) {
1693 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1694 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1695 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1699 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1702 $parameters = array();
1703 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1704 $sql .= $hookmanager->resPrint;
1707 $nbtotalofrecords =
'';
1710 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1711 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1712 $resql = $db->query($sqlforcount);
1714 $objforcount = $db->fetch_object($resql);
1715 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1720 if (($page * $limit) > $nbtotalofrecords) {
1728 $sql .= $db->order($sortfield, $sortorder);
1730 $sql .= $db->plimit($limit + 1, $offset);
1733 $resql = $db->query($sql);
1739 $num = $db->num_rows($resql);
1742 if (!empty($projectidforalltimes)) {
1743 print
'<!-- List of time spent for project -->' .
"\n";
1745 $title = $langs->trans(
"ListTaskTimeUserProject");
1747 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1749 print
'<!-- List of time spent -->' .
"\n";
1751 $title = $langs->trans(
"ListTaskTimeForTask");
1753 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1758 $row = $db->fetch_object($resql);
1770 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1771 print
'<!-- table to add time spent -->' .
"\n";
1773 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1776 print
'<div class="div-table-responsive-no-min">';
1777 print
'<table class="noborder nohover centpercent">';
1779 print
'<tr class="liste_titre">';
1780 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1781 if (!empty($allprojectforuser)) {
1782 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1785 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1787 print
'<td>' . $langs->trans(
"By") .
'</td>';
1788 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1789 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1790 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1794 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1795 print
'<td>'.$langs->trans(
"Product").
'</td>';
1799 $parameters = array(
'mode' =>
'create');
1800 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1801 print $hookmanager->resPrint;
1805 print
'<tr class="oddeven nohover">';
1808 print
'<td class="maxwidthonsmartphone">';
1810 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1813 if (!empty($allprojectforuser)) {
1822 print
'<td class="maxwidthonsmartphone">';
1823 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1828 print
'<td class="maxwidthonsmartphone nowraponall">';
1829 $contactsofproject = $projectstatic->getListContactId(
'internal');
1830 if (count($contactsofproject) > 0) {
1831 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1832 if (in_array($user->id, $contactsofproject)) {
1833 $userid = $user->id;
1835 $userid = $contactsofproject[0];
1838 if ($projectstatic->public) {
1839 $contactsofproject = array();
1841 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1844 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1851 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1855 print
'<td class="nowraponall">';
1856 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1857 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1858 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1860 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1864 print
'<td class="nowrap">';
1865 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1873 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1874 print
'<td class="nowraponall">';
1876 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'', null, 1);
1882 $parameters = array(
'mode' =>
'create');
1883 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1884 print $hookmanager->resPrint;
1886 print
'<td class="center">';
1887 $form->buttonsSaveCancel();
1888 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1889 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1898 $moreforfilter =
'';
1900 $parameters = array();
1901 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1902 if (empty($reshook)) {
1903 $moreforfilter .= $hookmanager->resPrint;
1905 $moreforfilter = $hookmanager->resPrint;
1908 if (!empty($moreforfilter)) {
1909 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1910 print $moreforfilter;
1914 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1915 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1916 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1918 print
'<div class="div-table-responsive">';
1919 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1923 print
'<tr class="liste_titre_filter">';
1926 print
'<td class="liste_titre center">';
1927 $searchpicto = $form->showFilterButtons(
'left');
1932 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1933 print
'<td class="liste_titre left">';
1934 print
'<div class="nowrapfordate">';
1935 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1937 print
'<div class="nowrapfordate">';
1938 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1943 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1944 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1948 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1949 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1952 if (!empty($allprojectforuser)) {
1953 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1954 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1956 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1957 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1961 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1962 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1963 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1965 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1966 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1970 if (!empty($arrayfields[
'author'][
'checked'])) {
1971 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>';
1974 if (!empty($arrayfields[
't.note'][
'checked'])) {
1975 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1978 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1980 print
'<td class="liste_titre right">';
1982 $durationtouse_start =
'';
1983 if ($search_timespent_starthour || $search_timespent_startmin) {
1984 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1986 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1987 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1990 $durationtouse_end =
'';
1991 if ($search_timespent_endhour || $search_timespent_endmin) {
1992 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1994 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
1995 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2001 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2002 print
'<td class="liste_titre right"></td>';
2005 if (!empty($arrayfields[
'value'][
'checked'])) {
2006 print
'<td class="liste_titre"></td>';
2009 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2010 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2018 $parameters = array(
'arrayfields' => $arrayfields);
2019 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2020 print $hookmanager->resPrint;
2023 print
'<td class="liste_titre center">';
2024 $searchpicto = $form->showFilterButtons();
2028 print
'</tr>' .
"\n";
2031 $totalarray = array();
2032 $totalarray[
'nbfield'] = 0;
2036 print
'<tr class="liste_titre">';
2038 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2039 $totalarray[
'nbfield']++;
2041 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2042 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2043 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2046 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2047 $totalarray[
'nbfield']++;
2049 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2051 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2052 $totalarray[
'nbfield']++;
2054 if (!empty($allprojectforuser)) {
2055 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2057 $totalarray[
'nbfield']++;
2059 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2060 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2061 $totalarray[
'nbfield']++;
2064 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2065 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2066 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2067 $totalarray[
'nbfield']++;
2069 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2070 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2071 $totalarray[
'nbfield']++;
2074 if (!empty($arrayfields[
'author'][
'checked'])) {
2075 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2076 $totalarray[
'nbfield']++;
2078 if (!empty($arrayfields[
't.note'][
'checked'])) {
2079 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2080 $totalarray[
'nbfield']++;
2082 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2083 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2084 $totalarray[
'nbfield']++;
2086 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2087 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2088 $totalarray[
'nbfield']++;
2091 if (!empty($arrayfields[
'value'][
'checked'])) {
2092 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2093 $totalarray[
'nbfield']++;
2095 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2096 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2097 $totalarray[
'nbfield']++;
2104 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2105 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2106 print $hookmanager->resPrint;
2108 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2109 $totalarray[
'nbfield']++;
2113 $tasktmp =
new Task($db);
2114 $tmpinvoice =
new Facture($db);
2117 $param .=
'&page='.((int) $page);
2119 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2123 $savnbfield = $totalarray[
'nbfield'];
2124 $totalarray = array();
2125 $totalarray[
'nbfield'] = 0;
2127 foreach ($tasks as $task_time) {
2133 $invoiced = $task_time->invoice_id ? true :
false;
2135 $date1 = $db->jdate($task_time->element_date);
2136 $date2 = $db->jdate($task_time->element_datehour);
2140 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2144 print
'<td class="center nowraponall">';
2145 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2146 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2147 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2149 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2150 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2151 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2152 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' :
'').
'">';
2153 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2157 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' :
'') .
'">';
2158 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2162 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' :
'').
'">';
2163 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2166 if ($massactionbutton || $massaction) {
2168 if (in_array($task_time->rowid, $arrayofselected)) {
2174 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2175 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2179 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2180 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2189 $totalarray[
'nbfield']++;
2194 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2195 print
'<td class="nowrap">';
2196 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2197 if (empty($task_time->element_date_withhour)) {
2198 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2200 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2203 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2207 $totalarray[
'nbfield']++;
2212 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2213 print
'<td class="tdoverflowmax125">';
2214 if ($task_time->fk_soc > 0) {
2215 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2216 $tmpsociete =
new Societe($db);
2217 $tmpsociete->fetch($task_time->fk_soc);
2218 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2220 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2222 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2226 $totalarray[
'nbfield']++;
2231 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2232 if ($task_time->fk_soc > 0) {
2233 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2234 $tmpsociete =
new Societe($db);
2235 $tmpsociete->fetch($task_time->fk_soc);
2236 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2238 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2240 $valtoshow = $tmpsociete->name_alias;
2242 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2246 $totalarray[
'nbfield']++;
2251 if (!empty($allprojectforuser)) {
2252 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2253 print
'<td class="nowraponall">';
2254 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2255 $tmpproject =
new Project($db);
2256 $tmpproject->fetch($task_time->fk_projet);
2257 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2259 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2261 print $tmpproject->getNomUrl(1);
2264 $totalarray[
'nbfield']++;
2267 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2268 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2269 $tmpproject =
new Project($db);
2270 $tmpproject->fetch($task_time->fk_projet);
2271 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2273 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2275 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2279 $totalarray[
'nbfield']++;
2285 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2286 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2287 print
'<td class="nowrap">';
2288 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2289 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2291 $tasktmp->id = $task_time->fk_element;
2292 $tasktmp->ref = $task_time->ref;
2293 $tasktmp->label = $task_time->label;
2294 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2298 $totalarray[
'nbfield']++;
2301 } elseif ($action !==
'createtime') {
2302 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2306 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2307 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2308 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2312 $totalarray[
'nbfield']++;
2318 if (!empty($arrayfields[
'author'][
'checked'])) {
2319 print
'<td class="minwidth100 tdoverflowmax125">';
2320 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2323 $object->fetch($task_time->fk_element);
2325 $contactsoftask =
$object->getListContactId(
'internal');
2326 if (!in_array($task_time->fk_user, $contactsoftask)) {
2327 $contactsoftask[] = $task_time->fk_user;
2329 if (count($contactsoftask) > 0) {
2330 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2331 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2333 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2336 $userstatic->id = $task_time->fk_user;
2337 $userstatic->lastname = $task_time->lastname;
2338 $userstatic->firstname = $task_time->firstname;
2339 $userstatic->photo = $task_time->photo;
2340 $userstatic->gender = $task_time->gender;
2341 $userstatic->status = $task_time->user_status;
2343 print $userstatic->getNomUrl(-1);
2347 $totalarray[
'nbfield']++;
2352 if (!empty($arrayfields[
't.note'][
'checked'])) {
2353 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2354 print
'<td class="small">';
2355 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2358 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2363 $totalarray[
'nbfield']++;
2365 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2366 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2370 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2371 print
'<td class="right nowraponall">';
2372 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2373 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2374 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2380 $totalarray[
'nbfield']++;
2383 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2385 if (empty($totalarray[
'val'][
't.element_duration'])) {
2386 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2388 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2391 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2393 if (empty($totalarray[
'totalduration'])) {
2394 $totalarray[
'totalduration'] = $task_time->element_duration;
2396 $totalarray[
'totalduration'] += $task_time->element_duration;
2401 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2402 print
'<td class="nowraponall">';
2403 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2405 print $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', 0,
'',
null, 1);
2406 } elseif (!empty($task_time->fk_product)) {
2408 $resultFetch = $product->fetch($task_time->fk_product);
2409 if ($resultFetch < 0) {
2412 print $product->getNomUrl(1);
2417 $totalarray[
'nbfield']++;
2422 if (!empty($arrayfields[
'value'][
'checked'])) {
2423 $langs->load(
"salaries");
2424 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2426 print
'<td class="nowraponall right">';
2427 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2428 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2432 $totalarray[
'nbfield']++;
2435 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2437 if (empty($totalarray[
'val'][
'value'])) {
2438 $totalarray[
'val'][
'value'] = $value;
2440 $totalarray[
'val'][
'value'] += $value;
2443 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2445 if (empty($totalarray[
'totalvalue'])) {
2446 $totalarray[
'totalvalue'] = $value;
2448 $totalarray[
'totalvalue'] += $value;
2453 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2454 print
'<td class="center">';
2456 if ($projectstatic->usage_bill_time) {
2457 if ($task_time->invoice_id) {
2458 $result = $tmpinvoice->fetch($task_time->invoice_id);
2460 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2461 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2463 print $tmpinvoice->getNomUrl(1);
2464 if (!empty($task_time->invoice_line_id)) {
2466 $invoiceLine->fetch($task_time->invoice_line_id);
2467 if (!empty($invoiceLine->id)) {
2468 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2469 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2476 if (intval($task_time->billable) == 1) {
2477 print $langs->trans(
"No");
2479 print $langs->trans(
"Disabled");
2483 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2488 $totalarray[
'nbfield']++;
2498 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2499 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2500 print $hookmanager->resPrint;
2504 print
'<td class="center nowraponall">';
2505 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2506 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2507 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2509 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2510 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2511 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2512 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' :
'').
'">';
2513 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2517 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' :
'') .
'">';
2518 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2522 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' :
'').
'">';
2523 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2526 if ($massactionbutton || $massaction) {
2528 if (in_array($task_time->rowid, $arrayofselected)) {
2534 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2535 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2539 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2540 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2549 $totalarray[
'nbfield']++;
2558 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2559 print
'<!-- first line -->';
2560 print
'<tr class="oddeven">';
2568 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2569 print
'<td class="nowrap">';
2570 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2571 if (empty($task_time->element_date_withhour)) {
2572 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2574 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2577 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2583 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2584 print
'<td class="nowrap">';
2589 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2590 print
'<td class="nowrap">';
2595 if (!empty($allprojectforuser)) {
2596 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2597 print
'<td class="nowrap">';
2603 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2604 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2605 print
'<td class="nowrap">';
2606 $tasktmp->id = $task_time->fk_element;
2607 $tasktmp->ref = $task_time->ref;
2608 $tasktmp->label = $task_time->label;
2609 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2615 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2616 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2617 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2624 if (!empty($arrayfields[
'author'][
'checked'])) {
2625 print
'<td class="nowraponall">';
2626 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2628 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2631 $contactsoftask =
$object->getListContactId(
'internal');
2632 if (!in_array($task_time->fk_user, $contactsoftask)) {
2633 $contactsoftask[] = $task_time->fk_user;
2635 if (count($contactsoftask) > 0) {
2636 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2637 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2639 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2642 $userstatic->id = $task_time->fk_user;
2643 $userstatic->lastname = $task_time->lastname;
2644 $userstatic->firstname = $task_time->firstname;
2645 $userstatic->photo = $task_time->photo;
2646 $userstatic->status = $task_time->user_status;
2647 print $userstatic->getNomUrl(-1);
2653 if (!empty($arrayfields[
't.note'][
'checked'])) {
2654 print
'<td class="tdoverflowmax300">';
2655 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2656 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2661 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2662 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2666 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2667 print
'<td class="right">';
2668 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2669 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2670 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2678 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2679 print
'<td class="nowraponall tdoverflowmax125">';
2684 if (!empty($arrayfields[
'value'][
'checked'])) {
2685 print
'<td class="right">';
2686 print
'<span class="amount">';
2687 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2688 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2694 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2695 print
'<td class="right">';
2696 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2697 if (isset($task_time->total_ht)) {
2698 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2709 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2710 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2711 print $hookmanager->resPrint;
2715 print
'<td class="center nowraponall">';
2724 print
'<!-- second line --><tr class="oddeven">';
2728 print
'<td class="center nowraponall">';
2733 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2734 print
'<td class="nowrap">';
2735 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2736 if (empty($task_time->element_date_withhour)) {
2737 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2739 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2742 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2748 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2749 print
'<td class="nowrap">';
2754 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2755 print
'<td class="nowrap">';
2760 if (!empty($allprojectforuser)) {
2761 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2762 print
'<td class="nowrap">';
2768 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2769 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2770 print
'<td class="nowrap">';
2771 $tasktmp->id = $task_time->fk_element;
2772 $tasktmp->ref = $task_time->ref;
2773 $tasktmp->label = $task_time->label;
2774 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2780 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2781 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2782 print
'<td class="nowrap">';
2789 if (!empty($arrayfields[
'author'][
'checked'])) {
2790 print
'<td class="nowraponall tdoverflowmax100">';
2791 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2793 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2796 $contactsoftask =
$object->getListContactId(
'internal');
2797 if (!in_array($task_time->fk_user, $contactsoftask)) {
2798 $contactsoftask[] = $task_time->fk_user;
2800 if (count($contactsoftask) > 0) {
2801 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2802 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2804 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2807 $userstatic->id = $task_time->fk_user;
2808 $userstatic->lastname = $task_time->lastname;
2809 $userstatic->firstname = $task_time->firstname;
2810 $userstatic->photo = $task_time->photo;
2811 $userstatic->status = $task_time->user_status;
2812 print $userstatic->getNomUrl(-1);
2818 if (!empty($arrayfields[
't.note'][
'checked'])) {
2819 print
'<td class="small tdoverflowmax300"">';
2820 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2821 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2826 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2827 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2831 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2832 print
'<td class="right">';
2833 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2834 print
'<input type="hidden" name="old_duration_2" value="0">';
2835 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2843 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2844 print
'<td class="nowraponall tdoverflowmax125">';
2849 if (!empty($arrayfields[
'value'][
'checked'])) {
2850 print
'<td class="right">';
2851 print
'<span class="amount">';
2853 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2859 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2860 print
'<td class="right">';
2861 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2862 if (isset($task_time->total_ht)) {
2863 print
'<span class="amount">';
2864 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2876 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2877 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2878 print $hookmanager->resPrint;
2882 print
'<td class="center nowraponall">';
2894 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2895 print
'<tr class="liste_total">';
2897 while ($i < $totalarray[
'nbfield']) {
2900 if ($num < $limit && empty($offset)) {
2901 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2903 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2905 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2906 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2907 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2908 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2917 if (!count($tasks)) {
2918 $totalnboffields = 1;
2919 foreach ($arrayfields as $value) {
2920 if (!empty($value[
'checked'])) {
2924 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2925 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2929 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2930 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2931 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_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)
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.