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 .
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
57if (isModEnabled(
'eventorganization')) {
58 $langsLoad[] =
'eventorganization';
61$langs->loadLangs($langsLoad);
63$action =
GETPOST(
'action',
'alpha');
64$massaction =
GETPOST(
'massaction',
'alpha');
65$confirm =
GETPOST(
'confirm',
'alpha');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$toselect =
GETPOST(
'toselect',
'array');
68$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
69$backtopage =
GETPOST(
'backtopage',
'alpha');
70$optioncss =
GETPOST(
'optioncss',
'alpha');
71$mode =
GETPOST(
'mode',
'alpha');
77$project_ref =
GETPOST(
'project_ref',
'alpha');
83$search_date_startday =
GETPOSTINT(
'search_date_startday');
84$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
85$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
86$search_date_endday =
GETPOSTINT(
'search_date_endday');
87$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
88$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
89$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
90$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
91$search_note =
GETPOST(
'search_note',
'alpha');
92$search_duration =
GETPOST(
'search_duration',
'alpha');
93$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
94$search_task_label =
GETPOST(
'search_task_label',
'alpha');
95$search_user =
GETPOST(
'search_user',
'intcomma');
96$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
97$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
98$search_company =
GETPOST(
'$search_company',
'alpha');
99$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
100$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
101$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
102$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
103$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
104$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
105$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
108$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
109$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
111if (empty($page) || $page == -1) {
114$offset = $limit * $page;
115$pageprev = $page - 1;
116$pagenext = $page + 1;
118 $sortfield =
't.element_date,t.element_datehour,t.rowid';
121 $sortorder =
'DESC,DESC,DESC';
124$childids = $user->getAllChildIds(1);
128$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
132$projectstatic =
new Project($db);
135$extrafields->fetch_name_optionals_label($projectstatic->table_element);
136$extrafields->fetch_name_optionals_label(
$object->table_element);
139if ($id > 0 || $ref) {
147if (!$user->hasRight(
'projet',
'lire')) {
156 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
157 $search_user = $user->id;
167if (
GETPOST(
'cancel',
'alpha')) {
170if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
174$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
175$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
180include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
183if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
188 $search_duration =
'';
189 $search_date_startday =
'';
190 $search_date_startmonth =
'';
191 $search_date_startyear =
'';
192 $search_date_endday =
'';
193 $search_date_endmonth =
'';
194 $search_date_endyear =
'';
195 $search_date_start =
'';
196 $search_date_end =
'';
197 $search_task_ref =
'';
198 $search_company =
'';
199 $search_company_alias =
'';
200 $search_project_ref =
'';
201 $search_project_label =
'';
202 $search_task_label =
'';
204 $search_valuebilled =
'';
205 $search_product_ref =
'';
207 $search_array_options = array();
208 $search_timespent_starthour =
'';
209 $search_timespent_startmin =
'';
210 $search_timespent_endhour =
'';
211 $search_timespent_endmin =
'';
215if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
216 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
217 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
218 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
219 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
223 $langs->load(
"errors");
224 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
234 $action =
'createtime';
244 if (empty(
$object->project->status)) {
245 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
246 $action =
'createtime';
257 $object->timespent_withhour = 1;
260 $object->timespent_withhour = 0;
265 $result =
$object->addTimeSpent($user);
276 $action =
'createtime';
280if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
281 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
282 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
298 $object->fetch($id_temp, $ref);
300 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
304 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
306 $object->timespent_withhour = 1;
307 } elseif (!empty($timespent_date)) {
308 $object->timespent_date = $timespent_date;
309 $object->timespent_withhour = 0;
317 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
318 $result =
$object->updateTimeSpent($user);
331 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
335 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
338 $object->timespent_withhour = 1;
339 } elseif (!empty($timespent_date)) {
340 $object->timespent_date = $timespent_date;
341 $object->timespent_datehour = $timespent_date;
342 $object->timespent_withhour = 0;
350 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
351 $result =
$object->updateTimeSpent($user);
366if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
369 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
370 $result =
$object->delTimeSpent($user);
373 $langs->load(
"errors");
384if (!empty($project_ref) && !empty($withproject)) {
385 if ($projectstatic->fetch(0, $project_ref) > 0) {
386 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
387 if (count($tasksarray) > 0) {
388 $id = $tasksarray[0]->id;
390 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
397$projectidforalltimes = 0;
399 $projectidforalltimes =
GETPOSTINT(
'projectid');
401 $result = $projectstatic->fetch($projectidforalltimes);
402 if (!empty($projectstatic->socid)) {
403 $projectstatic->fetch_thirdparty();
405 $res = $projectstatic->fetch_optionals();
406} elseif (
GETPOST(
'project_ref',
'alpha')) {
407 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
408 $projectidforalltimes = $projectstatic->id;
412 $result = $projectstatic->fetch(
$object->fk_project);
415if ($id <= 0 && $projectidforalltimes == 0) {
416 $allprojectforuser = $user->id;
419if ($action ==
'confirm_generateinvoice') {
420 if (!empty($projectstatic->socid)) {
421 $projectstatic->fetch_thirdparty();
424 if (!($projectstatic->thirdparty->id > 0)) {
425 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
427 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
428 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
429 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
431 $tmpinvoice =
new Facture($db);
432 $tmptimespent =
new Task($db);
433 $tmpproduct =
new Product($db);
434 $fuser =
new User($db);
439 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
442 $prodDurationHoursBase = 1.0;
443 $product_data_cache = array();
445 $tmpproduct->fetch($idprod);
451 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
452 if ($prodDurationHoursBase < 0) {
454 $langs->load(
"errors");
458 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
460 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
461 $txtva = $dataforprice[
'tva_tx'];
462 $localtax1 = $dataforprice[
'localtax1'];
463 $localtax2 = $dataforprice[
'localtax2'];
465 $prodDurationHoursBase = 1;
473 $tmpinvoice->socid = $projectstatic->thirdparty->id;
475 $tmpinvoice->fk_project = $projectstatic->id;
476 $tmpinvoice->cond_reglement_id = $condidproject;
477 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
478 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
481 $tmpinvoice->fetch($invoiceToUse);
483 $result = $tmpinvoice->create($user);
491 if ($generateinvoicemode ==
'onelineperuser') {
492 $arrayoftasks = array();
493 foreach ($toselect as $key => $value) {
495 $object->fetchTimeSpent($value);
496 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
497 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
500 foreach ($arrayoftasks as $userid => $data) {
501 $fuser->fetch($userid);
502 $username = $fuser->getFullName($langs);
504 foreach ($data as $fk_product => $timespent_data) {
506 $qtyhour = $timespent_data[
'timespent'] / 3600;
513 } elseif ($idprod <= 0) {
516 $pu_ht = $fuser->thm;
521 if ($timespent_data[
'timespent']) {
522 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
527 $prodDurationHours = $prodDurationHoursBase;
528 $idprodline = $idprod;
531 $localtax1line = $localtax1;
532 $localtax2line = $localtax2;
535 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
536 if (!array_key_exists($fk_product, $product_data_cache)) {
537 $result = $tmpproduct->fetch($fk_product);
542 $prodDurationHours = $tmpproduct->getProductDurationHours();
543 if ($prodDurationHours < 0) {
545 $langs->load(
"errors");
549 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
551 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
552 $txtvaline = $dataforprice[
'tva_tx'];
553 $localtax1line = $dataforprice[
'localtax1'];
554 $localtax2line = $dataforprice[
'localtax2'];
556 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
558 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
559 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
560 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
561 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
562 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
564 $idprodline = $fk_product;
571 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject,
'',
'', 0, 0,
'',
'HT', 0,
Product::TYPE_SERVICE);
578 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
579 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
580 $result = $db->query($sql);
588 } elseif ($generateinvoicemode ==
'onelineperperiod') {
589 $arrayoftasks = array();
591 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
592 foreach ($toselect as $key => $value) {
594 $object->fetchTimeSpent($value);
596 $ftask =
new Task($db);
599 $fuser->fetch(
$object->timespent_fk_user);
600 $username = $fuser->getFullName($langs);
602 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
603 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
604 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
607 if (!empty($withdetail)) {
608 if (!empty(
$object->timespent_withhour)) {
615 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
616 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
619 $pu_ht_saved = $pu_ht;
620 foreach ($arrayoftasks as $timespent_id => $value) {
621 $pu_ht = $pu_ht_saved;
622 $userid = $value[
'user'];
626 $qtyhour = $value[
'timespent'] / 3600;
630 if ($value[
'timespent']) {
631 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
636 $prodDurationHours = $prodDurationHoursBase;
637 $idprodline = $idprod;
640 $localtax1line = $localtax1;
641 $localtax2line = $localtax2;
643 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
644 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
645 $result = $tmpproduct->fetch($value[
'fk_product']);
650 $prodDurationHours = $tmpproduct->getProductDurationHours();
651 if ($prodDurationHours < 0) {
653 $langs->load(
"errors");
657 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
659 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
660 $txtvaline = $dataforprice[
'tva_tx'];
661 $localtax1line = $dataforprice[
'localtax1'];
662 $localtax2line = $dataforprice[
'localtax2'];
664 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
666 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
667 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
668 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
669 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
670 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
672 $idprodline = $value[
'fk_product'];
678 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject,
'',
'', 0, 0,
'',
'HT', 0,
Product::TYPE_SERVICE);
686 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
687 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
688 $result = $db->query($sql);
695 } elseif ($generateinvoicemode ==
'onelinepertask') {
696 $arrayoftasks = array();
697 foreach ($toselect as $key => $value) {
699 $object->fetchTimeSpent($value);
701 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
702 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
705 foreach ($arrayoftasks as $task_id => $data) {
706 $ftask =
new Task($db);
707 $ftask->fetch($task_id);
709 foreach ($data as $fk_product => $timespent_data) {
710 $qtyhour = $timespent_data[
'timespent'] / 3600;
714 $prodDurationHours = $prodDurationHoursBase;
715 $idprodline = $idprod;
718 $localtax1line = $localtax1;
719 $localtax2line = $localtax2;
721 if (!empty($fk_product) && $fk_product !== $idprod) {
722 if (!array_key_exists($fk_product, $product_data_cache)) {
723 $result = $tmpproduct->fetch($fk_product);
728 $prodDurationHours = $tmpproduct->getProductDurationHours();
729 if ($prodDurationHours < 0) {
731 $langs->load(
"errors");
735 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
737 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
738 $txtvaline = $dataforprice[
'tva_tx'];
739 $localtax1line = $dataforprice[
'localtax1'];
740 $localtax2line = $dataforprice[
'localtax2'];
742 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
744 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
745 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
746 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
747 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
748 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
750 $idprodline = $fk_product;
754 if ($idprodline > 0) {
756 $pu_ht_for_task = $pu_htline;
759 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
761 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
767 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
769 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
775 $lineName = $ftask->ref .
' - ' . $ftask->label;
776 $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);
785 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
786 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
787 $result = $db->query($sql);
800 $urltoinvoice = $tmpinvoice->getNomUrl(0);
801 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
802 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
812if ($action ==
'confirm_generateinter') {
813 $langs->load(
'interventions');
815 if (!empty($projectstatic->socid)) {
816 $projectstatic->fetch_thirdparty();
819 if (!($projectstatic->thirdparty->id > 0)) {
820 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
822 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
823 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
824 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
827 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
829 $tmptimespent =
new Task($db);
830 $fuser =
new User($db);
836 $tmpinter->socid = $projectstatic->thirdparty->id;
838 $tmpinter->fk_project = $projectstatic->id;
839 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
842 $tmpinter->fetch($interToUse);
844 $result = $tmpinter->create($user);
852 $arrayoftasks = array();
853 foreach ($toselect as $key => $value) {
855 $object->fetchTimeSpent($value);
858 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
859 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
860 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
861 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
864 foreach ($arrayoftasks as $timespent_id => $value) {
865 $ftask =
new Task($db);
866 $ftask->fetch($value[
'id']);
868 $qtyhour = $value[
'timespent'] / 3600;
872 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
877 $urltointer = $tmpinter->getNomUrl(0);
878 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
879 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
896$form =
new Form($db);
899$userstatic =
new User($db);
901$arrayofselected = is_array($toselect) ? $toselect : array();
903$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
904if (!empty($withproject)) {
905 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
909llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
911if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
915 if ($projectidforalltimes > 0) {
916 $result = $projectstatic->fetch($projectidforalltimes);
917 if (!empty($projectstatic->socid)) {
918 $projectstatic->fetch_thirdparty();
920 $res = $projectstatic->fetch_optionals();
921 } elseif (
$object->fetch($id, $ref) >= 0) {
922 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
925 $result = $projectstatic->fetch(
$object->fk_project);
926 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
927 $projectstatic->fetchComments();
929 if (!empty($projectstatic->socid)) {
930 $projectstatic->fetch_thirdparty();
932 $res = $projectstatic->fetch_optionals();
934 $object->project = clone $projectstatic;
937 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
938 $linktocreatetime =
'';
940 if ($projectstatic->id > 0) {
943 if (empty($id) || $tab ==
'timespent') {
950 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
952 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
954 $param .=
'&search_user=' . ((int) $search_user);
957 $param .=
'&search_month=' . ((int) $search_month);
960 $param .=
'&search_year=' . ((int) $search_year);
965 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
967 $morehtmlref =
'<div class="refidno">';
969 $morehtmlref .= $projectstatic->title;
971 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
972 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
974 $morehtmlref .=
'</div>';
977 if (!$user->hasRight(
'projet',
'all',
'lire')) {
978 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
979 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
982 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
984 print
'<div class="fichecenter">';
985 print
'<div class="fichehalfleft">';
986 print
'<div class="underbanner clearboth"></div>';
988 print
'<table class="border tableforfield centpercent">';
992 print
'<tr><td class="tdtop">';
993 print $langs->trans(
"Usage");
997 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
998 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
999 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1003 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1004 $htmltext = $langs->trans(
"ProjectFollowTasks");
1005 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1009 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"' :
'')) .
'"> ';
1010 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1011 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1014 if (isModEnabled(
'eventorganization')) {
1015 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"' :
'')) .
'"> ';
1016 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1017 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1023 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1024 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1025 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1030 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1032 print($start ? $start :
'?');
1035 print($end ? $end :
'?');
1036 if ($projectstatic->hasDelay()) {
1042 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1043 if ($projectstatic->public) {
1044 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1045 print $langs->trans(
'SharedProject');
1047 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1048 print $langs->trans(
'PrivateProject');
1056 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1062 print
'<div class="fichehalfright">';
1063 print
'<div class="underbanner clearboth"></div>';
1065 print
'<table class="border tableforfield centpercent">';
1068 if (isModEnabled(
'category')) {
1069 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1070 print $form->showCategories($projectstatic->id,
'project', 1);
1075 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1076 if ($projectstatic->description) {
1077 print
'<tr><td class="nottitleforfield" colspan="2">';
1078 print
'<div class="longmessagecut">';
1089 print
'<div class="clearboth"></div>';
1099 $linktocreatetimeBtnStatus = 0;
1100 $linktocreatetimeUrl =
'';
1101 $linktocreatetimeHelpText =
'';
1102 if ($user->hasRight(
'projet',
'time')) {
1103 if ($projectstatic->public || $userRead > 0) {
1104 $linktocreatetimeBtnStatus = 1;
1106 if (!empty($projectidforalltimes)) {
1108 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1109 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1112 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1113 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1116 $linktocreatetimeBtnStatus = -2;
1117 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1120 $linktocreatetimeBtnStatus = -2;
1121 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1124 $paramsbutton = array(
'morecss' =>
'reposition');
1125 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1128 $massactionbutton =
'';
1129 $arrayofmassactions = array();
1131 if ($projectstatic->id > 0) {
1133 if ($projectstatic->usage_bill_time) {
1134 $arrayofmassactions = array(
1135 'generateinvoice' => $langs->trans(
"GenerateBill"),
1139 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1140 $langs->load(
"interventions");
1141 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1145 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1146 $arrayofmassactions = array();
1148 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1153 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1155 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1157 if ($action ==
'deleteline') {
1158 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1159 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1162 $param = ($withproject ?
'&withproject=1' :
'');
1163 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1164 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1166 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1167 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1168 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1170 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1176 if (empty($withproject)) {
1177 $morehtmlref .=
'<div class="refidno">';
1178 $morehtmlref .= $langs->trans(
"Project") .
': ';
1179 $morehtmlref .= $projectstatic->getNomUrl(1);
1180 $morehtmlref .=
'<br>';
1183 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1184 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1185 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1187 $morehtmlref .=
'</div>';
1190 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1192 print
'<div class="fichecenter">';
1193 print
'<div class="fichehalfleft">';
1195 print
'<div class="underbanner clearboth"></div>';
1196 print
'<table class="border centpercent tableforfield">';
1199 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1200 if (
$object->fk_task_parent > 0) {
1201 $tasktmp =
new Task($db);
1202 $tasktmp->fetch(
$object->fk_task_parent);
1203 print $tasktmp->getNomUrl(1);
1208 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1210 print($start ? $start :
'?');
1213 print($end ? $end :
'?');
1220 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1221 if (
$object->planned_workload) {
1229 print
'<div class="fichehalfright">';
1231 print
'<div class="underbanner clearboth"></div>';
1232 print
'<table class="border tableforfield centpercent">';
1235 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1240 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1241 if (
$object->planned_workload) {
1242 $tmparray =
$object->getSummaryOfTimeSpent();
1243 if ($tmparray[
'total_duration'] > 0) {
1244 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1249 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1260 print
'<div class="clearboth"></div>';
1264 if ($action ==
'deleteline') {
1265 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1266 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1271 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1273 $hookmanager->initHooks(array(
'tasktimelist'));
1277 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1279 $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);
1280 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1284 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1285 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1286 if (empty($reshook)) {
1287 $formconfirm .= $hookmanager->resPrint;
1288 } elseif ($reshook > 0) {
1289 $formconfirm = $hookmanager->resPrint;
1296 $arrayfields = array();
1297 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1298 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1299 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1300 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1301 if (! empty($allprojectforuser)) {
1302 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1303 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1305 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1306 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1308 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1309 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1310 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1311 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1313 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1314 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1315 $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));
1317 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1320 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1323 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1324 $param .=
'&contextpage=' . urlencode($contextpage);
1326 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1327 $param .=
'&limit='.((int) $limit);
1329 if ($search_month > 0) {
1330 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1332 if ($search_year > 0) {
1333 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1335 if (!empty($search_user)) {
1336 $param .=
'&search_user='.urlencode($search_user);
1338 if ($search_task_ref !=
'') {
1339 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1341 if ($search_company !=
'') {
1342 $param .=
'&$search_company=' . urlencode($search_company);
1344 if ($search_company_alias !=
'') {
1345 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1347 if ($search_project_ref !=
'') {
1348 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1350 if ($search_project_label !=
'') {
1351 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1353 if ($search_task_label !=
'') {
1354 $param .=
'&search_task_label=' . urlencode($search_task_label);
1356 if ($search_note !=
'') {
1357 $param .=
'&search_note=' . urlencode($search_note);
1359 if ($search_duration !=
'') {
1360 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1362 if ($optioncss !=
'') {
1363 $param .=
'&optioncss=' . urlencode($optioncss);
1365 if ($search_date_startday) {
1366 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1368 if ($search_date_startmonth) {
1369 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1371 if ($search_date_startyear) {
1372 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1374 if ($search_date_endday) {
1375 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1377 if ($search_date_endmonth) {
1378 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1380 if ($search_date_endyear) {
1381 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1383 if ($search_timespent_starthour) {
1384 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1386 if ($search_timespent_startmin) {
1387 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1389 if ($search_timespent_endhour) {
1390 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1392 if ($search_timespent_endmin) {
1393 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1401 $param .=
'&id=' . urlencode((
string) ($id));
1404 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1407 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1410 $parameters = array(
'param' => &$param);
1411 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1412 $param .= $hookmanager->resPrint;
1414 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1415 if ($optioncss !=
'') {
1416 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1418 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1419 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1420 if ($action ==
'editline') {
1421 print
'<input type="hidden" name="action" value="updateline">';
1422 } elseif ($action ==
'splitline') {
1423 print
'<input type="hidden" name="action" value="updatesplitline">';
1424 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1425 print
'<input type="hidden" name="action" value="addtimespent">';
1426 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1427 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1428 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1429 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1431 print
'<input type="hidden" name="action" value="list">';
1433 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1434 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1436 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1437 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1438 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1439 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1440 print
'<input type="hidden" name="page_y" value="">';
1443 if ($massaction ==
'generateinvoice') {
1444 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1445 print
'<table class="noborder centerpercent">';
1447 print
'<td class="titlefield">';
1448 print $langs->trans(
'DateInvoice');
1451 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1457 print $langs->trans(
'Mode');
1461 'onelineperuser' =>
'OneLinePerUser',
1462 'onelinepertask' =>
'OneLinePerTask',
1463 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1465 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1466 print
"\n" .
'<script type="text/javascript">';
1468 $(document).ready(function () {
1469 setDetailVisibility();
1470 $("#generateinvoicemode").change(function() {
1471 setDetailVisibility();
1473 function setDetailVisibility() {
1474 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1475 if (generateinvoicemode=="onelineperperiod") {
1476 $("#detail_time_duration").show();
1478 $("#detail_time_duration").hide();
1483 print
'</script>' .
"\n";
1484 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1488 if (isModEnabled(
"service")) {
1491 print $langs->trans(
'ServiceToUseOnLines');
1494 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1499 print
'<td class="titlefield">';
1500 print $langs->trans(
'InvoiceToUse');
1503 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1507 print
'<td class="titlefield">';
1508 print $langs->trans(
"CustomerRelativeDiscount");
1511 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1514 print
'<tr class="newinvoicedetail">';
1515 print
'<td class="titlefield">';
1516 print $langs->trans(
"PaymentConditions");
1519 print $form->getSelectConditionsPaiements($projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1533 print
'<div class="center">';
1534 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1535 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1539 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1540 print
'<div class="center">';
1541 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1545 } elseif ($massaction ==
'generateinter') {
1547 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1549 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1551 print
'<table class="noborder centpercent">';
1553 print
'<td class="titlefield">';
1554 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1558 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1563 print
'<div class="center">';
1564 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1565 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1569 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1570 print
'<div class="center">';
1571 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1578 $parameters = array(
1579 'toselect' => $toselect,
1580 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1583 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1587 print $hookmanager->resPrint;
1595 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1596 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1598 $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,";
1599 $sql .=
" t.fk_product,";
1600 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1601 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1602 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1603 $sql .=
" p.fk_soc,s.name_alias,";
1604 $sql .=
" t.invoice_line_id,";
1605 $sql .=
" pt.billable";
1607 $parameters = array();
1608 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1609 $sql .= $hookmanager->resPrint;
1610 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1614 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1615 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1616 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1617 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1618 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1619 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1620 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1621 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1624 $parameters = array();
1625 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1626 $sql .= $hookmanager->resPrint;
1627 $sql .=
" WHERE elementtype = 'task'";
1628 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1629 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1633 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1634 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1636 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1638 $sql .=
" AND t.fk_element =".((int)
$object->id);
1639 } elseif (!empty($projectidforalltimes)) {
1641 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1642 } elseif (!empty($allprojectforuser)) {
1644 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1645 $search_user = $user->id;
1647 if ($search_user > 0) {
1648 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1655 if ($search_task_ref) {
1658 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1659 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1661 if ($search_company) {
1664 if ($search_company_alias) {
1668 if ($search_project_ref) {
1671 if ($search_project_label) {
1674 if ($search_task_label) {
1677 if ($search_user > 0) {
1680 if (!empty($search_product_ref)) {
1683 if ($search_valuebilled ==
'1') {
1684 $sql .=
' AND t.invoice_id > 0';
1686 if ($search_valuebilled ==
'0') {
1687 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1690 if ($search_date_start) {
1691 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1693 if ($search_date_end) {
1694 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1697 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1698 if ($search_timespent_starthour || $search_timespent_startmin) {
1699 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1700 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1701 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1704 if ($search_timespent_endhour || $search_timespent_endmin) {
1705 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1706 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1707 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1711 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1714 $parameters = array();
1715 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1716 $sql .= $hookmanager->resPrint;
1719 $nbtotalofrecords =
'';
1722 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1723 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1724 $resql = $db->query($sqlforcount);
1726 $objforcount = $db->fetch_object($resql);
1727 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1732 if (($page * $limit) > $nbtotalofrecords) {
1740 $sql .= $db->order($sortfield, $sortorder);
1742 $sql .= $db->plimit($limit + 1, $offset);
1745 $resql = $db->query($sql);
1751 $num = $db->num_rows($resql);
1754 if (!empty($projectidforalltimes)) {
1755 print
'<!-- List of time spent for project -->' .
"\n";
1757 $title = $langs->trans(
"ListTaskTimeUserProject");
1759 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1761 print
'<!-- List of time spent -->' .
"\n";
1763 $title = $langs->trans(
"ListTaskTimeForTask");
1765 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1770 $row = $db->fetch_object($resql);
1782 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1783 print
'<!-- table to add time spent -->' .
"\n";
1785 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1788 print
'<div class="div-table-responsive-no-min">';
1789 print
'<table class="noborder nohover centpercent">';
1791 print
'<tr class="liste_titre">';
1792 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1793 if (!empty($allprojectforuser)) {
1794 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1797 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1799 print
'<td>' . $langs->trans(
"By") .
'</td>';
1800 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1801 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1802 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1806 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1807 print
'<td>'.$langs->trans(
"Product").
'</td>';
1811 $parameters = array(
'mode' =>
'create');
1812 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1813 print $hookmanager->resPrint;
1817 print
'<tr class="oddeven nohover">';
1820 print
'<td class="maxwidthonsmartphone">';
1822 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1825 if (!empty($allprojectforuser)) {
1834 print
'<td class="maxwidthonsmartphone">';
1835 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1840 print
'<td class="maxwidthonsmartphone nowraponall">';
1841 $contactsofproject = $projectstatic->getListContactId(
'internal');
1842 if (count($contactsofproject) > 0) {
1843 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1844 if (in_array($user->id, $contactsofproject)) {
1845 $userid = $user->id;
1847 $userid = $contactsofproject[0];
1850 if ($projectstatic->public) {
1851 $contactsofproject = array();
1853 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1856 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1863 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1867 print
'<td class="nowraponall">';
1868 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1869 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1870 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1872 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1876 print
'<td class="nowrap">';
1877 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1885 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1886 print
'<td class="nowraponall">';
1888 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);
1894 $parameters = array(
'mode' =>
'create');
1895 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1896 print $hookmanager->resPrint;
1898 print
'<td class="center">';
1899 $form->buttonsSaveCancel();
1900 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1901 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1910 $moreforfilter =
'';
1912 $parameters = array();
1913 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1914 if (empty($reshook)) {
1915 $moreforfilter .= $hookmanager->resPrint;
1917 $moreforfilter = $hookmanager->resPrint;
1920 if (!empty($moreforfilter)) {
1921 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1922 print $moreforfilter;
1926 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1927 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1928 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1930 print
'<div class="div-table-responsive">';
1931 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1935 print
'<tr class="liste_titre_filter">';
1938 print
'<td class="liste_titre center">';
1939 $searchpicto = $form->showFilterButtons(
'left');
1944 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1945 print
'<td class="liste_titre left">';
1946 print
'<div class="nowrapfordate">';
1947 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1949 print
'<div class="nowrapfordate">';
1950 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1955 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1956 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1960 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1961 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1964 if (!empty($allprojectforuser)) {
1965 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1966 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1968 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1969 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1973 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1974 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1975 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1977 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1978 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1982 if (!empty($arrayfields[
'author'][
'checked'])) {
1983 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>';
1986 if (!empty($arrayfields[
't.note'][
'checked'])) {
1987 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1990 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1992 print
'<td class="liste_titre right">';
1994 $durationtouse_start =
'';
1995 if ($search_timespent_starthour || $search_timespent_startmin) {
1996 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1998 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1999 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2002 $durationtouse_end =
'';
2003 if ($search_timespent_endhour || $search_timespent_endmin) {
2004 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2006 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2007 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2013 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2014 print
'<td class="liste_titre right"></td>';
2017 if (!empty($arrayfields[
'value'][
'checked'])) {
2018 print
'<td class="liste_titre"></td>';
2021 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2022 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2030 $parameters = array(
'arrayfields' => $arrayfields);
2031 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2032 print $hookmanager->resPrint;
2035 print
'<td class="liste_titre center">';
2036 $searchpicto = $form->showFilterButtons();
2040 print
'</tr>' .
"\n";
2043 $totalarray = array();
2044 $totalarray[
'nbfield'] = 0;
2048 print
'<tr class="liste_titre">';
2050 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2051 $totalarray[
'nbfield']++;
2053 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2054 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2055 $totalarray[
'nbfield']++;
2057 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2058 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2059 $totalarray[
'nbfield']++;
2061 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2063 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2064 $totalarray[
'nbfield']++;
2066 if (!empty($allprojectforuser)) {
2067 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2069 $totalarray[
'nbfield']++;
2071 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2072 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2073 $totalarray[
'nbfield']++;
2076 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2077 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2078 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2079 $totalarray[
'nbfield']++;
2081 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2082 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2083 $totalarray[
'nbfield']++;
2086 if (!empty($arrayfields[
'author'][
'checked'])) {
2087 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2088 $totalarray[
'nbfield']++;
2090 if (!empty($arrayfields[
't.note'][
'checked'])) {
2091 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2092 $totalarray[
'nbfield']++;
2094 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2095 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2096 $totalarray[
'nbfield']++;
2098 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2099 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2100 $totalarray[
'nbfield']++;
2103 if (!empty($arrayfields[
'value'][
'checked'])) {
2104 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2105 $totalarray[
'nbfield']++;
2107 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2108 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2109 $totalarray[
'nbfield']++;
2116 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2117 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2118 print $hookmanager->resPrint;
2120 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2121 $totalarray[
'nbfield']++;
2125 $tasktmp =
new Task($db);
2126 $tmpinvoice =
new Facture($db);
2129 $param .=
'&page='.((int) $page);
2131 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2135 $savnbfield = $totalarray[
'nbfield'];
2136 $totalarray = array();
2137 $totalarray[
'nbfield'] = 0;
2139 foreach ($tasks as $task_time) {
2145 $invoiced = $task_time->invoice_id ? true :
false;
2147 $date1 = $db->jdate($task_time->element_date);
2148 $date2 = $db->jdate($task_time->element_datehour);
2152 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2156 print
'<td class="center nowraponall">';
2157 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2158 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2159 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2161 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2162 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2163 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2164 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' :
'').
'">';
2165 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2169 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' :
'') .
'">';
2170 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2174 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' :
'').
'">';
2175 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2178 if ($massactionbutton || $massaction) {
2180 if (in_array($task_time->rowid, $arrayofselected)) {
2186 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2187 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2191 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2192 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2201 $totalarray[
'nbfield']++;
2206 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2207 print
'<td class="nowrap">';
2208 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2209 if (empty($task_time->element_date_withhour)) {
2210 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2212 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2215 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2219 $totalarray[
'nbfield']++;
2224 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2225 print
'<td class="tdoverflowmax125">';
2226 if ($task_time->fk_soc > 0) {
2227 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2228 $tmpsociete =
new Societe($db);
2229 $tmpsociete->fetch($task_time->fk_soc);
2230 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2232 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2234 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2238 $totalarray[
'nbfield']++;
2243 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2244 if ($task_time->fk_soc > 0) {
2245 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2246 $tmpsociete =
new Societe($db);
2247 $tmpsociete->fetch($task_time->fk_soc);
2248 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2250 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2252 $valtoshow = $tmpsociete->name_alias;
2254 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2258 $totalarray[
'nbfield']++;
2263 if (!empty($allprojectforuser)) {
2264 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2265 print
'<td class="nowraponall">';
2266 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2267 $tmpproject =
new Project($db);
2268 $tmpproject->fetch($task_time->fk_projet);
2269 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2271 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2273 print $tmpproject->getNomUrl(1);
2276 $totalarray[
'nbfield']++;
2279 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2280 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2281 $tmpproject =
new Project($db);
2282 $tmpproject->fetch($task_time->fk_projet);
2283 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2285 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2287 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2291 $totalarray[
'nbfield']++;
2297 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2298 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2299 print
'<td class="nowrap">';
2300 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2301 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2303 $tasktmp->id = $task_time->fk_element;
2304 $tasktmp->ref = $task_time->ref;
2305 $tasktmp->label = $task_time->label;
2306 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2310 $totalarray[
'nbfield']++;
2313 } elseif ($action !==
'createtime') {
2314 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2318 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2319 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2320 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2324 $totalarray[
'nbfield']++;
2330 if (!empty($arrayfields[
'author'][
'checked'])) {
2331 print
'<td class="minwidth100 tdoverflowmax125">';
2332 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2335 $object->fetch($task_time->fk_element);
2337 $contactsoftask =
$object->getListContactId(
'internal');
2338 if (!in_array($task_time->fk_user, $contactsoftask)) {
2339 $contactsoftask[] = $task_time->fk_user;
2341 if (count($contactsoftask) > 0) {
2342 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2343 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2345 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2348 $userstatic->id = $task_time->fk_user;
2349 $userstatic->lastname = $task_time->lastname;
2350 $userstatic->firstname = $task_time->firstname;
2351 $userstatic->photo = $task_time->photo;
2352 $userstatic->gender = $task_time->gender;
2353 $userstatic->status = $task_time->user_status;
2355 print $userstatic->getNomUrl(-1);
2359 $totalarray[
'nbfield']++;
2364 if (!empty($arrayfields[
't.note'][
'checked'])) {
2365 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2366 print
'<td class="small">';
2367 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2370 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2375 $totalarray[
'nbfield']++;
2377 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2378 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2382 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2383 print
'<td class="right nowraponall">';
2384 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2385 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2386 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2392 $totalarray[
'nbfield']++;
2395 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2397 if (empty($totalarray[
'val'][
't.element_duration'])) {
2398 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2400 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2403 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2405 if (empty($totalarray[
'totalduration'])) {
2406 $totalarray[
'totalduration'] = $task_time->element_duration;
2408 $totalarray[
'totalduration'] += $task_time->element_duration;
2413 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2414 print
'<td class="nowraponall">';
2415 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2417 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);
2418 } elseif (!empty($task_time->fk_product)) {
2420 $resultFetch = $product->fetch($task_time->fk_product);
2421 if ($resultFetch < 0) {
2424 print $product->getNomUrl(1);
2429 $totalarray[
'nbfield']++;
2434 if (!empty($arrayfields[
'value'][
'checked'])) {
2435 $langs->load(
"salaries");
2436 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2438 print
'<td class="nowraponall right">';
2439 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2440 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2444 $totalarray[
'nbfield']++;
2447 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2449 if (empty($totalarray[
'val'][
'value'])) {
2450 $totalarray[
'val'][
'value'] = $value;
2452 $totalarray[
'val'][
'value'] += $value;
2455 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2457 if (empty($totalarray[
'totalvalue'])) {
2458 $totalarray[
'totalvalue'] = $value;
2460 $totalarray[
'totalvalue'] += $value;
2465 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2466 print
'<td class="center">';
2468 if ($projectstatic->usage_bill_time) {
2469 if ($task_time->invoice_id) {
2470 $result = $tmpinvoice->fetch($task_time->invoice_id);
2472 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2473 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2475 print $tmpinvoice->getNomUrl(1);
2476 if (!empty($task_time->invoice_line_id)) {
2478 $invoiceLine->fetch($task_time->invoice_line_id);
2479 if (!empty($invoiceLine->id)) {
2480 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2481 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2488 if (intval($task_time->billable) == 1) {
2489 print $langs->trans(
"No");
2491 print $langs->trans(
"Disabled");
2495 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2500 $totalarray[
'nbfield']++;
2510 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2511 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2512 print $hookmanager->resPrint;
2516 print
'<td class="center nowraponall">';
2517 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2518 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2519 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2521 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2522 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2523 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2524 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' :
'').
'">';
2525 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2529 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' :
'') .
'">';
2530 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2534 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' :
'').
'">';
2535 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2538 if ($massactionbutton || $massaction) {
2540 if (in_array($task_time->rowid, $arrayofselected)) {
2546 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2547 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2551 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2552 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2561 $totalarray[
'nbfield']++;
2570 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2571 print
'<!-- first line -->';
2572 print
'<tr class="oddeven">';
2580 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2581 print
'<td class="nowrap">';
2582 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2583 if (empty($task_time->element_date_withhour)) {
2584 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2586 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2589 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2595 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2596 print
'<td class="nowrap">';
2601 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2602 print
'<td class="nowrap">';
2607 if (!empty($allprojectforuser)) {
2608 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2609 print
'<td class="nowrap">';
2615 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2616 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2617 print
'<td class="nowrap">';
2618 $tasktmp->id = $task_time->fk_element;
2619 $tasktmp->ref = $task_time->ref;
2620 $tasktmp->label = $task_time->label;
2621 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2627 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2628 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2629 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2636 if (!empty($arrayfields[
'author'][
'checked'])) {
2637 print
'<td class="nowraponall">';
2638 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2640 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2643 $contactsoftask =
$object->getListContactId(
'internal');
2644 if (!in_array($task_time->fk_user, $contactsoftask)) {
2645 $contactsoftask[] = $task_time->fk_user;
2647 if (count($contactsoftask) > 0) {
2648 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2649 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2651 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2654 $userstatic->id = $task_time->fk_user;
2655 $userstatic->lastname = $task_time->lastname;
2656 $userstatic->firstname = $task_time->firstname;
2657 $userstatic->photo = $task_time->photo;
2658 $userstatic->status = $task_time->user_status;
2659 print $userstatic->getNomUrl(-1);
2665 if (!empty($arrayfields[
't.note'][
'checked'])) {
2666 print
'<td class="tdoverflowmax300">';
2667 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2668 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2673 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2674 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2678 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2679 print
'<td class="right">';
2680 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2681 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2682 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2690 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2691 print
'<td class="nowraponall tdoverflowmax125">';
2696 if (!empty($arrayfields[
'value'][
'checked'])) {
2697 print
'<td class="right">';
2698 print
'<span class="amount">';
2699 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2700 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2706 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2707 print
'<td class="right">';
2708 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2709 if (isset($task_time->total_ht)) {
2710 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2721 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2722 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2723 print $hookmanager->resPrint;
2727 print
'<td class="center nowraponall">';
2736 print
'<!-- second line --><tr class="oddeven">';
2740 print
'<td class="center nowraponall">';
2745 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2746 print
'<td class="nowrap">';
2747 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2748 if (empty($task_time->element_date_withhour)) {
2749 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2751 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2754 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2760 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2761 print
'<td class="nowrap">';
2766 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2767 print
'<td class="nowrap">';
2772 if (!empty($allprojectforuser)) {
2773 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2774 print
'<td class="nowrap">';
2780 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2781 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2782 print
'<td class="nowrap">';
2783 $tasktmp->id = $task_time->fk_element;
2784 $tasktmp->ref = $task_time->ref;
2785 $tasktmp->label = $task_time->label;
2786 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2792 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2793 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2794 print
'<td class="nowrap">';
2801 if (!empty($arrayfields[
'author'][
'checked'])) {
2802 print
'<td class="nowraponall tdoverflowmax100">';
2803 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2805 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2808 $contactsoftask =
$object->getListContactId(
'internal');
2809 if (!in_array($task_time->fk_user, $contactsoftask)) {
2810 $contactsoftask[] = $task_time->fk_user;
2812 if (count($contactsoftask) > 0) {
2813 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2814 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2816 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2819 $userstatic->id = $task_time->fk_user;
2820 $userstatic->lastname = $task_time->lastname;
2821 $userstatic->firstname = $task_time->firstname;
2822 $userstatic->photo = $task_time->photo;
2823 $userstatic->status = $task_time->user_status;
2824 print $userstatic->getNomUrl(-1);
2830 if (!empty($arrayfields[
't.note'][
'checked'])) {
2831 print
'<td class="small tdoverflowmax300"">';
2832 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2833 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2838 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2839 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2843 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2844 print
'<td class="right">';
2845 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2846 print
'<input type="hidden" name="old_duration_2" value="0">';
2847 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2855 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2856 print
'<td class="nowraponall tdoverflowmax125">';
2861 if (!empty($arrayfields[
'value'][
'checked'])) {
2862 print
'<td class="right">';
2863 print
'<span class="amount">';
2865 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2871 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2872 print
'<td class="right">';
2873 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2874 if (isset($task_time->total_ht)) {
2875 print
'<span class="amount">';
2876 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2888 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2889 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2890 print $hookmanager->resPrint;
2894 print
'<td class="center nowraponall">';
2906 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2907 print
'<tr class="liste_total">';
2909 while ($i < $totalarray[
'nbfield']) {
2912 if ($num < $limit && empty($offset)) {
2913 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2915 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2917 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2918 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2919 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2920 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2929 if (!count($tasks)) {
2930 $totalnboffields = 1;
2931 foreach ($arrayfields as $value) {
2932 if (!empty($value[
'checked'])) {
2936 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2937 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2941 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2942 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2943 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.