35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
46$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
47if (isModEnabled(
'eventorganization')) {
48 $langsLoad[] =
'eventorganization';
51$langs->loadLangs($langsLoad);
53$action =
GETPOST(
'action',
'alpha');
54$massaction =
GETPOST(
'massaction',
'alpha');
55$confirm =
GETPOST(
'confirm',
'alpha');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$toselect =
GETPOST(
'toselect',
'array');
58$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$optioncss =
GETPOST(
'optioncss',
'alpha');
61$mode =
GETPOST(
'mode',
'alpha');
67$project_ref =
GETPOST(
'project_ref',
'alpha');
73$search_date_startday =
GETPOSTINT(
'search_date_startday');
74$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
75$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
76$search_date_endday =
GETPOSTINT(
'search_date_endday');
77$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
78$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
79$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
80$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
81$search_note =
GETPOST(
'search_note',
'alpha');
82$search_duration =
GETPOST(
'search_duration',
'alpha');
83$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
84$search_task_label =
GETPOST(
'search_task_label',
'alpha');
85$search_user =
GETPOST(
'search_user',
'intcomma');
86$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
87$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
88$search_company =
GETPOST(
'$search_company',
'alpha');
89$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
90$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
91$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
92$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
93$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
94$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
95$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
98$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
99$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
101if (empty($page) || $page == -1) {
104$offset = $limit * $page;
105$pageprev = $page - 1;
106$pagenext = $page + 1;
108 $sortfield =
't.element_date,t.element_datehour,t.rowid';
111 $sortorder =
'DESC,DESC,DESC';
114$childids = $user->getAllChildIds(1);
118$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
122$projectstatic =
new Project($db);
125$extrafields->fetch_name_optionals_label($projectstatic->table_element);
126$extrafields->fetch_name_optionals_label(
$object->table_element);
129if ($id > 0 || $ref) {
137if (!$user->hasRight(
'projet',
'lire')) {
146 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
147 $search_user = $user->id;
156if (
GETPOST(
'cancel',
'alpha')) {
159if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
163$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
169include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
172if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
177 $search_duration =
'';
179 $search_date_startday =
'';
180 $search_date_startmonth =
'';
181 $search_date_startyear =
'';
182 $search_date_endday =
'';
183 $search_date_endmonth =
'';
184 $search_date_endyear =
'';
185 $search_date_start =
'';
186 $search_date_end =
'';
187 $search_task_ref =
'';
188 $search_company =
'';
189 $search_company_alias =
'';
190 $search_project_ref =
'';
191 $search_project_label =
'';
192 $search_task_label =
'';
194 $search_valuebilled =
'';
195 $search_product_ref =
'';
197 $search_array_options = array();
198 $search_timespent_starthour =
'';
199 $search_timespent_startmin =
'';
200 $search_timespent_endhour =
'';
201 $search_timespent_endmin =
'';
205if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
208 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
209 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
210 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
211 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
215 $langs->load(
"errors");
216 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
225 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
226 $action =
'createtime';
236 if (empty(
$object->project->status)) {
237 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
238 $action =
'createtime';
249 $object->timespent_withhour = 1;
256 $result =
$object->addTimeSpent($user);
267 $action =
'createtime';
271if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
274 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
275 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
287 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
288 $result =
$object->delTimeSpent($user);
291 $object->fetch($id_temp, $ref);
293 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
297 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
299 $object->timespent_withhour = 1;
309 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
310 $result =
$object->addTimeSpent($user);
322 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
326 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
328 $object->timespent_withhour = 1;
338 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
339 $result =
$object->updateTimeSpent($user);
354if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
357 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
358 $result =
$object->delTimeSpent($user);
361 $langs->load(
"errors");
372if (!empty($project_ref) && !empty($withproject)) {
373 if ($projectstatic->fetch(0, $project_ref) > 0) {
374 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
375 if (count($tasksarray) > 0) {
376 $id = $tasksarray[0]->id;
378 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
385$projectidforalltimes = 0;
387 $projectidforalltimes =
GETPOSTINT(
'projectid');
389 $result = $projectstatic->fetch($projectidforalltimes);
390 if (!empty($projectstatic->socid)) {
391 $projectstatic->fetch_thirdparty();
393 $res = $projectstatic->fetch_optionals();
394} elseif (
GETPOST(
'project_ref',
'alpha')) {
395 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
396 $projectidforalltimes = $projectstatic->id;
400 $result = $projectstatic->fetch(
$object->fk_project);
403if ($id <= 0 && $projectidforalltimes == 0) {
404 $allprojectforuser = $user->id;
407if ($action ==
'confirm_generateinvoice') {
408 if (!empty($projectstatic->socid)) {
409 $projectstatic->fetch_thirdparty();
412 if (!($projectstatic->thirdparty->id > 0)) {
413 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
415 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
416 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
417 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
419 $tmpinvoice =
new Facture($db);
420 $tmptimespent =
new Task($db);
421 $tmpproduct =
new Product($db);
422 $fuser =
new User($db);
427 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
430 $prodDurationHoursBase = 1.0;
431 $product_data_cache = array();
433 $tmpproduct->fetch($idprod);
439 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
440 if ($prodDurationHoursBase < 0) {
442 $langs->load(
"errors");
446 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
448 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
449 $txtva = $dataforprice[
'tva_tx'];
450 $localtax1 = $dataforprice[
'localtax1'];
451 $localtax2 = $dataforprice[
'localtax2'];
453 $prodDurationHoursBase = 1;
461 $tmpinvoice->socid = $projectstatic->thirdparty->id;
463 $tmpinvoice->fk_project = $projectstatic->id;
464 $tmpinvoice->cond_reglement_id = $condidproject;
465 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
466 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
469 $tmpinvoice->fetch($invoiceToUse);
471 $result = $tmpinvoice->create($user);
479 if ($generateinvoicemode ==
'onelineperuser') {
480 $arrayoftasks = array();
481 foreach ($toselect as $key => $value) {
483 $object->fetchTimeSpent($value);
484 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
485 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
488 foreach ($arrayoftasks as $userid => $data) {
489 $fuser->fetch($userid);
490 $username = $fuser->getFullName($langs);
492 foreach ($data as $fk_product => $timespent_data) {
494 $qtyhour = $timespent_data[
'timespent'] / 3600;
495 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
501 } elseif ($idprod <= 0) {
504 $pu_ht = $fuser->thm;
509 if ($timespent_data[
'timespent']) {
510 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
515 $prodDurationHours = $prodDurationHoursBase;
516 $idprodline = $idprod;
519 $localtax1line = $localtax1;
520 $localtax2line = $localtax2;
523 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
524 if (!array_key_exists($fk_product, $product_data_cache)) {
525 $result = $tmpproduct->fetch($fk_product);
530 $prodDurationHours = $tmpproduct->getProductDurationHours();
531 if ($prodDurationHours < 0) {
533 $langs->load(
"errors");
537 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
539 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
540 $txtvaline = $dataforprice[
'tva_tx'];
541 $localtax1line = $dataforprice[
'localtax1'];
542 $localtax2line = $dataforprice[
'localtax2'];
544 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
546 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
547 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
548 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
549 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
550 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
552 $idprodline = $fk_product;
556 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
563 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
564 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
565 $result = $db->query($sql);
573 } elseif ($generateinvoicemode ==
'onelineperperiod') {
574 $arrayoftasks = array();
576 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
577 foreach ($toselect as $key => $value) {
579 $object->fetchTimeSpent($value);
581 $ftask =
new Task($db);
584 $fuser->fetch(
$object->timespent_fk_user);
585 $username = $fuser->getFullName($langs);
587 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
588 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
589 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
592 if (!empty($withdetail)) {
593 if (!empty(
$object->timespent_withhour)) {
600 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
601 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
604 foreach ($arrayoftasks as $timespent_id => $value) {
605 $userid = $value[
'user'];
609 $qtyhour = $value[
'timespent'] / 3600;
613 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
617 $prodDurationHours = $prodDurationHoursBase;
618 $idprodline = $idprod;
621 $localtax1line = $localtax1;
622 $localtax2line = $localtax2;
624 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
625 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
626 $result = $tmpproduct->fetch($value[
'fk_product']);
631 $prodDurationHours = $tmpproduct->getProductDurationHours();
632 if ($prodDurationHours < 0) {
634 $langs->load(
"errors");
638 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
640 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
641 $txtvaline = $dataforprice[
'tva_tx'];
642 $localtax1line = $dataforprice[
'localtax1'];
643 $localtax2line = $dataforprice[
'localtax2'];
645 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
647 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
648 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
649 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
650 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
651 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
653 $idprodline = $value[
'fk_product'];
655 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
663 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
664 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
665 $result = $db->query($sql);
672 } elseif ($generateinvoicemode ==
'onelinepertask') {
673 $arrayoftasks = array();
674 foreach ($toselect as $key => $value) {
676 $object->fetchTimeSpent($value);
678 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
679 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
682 foreach ($arrayoftasks as $task_id => $data) {
683 $ftask =
new Task($db);
684 $ftask->fetch($task_id);
686 foreach ($data as $fk_product => $timespent_data) {
687 $qtyhour = $timespent_data[
'timespent'] / 3600;
688 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
691 $prodDurationHours = $prodDurationHoursBase;
692 $idprodline = $idprod;
695 $localtax1line = $localtax1;
696 $localtax2line = $localtax2;
698 if (!empty($fk_product) && $fk_product !== $idprod) {
699 if (!array_key_exists($fk_product, $product_data_cache)) {
700 $result = $tmpproduct->fetch($fk_product);
705 $prodDurationHours = $tmpproduct->getProductDurationHours();
706 if ($prodDurationHours < 0) {
708 $langs->load(
"errors");
712 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
714 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
715 $txtvaline = $dataforprice[
'tva_tx'];
716 $localtax1line = $dataforprice[
'localtax1'];
717 $localtax2line = $dataforprice[
'localtax2'];
719 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
721 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
722 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
723 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
724 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
725 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
727 $idprodline = $fk_product;
731 if ($idprodline > 0) {
733 $pu_ht_for_task = $pu_htline;
736 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
738 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
744 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
746 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
752 $lineName = $ftask->ref .
' - ' . $ftask->label;
753 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0, null, $pa_ht);
762 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
763 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
764 $result = $db->query($sql);
777 $urltoinvoice = $tmpinvoice->getNomUrl(0);
778 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
779 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
791if ($action ==
'confirm_generateinter') {
792 $langs->load(
'interventions');
794 if (!empty($projectstatic->socid)) {
795 $projectstatic->fetch_thirdparty();
798 if (!($projectstatic->thirdparty->id > 0)) {
799 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
801 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
802 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
803 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
806 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
808 $tmptimespent =
new Task($db);
809 $fuser =
new User($db);
815 $tmpinter->socid = $projectstatic->thirdparty->id;
817 $tmpinter->fk_project = $projectstatic->id;
818 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
821 $tmpinter->fetch($interToUse);
823 $result = $tmpinter->create($user);
831 $arrayoftasks = array();
832 foreach ($toselect as $key => $value) {
834 $object->fetchTimeSpent($value);
837 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
838 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
839 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
840 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
843 foreach ($arrayoftasks as $timespent_id => $value) {
844 $ftask =
new Task($db);
845 $ftask->fetch($value[
'id']);
847 $qtyhour = $value[
'timespent'] / 3600;
848 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
851 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
856 $urltointer = $tmpinter->getNomUrl(0);
857 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
858 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
875$form =
new Form($db);
878$userstatic =
new User($db);
880$arrayofselected = is_array($toselect) ? $toselect : array();
882$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
883if (!empty($withproject)) {
884 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
888llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
890if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
894 if ($projectidforalltimes > 0) {
895 $result = $projectstatic->fetch($projectidforalltimes);
896 if (!empty($projectstatic->socid)) {
897 $projectstatic->fetch_thirdparty();
899 $res = $projectstatic->fetch_optionals();
900 } elseif (
$object->fetch($id, $ref) >= 0) {
901 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
904 $result = $projectstatic->fetch(
$object->fk_project);
905 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
906 $projectstatic->fetchComments();
908 if (!empty($projectstatic->socid)) {
909 $projectstatic->fetch_thirdparty();
911 $res = $projectstatic->fetch_optionals();
913 $object->project = clone $projectstatic;
916 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
917 $linktocreatetime =
'';
919 if ($projectstatic->id > 0) {
922 if (empty($id) || $tab ==
'timespent') {
929 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
931 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
933 $param .=
'&search_user=' . ((int) $search_user);
936 $param .=
'&search_month=' . ((int) $search_month);
939 $param .=
'&search_year=' . ((int) $search_year);
944 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
946 $morehtmlref =
'<div class="refidno">';
948 $morehtmlref .= $projectstatic->title;
950 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
951 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
953 $morehtmlref .=
'</div>';
956 if (!$user->hasRight(
'projet',
'all',
'lire')) {
957 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
958 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0') .
")";
961 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
963 print
'<div class="fichecenter">';
964 print
'<div class="fichehalfleft">';
965 print
'<div class="underbanner clearboth"></div>';
967 print
'<table class="border tableforfield centpercent">';
971 print
'<tr><td class="tdtop">';
972 print $langs->trans(
"Usage");
976 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
977 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
978 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
982 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
983 $htmltext = $langs->trans(
"ProjectFollowTasks");
984 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
988 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"' :
'')) .
'"> ';
989 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
990 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
993 if (isModEnabled(
'eventorganization')) {
994 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"' :
'')) .
'"> ';
995 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
996 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1002 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1003 if ($projectstatic->public) {
1004 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1005 print $langs->trans(
'SharedProject');
1007 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1008 print $langs->trans(
'PrivateProject');
1013 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1014 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1015 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency) .
'</span>';
1020 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1022 print($start ? $start :
'?');
1025 print($end ? $end :
'?');
1026 if ($projectstatic->hasDelay()) {
1035 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1041 print
'<div class="fichehalfright">';
1042 print
'<div class="underbanner clearboth"></div>';
1044 print
'<table class="border tableforfield centpercent">';
1047 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1052 if (isModEnabled(
'category')) {
1053 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1054 print $form->showCategories($projectstatic->id,
'project', 1);
1063 print
'<div class="clearboth"></div>';
1073 $linktocreatetimeBtnStatus = 0;
1074 $linktocreatetimeUrl =
'';
1075 $linktocreatetimeHelpText =
'';
1076 if ($user->hasRight(
'projet',
'time')) {
1077 if ($projectstatic->public || $userRead > 0) {
1078 $linktocreatetimeBtnStatus = 1;
1080 if (!empty($projectidforalltimes)) {
1082 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1083 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1086 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1087 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1090 $linktocreatetimeBtnStatus = -2;
1091 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1094 $linktocreatetimeBtnStatus = -2;
1095 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1098 $paramsbutton = array(
'morecss' =>
'reposition');
1099 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1102 $massactionbutton =
'';
1103 $arrayofmassactions = array();
1105 if ($projectstatic->id > 0) {
1107 if ($projectstatic->usage_bill_time) {
1108 $arrayofmassactions = array(
1109 'generateinvoice' => $langs->trans(
"GenerateBill"),
1113 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1114 $langs->load(
"interventions");
1115 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1119 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1120 $arrayofmassactions = array();
1122 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1127 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1129 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1131 if ($action ==
'deleteline') {
1132 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1133 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1136 $param = ($withproject ?
'&withproject=1' :
'');
1137 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1138 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1140 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1141 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1142 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1144 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1150 if (empty($withproject)) {
1151 $morehtmlref .=
'<div class="refidno">';
1152 $morehtmlref .= $langs->trans(
"Project") .
': ';
1153 $morehtmlref .= $projectstatic->getNomUrl(1);
1154 $morehtmlref .=
'<br>';
1157 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1158 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1159 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1161 $morehtmlref .=
'</div>';
1164 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1166 print
'<div class="fichecenter">';
1167 print
'<div class="fichehalfleft">';
1169 print
'<div class="underbanner clearboth"></div>';
1170 print
'<table class="border centpercent tableforfield">';
1173 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1174 if (
$object->fk_task_parent > 0) {
1175 $tasktmp =
new Task($db);
1176 $tasktmp->fetch(
$object->fk_task_parent);
1177 print $tasktmp->getNomUrl(1);
1182 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1184 print($start ? $start :
'?');
1187 print($end ? $end :
'?');
1194 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1195 if (
$object->planned_workload) {
1203 print
'<div class="fichehalfright">';
1205 print
'<div class="underbanner clearboth"></div>';
1206 print
'<table class="border tableforfield centpercent">';
1209 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1214 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1215 if (
$object->planned_workload) {
1216 $tmparray =
$object->getSummaryOfTimeSpent();
1217 if ($tmparray[
'total_duration'] > 0) {
1218 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1223 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1234 print
'<div class="clearboth"></div>';
1238 if ($action ==
'deleteline') {
1239 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1240 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1245 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1247 $hookmanager->initHooks(array(
'tasktimelist'));
1251 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1253 $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);
1254 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1258 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1259 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1260 if (empty($reshook)) {
1261 $formconfirm .= $hookmanager->resPrint;
1262 } elseif ($reshook > 0) {
1263 $formconfirm = $hookmanager->resPrint;
1270 $arrayfields = array();
1271 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1272 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1273 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1274 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1275 if (! empty($allprojectforuser)) {
1276 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1277 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1279 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1280 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1282 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1283 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1284 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1285 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1287 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1288 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1289 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' => 1,
'enabled' => (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1291 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1294 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1297 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1298 $param .=
'&contextpage=' . urlencode($contextpage);
1300 if ($limit > 0 && $limit != $conf->liste_limit) {
1301 $param .=
'&limit='.((int) $limit);
1303 if ($search_month > 0) {
1304 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1306 if ($search_year > 0) {
1307 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1309 if (!empty($search_user)) {
1310 $param .=
'&search_user='.urlencode($search_user);
1312 if ($search_task_ref !=
'') {
1313 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1315 if ($search_company !=
'') {
1316 $param .=
'&$search_company=' . urlencode($search_company);
1318 if ($search_company_alias !=
'') {
1319 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1321 if ($search_project_ref !=
'') {
1322 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1324 if ($search_project_label !=
'') {
1325 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1327 if ($search_task_label !=
'') {
1328 $param .=
'&search_task_label=' . urlencode($search_task_label);
1330 if ($search_note !=
'') {
1331 $param .=
'&search_note=' . urlencode($search_note);
1333 if ($search_duration !=
'') {
1334 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1336 if ($optioncss !=
'') {
1337 $param .=
'&optioncss=' . urlencode($optioncss);
1339 if ($search_date_startday) {
1340 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1342 if ($search_date_startmonth) {
1343 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1345 if ($search_date_startyear) {
1346 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1348 if ($search_date_endday) {
1349 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1351 if ($search_date_endmonth) {
1352 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1354 if ($search_date_endyear) {
1355 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1357 if ($search_timespent_starthour) {
1358 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1360 if ($search_timespent_startmin) {
1361 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1363 if ($search_timespent_endhour) {
1364 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1366 if ($search_timespent_endmin) {
1367 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1375 $param .=
'&id=' . urlencode((
string) ($id));
1378 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1381 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1384 $parameters = array(
'param' => &$param);
1385 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1386 $param .= $hookmanager->resPrint;
1388 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1389 if ($optioncss !=
'') {
1390 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1392 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1393 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1394 if ($action ==
'editline') {
1395 print
'<input type="hidden" name="action" value="updateline">';
1396 } elseif ($action ==
'splitline') {
1397 print
'<input type="hidden" name="action" value="updatesplitline">';
1398 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1399 print
'<input type="hidden" name="action" value="addtimespent">';
1400 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1401 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1402 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1403 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1405 print
'<input type="hidden" name="action" value="list">';
1407 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1408 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1410 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1411 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1412 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1413 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1414 print
'<input type="hidden" name="page_y" value="">';
1417 if ($massaction ==
'generateinvoice') {
1418 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1419 print
'<table class="noborder centerpercent">';
1421 print
'<td class="titlefield">';
1422 print $langs->trans(
'DateInvoice');
1425 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1431 print $langs->trans(
'Mode');
1435 'onelineperuser' =>
'OneLinePerUser',
1436 'onelinepertask' =>
'OneLinePerTask',
1437 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1439 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1440 print
"\n" .
'<script type="text/javascript">';
1442 $(document).ready(function () {
1443 setDetailVisibility();
1444 $("#generateinvoicemode").change(function() {
1445 setDetailVisibility();
1447 function setDetailVisibility() {
1448 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1449 if (generateinvoicemode=="onelineperperiod") {
1450 $("#detail_time_duration").show();
1452 $("#detail_time_duration").hide();
1457 print
'</script>' .
"\n";
1458 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1462 if (isModEnabled(
"service")) {
1465 print $langs->trans(
'ServiceToUseOnLines');
1468 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1473 print
'<td class="titlefield">';
1474 print $langs->trans(
'InvoiceToUse');
1477 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1481 print
'<td class="titlefield">';
1482 print $langs->trans(
"CustomerRelativeDiscount");
1485 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1488 print
'<tr class="newinvoicedetail">';
1489 print
'<td class="titlefield">';
1490 print $langs->trans(
"PaymentConditions");
1493 print $form->getSelectConditionsPaiements($projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1507 print
'<div class="center">';
1508 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1509 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1513 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1514 print
'<div class="center">';
1515 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1519 } elseif ($massaction ==
'generateinter') {
1521 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1523 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1525 print
'<table class="noborder centpercent">';
1527 print
'<td class="titlefield">';
1528 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1532 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1537 print
'<div class="center">';
1538 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1539 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1543 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1544 print
'<div class="center">';
1545 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1552 $parameters = array(
1553 'toselect' => $toselect,
1554 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1557 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1561 print $hookmanager->resPrint;
1569 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1570 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1572 $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,";
1573 $sql .=
" t.fk_product,";
1574 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1575 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1576 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1577 $sql .=
" p.fk_soc,s.name_alias,";
1578 $sql .=
" t.invoice_line_id,";
1579 $sql .=
" pt.billable";
1581 $parameters = array();
1582 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1583 $sql .= $hookmanager->resPrint;
1584 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1588 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1589 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1590 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1591 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1592 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1593 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1594 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1595 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1598 $parameters = array();
1599 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1600 $sql .= $hookmanager->resPrint;
1601 $sql .=
" WHERE elementtype = 'task'";
1602 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1603 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1607 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1608 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1610 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1612 $sql .=
" AND t.fk_element =".((int)
$object->id);
1613 } elseif (!empty($projectidforalltimes)) {
1615 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1616 } elseif (!empty($allprojectforuser)) {
1618 if (empty($search_user)) {
1619 $search_user = $user->id;
1621 if ($search_user > 0) {
1622 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1629 if ($search_task_ref) {
1632 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1633 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1635 if ($search_company) {
1638 if ($search_company_alias) {
1642 if ($search_project_ref) {
1645 if ($search_project_label) {
1648 if ($search_task_label) {
1651 if ($search_user > 0) {
1654 if (!empty($search_product_ref)) {
1657 if ($search_valuebilled ==
'1') {
1658 $sql .=
' AND t.invoice_id > 0';
1660 if ($search_valuebilled ==
'0') {
1661 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1664 if ($search_date_start) {
1665 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1667 if ($search_date_end) {
1668 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1671 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1672 if ($search_timespent_starthour || $search_timespent_startmin) {
1673 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1674 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1675 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1678 if ($search_timespent_endhour || $search_timespent_endmin) {
1679 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1680 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1681 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1685 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1688 $parameters = array();
1689 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1690 $sql .= $hookmanager->resPrint;
1693 $nbtotalofrecords =
'';
1696 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1697 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1698 $resql = $db->query($sqlforcount);
1700 $objforcount = $db->fetch_object($resql);
1701 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1706 if (($page * $limit) > $nbtotalofrecords) {
1714 $sql .= $db->order($sortfield, $sortorder);
1716 $sql .= $db->plimit($limit + 1, $offset);
1719 $resql = $db->query($sql);
1725 $num = $db->num_rows($resql);
1728 if (!empty($projectidforalltimes)) {
1729 print
'<!-- List of time spent for project -->' .
"\n";
1731 $title = $langs->trans(
"ListTaskTimeUserProject");
1733 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1735 print
'<!-- List of time spent -->' .
"\n";
1737 $title = $langs->trans(
"ListTaskTimeForTask");
1739 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1744 $row = $db->fetch_object($resql);
1756 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1757 print
'<!-- table to add time spent -->' .
"\n";
1759 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1762 print
'<div class="div-table-responsive-no-min">';
1763 print
'<table class="noborder nohover centpercent">';
1765 print
'<tr class="liste_titre">';
1766 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1767 if (!empty($allprojectforuser)) {
1768 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1771 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1773 print
'<td>' . $langs->trans(
"By") .
'</td>';
1774 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1775 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1776 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1780 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1781 print
'<td>'.$langs->trans(
"Product").
'</td>';
1785 $parameters = array(
'mode' =>
'create');
1786 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1787 print $hookmanager->resPrint;
1791 print
'<tr class="oddeven nohover">';
1794 print
'<td class="maxwidthonsmartphone">';
1796 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1799 if (!empty($allprojectforuser)) {
1808 print
'<td class="maxwidthonsmartphone">';
1809 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1814 print
'<td class="maxwidthonsmartphone nowraponall">';
1815 $contactsofproject = $projectstatic->getListContactId(
'internal');
1816 if (count($contactsofproject) > 0) {
1817 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1818 if (in_array($user->id, $contactsofproject)) {
1819 $userid = $user->id;
1821 $userid = $contactsofproject[0];
1824 if ($projectstatic->public) {
1825 $contactsofproject = array();
1827 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1830 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1837 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1841 print
'<td class="nowraponall">';
1842 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1843 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1844 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1846 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1850 print
'<td class="nowrap">';
1851 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1859 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1860 print
'<td class="nowraponall">';
1862 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'', null, 1);
1868 $parameters = array(
'mode' =>
'create');
1869 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1870 print $hookmanager->resPrint;
1872 print
'<td class="center">';
1873 $form->buttonsSaveCancel();
1874 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1875 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1884 $moreforfilter =
'';
1886 $parameters = array();
1887 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1888 if (empty($reshook)) {
1889 $moreforfilter .= $hookmanager->resPrint;
1891 $moreforfilter = $hookmanager->resPrint;
1894 if (!empty($moreforfilter)) {
1895 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1896 print $moreforfilter;
1900 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1901 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1902 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1904 print
'<div class="div-table-responsive">';
1905 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1909 print
'<tr class="liste_titre_filter">';
1912 print
'<td class="liste_titre center">';
1913 $searchpicto = $form->showFilterButtons(
'left');
1918 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1919 print
'<td class="liste_titre left">';
1920 print
'<div class="nowrapfordate">';
1921 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1923 print
'<div class="nowrapfordate">';
1924 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1929 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1930 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1934 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1935 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1938 if (!empty($allprojectforuser)) {
1939 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1940 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1942 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1943 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1947 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1948 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1949 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1951 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1952 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1956 if (!empty($arrayfields[
'author'][
'checked'])) {
1957 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>';
1960 if (!empty($arrayfields[
't.note'][
'checked'])) {
1961 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1964 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1966 print
'<td class="liste_titre right">';
1968 $durationtouse_start =
'';
1969 if ($search_timespent_starthour || $search_timespent_startmin) {
1970 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1972 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1973 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1976 $durationtouse_end =
'';
1977 if ($search_timespent_endhour || $search_timespent_endmin) {
1978 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1980 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
1981 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1987 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1988 print
'<td class="liste_titre right"></td>';
1991 if (!empty($arrayfields[
'value'][
'checked'])) {
1992 print
'<td class="liste_titre"></td>';
1995 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1996 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2004 $parameters = array(
'arrayfields' => $arrayfields);
2005 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2006 print $hookmanager->resPrint;
2009 print
'<td class="liste_titre center">';
2010 $searchpicto = $form->showFilterButtons();
2014 print
'</tr>' .
"\n";
2017 $totalarray = array();
2018 $totalarray[
'nbfield'] = 0;
2022 print
'<tr class="liste_titre">';
2024 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2025 $totalarray[
'nbfield']++;
2027 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2028 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2029 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2032 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2033 $totalarray[
'nbfield']++;
2035 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2037 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2038 $totalarray[
'nbfield']++;
2040 if (!empty($allprojectforuser)) {
2041 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2043 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2046 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2047 $totalarray[
'nbfield']++;
2050 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2051 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2052 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2053 $totalarray[
'nbfield']++;
2055 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2056 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2057 $totalarray[
'nbfield']++;
2060 if (!empty($arrayfields[
'author'][
'checked'])) {
2061 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2062 $totalarray[
'nbfield']++;
2064 if (!empty($arrayfields[
't.note'][
'checked'])) {
2065 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2066 $totalarray[
'nbfield']++;
2068 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2069 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2070 $totalarray[
'nbfield']++;
2072 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2073 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2074 $totalarray[
'nbfield']++;
2077 if (!empty($arrayfields[
'value'][
'checked'])) {
2078 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2079 $totalarray[
'nbfield']++;
2081 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2082 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2083 $totalarray[
'nbfield']++;
2090 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2091 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2092 print $hookmanager->resPrint;
2094 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2095 $totalarray[
'nbfield']++;
2099 $tasktmp =
new Task($db);
2100 $tmpinvoice =
new Facture($db);
2103 $param .=
'&page='.((int) $page);
2105 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2109 $savnbfield = $totalarray[
'nbfield'];
2110 $totalarray = array();
2111 $totalarray[
'nbfield'] = 0;
2113 foreach ($tasks as $task_time) {
2118 $date1 = $db->jdate($task_time->element_date);
2119 $date2 = $db->jdate($task_time->element_datehour);
2123 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2127 print
'<td class="center nowraponall">';
2128 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2129 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2130 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2132 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2133 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2134 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2135 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' :
'').
'">';
2136 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2140 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' :
'') .
'">';
2141 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2145 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' :
'').
'">';
2146 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2149 if ($massactionbutton || $massaction) {
2151 if (in_array($task_time->rowid, $arrayofselected)) {
2155 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2161 $totalarray[
'nbfield']++;
2166 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2167 print
'<td class="nowrap">';
2168 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2169 if (empty($task_time->element_date_withhour)) {
2170 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2172 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2175 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2179 $totalarray[
'nbfield']++;
2184 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2185 print
'<td class="tdoverflowmax125">';
2186 if ($task_time->fk_soc > 0) {
2187 if (empty($conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2188 $tmpsociete =
new Societe($db);
2189 $tmpsociete->fetch($task_time->fk_soc);
2190 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2192 $tmpsociete = $conf->cache[
'thirdparty'][$task_time->fk_soc];
2194 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2198 $totalarray[
'nbfield']++;
2203 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2204 if ($task_time->fk_soc > 0) {
2205 if (empty($conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2206 $tmpsociete =
new Societe($db);
2207 $tmpsociete->fetch($task_time->fk_soc);
2208 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2210 $tmpsociete = $conf->cache[
'thirdparty'][$task_time->fk_soc];
2212 $valtoshow = $tmpsociete->name_alias;
2214 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2218 $totalarray[
'nbfield']++;
2223 if (!empty($allprojectforuser)) {
2224 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2225 print
'<td class="nowraponall">';
2226 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2227 $tmpproject =
new Project($db);
2228 $tmpproject->fetch($task_time->fk_projet);
2229 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2231 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2233 print $tmpproject->getNomUrl(1);
2236 $totalarray[
'nbfield']++;
2239 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2240 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2241 $tmpproject =
new Project($db);
2242 $tmpproject->fetch($task_time->fk_projet);
2243 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2245 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2247 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2251 $totalarray[
'nbfield']++;
2257 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2258 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2259 print
'<td class="nowrap">';
2260 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2261 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2263 $tasktmp->id = $task_time->fk_element;
2264 $tasktmp->ref = $task_time->ref;
2265 $tasktmp->label = $task_time->label;
2266 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2270 $totalarray[
'nbfield']++;
2273 } elseif ($action !==
'createtime') {
2274 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2278 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2279 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2280 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2284 $totalarray[
'nbfield']++;
2290 if (!empty($arrayfields[
'author'][
'checked'])) {
2291 print
'<td class="minwidth100 tdoverflowmax125">';
2292 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2295 $object->fetch($task_time->fk_element);
2297 $contactsoftask =
$object->getListContactId(
'internal');
2298 if (!in_array($task_time->fk_user, $contactsoftask)) {
2299 $contactsoftask[] = $task_time->fk_user;
2301 if (count($contactsoftask) > 0) {
2302 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2303 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2305 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2308 $userstatic->id = $task_time->fk_user;
2309 $userstatic->lastname = $task_time->lastname;
2310 $userstatic->firstname = $task_time->firstname;
2311 $userstatic->photo = $task_time->photo;
2312 $userstatic->gender = $task_time->gender;
2313 $userstatic->status = $task_time->user_status;
2315 print $userstatic->getNomUrl(-1);
2319 $totalarray[
'nbfield']++;
2324 if (!empty($arrayfields[
't.note'][
'checked'])) {
2325 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2326 print
'<td class="small">';
2327 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2330 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2335 $totalarray[
'nbfield']++;
2337 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2338 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2342 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2343 print
'<td class="right nowraponall">';
2344 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2345 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2346 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2352 $totalarray[
'nbfield']++;
2355 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2357 if (empty($totalarray[
'val'][
't.element_duration'])) {
2358 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2360 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2363 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2365 if (empty($totalarray[
'totalduration'])) {
2366 $totalarray[
'totalduration'] = $task_time->element_duration;
2368 $totalarray[
'totalduration'] += $task_time->element_duration;
2373 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2374 print
'<td class="nowraponall">';
2375 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2377 print $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', 0,
'',
null, 1);
2378 } elseif (!empty($task_time->fk_product)) {
2380 $resultFetch = $product->fetch($task_time->fk_product);
2381 if ($resultFetch < 0) {
2384 print $product->getNomUrl(1);
2389 $totalarray[
'nbfield']++;
2394 if (!empty($arrayfields[
'value'][
'checked'])) {
2395 $langs->load(
"salaries");
2396 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2398 print
'<td class="nowraponall right">';
2399 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2400 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2404 $totalarray[
'nbfield']++;
2407 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2409 if (empty($totalarray[
'val'][
'value'])) {
2410 $totalarray[
'val'][
'value'] = $value;
2412 $totalarray[
'val'][
'value'] += $value;
2415 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2417 if (empty($totalarray[
'totalvalue'])) {
2418 $totalarray[
'totalvalue'] = $value;
2420 $totalarray[
'totalvalue'] += $value;
2426 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2427 print
'<td class="center">';
2429 if ($projectstatic->usage_bill_time) {
2430 if ($task_time->invoice_id) {
2431 $result = $tmpinvoice->fetch($task_time->invoice_id);
2433 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2434 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2436 print $tmpinvoice->getNomUrl(1);
2437 if (!empty($task_time->invoice_line_id)) {
2439 $invoiceLine->fetch($task_time->invoice_line_id);
2440 if (!empty($invoiceLine->id)) {
2441 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2442 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2449 if (intval($task_time->billable) == 1) {
2450 print $langs->trans(
"No");
2452 print $langs->trans(
"Disabled");
2456 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2461 $totalarray[
'nbfield']++;
2471 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2472 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2473 print $hookmanager->resPrint;
2477 print
'<td class="center nowraponall">';
2478 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2479 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2480 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2482 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2483 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2484 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2485 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' :
'').
'">';
2486 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2490 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' :
'') .
'">';
2491 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2495 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' :
'').
'">';
2496 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2499 if ($massactionbutton || $massaction) {
2501 if (in_array($task_time->rowid, $arrayofselected)) {
2506 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2507 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2511 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2512 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2521 $totalarray[
'nbfield']++;
2530 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2531 print
'<!-- first line -->';
2532 print
'<tr class="oddeven">';
2540 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2541 print
'<td class="nowrap">';
2542 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2543 if (empty($task_time->element_date_withhour)) {
2544 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2546 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2549 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2555 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2556 print
'<td class="nowrap">';
2561 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2562 print
'<td class="nowrap">';
2567 if (!empty($allprojectforuser)) {
2568 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2569 print
'<td class="nowrap">';
2575 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2576 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2577 print
'<td class="nowrap">';
2578 $tasktmp->id = $task_time->fk_element;
2579 $tasktmp->ref = $task_time->ref;
2580 $tasktmp->label = $task_time->label;
2581 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2587 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2588 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2589 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2596 if (!empty($arrayfields[
'author'][
'checked'])) {
2597 print
'<td class="nowraponall">';
2598 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2602 $contactsoftask =
$object->getListContactId(
'internal');
2603 if (!in_array($task_time->fk_user, $contactsoftask)) {
2604 $contactsoftask[] = $task_time->fk_user;
2606 if (count($contactsoftask) > 0) {
2607 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2608 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2610 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2613 $userstatic->id = $task_time->fk_user;
2614 $userstatic->lastname = $task_time->lastname;
2615 $userstatic->firstname = $task_time->firstname;
2616 $userstatic->photo = $task_time->photo;
2617 $userstatic->status = $task_time->user_status;
2618 print $userstatic->getNomUrl(-1);
2624 if (!empty($arrayfields[
't.note'][
'checked'])) {
2625 print
'<td class="tdoverflowmax300">';
2626 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2627 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2632 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2633 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2637 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2638 print
'<td class="right">';
2639 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2640 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2641 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2649 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2650 print
'<td class="nowraponall tdoverflowmax125">';
2655 if (!empty($arrayfields[
'value'][
'checked'])) {
2656 print
'<td class="right">';
2657 print
'<span class="amount">';
2658 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2659 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2665 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2666 print
'<td class="right">';
2667 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2668 if (isset($task_time->total_ht)) {
2669 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2680 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2681 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2682 print $hookmanager->resPrint;
2686 print
'<td class="center nowraponall">';
2695 print
'<!-- second line --><tr class="oddeven">';
2699 print
'<td class="center nowraponall">';
2704 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2705 print
'<td class="nowrap">';
2706 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2707 if (empty($task_time->element_date_withhour)) {
2708 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2710 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2713 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2719 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2720 print
'<td class="nowrap">';
2725 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2726 print
'<td class="nowrap">';
2731 if (!empty($allprojectforuser)) {
2732 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2733 print
'<td class="nowrap">';
2739 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2740 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2741 print
'<td class="nowrap">';
2742 $tasktmp->id = $task_time->fk_element;
2743 $tasktmp->ref = $task_time->ref;
2744 $tasktmp->label = $task_time->label;
2745 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2751 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2752 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2753 print
'<td class="nowrap">';
2760 if (!empty($arrayfields[
'author'][
'checked'])) {
2761 print
'<td class="nowraponall tdoverflowmax100">';
2762 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2766 $contactsoftask =
$object->getListContactId(
'internal');
2767 if (!in_array($task_time->fk_user, $contactsoftask)) {
2768 $contactsoftask[] = $task_time->fk_user;
2770 if (count($contactsoftask) > 0) {
2771 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2772 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2774 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2777 $userstatic->id = $task_time->fk_user;
2778 $userstatic->lastname = $task_time->lastname;
2779 $userstatic->firstname = $task_time->firstname;
2780 $userstatic->photo = $task_time->photo;
2781 $userstatic->status = $task_time->user_status;
2782 print $userstatic->getNomUrl(-1);
2788 if (!empty($arrayfields[
't.note'][
'checked'])) {
2789 print
'<td class="small tdoverflowmax300"">';
2790 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2791 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2796 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2797 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2801 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2802 print
'<td class="right">';
2803 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2804 print
'<input type="hidden" name="old_duration_2" value="0">';
2805 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2813 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2814 print
'<td class="nowraponall tdoverflowmax125">';
2819 if (!empty($arrayfields[
'value'][
'checked'])) {
2820 print
'<td class="right">';
2821 print
'<span class="amount">';
2823 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2829 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2830 print
'<td class="right">';
2831 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2832 if (isset($task_time->total_ht)) {
2833 print
'<span class="amount">';
2834 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2846 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2847 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2848 print $hookmanager->resPrint;
2852 print
'<td class="center nowraponall">';
2864 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2865 print
'<tr class="liste_total">';
2867 while ($i < $totalarray[
'nbfield']) {
2870 if ($num < $limit && empty($offset)) {
2871 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2873 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2875 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2876 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2877 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2878 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2887 if (!count($tasks)) {
2888 $totalnboffields = 1;
2889 foreach ($arrayfields as $value) {
2890 if (!empty($value[
'checked'])) {
2894 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2895 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2899 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2900 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2901 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.