36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56@phan-var-force ?string $uploaddir
60$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61if (isModEnabled(
'eventorganization')) {
62 $langsLoad[] =
'eventorganization';
65$langs->loadLangs($langsLoad);
67$action =
GETPOST(
'action',
'alpha');
68$massaction =
GETPOST(
'massaction',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$cancel =
GETPOST(
'cancel',
'alpha');
71$toselect =
GETPOST(
'toselect',
'array');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
73$backtopage =
GETPOST(
'backtopage',
'alpha');
74$optioncss =
GETPOST(
'optioncss',
'alpha');
75$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
136$projectstatic =
new Project($db);
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
142$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
145if ($id > 0 || $ref) {
153if (!$user->hasRight(
'projet',
'lire')) {
162 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
163 $search_user = $user->id;
173if (
GETPOST(
'cancel',
'alpha')) {
176if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
180$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
181$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
186include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
189if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
194 $search_duration =
'';
195 $search_date_startday =
'';
196 $search_date_startmonth =
'';
197 $search_date_startyear =
'';
198 $search_date_endday =
'';
199 $search_date_endmonth =
'';
200 $search_date_endyear =
'';
201 $search_date_start =
'';
202 $search_date_end =
'';
203 $search_task_ref =
'';
204 $search_company =
'';
205 $search_company_alias =
'';
206 $search_project_ref =
'';
207 $search_project_label =
'';
208 $search_task_label =
'';
210 $search_valuebilled =
'';
211 $search_product_ref =
'';
213 $search_array_options = array();
214 $search_timespent_starthour =
'';
215 $search_timespent_startmin =
'';
216 $search_timespent_endhour =
'';
217 $search_timespent_endmin =
'';
221if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
222 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
223 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
224 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
225 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
229 $langs->load(
"errors");
230 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
239 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
240 $action =
'createtime';
250 if (empty(
$object->project->status)) {
251 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
252 $action =
'createtime';
263 $object->timespent_withhour = 1;
266 $object->timespent_withhour = 0;
271 $result =
$object->addTimeSpent($user);
282 $action =
'createtime';
286if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
287 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
288 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
301 $timespentoldowner =
$object->timespent_fk_user;
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;
324 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
325 $result =
$object->updateTimeSpent($user);
337 $timespentoldowner =
$object->timespent_fk_user;
339 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
343 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
346 $object->timespent_withhour = 1;
347 } elseif (!empty($timespent_date)) {
348 $object->timespent_date = $timespent_date;
349 $object->timespent_datehour = $timespent_date;
350 $object->timespent_withhour = 0;
358 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
359 $result =
$object->updateTimeSpent($user);
374if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
377 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
378 $result =
$object->delTimeSpent($user);
381 $langs->load(
"errors");
392if (!empty($project_ref) && !empty($withproject)) {
393 if ($projectstatic->fetch(0, $project_ref) > 0) {
394 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
395 if (count($tasksarray) > 0) {
396 $id = $tasksarray[0]->id;
398 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
405$projectidforalltimes = 0;
407 $projectidforalltimes =
GETPOSTINT(
'projectid');
409 $result = $projectstatic->fetch($projectidforalltimes);
410 if (!empty($projectstatic->socid)) {
411 $projectstatic->fetch_thirdparty();
413 $res = $projectstatic->fetch_optionals();
414} elseif (
GETPOST(
'project_ref',
'alpha')) {
415 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
416 $projectidforalltimes = $projectstatic->id;
420 $result = $projectstatic->fetch(
$object->fk_project);
423$allprojectforuser = 0;
424if ($id <= 0 && $projectidforalltimes == 0) {
425 $allprojectforuser = $user->id;
428if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
429 if (!empty($projectstatic->socid)) {
430 $projectstatic->fetch_thirdparty();
433 if (!($projectstatic->thirdparty->id > 0)) {
434 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
436 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
437 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
438 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
440 $tmpinvoice =
new Facture($db);
441 $tmptimespent =
new Task($db);
442 $tmpproduct =
new Product($db);
443 $fuser =
new User($db);
448 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
451 $prodDurationHoursBase = 1.0;
452 $product_data_cache = array();
454 $tmpproduct->fetch($idprod);
460 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
461 if ($prodDurationHoursBase < 0) {
463 $langs->load(
"errors");
467 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
469 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
470 $txtva = $dataforprice[
'tva_tx'];
471 $localtax1 = $dataforprice[
'localtax1'];
472 $localtax2 = $dataforprice[
'localtax2'];
474 $prodDurationHoursBase = 1;
482 $tmpinvoice->socid = $projectstatic->thirdparty->id;
484 $tmpinvoice->fk_project = $projectstatic->id;
485 $tmpinvoice->cond_reglement_id = $condidproject;
486 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
487 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
490 $tmpinvoice->fetch($invoiceToUse);
492 $result = $tmpinvoice->create($user);
500 if ($generateinvoicemode ==
'onelineperuser') {
501 $arrayoftasks = array();
502 foreach ($toselect as $key => $value) {
504 $object->fetchTimeSpent($value);
505 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
506 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
509 foreach ($arrayoftasks as $userid => $data) {
510 $fuser->fetch($userid);
511 $username = $fuser->getFullName($langs);
513 foreach ($data as $fk_product => $timespent_data) {
515 $qtyhour = $timespent_data[
'timespent'] / 3600;
522 } elseif ($idprod <= 0) {
525 $pu_ht = $fuser->thm;
530 if ($timespent_data[
'timespent']) {
531 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
536 $prodDurationHours = $prodDurationHoursBase;
537 $idprodline = $idprod;
540 $localtax1line = $localtax1;
541 $localtax2line = $localtax2;
544 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
545 if (!array_key_exists($fk_product, $product_data_cache)) {
546 $result = $tmpproduct->fetch($fk_product);
551 $prodDurationHours = $tmpproduct->getProductDurationHours();
552 if ($prodDurationHours < 0) {
554 $langs->load(
"errors");
560 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
562 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
563 $txtvaline = $dataforprice[
'tva_tx'];
564 $localtax1line = $dataforprice[
'localtax1'];
565 $localtax2line = $dataforprice[
'localtax2'];
567 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
569 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
570 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
571 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
572 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
573 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
575 $idprodline = $fk_product;
582 $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);
589 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
590 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
591 $result = $db->query($sql);
599 } elseif ($generateinvoicemode ==
'onelineperperiod') {
600 $arrayoftasks = array();
602 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
603 foreach ($toselect as $key => $value) {
605 $object->fetchTimeSpent($value);
607 $ftask =
new Task($db);
610 $fuser->fetch(
$object->timespent_fk_user);
611 $username = $fuser->getFullName($langs);
613 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
614 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
615 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
618 if (!empty($withdetail)) {
619 if (!empty(
$object->timespent_withhour)) {
626 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
627 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
630 $pu_ht_saved = $pu_ht;
631 foreach ($arrayoftasks as $timespent_id => $value) {
632 $pu_ht = $pu_ht_saved;
633 $userid = $value[
'user'];
637 $qtyhour = $value[
'timespent'] / 3600;
641 if ($value[
'timespent']) {
642 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
647 $prodDurationHours = $prodDurationHoursBase;
648 $idprodline = $idprod;
651 $localtax1line = $localtax1;
652 $localtax2line = $localtax2;
654 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
655 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
656 $result = $tmpproduct->fetch($value[
'fk_product']);
661 $prodDurationHours = $tmpproduct->getProductDurationHours();
662 if ($prodDurationHours < 0) {
664 $langs->load(
"errors");
670 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
672 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
673 $txtvaline = $dataforprice[
'tva_tx'];
674 $localtax1line = $dataforprice[
'localtax1'];
675 $localtax2line = $dataforprice[
'localtax2'];
677 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
679 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
680 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
681 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
682 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
683 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
685 $idprodline = $value[
'fk_product'];
691 $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);
699 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
700 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
701 $result = $db->query($sql);
708 } elseif ($generateinvoicemode ==
'onelinepertask') {
709 $arrayoftasks = array();
710 foreach ($toselect as $key => $value) {
712 $object->fetchTimeSpent($value);
714 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
715 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
718 foreach ($arrayoftasks as $task_id => $data) {
719 $ftask =
new Task($db);
720 $ftask->fetch($task_id);
722 foreach ($data as $fk_product => $timespent_data) {
723 $qtyhour = $timespent_data[
'timespent'] / 3600;
727 $prodDurationHours = $prodDurationHoursBase;
728 $idprodline = $idprod;
731 $localtax1line = $localtax1;
732 $localtax2line = $localtax2;
734 if (!empty($fk_product) && $fk_product !== $idprod) {
735 if (!array_key_exists($fk_product, $product_data_cache)) {
736 $result = $tmpproduct->fetch($fk_product);
741 $prodDurationHours = $tmpproduct->getProductDurationHours();
742 if ($prodDurationHours < 0) {
744 $langs->load(
"errors");
750 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
752 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
753 $txtvaline = $dataforprice[
'tva_tx'];
754 $localtax1line = $dataforprice[
'localtax1'];
755 $localtax2line = $dataforprice[
'localtax2'];
757 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
759 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
760 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
761 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
762 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
763 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
765 $idprodline = $fk_product;
769 if ($idprodline > 0) {
771 $pu_ht_for_task = $pu_htline;
774 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
776 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
782 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
784 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
790 $lineName = $ftask->ref .
' - ' . $ftask->label;
791 $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);
800 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
801 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
802 $result = $db->query($sql);
815 $urltoinvoice = $tmpinvoice->getNomUrl(0);
816 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
817 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
827if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
828 $langs->load(
'interventions');
830 if (!empty($projectstatic->socid)) {
831 $projectstatic->fetch_thirdparty();
834 if (!($projectstatic->thirdparty->id > 0)) {
835 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
837 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
838 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
839 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
842 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
844 $tmptimespent =
new Task($db);
845 $fuser =
new User($db);
851 $tmpinter->socid = $projectstatic->thirdparty->id;
853 $tmpinter->fk_project = $projectstatic->id;
854 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->description :
'');
857 $tmpinter->fetch($interToUse);
859 $result = $tmpinter->create($user);
867 $arrayoftasks = array();
868 foreach ($toselect as $key => $value) {
870 $object->fetchTimeSpent($value);
873 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
874 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
875 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
876 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
879 foreach ($arrayoftasks as $timespent_id => $value) {
880 $ftask =
new Task($db);
881 $ftask->fetch($value[
'id']);
883 $qtyhour = $value[
'timespent'] / 3600;
887 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
892 $timespent->fetch($timespent_id);
893 $timespent->intervention_id = $tmpinter->id;
894 $timespent->intervention_line_id = $lineid;
895 $result = $timespent->update($user);
905 $urltointer = $tmpinter->getNomUrl(0);
906 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
907 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
924$form =
new Form($db);
927$userstatic =
new User($db);
929$arrayofselected = is_array($toselect) ? $toselect : array();
931$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
932if (!empty($withproject)) {
933 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
937llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
939if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
943 if ($projectidforalltimes > 0) {
944 $result = $projectstatic->fetch($projectidforalltimes);
945 if (!empty($projectstatic->socid)) {
946 $projectstatic->fetch_thirdparty();
948 $res = $projectstatic->fetch_optionals();
949 } elseif (
$object->fetch($id, $ref) >= 0) {
950 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
953 $result = $projectstatic->fetch(
$object->fk_project);
954 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
955 $projectstatic->fetchComments();
957 if (!empty($projectstatic->socid)) {
958 $projectstatic->fetch_thirdparty();
960 $res = $projectstatic->fetch_optionals();
962 $object->project = clone $projectstatic;
965 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
966 $linktocreatetime =
'';
968 if ($projectstatic->id > 0) {
971 if (empty($id) || $tab ==
'timespent') {
978 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
980 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
982 $param .=
'&search_user=' . ((int) $search_user);
985 $param .=
'&search_month=' . ((int) $search_month);
988 $param .=
'&search_year=' . ((int) $search_year);
993 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
995 $morehtmlref =
'<div class="refidno">';
997 $morehtmlref .= $projectstatic->title;
999 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
1000 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
1002 $morehtmlref .=
'</div>';
1005 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1006 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
1007 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1010 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1012 print
'<div class="fichecenter">';
1013 print
'<div class="fichehalfleft">';
1014 print
'<div class="underbanner clearboth"></div>';
1016 print
'<table class="border tableforfield centpercent">';
1020 print
'<tr><td class="tdtop">';
1021 print $langs->trans(
"Usage");
1025 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1026 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1027 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1031 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1032 $htmltext = $langs->trans(
"ProjectFollowTasks");
1033 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1037 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"' :
'')) .
'"> ';
1038 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1039 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1042 if (isModEnabled(
'eventorganization')) {
1043 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"' :
'')) .
'"> ';
1044 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1045 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1051 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1052 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1053 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1058 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1060 print($start ? $start :
'?');
1063 print($end ? $end :
'?');
1064 if ($projectstatic->hasDelay()) {
1070 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1071 if ($projectstatic->public) {
1072 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1073 print $langs->trans(
'SharedProject');
1075 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1076 print $langs->trans(
'PrivateProject');
1084 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1090 print
'<div class="fichehalfright">';
1091 print
'<div class="underbanner clearboth"></div>';
1093 print
'<table class="border tableforfield centpercent">';
1096 if (isModEnabled(
'category')) {
1097 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1098 print $form->showCategories($projectstatic->id,
'project', 1);
1103 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1104 if ($projectstatic->description) {
1105 print
'<tr><td class="nottitleforfield" colspan="2">';
1106 print
'<div class="longmessagecut">';
1117 print
'<div class="clearboth"></div>';
1127 $linktocreatetimeBtnStatus = 0;
1128 $linktocreatetimeUrl =
'';
1129 $linktocreatetimeHelpText =
'';
1130 if ($user->hasRight(
'projet',
'time')) {
1131 if ($projectstatic->public || $userRead > 0) {
1132 $linktocreatetimeBtnStatus = 1;
1134 if (!empty($projectidforalltimes)) {
1136 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1137 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1140 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1141 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1144 $linktocreatetimeBtnStatus = -2;
1145 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1148 $linktocreatetimeBtnStatus = -2;
1149 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1152 $paramsbutton = array(
'morecss' =>
'reposition');
1153 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1156 $massactionbutton =
'';
1157 $arrayofmassactions = array();
1159 if ($projectstatic->id > 0) {
1161 if ($projectstatic->usage_bill_time) {
1162 $arrayofmassactions = array(
1163 'generateinvoice' => $langs->trans(
"GenerateBill"),
1167 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1168 $langs->load(
"interventions");
1169 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1173 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1174 $arrayofmassactions = array();
1176 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1181 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1183 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1185 if ($action ==
'deleteline') {
1186 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1187 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1190 $param = ($withproject ?
'&withproject=1' :
'');
1191 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1192 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1194 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1195 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1196 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1198 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1204 if (empty($withproject)) {
1205 $morehtmlref .=
'<div class="refidno">';
1206 $morehtmlref .= $langs->trans(
"Project") .
': ';
1207 $morehtmlref .= $projectstatic->getNomUrl(1);
1208 $morehtmlref .=
'<br>';
1211 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1212 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1213 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1215 $morehtmlref .=
'</div>';
1218 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1220 print
'<div class="fichecenter">';
1221 print
'<div class="fichehalfleft">';
1223 print
'<div class="underbanner clearboth"></div>';
1224 print
'<table class="border centpercent tableforfield">';
1227 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1228 if (
$object->fk_task_parent > 0) {
1229 $tasktmp =
new Task($db);
1230 $tasktmp->fetch(
$object->fk_task_parent);
1231 print $tasktmp->getNomUrl(1);
1236 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1238 print($start ? $start :
'?');
1241 print($end ? $end :
'?');
1248 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1249 if (
$object->planned_workload) {
1257 print
'<div class="fichehalfright">';
1259 print
'<div class="underbanner clearboth"></div>';
1260 print
'<table class="border tableforfield centpercent">';
1263 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1268 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1269 if (
$object->planned_workload) {
1270 $tmparray =
$object->getSummaryOfTimeSpent();
1271 if ($tmparray[
'total_duration'] > 0) {
1272 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1277 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1288 print
'<div class="clearboth"></div>';
1292 if ($action ==
'deleteline') {
1293 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1294 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1299 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1301 $hookmanager->initHooks(array(
'tasktimelist'));
1305 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1307 $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);
1308 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1312 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1313 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1314 if (empty($reshook)) {
1315 $formconfirm .= $hookmanager->resPrint;
1316 } elseif ($reshook > 0) {
1317 $formconfirm = $hookmanager->resPrint;
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 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1339 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1341 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1342 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int) isModEnabled(
"salaries"));
1343 $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));
1345 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1350 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1351 $param .=
'&contextpage=' . urlencode($contextpage);
1353 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1354 $param .=
'&limit='.((int) $limit);
1356 if ($search_month > 0) {
1357 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1359 if ($search_year > 0) {
1360 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1362 if (!empty($search_user)) {
1363 $param .=
'&search_user='.urlencode($search_user);
1365 if ($search_task_ref !=
'') {
1366 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1368 if ($search_company !=
'') {
1369 $param .=
'&$search_company=' . urlencode($search_company);
1371 if ($search_company_alias !=
'') {
1372 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1374 if ($search_project_ref !=
'') {
1375 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1377 if ($search_project_label !=
'') {
1378 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1380 if ($search_task_label !=
'') {
1381 $param .=
'&search_task_label=' . urlencode($search_task_label);
1383 if ($search_note !=
'') {
1384 $param .=
'&search_note=' . urlencode($search_note);
1386 if ($search_duration !=
'') {
1387 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1389 if ($optioncss !=
'') {
1390 $param .=
'&optioncss=' . urlencode($optioncss);
1392 if ($search_date_startday) {
1393 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1395 if ($search_date_startmonth) {
1396 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1398 if ($search_date_startyear) {
1399 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1401 if ($search_date_endday) {
1402 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1404 if ($search_date_endmonth) {
1405 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1407 if ($search_date_endyear) {
1408 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1410 if ($search_timespent_starthour) {
1411 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1413 if ($search_timespent_startmin) {
1414 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1416 if ($search_timespent_endhour) {
1417 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1419 if ($search_timespent_endmin) {
1420 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1424 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1426 $param .=
'&id=' . urlencode((
string) ($id));
1429 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1432 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1435 $parameters = array(
'param' => &$param);
1436 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1437 $param .= $hookmanager->resPrint;
1439 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1440 if ($optioncss !=
'') {
1441 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1443 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1444 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1445 if ($action ==
'editline') {
1446 print
'<input type="hidden" name="action" value="updateline">';
1447 } elseif ($action ==
'splitline') {
1448 print
'<input type="hidden" name="action" value="updatesplitline">';
1449 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1450 print
'<input type="hidden" name="action" value="addtimespent">';
1451 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1452 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1453 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1454 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1456 print
'<input type="hidden" name="action" value="list">';
1458 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1459 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1461 print
'<input type="hidden" name="id" value="' .
$id .
'">';
1462 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1463 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1464 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1465 print
'<input type="hidden" name="page_y" value="">';
1468 if ($massaction ==
'generateinvoice') {
1469 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1470 print
'<table class="noborder centerpercent">';
1472 print
'<td class="titlefield">';
1473 print $langs->trans(
'DateInvoice');
1476 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1482 print $langs->trans(
'Mode');
1486 'onelineperuser' =>
'OneLinePerUser',
1487 'onelinepertask' =>
'OneLinePerTask',
1488 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1490 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1491 print
"\n" .
'<script type="text/javascript">';
1493 $(document).ready(function () {
1494 setDetailVisibility();
1495 $("#generateinvoicemode").change(function() {
1496 setDetailVisibility();
1498 function setDetailVisibility() {
1499 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1500 if (generateinvoicemode=="onelineperperiod") {
1501 $("#detail_time_duration").show();
1503 $("#detail_time_duration").hide();
1508 print
'</script>' .
"\n";
1509 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1513 if (isModEnabled(
"service")) {
1516 print $langs->trans(
'ServiceToUseOnLines');
1519 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1524 print
'<td class="titlefield">';
1525 print $langs->trans(
'InvoiceToUse');
1528 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1532 print
'<td class="titlefield">';
1533 print $langs->trans(
"CustomerRelativeDiscount");
1536 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1539 print
'<tr class="newinvoicedetail">';
1540 print
'<td class="titlefield">';
1541 print $langs->trans(
"PaymentConditions");
1544 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1558 print
'<div class="center">';
1559 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1560 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1564 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1565 print
'<div class="center">';
1566 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1570 } elseif ($massaction ==
'generateinter') {
1572 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1574 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1576 print
'<table class="noborder centpercent">';
1578 print
'<td class="titlefield">';
1579 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1583 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1588 print
'<div class="center">';
1589 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1590 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1594 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1595 print
'<div class="center">';
1596 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1603 $parameters = array(
1604 'toselect' => $toselect,
1605 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1608 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1612 print $hookmanager->resPrint;
1620 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1621 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1623 $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,";
1624 $sql .=
" t.fk_product, t.invoice_line_id,";
1625 $sql .=
" pt.ref, pt.label, pt.fk_projet, pt.billable,";
1626 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1627 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1628 $sql .=
" p.fk_soc,s.name_alias";
1629 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1630 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1631 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1635 $parameters = array();
1636 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1637 $sql .= $hookmanager->resPrint;
1638 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1642 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1643 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1644 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1645 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1646 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1647 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1648 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1649 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1650 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1653 $parameters = array();
1654 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1655 $sql .= $hookmanager->resPrint;
1656 $sql .=
" WHERE elementtype = 'task'";
1657 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1658 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1662 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1663 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1665 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1667 $sql .=
" AND t.fk_element =".((int)
$object->id);
1668 } elseif (!empty($projectidforalltimes)) {
1670 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1671 } elseif (!empty($allprojectforuser)) {
1673 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1674 $search_user = $user->id;
1676 if ($search_user > 0) {
1677 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1684 if ($search_task_ref) {
1687 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1688 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1690 if ($search_company) {
1693 if ($search_company_alias) {
1697 if ($search_project_ref) {
1700 if ($search_project_label) {
1703 if ($search_task_label) {
1706 if ($search_user > 0) {
1709 if (!empty($search_product_ref)) {
1712 if ($search_valuebilled ==
'1') {
1713 $sql .=
' AND t.invoice_id > 0';
1715 if ($search_valuebilled ==
'0') {
1716 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1719 if ($search_date_start) {
1720 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1722 if ($search_date_end) {
1723 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1726 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1727 if ($search_timespent_starthour || $search_timespent_startmin) {
1728 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1729 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1730 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1733 if ($search_timespent_endhour || $search_timespent_endmin) {
1734 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1735 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1736 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1740 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1743 $extrafieldsobjectkey =
'projet_task';
1744 $extrafieldsobjectprefix =
'efpt.';
1745 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1748 $parameters = array();
1749 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1750 $sql .= $hookmanager->resPrint;
1753 $nbtotalofrecords =
'';
1756 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1757 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1758 $resql = $db->query($sqlforcount);
1760 $objforcount = $db->fetch_object($resql);
1761 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1766 if (($page * $limit) > $nbtotalofrecords) {
1774 $sql .= $db->order($sortfield, $sortorder);
1776 $sql .= $db->plimit($limit + 1, $offset);
1779 $resql = $db->query($sql);
1785 $num = $db->num_rows($resql);
1788 if (!empty($projectidforalltimes)) {
1789 print
'<!-- List of time spent for project -->' .
"\n";
1791 $title = $langs->trans(
"ListTaskTimeUserProject");
1793 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1795 print
'<!-- List of time spent -->' .
"\n";
1797 $title = $langs->trans(
"ListTaskTimeForTask");
1799 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1804 $row = $db->fetch_object($resql);
1816 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1817 print
'<!-- table to add time spent -->' .
"\n";
1819 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1822 print
'<div class="div-table-responsive-no-min">';
1823 print
'<table class="noborder nohover centpercent">';
1825 print
'<tr class="liste_titre">';
1826 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1827 if (!empty($allprojectforuser)) {
1828 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1831 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1833 print
'<td>' . $langs->trans(
"By") .
'</td>';
1834 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1835 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1836 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1840 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1841 print
'<td>'.$langs->trans(
"Product").
'</td>';
1845 $parameters = array(
'mode' =>
'create');
1846 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1847 print $hookmanager->resPrint;
1851 print
'<tr class="oddeven nohover">';
1854 print
'<td class="maxwidthonsmartphone">';
1856 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1859 if (!empty($allprojectforuser)) {
1868 print
'<td class="maxwidthonsmartphone">';
1869 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1874 print
'<td class="maxwidthonsmartphone nowraponall">';
1875 $contactsofproject = $projectstatic->getListContactId(
'internal');
1876 if (count($contactsofproject) > 0) {
1877 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1878 if (in_array($user->id, $contactsofproject)) {
1879 $userid = $user->id;
1881 $userid = $contactsofproject[0];
1884 if ($projectstatic->public) {
1885 $contactsofproject = array();
1887 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1890 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1897 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1901 print
'<td class="nowraponall">';
1902 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1903 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1904 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1906 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1910 print
'<td class="nowrap">';
1911 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1919 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1920 print
'<td class="nowraponall">';
1922 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);
1928 $parameters = array(
'mode' =>
'create');
1929 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1930 print $hookmanager->resPrint;
1932 print
'<td class="center">';
1933 $form->buttonsSaveCancel();
1934 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1935 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1944 $moreforfilter =
'';
1946 $parameters = array();
1947 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1948 if (empty($reshook)) {
1949 $moreforfilter .= $hookmanager->resPrint;
1951 $moreforfilter = $hookmanager->resPrint;
1954 if (!empty($moreforfilter)) {
1955 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1956 print $moreforfilter;
1960 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1961 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1962 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1964 print
'<!-- Liste of time spent -->'.
"\n";
1965 print
'<div class="div-table-responsive">';
1966 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1970 print
'<tr class="liste_titre_filter">';
1973 print
'<td class="liste_titre center">';
1974 $searchpicto = $form->showFilterButtons(
'left');
1979 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1980 print
'<td class="liste_titre left">';
1981 print
'<div class="nowrapfordate paddingright">';
1982 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1984 print
'<div class="nowrapfordate">';
1985 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1990 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1991 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1995 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1996 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1999 if (!empty($allprojectforuser)) {
2000 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2001 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
2003 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2004 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2008 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2009 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2010 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2012 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2013 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2017 if (!empty($arrayfields[
'author'][
'checked'])) {
2018 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>';
2021 if (!empty($arrayfields[
't.note'][
'checked'])) {
2022 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2025 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2027 print
'<td class="liste_titre right">';
2029 $durationtouse_start =
'';
2030 if ($search_timespent_starthour || $search_timespent_startmin) {
2031 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2033 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
2034 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2037 $durationtouse_end =
'';
2038 if ($search_timespent_endhour || $search_timespent_endmin) {
2039 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2041 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2042 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2048 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2049 print
'<td class="liste_titre right"></td>';
2052 if (!empty($arrayfields[
'value'][
'checked'])) {
2053 print
'<td class="liste_titre"></td>';
2056 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2057 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2061 $extrafieldsobjectkey =
'projet_task';
2062 $extrafieldsobjectprefix =
'ef.';
2063 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2065 $parameters = array(
'arrayfields' => $arrayfields);
2066 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2067 print $hookmanager->resPrint;
2070 print
'<td class="liste_titre center">';
2071 $searchpicto = $form->showFilterButtons();
2075 print
'</tr>' .
"\n";
2083 print
'<tr class="liste_titre">';
2085 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2088 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2089 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2092 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2093 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2096 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2098 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2101 if (!empty($allprojectforuser)) {
2102 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2103 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2106 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2107 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2111 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2112 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2113 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2116 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2117 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2121 if (!empty($arrayfields[
'author'][
'checked'])) {
2122 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2125 if (!empty($arrayfields[
't.note'][
'checked'])) {
2126 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2129 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2130 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2133 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2134 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2138 if (!empty($arrayfields[
'value'][
'checked'])) {
2139 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2142 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2143 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2147 $extrafieldsobjectkey =
'projet_task';
2148 $extrafieldsobjectprefix =
'ef.';
2149 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2151 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2152 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2153 print $hookmanager->resPrint;
2155 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2160 $tasktmp =
new Task($db);
2161 $tmpinvoice =
new Facture($db);
2164 $param .=
'&page='.((int) $page);
2166 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2174 foreach ($tasks as $task_time) {
2180 $invoiced = $task_time->invoice_id ? true :
false;
2182 $date1 = $db->jdate($task_time->element_date);
2183 $date2 = $db->jdate($task_time->element_datehour);
2187 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2191 print
'<td class="center nowraponall">';
2192 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2193 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2194 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2196 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2197 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2198 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2199 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' :
'').
'">';
2200 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2204 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' :
'') .
'">';
2205 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2209 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' :
'').
'">';
2210 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2213 if ($massactionbutton || $massaction) {
2215 if (in_array($task_time->rowid, $arrayofselected)) {
2221 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2222 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2226 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2227 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2241 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2242 print
'<td class="nowrap">';
2243 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2244 if (empty($task_time->element_date_withhour)) {
2245 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2247 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2250 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2259 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2260 print
'<td class="tdoverflowmax125">';
2261 if ($task_time->fk_soc > 0) {
2262 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2263 $tmpsociete =
new Societe($db);
2264 $tmpsociete->fetch($task_time->fk_soc);
2265 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2267 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2269 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2278 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2280 if ($task_time->fk_soc > 0) {
2281 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2282 $tmpsociete =
new Societe($db);
2283 $tmpsociete->fetch($task_time->fk_soc);
2284 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2286 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2288 $valtoshow = $tmpsociete->name_alias;
2290 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2298 if (!empty($allprojectforuser)) {
2300 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2301 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2302 $tmpproject =
new Project($db);
2303 $tmpproject->fetch($task_time->fk_projet);
2304 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2306 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2308 print
'<td class="nowraponall">';
2309 print $tmpproject->getNomUrl(1);
2316 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2317 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2318 $tmpproject =
new Project($db);
2319 $tmpproject->fetch($task_time->fk_projet);
2320 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2322 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2324 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2325 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2328 print $tmpproject->getNomUrl(1,
'', -1);
2338 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2339 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2340 print
'<td class="nowrap">';
2341 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2342 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2344 $tasktmp->id = $task_time->fk_element;
2345 $tasktmp->ref = $task_time->ref;
2346 $tasktmp->label = $task_time->label;
2347 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2354 } elseif ($action !==
'createtime') {
2355 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2359 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2360 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2361 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2362 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2365 $tasktmp->id = $task_time->fk_element;
2366 $tasktmp->ref = $task_time->ref;
2367 $tasktmp->label = $task_time->label;
2368 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2378 if (!empty($arrayfields[
'author'][
'checked'])) {
2379 print
'<td class="tdoverflowmax125">';
2380 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2383 $object->fetch($task_time->fk_element);
2385 $contactsoftask =
$object->getListContactId(
'internal');
2386 if (!in_array($task_time->fk_user, $contactsoftask)) {
2387 $contactsoftask[] = $task_time->fk_user;
2389 if (count($contactsoftask) > 0) {
2390 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2391 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2393 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2396 $userstatic->id = $task_time->fk_user;
2397 $userstatic->lastname = $task_time->lastname;
2398 $userstatic->firstname = $task_time->firstname;
2399 $userstatic->photo = $task_time->photo;
2400 $userstatic->gender = $task_time->gender;
2401 $userstatic->status = $task_time->user_status;
2403 print $userstatic->getNomUrl(-1);
2412 if (!empty($arrayfields[
't.note'][
'checked'])) {
2413 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2414 print
'<td class="small">';
2415 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2418 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2425 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2426 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2430 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2431 print
'<td class="right nowraponall">';
2432 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2433 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2434 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2445 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2446 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2448 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2454 $totalarray[
'totalduration'] = $task_time->element_duration;
2456 $totalarray[
'totalduration'] += $task_time->element_duration;
2461 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2462 print
'<td class="nowraponall">';
2463 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2465 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);
2466 } elseif (!empty($task_time->fk_product)) {
2468 $resultFetch = $product->fetch($task_time->fk_product);
2469 if ($resultFetch < 0) {
2472 print $product->getNomUrl(1);
2482 if (!empty($arrayfields[
'value'][
'checked'])) {
2483 $langs->load(
"salaries");
2484 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2486 print
'<td class="nowraponall right">';
2487 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2488 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2513 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2514 print
'<td class="center">';
2516 if ($projectstatic->usage_bill_time) {
2517 if ($task_time->invoice_id) {
2518 $result = $tmpinvoice->fetch($task_time->invoice_id);
2520 if ($user->hasRight(
'facture',
'lire')) {
2521 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2522 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2524 print $tmpinvoice->getNomUrl(1);
2525 if (!empty($task_time->invoice_line_id)) {
2527 $invoiceLine->fetch($task_time->invoice_line_id);
2528 if (!empty($invoiceLine->id)) {
2529 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2530 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2535 print $langs->trans(
"Yes");
2540 if (intval($task_time->billable) == 1) {
2541 print $langs->trans(
"No");
2543 print $langs->trans(
"Disabled");
2547 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2558 $extrafieldsobjectkey =
'projet_task';
2559 $extrafieldsobjectprefix =
'ef.';
2560 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2563 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2564 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2565 print $hookmanager->resPrint;
2569 print
'<td class="center nowraponall">';
2570 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2571 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2572 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2574 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2575 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2576 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2577 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' :
'').
'">';
2578 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2582 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' :
'') .
'">';
2583 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2587 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' :
'').
'">';
2588 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2591 if ($massactionbutton || $massaction) {
2593 if (in_array($task_time->rowid, $arrayofselected)) {
2599 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2600 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2604 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2605 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2623 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2624 print
'<!-- first line -->';
2625 print
'<tr class="oddeven">';
2633 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2634 print
'<td class="nowrap">';
2635 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2636 if (empty($task_time->element_date_withhour)) {
2637 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2639 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2642 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2648 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2649 print
'<td class="nowrap">';
2654 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2655 print
'<td class="nowrap">';
2660 if (!empty($allprojectforuser)) {
2661 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2662 print
'<td class="nowrap">';
2668 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2669 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2670 print
'<td class="nowrap">';
2671 $tasktmp->id = $task_time->fk_element;
2672 $tasktmp->ref = $task_time->ref;
2673 $tasktmp->label = $task_time->label;
2674 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2680 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2681 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2682 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2689 if (!empty($arrayfields[
'author'][
'checked'])) {
2690 print
'<td class="nowraponall">';
2691 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2693 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2696 $contactsoftask =
$object->getListContactId(
'internal');
2697 if (!in_array($task_time->fk_user, $contactsoftask)) {
2698 $contactsoftask[] = $task_time->fk_user;
2700 if (count($contactsoftask) > 0) {
2701 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2702 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2704 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2707 $userstatic->id = $task_time->fk_user;
2708 $userstatic->lastname = $task_time->lastname;
2709 $userstatic->firstname = $task_time->firstname;
2710 $userstatic->photo = $task_time->photo;
2711 $userstatic->status = $task_time->user_status;
2712 print $userstatic->getNomUrl(-1);
2718 if (!empty($arrayfields[
't.note'][
'checked'])) {
2719 print
'<td class="tdoverflowmax300">';
2720 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2721 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2726 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2727 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2731 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2732 print
'<td class="right">';
2733 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2734 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2735 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2743 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2744 print
'<td class="nowraponall tdoverflowmax125">';
2749 if (!empty($arrayfields[
'value'][
'checked'])) {
2750 print
'<td class="right">';
2751 print
'<span class="amount">';
2752 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2753 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2759 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2760 print
'<td class="right">';
2761 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2762 if (isset($task_time->total_ht)) {
2763 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2770 $extrafieldsobjectkey =
'projet_task';
2771 $extrafieldsobjectprefix =
'ef.';
2772 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2775 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2776 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2777 print $hookmanager->resPrint;
2781 print
'<td class="center nowraponall">';
2790 print
'<!-- second line --><tr class="oddeven">';
2794 print
'<td class="center nowraponall">';
2799 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2800 print
'<td class="nowraponall">';
2801 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2802 if (empty($task_time->element_date_withhour)) {
2803 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2805 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2808 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2814 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2820 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2826 if (!empty($allprojectforuser)) {
2827 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2834 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2835 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2836 print
'<td class="nowraponall">';
2837 $tasktmp->id = $task_time->fk_element;
2838 $tasktmp->ref = $task_time->ref;
2839 $tasktmp->label = $task_time->label;
2840 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2846 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2847 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2848 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2855 if (!empty($arrayfields[
'author'][
'checked'])) {
2856 print
'<td class="nowraponall tdoverflowmax100">';
2857 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2859 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2862 $contactsoftask =
$object->getListContactId(
'internal');
2863 if (!in_array($task_time->fk_user, $contactsoftask)) {
2864 $contactsoftask[] = $task_time->fk_user;
2866 if (count($contactsoftask) > 0) {
2867 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2868 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2870 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2873 $userstatic->id = $task_time->fk_user;
2874 $userstatic->lastname = $task_time->lastname;
2875 $userstatic->firstname = $task_time->firstname;
2876 $userstatic->photo = $task_time->photo;
2877 $userstatic->status = $task_time->user_status;
2878 print $userstatic->getNomUrl(-1);
2884 if (!empty($arrayfields[
't.note'][
'checked'])) {
2885 print
'<td class="small tdoverflowmax300"">';
2886 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2887 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2892 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2893 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2897 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2898 print
'<td class="right">';
2899 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2900 print
'<input type="hidden" name="old_duration_2" value="0">';
2901 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2909 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2910 print
'<td class="nowraponall tdoverflowmax125">';
2915 if (!empty($arrayfields[
'value'][
'checked'])) {
2916 print
'<td class="right">';
2917 print
'<span class="amount nowraponall">';
2919 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2926 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2927 print
'<td class="right">';
2928 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2929 if (isset($task_time->total_ht)) {
2930 print
'<span class="amount nowraponall">';
2931 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2939 $extrafieldsobjectkey =
'projet_task';
2940 $extrafieldsobjectprefix =
'ef.';
2941 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2944 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2945 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2946 print $hookmanager->resPrint;
2950 print
'<td class="center nowraponall">';
2963 print
'<tr class="liste_total">';
2968 if ($num < $limit && empty($offset)) {
2969 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2971 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2985 if (!count($tasks)) {
2986 $totalnboffields = 1;
2987 foreach ($arrayfields as $value) {
2988 if (!empty($value[
'checked'])) {
2992 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2993 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2997 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2998 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2999 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.