36require
'../../main.inc.php';
46@phan-var-force ?string $uploaddir
48require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
52require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
53require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
59$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61 $langsLoad[] =
'eventorganization';
64$langs->loadLangs($langsLoad);
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array:int');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
73$optioncss =
GETPOST(
'optioncss',
'alpha');
74$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
142$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
145if ($id > 0 || $ref) {
154if (!$user->hasRight(
'projet',
'lire')) {
163 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
164 $search_user = $user->id;
175if (
GETPOST(
'cancel',
'alpha')) {
178if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
182$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
183$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
188include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
191if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
196 $search_duration =
'';
197 $search_date_startday =
'';
198 $search_date_startmonth =
'';
199 $search_date_startyear =
'';
200 $search_date_endday =
'';
201 $search_date_endmonth =
'';
202 $search_date_endyear =
'';
203 $search_date_start =
'';
204 $search_date_end =
'';
205 $search_task_ref =
'';
206 $search_company =
'';
207 $search_company_alias =
'';
208 $search_project_ref =
'';
209 $search_project_label =
'';
210 $search_task_label =
'';
212 $search_valuebilled =
'';
213 $search_product_ref =
'';
215 $search_array_options = array();
216 $search_timespent_starthour =
'';
217 $search_timespent_startmin =
'';
218 $search_timespent_endhour =
'';
219 $search_timespent_endmin =
'';
223if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
224 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
225 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
226 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
227 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
231 $langs->load(
"errors");
232 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
241 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
242 $action =
'createtime';
252 if (empty(
$object->project->status)) {
253 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
254 $action =
'createtime';
265 $object->timespent_withhour = 1;
268 $object->timespent_withhour = 0;
273 $result =
$object->addTimeSpent($user);
284 $action =
'createtime';
288if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
289 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
290 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
301 $object->fetchTimeSpent($lineid);
305 $object->fetch($id_temp, $ref);
307 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
311 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
313 $object->timespent_withhour = 1;
314 } elseif (!empty($timespent_date)) {
315 $object->timespent_date = $timespent_date;
316 $object->timespent_withhour = 0;
319 if (GETPOSTISSET(
"userid_line")) {
327 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
328 $result =
$object->updateTimeSpent($user);
341 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
346 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
349 $object->timespent_withhour = 1;
350 } elseif (!empty($timespent_date)) {
351 $object->timespent_date = $timespent_date;
352 $object->timespent_datehour = $timespent_date;
353 $object->timespent_withhour = 0;
357 if (GETPOSTISSET(
"userid_line")) {
366 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
367 $result =
$object->updateTimeSpent($user);
382if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
385 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
386 $result =
$object->delTimeSpent($user);
389 $langs->load(
"errors");
400if (!empty($project_ref) && !empty($withproject)) {
401 if ($projectstatic->fetch(0, $project_ref) > 0) {
402 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
403 if (count($tasksarray) > 0) {
404 $id = $tasksarray[0]->id;
406 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
413$projectidforalltimes = 0;
415 $projectidforalltimes =
GETPOSTINT(
'projectid');
417 $result = $projectstatic->fetch($projectidforalltimes);
418 if (!empty($projectstatic->socid)) {
419 $projectstatic->fetch_thirdparty();
421 $res = $projectstatic->fetch_optionals();
422} elseif (
GETPOST(
'project_ref',
'alpha')) {
423 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
424 $projectidforalltimes = $projectstatic->id;
428 $result = $projectstatic->fetch(
$object->fk_project);
431$allprojectforuser = 0;
433if ($id <= 0 && $projectidforalltimes == 0) {
434 $allprojectforuser = $user->id;
437if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
438 if (!empty($projectstatic->socid)) {
439 $projectstatic->fetch_thirdparty();
442 if (!($projectstatic->thirdparty->id > 0)) {
443 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
445 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
446 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
447 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
459 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
462 $prodDurationHoursBase = 1.0;
463 $product_data_cache = array();
465 $result = $tmpproduct->fetch($idprod);
471 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
472 if ($prodDurationHoursBase < 0) {
474 $langs->load(
"errors");
478 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
480 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
481 $txtva = $dataforprice[
'tva_tx'];
482 $localtax1 =
get_localtax($txtva, 1, $projectstatic->thirdparty);
483 $localtax2 =
get_localtax($txtva, 2, $projectstatic->thirdparty);
485 $prodDurationHoursBase = 1;
493 $tmpinvoice->socid = $projectstatic->thirdparty->id;
495 $tmpinvoice->fk_project = $projectstatic->id;
496 $tmpinvoice->cond_reglement_id = $condidproject;
497 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
498 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
501 $tmpinvoice->fetch($invoiceToUse);
503 $result = $tmpinvoice->create($user);
511 if ($generateinvoicemode ==
'onelineperuser') {
512 $arrayoftasks = array();
513 foreach ($toselect as $key => $value) {
515 $object->fetchTimeSpent($value);
516 if (!array_key_exists(
$object->timespent_fk_user, $arrayoftasks)) {
517 $arrayoftasks[
$object->timespent_fk_user] = [
518 (int)
$object->timespent_fk_product => [
'timespent' => 0,
'totalvaluetodivideby3600' => 0]
521 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
522 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
525 foreach ($arrayoftasks as $userid => $data) {
526 $fuser->fetch($userid);
527 $username = $fuser->getFullName($langs);
529 foreach ($data as $fk_product => $timespent_data) {
531 $qtyhour = $timespent_data[
'timespent'] / 3600;
538 } elseif ($idprod <= 0) {
541 $pu_ht = $fuser->thm;
546 if ($timespent_data[
'timespent']) {
547 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
552 $prodDurationHours = $prodDurationHoursBase;
553 $idprodline = $idprod;
556 $localtax1line = $localtax1;
557 $localtax2line = $localtax2;
560 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
561 if (!array_key_exists($fk_product, $product_data_cache)) {
562 $result = $tmpproduct->fetch($fk_product);
567 $prodDurationHours = $tmpproduct->getProductDurationHours();
568 if ($prodDurationHours < 0) {
570 $langs->load(
"errors");
574 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
576 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
577 $txtvaline = $dataforprice[
'tva_tx'];
578 $localtax1line = $dataforprice[
'localtax1'];
579 $localtax2line = $dataforprice[
'localtax2'];
581 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
583 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
584 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
585 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
586 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
587 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
589 $idprodline = $fk_product;
596 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice").
' - '.$username .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
603 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
604 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
605 $result =
$db->query($sql);
613 } elseif ($generateinvoicemode ==
'onelineperperiod') {
614 $arrayoftasks = array();
616 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
617 foreach ($toselect as $key => $value) {
619 $object->fetchTimeSpent($value);
624 $fuser->fetch(
$object->timespent_fk_user);
625 $username = $fuser->getFullName($langs);
627 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
628 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
629 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
632 if (!empty($withdetail)) {
633 if (!empty(
$object->timespent_withhour)) {
640 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
641 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
644 $pu_ht_saved = $pu_ht;
645 foreach ($arrayoftasks as $timespent_id => $value) {
646 $pu_ht = $pu_ht_saved;
647 $userid = $value[
'user'];
651 $qtyhour = $value[
'timespent'] / 3600;
655 if ($value[
'timespent']) {
656 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
661 $prodDurationHours = $prodDurationHoursBase;
662 $idprodline = $idprod;
665 $localtax1line = $localtax1;
666 $localtax2line = $localtax2;
668 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
669 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
670 $result = $tmpproduct->fetch($value[
'fk_product']);
675 $prodDurationHours = $tmpproduct->getProductDurationHours();
676 if ($prodDurationHours < 0) {
678 $langs->load(
"errors");
682 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
684 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
685 $txtvaline = $dataforprice[
'tva_tx'];
686 $localtax1line = $dataforprice[
'localtax1'];
687 $localtax2line = $dataforprice[
'localtax2'];
689 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
691 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
692 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
693 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
694 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
695 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
697 $idprodline = $value[
'fk_product'];
703 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
711 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
712 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
713 $result =
$db->query($sql);
720 } elseif ($generateinvoicemode ==
'onelinepertask') {
721 $arrayoftasks = array();
722 foreach ($toselect as $key => $value) {
724 $object->fetchTimeSpent($value);
726 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
727 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
730 foreach ($arrayoftasks as $task_id => $data) {
732 $ftask->fetch($task_id);
734 foreach ($data as $fk_product => $timespent_data) {
735 $qtyhour = $timespent_data[
'timespent'] / 3600;
739 $prodDurationHours = $prodDurationHoursBase;
740 $idprodline = $idprod;
743 $localtax1line = $localtax1;
744 $localtax2line = $localtax2;
746 if (!empty($fk_product) && $fk_product !== $idprod) {
747 if (!array_key_exists($fk_product, $product_data_cache)) {
748 $result = $tmpproduct->fetch($fk_product);
753 $prodDurationHours = $tmpproduct->getProductDurationHours();
754 if ($prodDurationHours < 0) {
756 $langs->load(
"errors");
760 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
762 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
763 $txtvaline = $dataforprice[
'tva_tx'];
764 $localtax1line = $dataforprice[
'localtax1'];
765 $localtax2line = $dataforprice[
'localtax2'];
767 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
769 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
770 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
771 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
772 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
773 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
775 $idprodline = $fk_product;
779 if ($idprodline > 0) {
781 $pu_ht_for_task = $pu_htline;
784 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
786 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
792 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
794 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
800 $lineName = $ftask->ref .
' - ' . $ftask->label;
801 $lineid = $tmpinvoice->addline($lineName, (
float) $pu_ht_for_task, (
float)
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
$date_start, $date_end, 0, 0, 0,
'HT', 0, 1, -1, 0,
'', 0, 0, 0, $pa_ht);
810 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
811 $sql .=
' WHERE rowid IN (' .
$db->sanitize(implode(
',', $toselect)) .
')';
812 $result =
$db->query($sql);
825 $urltoinvoice = $tmpinvoice->getNomUrl(0);
826 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
827 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
837if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
838 $langs->load(
'interventions');
840 if (!empty($projectstatic->socid)) {
841 $projectstatic->fetch_thirdparty();
844 if (!($projectstatic->thirdparty->id > 0)) {
845 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
847 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
848 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
849 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
852 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
861 $tmpinter->socid = $projectstatic->thirdparty->id;
863 $tmpinter->fk_project = $projectstatic->id;
864 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
867 $tmpinter->fetch($interToUse);
869 $result = $tmpinter->create($user);
877 $arrayoftasks = array();
878 foreach ($toselect as $key => $value) {
880 $object->fetchTimeSpent($value);
883 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
884 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
885 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
886 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
889 foreach ($arrayoftasks as $timespent_id => $value) {
891 $ftask->fetch($value[
'id']);
893 $qtyhour = $value[
'timespent'] / 3600;
897 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
902 $timespent->fetch($timespent_id);
903 $timespent->intervention_id = $tmpinter->id;
904 $timespent->intervention_line_id = $lineid;
905 $result = $timespent->update($user);
915 $urltointer = $tmpinter->getNomUrl(0);
916 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
917 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
939$arrayofselected = is_array($toselect) ? $toselect : array();
941$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
942if (!empty($withproject)) {
943 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
947llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
950$param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
952 $param .=
'&search_user=' . ((int) $search_user);
955 $param .=
'&search_month=' . ((int) $search_month);
958 $param .=
'&search_year=' . ((int) $search_year);
962if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
964 if ($projectidforalltimes > 0) {
965 $result = $projectstatic->fetch($projectidforalltimes);
966 if (!empty($projectstatic->socid)) {
967 $projectstatic->fetch_thirdparty();
969 $res = $projectstatic->fetch_optionals();
970 } elseif (
$object->fetch($id, $ref) > 0) {
974 $result = $projectstatic->fetch(
$object->fk_project);
975 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
976 $projectstatic->fetchComments();
978 if (!empty($projectstatic->socid)) {
979 $projectstatic->fetch_thirdparty();
981 $res = $projectstatic->fetch_optionals();
983 $object->project = clone $projectstatic;
986 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
987 $linktocreatetime =
'';
989 if ($projectstatic->id > 0) {
992 if (empty($id) || $tab ==
'timespent') {
999 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
1003 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1005 $morehtmlref =
'<div class="refidno">';
1007 $morehtmlref .= $projectstatic->title;
1009 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
1010 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
1012 $morehtmlref .=
'</div>';
1015 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1016 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
1017 $projectstatic->next_prev_filter =
"rowid:IN:" .
$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1020 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1022 print
'<div class="fichecenter">';
1023 print
'<div class="fichehalfleft">';
1024 print
'<div class="underbanner clearboth"></div>';
1026 print
'<table class="border tableforfield centpercent">';
1030 print
'<tr><td class="tdtop">';
1031 print $langs->trans(
"Usage");
1035 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1036 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1037 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1041 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1042 $htmltext = $langs->trans(
"ProjectFollowTasks");
1043 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1047 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"' :
'')) .
'"> ';
1048 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1049 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1053 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"' :
'')) .
'"> ';
1054 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1055 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1061 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1062 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1063 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1068 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1070 print($start ? $start :
'?');
1073 print($end ? $end :
'?');
1074 if ($projectstatic->hasDelay()) {
1080 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1081 if ($projectstatic->public) {
1082 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1083 print $langs->trans(
'SharedProject');
1085 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1086 print $langs->trans(
'PrivateProject');
1094 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1100 print
'<div class="fichehalfright">';
1101 print
'<div class="underbanner clearboth"></div>';
1103 print
'<table class="border tableforfield centpercent">';
1107 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1108 print $form->showCategories($projectstatic->id,
'project', 1);
1113 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1114 if ($projectstatic->description) {
1115 print
'<tr><td class="nottitleforfield" colspan="2">';
1116 print
'<div class="longmessagecut">';
1127 print
'<div class="clearboth"></div>';
1135 $linktocreatetimeBtnStatus = 0;
1136 $linktocreatetimeUrl =
'';
1137 $linktocreatetimeHelpText =
'';
1138 if ($user->hasRight(
'projet',
'time')) {
1139 if ($projectstatic->public || $userRead > 0) {
1140 $linktocreatetimeBtnStatus = 1;
1142 if (!empty($projectidforalltimes)) {
1144 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1145 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1148 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1149 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1152 $linktocreatetimeBtnStatus = -2;
1153 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1156 $linktocreatetimeBtnStatus = -2;
1157 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1160 $paramsbutton = array(
'morecss' =>
'reposition');
1161 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1164 $massactionbutton =
'';
1165 $arrayofmassactions = array();
1167 if ($projectstatic->id > 0) {
1169 if ($projectstatic->usage_bill_time) {
1170 $arrayofmassactions = array(
1171 'generateinvoice' => $langs->trans(
"GenerateBill"),
1175 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1176 $langs->load(
"interventions");
1177 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1180 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1181 $arrayofmassactions = array();
1183 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1190 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1192 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1194 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
1195 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1197 if ($action ==
'deleteline') {
1198 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . $param;
1199 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1202 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1203 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1204 $object->next_prev_filter =
"fk_projet:IN:" .
$db->sanitize($projectsListId);
1206 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1212 if (empty($withproject)) {
1213 $morehtmlref .=
'<div class="refidno">';
1214 $morehtmlref .= $langs->trans(
"Project") .
': ';
1215 $morehtmlref .= $projectstatic->getNomUrl(1);
1216 $morehtmlref .=
'<br>';
1219 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1220 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1221 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1223 $morehtmlref .=
'</div>';
1226 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1228 print
'<div class="fichecenter">';
1229 print
'<div class="fichehalfleft">';
1231 print
'<div class="underbanner clearboth"></div>';
1232 print
'<table class="border centpercent tableforfield">';
1235 print
'<tr><td>' . $langs->trans(
"ParentTask") .
'</td><td>';
1236 if (
$object->fk_task_parent > 0) {
1238 $tasktmp->fetch(
$object->fk_task_parent);
1239 print $tasktmp->getNomUrl(1);
1244 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1246 print($start ? $start :
'?');
1249 print($end ? $end :
'?');
1256 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1257 if (
$object->planned_workload) {
1265 print
'<div class="fichehalfright">';
1267 print
'<div class="underbanner clearboth"></div>';
1268 print
'<table class="border tableforfield centpercent">';
1271 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1276 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1277 if (
$object->planned_workload) {
1278 $tmparray =
$object->getSummaryOfTimeSpent();
1279 if ($tmparray[
'total_duration'] > 0) {
1280 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1285 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1296 print
'<div class="clearboth"></div>';
1300 if ($action ==
'deleteline') {
1301 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($projectstatic->id > 0 ?
'projectid=' . $projectstatic->id : (
$object->id > 0 ?
"id=" .
$object->id :
'')) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'').
"&contextpage=" . urlencode($contextpage).$param;
1302 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1307 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1308 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1309 if (empty($reshook)) {
1310 $formconfirm .= $hookmanager->resPrint;
1311 } elseif ($reshook > 0) {
1312 $formconfirm = $hookmanager->resPrint;
1316 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1318 $hookmanager->initHooks(array(
'tasktimelist'));
1324 $arrayfields = array();
1325 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1326 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1327 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1328 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1329 if (! empty($allprojectforuser)) {
1330 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1331 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1333 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1334 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1336 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1337 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1338 $arrayfields[
't.tms'] = array(
'label' => $langs->trans(
"DateModification"),
'checked' =>
'0');
1339 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1340 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1342 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1343 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'0',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1344 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int)
isModEnabled(
"salaries"));
1345 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' =>
'1',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1347 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1352 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1353 $param .=
'&contextpage=' . urlencode($contextpage);
1355 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1356 $param .=
'&limit='.((int) $limit);
1359 $param .=
'&id='.((int) $id);
1361 if ($search_month > 0) {
1362 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1364 if ($search_year > 0) {
1365 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1367 if (!empty($search_user)) {
1368 $param .=
'&search_user='.urlencode($search_user);
1370 if ($search_task_ref !=
'') {
1371 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1373 if ($search_company !=
'') {
1374 $param .=
'&search_company=' . urlencode($search_company);
1376 if ($search_company_alias !=
'') {
1377 $param .=
'&search_company_alias=' . urlencode($search_company_alias);
1379 if ($search_project_ref !=
'') {
1380 $param .=
'&search_project_ref=' . urlencode($search_project_ref);
1382 if ($search_project_label !=
'') {
1383 $param .=
'&search_project_label=' . urlencode($search_project_label);
1385 if ($search_task_label !=
'') {
1386 $param .=
'&search_task_label=' . urlencode($search_task_label);
1388 if ($search_note !=
'') {
1389 $param .=
'&search_note=' . urlencode($search_note);
1391 if ($search_duration !=
'') {
1392 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1394 if ($optioncss !=
'') {
1395 $param .=
'&optioncss=' . urlencode($optioncss);
1397 if ($search_date_startday) {
1398 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1400 if ($search_date_startmonth) {
1401 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1403 if ($search_date_startyear) {
1404 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1406 if ($search_date_endday) {
1407 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1409 if ($search_date_endmonth) {
1410 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1412 if ($search_date_endyear) {
1413 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1415 if ($search_timespent_starthour) {
1416 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1418 if ($search_timespent_startmin) {
1419 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1421 if ($search_timespent_endhour) {
1422 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1424 if ($search_timespent_endmin) {
1425 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1428 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1430 $param .=
'&id=' . urlencode((
string) ($id));
1433 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1436 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1439 $parameters = array(
'param' => &$param);
1440 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1441 $param .= $hookmanager->resPrint;
1443 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1444 if ($optioncss !=
'') {
1445 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1447 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1448 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1449 if ($action ==
'editline') {
1450 print
'<input type="hidden" name="action" value="updateline">';
1451 } elseif ($action ==
'splitline') {
1452 print
'<input type="hidden" name="action" value="updatesplitline">';
1453 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1454 print
'<input type="hidden" name="action" value="addtimespent">';
1455 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1456 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1457 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1458 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1460 print
'<input type="hidden" name="action" value="list">';
1462 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1463 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1467 print
'<input type="hidden" name="id" value="' . ((int) $id) .
'">';
1468 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1469 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1470 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1471 print
'<input type="hidden" name="page_y" value="">';
1474 if ($massaction ==
'generateinvoice') {
1475 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1476 print
'<table class="noborder centerpercent">';
1478 print
'<td class="titlefield">';
1479 print $langs->trans(
'DateInvoice');
1482 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1488 print $langs->trans(
'Mode');
1492 'onelineperuser' =>
'OneLinePerUser',
1493 'onelinepertask' =>
'OneLinePerTask',
1494 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1496 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1497 print
"\n" .
'<script type="text/javascript">';
1499 $(document).ready(function () {
1500 setDetailVisibility();
1501 $("#generateinvoicemode").change(function() {
1502 setDetailVisibility();
1504 function setDetailVisibility() {
1505 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1506 if (generateinvoicemode=="onelineperperiod") {
1507 $("#detail_time_duration").show();
1509 $("#detail_time_duration").hide();
1514 print
'</script>' .
"\n";
1515 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1522 print $langs->trans(
'ServiceToUseOnLines');
1525 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1530 print
'<td class="titlefield">';
1531 print $langs->trans(
'InvoiceToUse');
1534 print $form->selectInvoiceForTimeProject($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1538 print
'<td class="titlefield">';
1539 print $langs->trans(
"CustomerRelativeDiscount");
1542 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1545 print
'<tr class="newinvoicedetail">';
1546 print
'<td class="titlefield">';
1547 print $langs->trans(
"PaymentConditions");
1550 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1564 print
'<div class="center">';
1565 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1566 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1570 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1571 print
'<div class="center">';
1572 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1576 } elseif ($massaction ==
'generateinter') {
1578 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1580 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1582 print
'<table class="noborder centpercent">';
1584 print
'<td class="titlefield">';
1585 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1589 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1594 print
'<div class="center">';
1595 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1596 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1600 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1601 print
'<div class="center">';
1602 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1609 $parameters = array(
1610 'toselect' => $toselect,
1611 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1614 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1618 print $hookmanager->resPrint;
1626 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1627 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1630 if ($projectstatic->usage_bill_time) {
1631 $arrayfields[
'valuebilled'][
'checked'] = 1;
1634 $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,";
1635 $sql .=
" t.fk_product, t.invoice_line_id, t.import_key, t.datec, t.tms,";
1636 $sql .=
" pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet, pt.billable,";
1637 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1638 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1639 $sql .=
" p.fk_soc, s.name_alias";
1640 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1641 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1642 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1646 $parameters = array();
1647 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1648 $sql .= $hookmanager->resPrint;
1649 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1653 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1654 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1655 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1656 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1657 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1658 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1659 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1660 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1661 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1664 $parameters = array();
1665 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1666 $sql .= $hookmanager->resPrint;
1667 $sql .=
" WHERE elementtype = 'task'";
1668 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1669 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1673 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1674 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1676 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1678 $sql .=
" AND t.fk_element =".((int)
$object->id);
1679 } elseif (!empty($projectidforalltimes)) {
1681 $sql .=
" AND pt.fk_projet IN (" .
$db->sanitize((
string) $projectidforalltimes) .
")";
1682 } elseif (!empty($allprojectforuser)) {
1684 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1685 $search_user = $user->id;
1687 if ($search_user > 0) {
1688 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1695 if ($search_task_ref) {
1698 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1699 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1701 if ($search_company) {
1704 if ($search_company_alias) {
1708 if ($search_project_ref) {
1711 if ($search_project_label) {
1714 if ($search_task_label) {
1717 if ($search_user > 0) {
1720 if (!empty($search_product_ref)) {
1723 if ($search_valuebilled ==
'1') {
1724 $sql .=
' AND t.invoice_id > 0';
1726 if ($search_valuebilled ==
'0') {
1727 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1730 if ($search_date_start) {
1731 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1733 if ($search_date_end) {
1734 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1737 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1738 if ($search_timespent_starthour || $search_timespent_startmin) {
1739 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1740 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1741 $sql .=
" AND t.element_duration >= " . ((int) $timespent_duration_start);
1744 if ($search_timespent_endhour || $search_timespent_endmin) {
1745 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1746 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1747 $sql .=
" AND t.element_duration <= " . ((int) $timespent_duration_end);
1751 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1754 $extrafieldsobjectkey =
'projet_task';
1755 $extrafieldsobjectprefix =
'efpt.';
1756 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1759 $parameters = array();
1760 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1761 $sql .= $hookmanager->resPrint;
1764 $nbtotalofrecords =
'';
1767 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1768 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1769 $resql =
$db->query($sqlforcount);
1771 $objforcount =
$db->fetch_object($resql);
1772 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1777 if (($page * $limit) > (
int) $nbtotalofrecords) {
1785 $sql .=
$db->order($sortfield, $sortorder);
1787 $sql .=
$db->plimit($limit + 1, $offset);
1790 $resql =
$db->query($sql);
1796 $num =
$db->num_rows($resql);
1799 if (!empty($projectidforalltimes)) {
1800 print
'<!-- List of time spent for project -->' .
"\n";
1802 $title = $langs->trans(
"ListTaskTimeUserProject");
1804 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1806 print
'<!-- List of time spent -->' .
"\n";
1808 $title = $langs->trans(
"ListTaskTimeForTask");
1810 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1815 $obj =
$db->fetch_object($resql);
1829 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1830 print
'<!-- table to add time spent -->' .
"\n";
1832 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1835 print
'<div class="div-table-responsive-no-min">';
1836 print
'<table class="noborder nohover centpercent">';
1838 print
'<tr class="liste_titre">';
1839 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1840 if (!empty($allprojectforuser)) {
1841 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1844 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1846 print
'<td>' . $langs->trans(
"By") .
'</td>';
1847 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1848 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1849 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1853 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1854 print
'<td>'.$langs->trans(
"Product").
'</td>';
1858 $parameters = array(
'mode' =>
'create');
1859 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1860 print $hookmanager->resPrint;
1864 print
'<tr class="oddeven nohover">';
1867 print
'<td class="maxwidthonsmartphone">';
1869 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1872 if (!empty($allprojectforuser)) {
1881 print
'<td class="maxwidthonsmartphone">';
1882 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1887 print
'<td class="maxwidthonsmartphone nowraponall">';
1888 $contactsofproject = $projectstatic->getListContactId(
'internal');
1889 if (count($contactsofproject) > 0) {
1890 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1891 if (in_array($user->id, $contactsofproject)) {
1892 $userid = $user->id;
1894 $userid = $contactsofproject[0];
1897 if ($projectstatic->public) {
1898 $contactsofproject = array();
1900 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1903 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1910 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1914 print
'<td class="nowraponall">';
1915 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1916 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1917 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1919 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1923 print
'<td class="nowrap">';
1924 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1932 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1933 print
'<td class="nowraponall">';
1935 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
1941 $parameters = array(
'mode' =>
'create');
1942 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1943 print $hookmanager->resPrint;
1945 print
'<td class="center">';
1946 $form->buttonsSaveCancel();
1947 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1948 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1957 $moreforfilter =
'';
1959 $parameters = array();
1960 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1961 if (empty($reshook)) {
1962 $moreforfilter .= $hookmanager->resPrint;
1964 $moreforfilter = $hookmanager->resPrint;
1967 if (!empty($moreforfilter)) {
1968 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1969 print $moreforfilter;
1973 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1974 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1975 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1978 if ($projectstatic->usage_bill_time) {
1979 $arrayfields[
'valuebilled'][
'checked'] = 1;
1982 print
'<!-- Liste of time spent -->'.
"\n";
1983 print
'<div class="div-table-responsive">';
1984 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1988 print
'<tr class="liste_titre_filter">';
1990 if (
$conf->main_checkbox_left_column) {
1991 print
'<td class="liste_titre center">';
1992 $searchpicto = $form->showFilterButtons(
'left');
1997 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1998 print
'<td class="liste_titre left">';
1999 print
'<div class="nowrapfordate paddingright">';
2000 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
2002 print
'<div class="nowrapfordate">';
2003 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
2008 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2009 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
2013 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2014 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
2017 if (!empty($allprojectforuser)) {
2018 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2019 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
2021 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2022 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2026 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2027 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2028 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2030 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2031 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2035 if (!empty($arrayfields[
'author'][
'checked'])) {
2036 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>';
2039 if (!empty($arrayfields[
't.note'][
'checked'])) {
2040 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2043 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2044 print
'<td class="liste_titre"></td>';
2047 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2049 print
'<td class="liste_titre right">';
2051 $durationtouse_start =
'';
2052 if ($search_timespent_starthour || $search_timespent_startmin) {
2053 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2055 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'fromhour') .
'</span> ';
2056 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2059 $durationtouse_end =
'';
2060 if ($search_timespent_endhour || $search_timespent_endmin) {
2061 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2063 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'tohour') .
'</span> ';
2064 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2070 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2071 print
'<td class="liste_titre"></td>';
2074 if (!empty($arrayfields[
'value'][
'checked'])) {
2075 print
'<td class="liste_titre"></td>';
2078 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2079 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2083 $extrafieldsobjectkey =
'projet_task';
2084 $extrafieldsobjectprefix =
'ef.';
2085 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2087 $parameters = array(
'arrayfields' => $arrayfields);
2088 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2089 print $hookmanager->resPrint;
2091 if (!
$conf->main_checkbox_left_column) {
2092 print
'<td class="liste_titre center">';
2093 $searchpicto = $form->showFilterButtons();
2097 print
'</tr>' .
"\n";
2105 print
'<tr class="liste_titre">';
2106 if (
$conf->main_checkbox_left_column) {
2107 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2110 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2111 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2114 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2115 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2118 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2120 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2123 if (!empty($allprojectforuser)) {
2124 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2125 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2128 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2129 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2133 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2134 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2135 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2138 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2139 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2143 if (!empty($arrayfields[
'author'][
'checked'])) {
2144 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2147 if (!empty($arrayfields[
't.note'][
'checked'])) {
2148 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2151 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2152 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
't.tms',
'', $param,
'', $sortfield, $sortorder);
2155 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2156 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2159 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2160 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2164 if (!empty($arrayfields[
'value'][
'checked'])) {
2165 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2168 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2169 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2173 $extrafieldsobjectkey =
'projet_task';
2174 $extrafieldsobjectprefix =
'ef.';
2175 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2177 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2178 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2179 print $hookmanager->resPrint;
2180 if (!
$conf->main_checkbox_left_column) {
2181 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2190 $param .=
'&page='.((int) $page);
2192 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2200 foreach ($tasks as $task_time) {
2206 $invoiced = $task_time->invoice_id ? true :
false;
2208 $date1 =
$db->jdate($task_time->element_date);
2209 $date2 =
$db->jdate($task_time->element_datehour);
2213 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2216 if (
$conf->main_checkbox_left_column) {
2217 print
'<td class="center nowraponall">';
2218 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2219 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2221 print
'<input type="hidden" name="id" value="' .
$id .
'">';
2223 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2225 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2226 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2227 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2228 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' :
'').
'">';
2229 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2233 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' :
'') .
'">';
2234 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2238 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' :
'').
'">';
2239 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2242 if ($massactionbutton || $massaction) {
2244 if (in_array($task_time->rowid, $arrayofselected)) {
2250 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2251 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2255 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2256 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2270 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2271 print
'<td class="nowrap">';
2272 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2273 if (empty($task_time->element_date_withhour)) {
2274 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2276 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2279 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2288 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2289 print
'<td class="tdoverflowmax125">';
2290 if ($task_time->fk_soc > 0) {
2291 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2293 $tmpsociete->fetch($task_time->fk_soc);
2294 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2296 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2298 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2307 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2309 if ($task_time->fk_soc > 0) {
2310 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2312 $tmpsociete->fetch($task_time->fk_soc);
2313 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2315 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2317 $valtoshow = $tmpsociete->name_alias;
2319 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2327 if (!empty($allprojectforuser)) {
2329 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2330 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2332 $tmpproject->fetch($task_time->fk_projet);
2333 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2335 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2337 print
'<td class="nowraponall">';
2338 print $tmpproject->getNomUrl(1);
2345 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2346 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2348 $tmpproject->fetch($task_time->fk_projet);
2349 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2351 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2353 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2354 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2357 print $tmpproject->getNomUrl(1,
'', -1);
2367 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2368 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2369 print
'<td class="nowrap">';
2370 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2371 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (
string) $projectstatic->id,
'');
2373 $tasktmp->id = $task_time->fk_element;
2374 $tasktmp->ref = $task_time->ref;
2375 $tasktmp->label = $task_time->label;
2376 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2383 } elseif ($action !==
'createtime') {
2384 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2388 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2389 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2390 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2391 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2394 $tasktmp->id = $task_time->fk_element;
2395 $tasktmp->ref = $task_time->ref;
2396 $tasktmp->label = $task_time->label;
2397 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2407 if (!empty($arrayfields[
'author'][
'checked'])) {
2408 print
'<td class="tdoverflowmax125">';
2409 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2412 $object->fetch($task_time->fk_element);
2414 $contactsoftask =
$object->getListContactId(
'internal');
2415 if (!in_array($task_time->fk_user, $contactsoftask)) {
2416 $contactsoftask[] = $task_time->fk_user;
2418 if (count($contactsoftask) > 0) {
2419 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2420 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2422 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2425 $userstatic->id = $task_time->fk_user;
2426 $userstatic->lastname = $task_time->lastname;
2427 $userstatic->firstname = $task_time->firstname;
2428 $userstatic->photo = $task_time->photo;
2429 $userstatic->gender = $task_time->gender;
2430 $userstatic->status = $task_time->user_status;
2432 print $userstatic->getNomUrl(-1);
2441 if (!empty($arrayfields[
't.note'][
'checked'])) {
2442 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2443 print
'<td class="small">';
2444 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2447 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2454 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2455 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2459 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2460 print
'<td class="nowraponall">';
2469 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2470 print
'<td class="right nowraponall">';
2471 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2472 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2473 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2484 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2485 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2487 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2493 $totalarray[
'totalduration'] = $task_time->element_duration;
2495 $totalarray[
'totalduration'] += $task_time->element_duration;
2500 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2501 print
'<td class="nowraponall">';
2502 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2504 print $form->select_produits($task_time->fk_product,
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
2505 } elseif (!empty($task_time->fk_product)) {
2507 $resultFetch = $product->fetch($task_time->fk_product);
2508 if ($resultFetch < 0) {
2511 print $product->getNomUrl(1);
2521 if (!empty($arrayfields[
'value'][
'checked'])) {
2522 $langs->load(
"salaries");
2523 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2525 print
'<td class="nowraponall right">';
2526 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2527 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2552 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2553 print
'<td class="center">';
2555 if ($projectstatic->usage_bill_time) {
2556 if ($task_time->invoice_id) {
2557 $result = $tmpinvoice->fetch($task_time->invoice_id);
2559 if ($user->hasRight(
'facture',
'lire')) {
2560 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2561 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2563 print $tmpinvoice->getNomUrl(1);
2564 if (!empty($task_time->invoice_line_id)) {
2566 $invoiceLine->fetch($task_time->invoice_line_id);
2567 if (!empty($invoiceLine->id)) {
2568 print
'<br><span class="small opacitymedium">'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2569 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2575 print $langs->trans(
"Yes");
2580 if (intval($task_time->billable) == 1) {
2581 print $langs->trans(
"No");
2583 print $langs->trans(
"Disabled");
2587 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2598 $extrafieldsobjectkey =
'projet_task';
2599 $extrafieldsobjectprefix =
'ef.';
2600 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2603 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2604 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2605 print $hookmanager->resPrint;
2608 if (!
$conf->main_checkbox_left_column) {
2609 print
'<td class="center nowraponall">';
2610 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2611 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2612 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2614 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2615 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2616 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2617 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' :
'').
'">';
2618 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2622 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' :
'') .
'">';
2623 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2627 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' :
'').
'">';
2628 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2631 if ($massactionbutton || $massaction) {
2633 if (in_array($task_time->rowid, $arrayofselected)) {
2639 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2640 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2644 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2645 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2663 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2664 print
'<!-- first line -->';
2665 print
'<tr class="oddeven">';
2668 if (
$conf->main_checkbox_left_column) {
2673 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2674 print
'<td class="nowrap">';
2675 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2676 if (empty($task_time->element_date_withhour)) {
2677 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2679 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2682 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2688 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2689 print
'<td class="nowrap">';
2694 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2695 print
'<td class="nowrap">';
2700 if (!empty($allprojectforuser)) {
2701 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2702 print
'<td class="nowrap">';
2708 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2709 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2710 print
'<td class="nowrap">';
2711 $tasktmp->id = $task_time->fk_element;
2712 $tasktmp->ref = $task_time->ref;
2713 $tasktmp->label = $task_time->label;
2714 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2720 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2721 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2722 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2729 if (!empty($arrayfields[
'author'][
'checked'])) {
2730 print
'<td class="nowraponall">';
2731 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2733 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2736 $contactsoftask =
$object->getListContactId(
'internal');
2737 if (!in_array($task_time->fk_user, $contactsoftask)) {
2738 $contactsoftask[] = $task_time->fk_user;
2740 if (count($contactsoftask) > 0) {
2741 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2742 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2744 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2747 $userstatic->id = $task_time->fk_user;
2748 $userstatic->lastname = $task_time->lastname;
2749 $userstatic->firstname = $task_time->firstname;
2750 $userstatic->photo = $task_time->photo;
2751 $userstatic->status = $task_time->user_status;
2752 print $userstatic->getNomUrl(-1);
2758 if (!empty($arrayfields[
't.note'][
'checked'])) {
2759 print
'<td class="tdoverflowmax300">';
2760 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2761 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2766 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2767 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2771 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2772 print
'<td class="nowraponall">';
2777 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2778 print
'<td class="right">';
2779 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2780 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2781 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2789 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2790 print
'<td class="nowraponall tdoverflowmax125">';
2795 if (!empty($arrayfields[
'value'][
'checked'])) {
2796 print
'<td class="right">';
2797 print
'<span class="amount">';
2798 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2799 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2805 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2806 print
'<td class="right">';
2807 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2808 if (isset($task_time->total_ht)) {
2809 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2816 $extrafieldsobjectkey =
'projet_task';
2817 $extrafieldsobjectprefix =
'ef.';
2818 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2821 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2822 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2823 print $hookmanager->resPrint;
2826 if (!
$conf->main_checkbox_left_column) {
2827 print
'<td class="center nowraponall">';
2836 print
'<!-- second line --><tr class="oddeven">';
2839 if (
$conf->main_checkbox_left_column) {
2840 print
'<td class="center nowraponall">';
2845 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2846 print
'<td class="nowraponall">';
2847 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2848 if (empty($task_time->element_date_withhour)) {
2849 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2851 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2854 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2860 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2866 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2872 if (!empty($allprojectforuser)) {
2873 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2880 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2881 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2882 print
'<td class="nowraponall">';
2883 $tasktmp->id = $task_time->fk_element;
2884 $tasktmp->ref = $task_time->ref;
2885 $tasktmp->label = $task_time->label;
2886 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2892 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2893 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2894 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2901 if (!empty($arrayfields[
'author'][
'checked'])) {
2902 print
'<td class="nowraponall tdoverflowmax100">';
2903 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2905 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2908 $contactsoftask =
$object->getListContactId(
'internal');
2909 if (!in_array($task_time->fk_user, $contactsoftask)) {
2910 $contactsoftask[] = $task_time->fk_user;
2912 if (count($contactsoftask) > 0) {
2913 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2914 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2916 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2919 $userstatic->id = $task_time->fk_user;
2920 $userstatic->lastname = $task_time->lastname;
2921 $userstatic->firstname = $task_time->firstname;
2922 $userstatic->photo = $task_time->photo;
2923 $userstatic->status = $task_time->user_status;
2924 print $userstatic->getNomUrl(-1);
2930 if (!empty($arrayfields[
't.note'][
'checked'])) {
2931 print
'<td class="small tdoverflowmax300"">';
2932 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2933 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2938 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2939 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2943 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2944 print
'<td class="nowraponall">';
2950 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2951 print
'<td class="right">';
2952 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2953 print
'<input type="hidden" name="old_duration_2" value="0">';
2954 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2962 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2963 print
'<td class="nowraponall tdoverflowmax125">';
2968 if (!empty($arrayfields[
'value'][
'checked'])) {
2969 print
'<td class="right">';
2970 print
'<span class="amount nowraponall">';
2972 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2979 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2980 print
'<td class="right">';
2981 if (isset($task_time->total_ht)) {
2982 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2983 print
'<span class="amount nowraponall small">';
2984 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2992 $extrafieldsobjectkey =
'projet_task';
2993 $extrafieldsobjectprefix =
'ef.';
2994 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2997 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2998 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2999 print $hookmanager->resPrint;
3002 if (!
$conf->main_checkbox_left_column) {
3003 print
'<td class="center nowraponall">';
3016 print
'<tr class="liste_total">';
3021 if ($num < $limit && empty($offset)) {
3022 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
3024 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
3038 if (!count($tasks)) {
3039 $totalnboffields = 1;
3040 foreach ($arrayfields as $value) {
3041 if (!empty($value[
'checked'])) {
3045 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
3046 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
3050 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3051 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3052 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
$date_start
Variables from include:
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 ...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
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...
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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.