36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56@phan-var-force ?string $uploaddir
60$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61if (isModEnabled(
'eventorganization')) {
62 $langsLoad[] =
'eventorganization';
65$langs->loadLangs($langsLoad);
67$action =
GETPOST(
'action',
'alpha');
68$massaction =
GETPOST(
'massaction',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$cancel =
GETPOST(
'cancel',
'alpha');
71$toselect =
GETPOST(
'toselect',
'array');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
73$backtopage =
GETPOST(
'backtopage',
'alpha');
74$optioncss =
GETPOST(
'optioncss',
'alpha');
75$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
136$projectstatic =
new Project($db);
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
143if ($id > 0 || $ref) {
151if (!$user->hasRight(
'projet',
'lire')) {
160 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
161 $search_user = $user->id;
171if (
GETPOST(
'cancel',
'alpha')) {
174if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
178$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
179$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
184include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
187if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
192 $search_duration =
'';
193 $search_date_startday =
'';
194 $search_date_startmonth =
'';
195 $search_date_startyear =
'';
196 $search_date_endday =
'';
197 $search_date_endmonth =
'';
198 $search_date_endyear =
'';
199 $search_date_start =
'';
200 $search_date_end =
'';
201 $search_task_ref =
'';
202 $search_company =
'';
203 $search_company_alias =
'';
204 $search_project_ref =
'';
205 $search_project_label =
'';
206 $search_task_label =
'';
208 $search_valuebilled =
'';
209 $search_product_ref =
'';
211 $search_array_options = array();
212 $search_timespent_starthour =
'';
213 $search_timespent_startmin =
'';
214 $search_timespent_endhour =
'';
215 $search_timespent_endmin =
'';
219if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
220 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
221 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
222 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
223 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
227 $langs->load(
"errors");
228 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
237 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
238 $action =
'createtime';
248 if (empty(
$object->project->status)) {
249 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
250 $action =
'createtime';
261 $object->timespent_withhour = 1;
264 $object->timespent_withhour = 0;
269 $result =
$object->addTimeSpent($user);
280 $action =
'createtime';
284if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
285 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
286 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
302 $object->fetch($id_temp, $ref);
304 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
308 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
310 $object->timespent_withhour = 1;
311 } elseif (!empty($timespent_date)) {
312 $object->timespent_date = $timespent_date;
313 $object->timespent_withhour = 0;
321 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
322 $result =
$object->updateTimeSpent($user);
335 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
339 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
342 $object->timespent_withhour = 1;
343 } elseif (!empty($timespent_date)) {
344 $object->timespent_date = $timespent_date;
345 $object->timespent_datehour = $timespent_date;
346 $object->timespent_withhour = 0;
354 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
355 $result =
$object->updateTimeSpent($user);
370if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
373 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
374 $result =
$object->delTimeSpent($user);
377 $langs->load(
"errors");
388if (!empty($project_ref) && !empty($withproject)) {
389 if ($projectstatic->fetch(0, $project_ref) > 0) {
390 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
391 if (count($tasksarray) > 0) {
392 $id = $tasksarray[0]->id;
394 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
401$projectidforalltimes = 0;
403 $projectidforalltimes =
GETPOSTINT(
'projectid');
405 $result = $projectstatic->fetch($projectidforalltimes);
406 if (!empty($projectstatic->socid)) {
407 $projectstatic->fetch_thirdparty();
409 $res = $projectstatic->fetch_optionals();
410} elseif (
GETPOST(
'project_ref',
'alpha')) {
411 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
412 $projectidforalltimes = $projectstatic->id;
416 $result = $projectstatic->fetch(
$object->fk_project);
419$allprojectforuser = 0;
420if ($id <= 0 && $projectidforalltimes == 0) {
421 $allprojectforuser = $user->id;
424if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
425 if (!empty($projectstatic->socid)) {
426 $projectstatic->fetch_thirdparty();
429 if (!($projectstatic->thirdparty->id > 0)) {
430 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
432 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
433 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
434 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
436 $tmpinvoice =
new Facture($db);
437 $tmptimespent =
new Task($db);
438 $tmpproduct =
new Product($db);
439 $fuser =
new User($db);
444 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
447 $prodDurationHoursBase = 1.0;
448 $product_data_cache = array();
450 $tmpproduct->fetch($idprod);
456 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
457 if ($prodDurationHoursBase < 0) {
459 $langs->load(
"errors");
463 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
465 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
466 $txtva = $dataforprice[
'tva_tx'];
467 $localtax1 = $dataforprice[
'localtax1'];
468 $localtax2 = $dataforprice[
'localtax2'];
470 $prodDurationHoursBase = 1;
478 $tmpinvoice->socid = $projectstatic->thirdparty->id;
480 $tmpinvoice->fk_project = $projectstatic->id;
481 $tmpinvoice->cond_reglement_id = $condidproject;
482 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
483 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
486 $tmpinvoice->fetch($invoiceToUse);
488 $result = $tmpinvoice->create($user);
496 if ($generateinvoicemode ==
'onelineperuser') {
497 $arrayoftasks = array();
498 foreach ($toselect as $key => $value) {
500 $object->fetchTimeSpent($value);
501 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
502 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
505 foreach ($arrayoftasks as $userid => $data) {
506 $fuser->fetch($userid);
507 $username = $fuser->getFullName($langs);
509 foreach ($data as $fk_product => $timespent_data) {
511 $qtyhour = $timespent_data[
'timespent'] / 3600;
518 } elseif ($idprod <= 0) {
521 $pu_ht = $fuser->thm;
526 if ($timespent_data[
'timespent']) {
527 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
532 $prodDurationHours = $prodDurationHoursBase;
533 $idprodline = $idprod;
536 $localtax1line = $localtax1;
537 $localtax2line = $localtax2;
540 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
541 if (!array_key_exists($fk_product, $product_data_cache)) {
542 $result = $tmpproduct->fetch($fk_product);
547 $prodDurationHours = $tmpproduct->getProductDurationHours();
548 if ($prodDurationHours < 0) {
550 $langs->load(
"errors");
554 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
556 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
557 $txtvaline = $dataforprice[
'tva_tx'];
558 $localtax1line = $dataforprice[
'localtax1'];
559 $localtax2line = $dataforprice[
'localtax2'];
561 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
563 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
564 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
565 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
566 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
567 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
569 $idprodline = $fk_product;
576 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice").
' - '.$username .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
583 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
584 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
585 $result = $db->query($sql);
593 } elseif ($generateinvoicemode ==
'onelineperperiod') {
594 $arrayoftasks = array();
596 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
597 foreach ($toselect as $key => $value) {
599 $object->fetchTimeSpent($value);
601 $ftask =
new Task($db);
604 $fuser->fetch(
$object->timespent_fk_user);
605 $username = $fuser->getFullName($langs);
607 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
608 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
609 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
612 if (!empty($withdetail)) {
613 if (!empty(
$object->timespent_withhour)) {
620 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
621 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
624 foreach ($arrayoftasks as $timespent_id => $value) {
625 $userid = $value[
'user'];
629 $qtyhour = $value[
'timespent'] / 3600;
633 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
637 $prodDurationHours = $prodDurationHoursBase;
638 $idprodline = $idprod;
641 $localtax1line = $localtax1;
642 $localtax2line = $localtax2;
644 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
645 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
646 $result = $tmpproduct->fetch($value[
'fk_product']);
651 $prodDurationHours = $tmpproduct->getProductDurationHours();
652 if ($prodDurationHours < 0) {
654 $langs->load(
"errors");
658 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
660 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
661 $txtvaline = $dataforprice[
'tva_tx'];
662 $localtax1line = $dataforprice[
'localtax1'];
663 $localtax2line = $dataforprice[
'localtax2'];
665 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
667 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
668 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
669 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
670 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
671 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
673 $idprodline = $value[
'fk_product'];
679 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
687 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
688 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
689 $result = $db->query($sql);
696 } elseif ($generateinvoicemode ==
'onelinepertask') {
697 $arrayoftasks = array();
698 foreach ($toselect as $key => $value) {
700 $object->fetchTimeSpent($value);
702 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
703 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
706 foreach ($arrayoftasks as $task_id => $data) {
707 $ftask =
new Task($db);
708 $ftask->fetch($task_id);
710 foreach ($data as $fk_product => $timespent_data) {
711 $qtyhour = $timespent_data[
'timespent'] / 3600;
715 $prodDurationHours = $prodDurationHoursBase;
716 $idprodline = $idprod;
719 $localtax1line = $localtax1;
720 $localtax2line = $localtax2;
722 if (!empty($fk_product) && $fk_product !== $idprod) {
723 if (!array_key_exists($fk_product, $product_data_cache)) {
724 $result = $tmpproduct->fetch($fk_product);
729 $prodDurationHours = $tmpproduct->getProductDurationHours();
730 if ($prodDurationHours < 0) {
732 $langs->load(
"errors");
736 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
738 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
739 $txtvaline = $dataforprice[
'tva_tx'];
740 $localtax1line = $dataforprice[
'localtax1'];
741 $localtax2line = $dataforprice[
'localtax2'];
743 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
745 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
746 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
747 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
748 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
749 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
751 $idprodline = $fk_product;
755 if ($idprodline > 0) {
757 $pu_ht_for_task = $pu_htline;
760 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
762 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
768 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
770 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
776 $lineName = $ftask->ref .
' - ' . $ftask->label;
777 $lineid = $tmpinvoice->addline($lineName, (
float) $pu_ht_for_task, (
float)
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject, $date_start, $date_end, 0, 0, 0,
'HT', 0, 1, -1, 0,
'', 0, 0, 0, $pa_ht);
786 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
787 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
788 $result = $db->query($sql);
801 $urltoinvoice = $tmpinvoice->getNomUrl(0);
802 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
803 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
813if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
814 $langs->load(
'interventions');
816 if (!empty($projectstatic->socid)) {
817 $projectstatic->fetch_thirdparty();
820 if (!($projectstatic->thirdparty->id > 0)) {
821 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
823 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
824 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
825 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
828 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
830 $tmptimespent =
new Task($db);
831 $fuser =
new User($db);
837 $tmpinter->socid = $projectstatic->thirdparty->id;
839 $tmpinter->fk_project = $projectstatic->id;
840 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
843 $tmpinter->fetch($interToUse);
845 $result = $tmpinter->create($user);
853 $arrayoftasks = array();
854 foreach ($toselect as $key => $value) {
856 $object->fetchTimeSpent($value);
859 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
860 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
861 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
862 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
865 foreach ($arrayoftasks as $timespent_id => $value) {
866 $ftask =
new Task($db);
867 $ftask->fetch($value[
'id']);
869 $qtyhour = $value[
'timespent'] / 3600;
873 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
878 $timespent->fetch($timespent_id);
879 $timespent->intervention_id = $tmpinter->id;
880 $timespent->intervention_line_id = $lineid;
881 $result = $timespent->update($user);
891 $urltointer = $tmpinter->getNomUrl(0);
892 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
893 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
910$form =
new Form($db);
913$userstatic =
new User($db);
915$arrayofselected = is_array($toselect) ? $toselect : array();
917$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
918if (!empty($withproject)) {
919 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
923llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
925if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
929 if ($projectidforalltimes > 0) {
930 $result = $projectstatic->fetch($projectidforalltimes);
931 if (!empty($projectstatic->socid)) {
932 $projectstatic->fetch_thirdparty();
934 $res = $projectstatic->fetch_optionals();
935 } elseif (
$object->fetch($id, $ref) >= 0) {
936 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
939 $result = $projectstatic->fetch(
$object->fk_project);
940 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
941 $projectstatic->fetchComments();
943 if (!empty($projectstatic->socid)) {
944 $projectstatic->fetch_thirdparty();
946 $res = $projectstatic->fetch_optionals();
948 $object->project = clone $projectstatic;
951 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
952 $linktocreatetime =
'';
954 if ($projectstatic->id > 0) {
957 if (empty($id) || $tab ==
'timespent') {
964 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
966 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
968 $param .=
'&search_user=' . ((int) $search_user);
971 $param .=
'&search_month=' . ((int) $search_month);
974 $param .=
'&search_year=' . ((int) $search_year);
979 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
981 $morehtmlref =
'<div class="refidno">';
983 $morehtmlref .= $projectstatic->title;
985 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
986 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
988 $morehtmlref .=
'</div>';
991 if (!$user->hasRight(
'projet',
'all',
'lire')) {
992 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
993 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
996 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
998 print
'<div class="fichecenter">';
999 print
'<div class="fichehalfleft">';
1000 print
'<div class="underbanner clearboth"></div>';
1002 print
'<table class="border tableforfield centpercent">';
1006 print
'<tr><td class="tdtop">';
1007 print $langs->trans(
"Usage");
1011 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1012 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1013 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1017 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1018 $htmltext = $langs->trans(
"ProjectFollowTasks");
1019 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1023 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"' :
'')) .
'"> ';
1024 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1025 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1028 if (isModEnabled(
'eventorganization')) {
1029 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"' :
'')) .
'"> ';
1030 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1031 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1037 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1038 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1039 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1044 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1046 print($start ? $start :
'?');
1049 print($end ? $end :
'?');
1050 if ($projectstatic->hasDelay()) {
1056 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1057 if ($projectstatic->public) {
1058 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1059 print $langs->trans(
'SharedProject');
1061 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1062 print $langs->trans(
'PrivateProject');
1070 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1076 print
'<div class="fichehalfright">';
1077 print
'<div class="underbanner clearboth"></div>';
1079 print
'<table class="border tableforfield centpercent">';
1082 if (isModEnabled(
'category')) {
1083 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1084 print $form->showCategories($projectstatic->id,
'project', 1);
1089 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1090 if ($projectstatic->description) {
1091 print
'<tr><td class="nottitleforfield" colspan="2">';
1092 print
'<div class="longmessagecut">';
1103 print
'<div class="clearboth"></div>';
1113 $linktocreatetimeBtnStatus = 0;
1114 $linktocreatetimeUrl =
'';
1115 $linktocreatetimeHelpText =
'';
1116 if ($user->hasRight(
'projet',
'time')) {
1117 if ($projectstatic->public || $userRead > 0) {
1118 $linktocreatetimeBtnStatus = 1;
1120 if (!empty($projectidforalltimes)) {
1122 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1123 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1126 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1127 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1130 $linktocreatetimeBtnStatus = -2;
1131 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1134 $linktocreatetimeBtnStatus = -2;
1135 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1138 $paramsbutton = array(
'morecss' =>
'reposition');
1139 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1142 $massactionbutton =
'';
1143 $arrayofmassactions = array();
1145 if ($projectstatic->id > 0) {
1147 if ($projectstatic->usage_bill_time) {
1148 $arrayofmassactions = array(
1149 'generateinvoice' => $langs->trans(
"GenerateBill"),
1153 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1154 $langs->load(
"interventions");
1155 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1159 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1160 $arrayofmassactions = array();
1162 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1167 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1169 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1171 if ($action ==
'deleteline') {
1172 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1173 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1176 $param = ($withproject ?
'&withproject=1' :
'');
1177 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1178 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1180 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1181 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1182 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1184 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1190 if (empty($withproject)) {
1191 $morehtmlref .=
'<div class="refidno">';
1192 $morehtmlref .= $langs->trans(
"Project") .
': ';
1193 $morehtmlref .= $projectstatic->getNomUrl(1);
1194 $morehtmlref .=
'<br>';
1197 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1198 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1199 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1201 $morehtmlref .=
'</div>';
1204 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1206 print
'<div class="fichecenter">';
1207 print
'<div class="fichehalfleft">';
1209 print
'<div class="underbanner clearboth"></div>';
1210 print
'<table class="border centpercent tableforfield">';
1213 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1214 if (
$object->fk_task_parent > 0) {
1215 $tasktmp =
new Task($db);
1216 $tasktmp->fetch(
$object->fk_task_parent);
1217 print $tasktmp->getNomUrl(1);
1222 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1224 print($start ? $start :
'?');
1227 print($end ? $end :
'?');
1234 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1235 if (
$object->planned_workload) {
1243 print
'<div class="fichehalfright">';
1245 print
'<div class="underbanner clearboth"></div>';
1246 print
'<table class="border tableforfield centpercent">';
1249 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1254 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1255 if (
$object->planned_workload) {
1256 $tmparray =
$object->getSummaryOfTimeSpent();
1257 if ($tmparray[
'total_duration'] > 0) {
1258 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1263 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1274 print
'<div class="clearboth"></div>';
1278 if ($action ==
'deleteline') {
1279 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1280 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1285 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1287 $hookmanager->initHooks(array(
'tasktimelist'));
1291 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1293 $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);
1294 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1298 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1299 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1300 if (empty($reshook)) {
1301 $formconfirm .= $hookmanager->resPrint;
1302 } elseif ($reshook > 0) {
1303 $formconfirm = $hookmanager->resPrint;
1310 $arrayfields = array();
1311 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1312 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1313 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1314 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1315 if (! empty($allprojectforuser)) {
1316 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1317 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1319 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1320 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1322 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1323 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1324 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1325 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1327 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1328 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int) isModEnabled(
"salaries"));
1329 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' =>
'1',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1331 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1336 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1337 $param .=
'&contextpage=' . urlencode($contextpage);
1339 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1340 $param .=
'&limit='.((int) $limit);
1342 if ($search_month > 0) {
1343 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1345 if ($search_year > 0) {
1346 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1348 if (!empty($search_user)) {
1349 $param .=
'&search_user='.urlencode($search_user);
1351 if ($search_task_ref !=
'') {
1352 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1354 if ($search_company !=
'') {
1355 $param .=
'&$search_company=' . urlencode($search_company);
1357 if ($search_company_alias !=
'') {
1358 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1360 if ($search_project_ref !=
'') {
1361 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1363 if ($search_project_label !=
'') {
1364 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1366 if ($search_task_label !=
'') {
1367 $param .=
'&search_task_label=' . urlencode($search_task_label);
1369 if ($search_note !=
'') {
1370 $param .=
'&search_note=' . urlencode($search_note);
1372 if ($search_duration !=
'') {
1373 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1375 if ($optioncss !=
'') {
1376 $param .=
'&optioncss=' . urlencode($optioncss);
1378 if ($search_date_startday) {
1379 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1381 if ($search_date_startmonth) {
1382 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1384 if ($search_date_startyear) {
1385 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1387 if ($search_date_endday) {
1388 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1390 if ($search_date_endmonth) {
1391 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1393 if ($search_date_endyear) {
1394 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1396 if ($search_timespent_starthour) {
1397 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1399 if ($search_timespent_startmin) {
1400 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1402 if ($search_timespent_endhour) {
1403 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1405 if ($search_timespent_endmin) {
1406 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1414 $param .=
'&id=' . urlencode((
string) ($id));
1417 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1420 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1423 $parameters = array(
'param' => &$param);
1424 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1425 $param .= $hookmanager->resPrint;
1427 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1428 if ($optioncss !=
'') {
1429 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1431 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1432 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1433 if ($action ==
'editline') {
1434 print
'<input type="hidden" name="action" value="updateline">';
1435 } elseif ($action ==
'splitline') {
1436 print
'<input type="hidden" name="action" value="updatesplitline">';
1437 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1438 print
'<input type="hidden" name="action" value="addtimespent">';
1439 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1440 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1441 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1442 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1444 print
'<input type="hidden" name="action" value="list">';
1446 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1447 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1449 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1450 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1451 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1452 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1453 print
'<input type="hidden" name="page_y" value="">';
1456 if ($massaction ==
'generateinvoice') {
1457 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1458 print
'<table class="noborder centerpercent">';
1460 print
'<td class="titlefield">';
1461 print $langs->trans(
'DateInvoice');
1464 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1470 print $langs->trans(
'Mode');
1474 'onelineperuser' =>
'OneLinePerUser',
1475 'onelinepertask' =>
'OneLinePerTask',
1476 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1478 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1479 print
"\n" .
'<script type="text/javascript">';
1481 $(document).ready(function () {
1482 setDetailVisibility();
1483 $("#generateinvoicemode").change(function() {
1484 setDetailVisibility();
1486 function setDetailVisibility() {
1487 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1488 if (generateinvoicemode=="onelineperperiod") {
1489 $("#detail_time_duration").show();
1491 $("#detail_time_duration").hide();
1496 print
'</script>' .
"\n";
1497 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1501 if (isModEnabled(
"service")) {
1504 print $langs->trans(
'ServiceToUseOnLines');
1507 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1512 print
'<td class="titlefield">';
1513 print $langs->trans(
'InvoiceToUse');
1516 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1520 print
'<td class="titlefield">';
1521 print $langs->trans(
"CustomerRelativeDiscount");
1524 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1527 print
'<tr class="newinvoicedetail">';
1528 print
'<td class="titlefield">';
1529 print $langs->trans(
"PaymentConditions");
1532 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1546 print
'<div class="center">';
1547 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1548 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1552 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1553 print
'<div class="center">';
1554 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1558 } elseif ($massaction ==
'generateinter') {
1560 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1562 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1564 print
'<table class="noborder centpercent">';
1566 print
'<td class="titlefield">';
1567 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1571 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1576 print
'<div class="center">';
1577 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1578 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1582 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1583 print
'<div class="center">';
1584 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1591 $parameters = array(
1592 'toselect' => $toselect,
1593 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1596 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1600 print $hookmanager->resPrint;
1608 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1609 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1611 $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,";
1612 $sql .=
" t.fk_product,";
1613 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1614 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1615 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1616 $sql .=
" p.fk_soc,s.name_alias,";
1617 $sql .=
" t.invoice_line_id,";
1618 $sql .=
" pt.billable";
1620 $parameters = array();
1621 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1622 $sql .= $hookmanager->resPrint;
1623 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1627 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1628 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1629 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1630 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1631 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1632 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1633 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1634 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1637 $parameters = array();
1638 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1639 $sql .= $hookmanager->resPrint;
1640 $sql .=
" WHERE elementtype = 'task'";
1641 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1642 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1646 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1647 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1649 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1651 $sql .=
" AND t.fk_element =".((int)
$object->id);
1652 } elseif (!empty($projectidforalltimes)) {
1654 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1655 } elseif (!empty($allprojectforuser)) {
1657 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1658 $search_user = $user->id;
1660 if ($search_user > 0) {
1661 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1668 if ($search_task_ref) {
1671 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1672 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1674 if ($search_company) {
1677 if ($search_company_alias) {
1681 if ($search_project_ref) {
1684 if ($search_project_label) {
1687 if ($search_task_label) {
1690 if ($search_user > 0) {
1693 if (!empty($search_product_ref)) {
1696 if ($search_valuebilled ==
'1') {
1697 $sql .=
' AND t.invoice_id > 0';
1699 if ($search_valuebilled ==
'0') {
1700 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1703 if ($search_date_start) {
1704 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1706 if ($search_date_end) {
1707 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1710 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1711 if ($search_timespent_starthour || $search_timespent_startmin) {
1712 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1713 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1714 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1717 if ($search_timespent_endhour || $search_timespent_endmin) {
1718 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1719 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1720 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1724 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1727 $parameters = array();
1728 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1729 $sql .= $hookmanager->resPrint;
1732 $nbtotalofrecords =
'';
1735 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1736 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1737 $resql = $db->query($sqlforcount);
1739 $objforcount = $db->fetch_object($resql);
1740 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1745 if (($page * $limit) > $nbtotalofrecords) {
1753 $sql .= $db->order($sortfield, $sortorder);
1755 $sql .= $db->plimit($limit + 1, $offset);
1758 $resql = $db->query($sql);
1764 $num = $db->num_rows($resql);
1767 if (!empty($projectidforalltimes)) {
1768 print
'<!-- List of time spent for project -->' .
"\n";
1770 $title = $langs->trans(
"ListTaskTimeUserProject");
1772 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1774 print
'<!-- List of time spent -->' .
"\n";
1776 $title = $langs->trans(
"ListTaskTimeForTask");
1778 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1783 $row = $db->fetch_object($resql);
1795 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1796 print
'<!-- table to add time spent -->' .
"\n";
1798 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1801 print
'<div class="div-table-responsive-no-min">';
1802 print
'<table class="noborder nohover centpercent">';
1804 print
'<tr class="liste_titre">';
1805 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1806 if (!empty($allprojectforuser)) {
1807 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1810 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1812 print
'<td>' . $langs->trans(
"By") .
'</td>';
1813 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1814 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1815 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1819 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1820 print
'<td>'.$langs->trans(
"Product").
'</td>';
1824 $parameters = array(
'mode' =>
'create');
1825 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1826 print $hookmanager->resPrint;
1830 print
'<tr class="oddeven nohover">';
1833 print
'<td class="maxwidthonsmartphone">';
1835 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1838 if (!empty($allprojectforuser)) {
1847 print
'<td class="maxwidthonsmartphone">';
1848 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1853 print
'<td class="maxwidthonsmartphone nowraponall">';
1854 $contactsofproject = $projectstatic->getListContactId(
'internal');
1855 if (count($contactsofproject) > 0) {
1856 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1857 if (in_array($user->id, $contactsofproject)) {
1858 $userid = $user->id;
1860 $userid = $contactsofproject[0];
1863 if ($projectstatic->public) {
1864 $contactsofproject = array();
1866 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1869 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1876 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1880 print
'<td class="nowraponall">';
1881 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1882 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1883 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1885 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1889 print
'<td class="nowrap">';
1890 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1898 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1899 print
'<td class="nowraponall">';
1901 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
1907 $parameters = array(
'mode' =>
'create');
1908 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1909 print $hookmanager->resPrint;
1911 print
'<td class="center">';
1912 $form->buttonsSaveCancel();
1913 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1914 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1923 $moreforfilter =
'';
1925 $parameters = array();
1926 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1927 if (empty($reshook)) {
1928 $moreforfilter .= $hookmanager->resPrint;
1930 $moreforfilter = $hookmanager->resPrint;
1933 if (!empty($moreforfilter)) {
1934 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1935 print $moreforfilter;
1939 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1940 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1941 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1943 print
'<!-- Liste of time spent -->'.
"\n";
1944 print
'<div class="div-table-responsive">';
1945 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1949 print
'<tr class="liste_titre_filter">';
1952 print
'<td class="liste_titre center">';
1953 $searchpicto = $form->showFilterButtons(
'left');
1958 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1959 print
'<td class="liste_titre left">';
1960 print
'<div class="nowrapfordate paddingright">';
1961 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1963 print
'<div class="nowrapfordate">';
1964 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1969 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1970 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1974 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1975 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1978 if (!empty($allprojectforuser)) {
1979 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1980 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1982 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1983 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1987 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1988 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1989 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1991 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1992 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1996 if (!empty($arrayfields[
'author'][
'checked'])) {
1997 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>';
2000 if (!empty($arrayfields[
't.note'][
'checked'])) {
2001 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2004 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2006 print
'<td class="liste_titre right">';
2008 $durationtouse_start =
'';
2009 if ($search_timespent_starthour || $search_timespent_startmin) {
2010 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2012 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
2013 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2016 $durationtouse_end =
'';
2017 if ($search_timespent_endhour || $search_timespent_endmin) {
2018 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2020 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2021 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2027 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2028 print
'<td class="liste_titre right"></td>';
2031 if (!empty($arrayfields[
'value'][
'checked'])) {
2032 print
'<td class="liste_titre"></td>';
2035 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2036 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2044 $parameters = array(
'arrayfields' => $arrayfields);
2045 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2046 print $hookmanager->resPrint;
2049 print
'<td class="liste_titre center">';
2050 $searchpicto = $form->showFilterButtons();
2054 print
'</tr>' .
"\n";
2062 print
'<tr class="liste_titre">';
2064 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2067 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2068 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2071 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2072 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2075 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2077 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2080 if (!empty($allprojectforuser)) {
2081 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2082 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2085 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2086 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2090 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2091 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2092 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2095 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2096 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2100 if (!empty($arrayfields[
'author'][
'checked'])) {
2101 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2104 if (!empty($arrayfields[
't.note'][
'checked'])) {
2105 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2108 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2109 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2112 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2113 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2117 if (!empty($arrayfields[
'value'][
'checked'])) {
2118 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2121 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2122 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2130 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2131 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2132 print $hookmanager->resPrint;
2134 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2139 $tasktmp =
new Task($db);
2140 $tmpinvoice =
new Facture($db);
2143 $param .=
'&page='.((int) $page);
2145 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2153 foreach ($tasks as $task_time) {
2159 $invoiced = $task_time->invoice_id ? true :
false;
2161 $date1 = $db->jdate($task_time->element_date);
2162 $date2 = $db->jdate($task_time->element_datehour);
2166 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2170 print
'<td class="center nowraponall">';
2171 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2172 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2173 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2175 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2176 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2177 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2178 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' :
'').
'">';
2179 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2183 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' :
'') .
'">';
2184 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2188 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' :
'').
'">';
2189 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2192 if ($massactionbutton || $massaction) {
2194 if (in_array($task_time->rowid, $arrayofselected)) {
2200 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2201 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2205 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2206 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2220 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2221 print
'<td class="nowrap">';
2222 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2223 if (empty($task_time->element_date_withhour)) {
2224 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2226 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2229 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2238 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2239 print
'<td class="tdoverflowmax125">';
2240 if ($task_time->fk_soc > 0) {
2241 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2242 $tmpsociete =
new Societe($db);
2243 $tmpsociete->fetch($task_time->fk_soc);
2244 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2246 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2248 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2257 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2259 if ($task_time->fk_soc > 0) {
2260 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2261 $tmpsociete =
new Societe($db);
2262 $tmpsociete->fetch($task_time->fk_soc);
2263 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2265 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2267 $valtoshow = $tmpsociete->name_alias;
2269 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2277 if (!empty($allprojectforuser)) {
2279 if (!empty($arrayfields[
'p.project_ref'][
'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="nowraponall">';
2288 print $tmpproject->getNomUrl(1);
2295 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2296 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2297 $tmpproject =
new Project($db);
2298 $tmpproject->fetch($task_time->fk_projet);
2299 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2301 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2303 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2304 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2307 print $tmpproject->getNomUrl(1,
'', -1);
2317 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2318 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2319 print
'<td class="nowrap">';
2320 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2321 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2323 $tasktmp->id = $task_time->fk_element;
2324 $tasktmp->ref = $task_time->ref;
2325 $tasktmp->label = $task_time->label;
2326 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2333 } elseif ($action !==
'createtime') {
2334 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2338 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2339 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2340 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2341 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2344 $tasktmp->id = $task_time->fk_element;
2345 $tasktmp->ref = $task_time->ref;
2346 $tasktmp->label = $task_time->label;
2347 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2357 if (!empty($arrayfields[
'author'][
'checked'])) {
2358 print
'<td class="tdoverflowmax125">';
2359 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2362 $object->fetch($task_time->fk_element);
2364 $contactsoftask =
$object->getListContactId(
'internal');
2365 if (!in_array($task_time->fk_user, $contactsoftask)) {
2366 $contactsoftask[] = $task_time->fk_user;
2368 if (count($contactsoftask) > 0) {
2369 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2370 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2372 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2375 $userstatic->id = $task_time->fk_user;
2376 $userstatic->lastname = $task_time->lastname;
2377 $userstatic->firstname = $task_time->firstname;
2378 $userstatic->photo = $task_time->photo;
2379 $userstatic->gender = $task_time->gender;
2380 $userstatic->status = $task_time->user_status;
2382 print $userstatic->getNomUrl(-1);
2391 if (!empty($arrayfields[
't.note'][
'checked'])) {
2392 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2393 print
'<td class="small">';
2394 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2397 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2404 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2405 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2409 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2410 print
'<td class="right nowraponall">';
2411 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2412 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2413 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2424 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2425 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2427 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2433 $totalarray[
'totalduration'] = $task_time->element_duration;
2435 $totalarray[
'totalduration'] += $task_time->element_duration;
2440 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2441 print
'<td class="nowraponall">';
2442 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2444 print $form->select_produits($task_time->fk_product,
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
2445 } elseif (!empty($task_time->fk_product)) {
2447 $resultFetch = $product->fetch($task_time->fk_product);
2448 if ($resultFetch < 0) {
2451 print $product->getNomUrl(1);
2461 if (!empty($arrayfields[
'value'][
'checked'])) {
2462 $langs->load(
"salaries");
2463 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2465 print
'<td class="nowraponall right">';
2466 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2467 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2492 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2493 print
'<td class="center">';
2495 if ($projectstatic->usage_bill_time) {
2496 if ($task_time->invoice_id) {
2497 $result = $tmpinvoice->fetch($task_time->invoice_id);
2499 if ($user->hasRight(
'facture',
'lire')) {
2500 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2501 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2503 print $tmpinvoice->getNomUrl(1);
2504 if (!empty($task_time->invoice_line_id)) {
2506 $invoiceLine->fetch($task_time->invoice_line_id);
2507 if (!empty($invoiceLine->id)) {
2508 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2509 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2514 print $langs->trans(
"Yes");
2519 if (intval($task_time->billable) == 1) {
2520 print $langs->trans(
"No");
2522 print $langs->trans(
"Disabled");
2526 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2541 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2542 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2543 print $hookmanager->resPrint;
2547 print
'<td class="center nowraponall">';
2548 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2549 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2550 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2552 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2553 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2554 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2555 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' :
'').
'">';
2556 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2560 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' :
'') .
'">';
2561 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2565 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' :
'').
'">';
2566 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2569 if ($massactionbutton || $massaction) {
2571 if (in_array($task_time->rowid, $arrayofselected)) {
2577 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2578 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2582 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2583 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2601 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2602 print
'<!-- first line -->';
2603 print
'<tr class="oddeven">';
2611 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2612 print
'<td class="nowrap">';
2613 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2614 if (empty($task_time->element_date_withhour)) {
2615 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2617 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2620 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2626 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2627 print
'<td class="nowrap">';
2632 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2633 print
'<td class="nowrap">';
2638 if (!empty($allprojectforuser)) {
2639 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2640 print
'<td class="nowrap">';
2646 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2647 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2648 print
'<td class="nowrap">';
2649 $tasktmp->id = $task_time->fk_element;
2650 $tasktmp->ref = $task_time->ref;
2651 $tasktmp->label = $task_time->label;
2652 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2658 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2659 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2660 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2667 if (!empty($arrayfields[
'author'][
'checked'])) {
2668 print
'<td class="nowraponall">';
2669 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2671 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2674 $contactsoftask =
$object->getListContactId(
'internal');
2675 if (!in_array($task_time->fk_user, $contactsoftask)) {
2676 $contactsoftask[] = $task_time->fk_user;
2678 if (count($contactsoftask) > 0) {
2679 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2680 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2682 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2685 $userstatic->id = $task_time->fk_user;
2686 $userstatic->lastname = $task_time->lastname;
2687 $userstatic->firstname = $task_time->firstname;
2688 $userstatic->photo = $task_time->photo;
2689 $userstatic->status = $task_time->user_status;
2690 print $userstatic->getNomUrl(-1);
2696 if (!empty($arrayfields[
't.note'][
'checked'])) {
2697 print
'<td class="tdoverflowmax300">';
2698 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2699 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2704 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2705 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2709 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2710 print
'<td class="right">';
2711 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2712 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2713 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2721 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2722 print
'<td class="nowraponall tdoverflowmax125">';
2727 if (!empty($arrayfields[
'value'][
'checked'])) {
2728 print
'<td class="right">';
2729 print
'<span class="amount">';
2730 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2731 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2737 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2738 print
'<td class="right">';
2739 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2740 if (isset($task_time->total_ht)) {
2741 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2752 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2753 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2754 print $hookmanager->resPrint;
2758 print
'<td class="center nowraponall">';
2767 print
'<!-- second line --><tr class="oddeven">';
2771 print
'<td class="center nowraponall">';
2776 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2777 print
'<td class="nowraponall">';
2778 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2779 if (empty($task_time->element_date_withhour)) {
2780 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2782 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2785 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2791 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2797 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2803 if (!empty($allprojectforuser)) {
2804 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2811 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2812 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2813 print
'<td class="nowraponall">';
2814 $tasktmp->id = $task_time->fk_element;
2815 $tasktmp->ref = $task_time->ref;
2816 $tasktmp->label = $task_time->label;
2817 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2823 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2824 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2825 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2832 if (!empty($arrayfields[
'author'][
'checked'])) {
2833 print
'<td class="nowraponall tdoverflowmax100">';
2834 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2836 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2839 $contactsoftask =
$object->getListContactId(
'internal');
2840 if (!in_array($task_time->fk_user, $contactsoftask)) {
2841 $contactsoftask[] = $task_time->fk_user;
2843 if (count($contactsoftask) > 0) {
2844 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2845 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2847 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2850 $userstatic->id = $task_time->fk_user;
2851 $userstatic->lastname = $task_time->lastname;
2852 $userstatic->firstname = $task_time->firstname;
2853 $userstatic->photo = $task_time->photo;
2854 $userstatic->status = $task_time->user_status;
2855 print $userstatic->getNomUrl(-1);
2861 if (!empty($arrayfields[
't.note'][
'checked'])) {
2862 print
'<td class="small tdoverflowmax300"">';
2863 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2864 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2869 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2870 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2874 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2875 print
'<td class="right">';
2876 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2877 print
'<input type="hidden" name="old_duration_2" value="0">';
2878 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2886 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2887 print
'<td class="nowraponall tdoverflowmax125">';
2892 if (!empty($arrayfields[
'value'][
'checked'])) {
2893 print
'<td class="right">';
2894 print
'<span class="amount nowraponall">';
2896 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2903 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2904 print
'<td class="right">';
2905 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2906 if (isset($task_time->total_ht)) {
2907 print
'<span class="amount nowraponall">';
2908 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2920 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2921 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2922 print $hookmanager->resPrint;
2926 print
'<td class="center nowraponall">';
2939 print
'<tr class="liste_total">';
2944 if ($num < $limit && empty($offset)) {
2945 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2947 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2961 if (!count($tasks)) {
2962 $totalnboffields = 1;
2963 foreach ($arrayfields as $value) {
2964 if (!empty($value[
'checked'])) {
2968 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2969 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2973 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2974 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2975 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.