35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
46$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
47if (isModEnabled(
'eventorganization')) {
48 $langsLoad[] =
'eventorganization';
51$langs->loadLangs($langsLoad);
53$action =
GETPOST(
'action',
'alpha');
54$massaction =
GETPOST(
'massaction',
'alpha');
55$confirm =
GETPOST(
'confirm',
'alpha');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$toselect =
GETPOST(
'toselect',
'array');
58$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$optioncss =
GETPOST(
'optioncss',
'alpha');
61$mode =
GETPOST(
'mode',
'alpha');
67$project_ref =
GETPOST(
'project_ref',
'alpha');
73$search_date_startday =
GETPOSTINT(
'search_date_startday');
74$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
75$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
76$search_date_endday =
GETPOSTINT(
'search_date_endday');
77$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
78$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
79$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
80$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
81$search_note =
GETPOST(
'search_note',
'alpha');
82$search_duration =
GETPOST(
'search_duration',
'alpha');
83$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
84$search_task_label =
GETPOST(
'search_task_label',
'alpha');
85$search_user =
GETPOST(
'search_user',
'intcomma');
86$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
87$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
88$search_company =
GETPOST(
'$search_company',
'alpha');
89$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
90$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
91$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
92$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
93$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
94$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
95$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
98$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
99$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
101if (empty($page) || $page == -1) {
104$offset = $limit * $page;
105$pageprev = $page - 1;
106$pagenext = $page + 1;
108 $sortfield =
't.element_date,t.element_datehour,t.rowid';
111 $sortorder =
'DESC,DESC,DESC';
114$childids = $user->getAllChildIds(1);
118$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
122$projectstatic =
new Project($db);
125$extrafields->fetch_name_optionals_label($projectstatic->table_element);
126$extrafields->fetch_name_optionals_label(
$object->table_element);
129if ($id > 0 || $ref) {
137if (!$user->hasRight(
'projet',
'lire')) {
146 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
147 $search_user = $user->id;
156if (
GETPOST(
'cancel',
'alpha')) {
159if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
163$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
169include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
172if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
177 $search_duration =
'';
178 $search_date_startday =
'';
179 $search_date_startmonth =
'';
180 $search_date_startyear =
'';
181 $search_date_endday =
'';
182 $search_date_endmonth =
'';
183 $search_date_endyear =
'';
184 $search_date_start =
'';
185 $search_date_end =
'';
186 $search_task_ref =
'';
187 $search_company =
'';
188 $search_company_alias =
'';
189 $search_project_ref =
'';
190 $search_project_label =
'';
191 $search_task_label =
'';
193 $search_valuebilled =
'';
194 $search_product_ref =
'';
196 $search_array_options = array();
197 $search_timespent_starthour =
'';
198 $search_timespent_startmin =
'';
199 $search_timespent_endhour =
'';
200 $search_timespent_endmin =
'';
204if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
207 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
208 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
209 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
210 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
214 $langs->load(
"errors");
215 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
224 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
225 $action =
'createtime';
235 if (empty(
$object->project->status)) {
236 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
237 $action =
'createtime';
248 $object->timespent_withhour = 1;
251 $object->timespent_withhour = 0;
256 $result =
$object->addTimeSpent($user);
267 $action =
'createtime';
271if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
274 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
275 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
290 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
291 $result =
$object->delTimeSpent($user);
294 $object->fetch($id_temp, $ref);
296 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
300 if (
GETPOST(
"timelinehour") !=
''
301 &&
GETPOST(
"timelinehour") >= 0
302 && !empty($timespent_date)) {
305 $object->timespent_withhour = 1;
306 } elseif (!empty($timespent_date)) {
307 $object->timespent_date = $timespent_date;
308 $object->timespent_withhour = 0;
316 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
317 $result =
$object->addTimeSpent($user);
330 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
334 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
336 $object->timespent_withhour = 1;
337 } elseif (!empty($timespent_date)) {
338 $object->timespent_date = $timespent_date;
339 $object->timespent_withhour = 0;
347 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
348 $result =
$object->updateTimeSpent($user);
363if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
366 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
367 $result =
$object->delTimeSpent($user);
370 $langs->load(
"errors");
381if (!empty($project_ref) && !empty($withproject)) {
382 if ($projectstatic->fetch(0, $project_ref) > 0) {
383 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
384 if (count($tasksarray) > 0) {
385 $id = $tasksarray[0]->id;
387 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
394$projectidforalltimes = 0;
396 $projectidforalltimes =
GETPOSTINT(
'projectid');
398 $result = $projectstatic->fetch($projectidforalltimes);
399 if (!empty($projectstatic->socid)) {
400 $projectstatic->fetch_thirdparty();
402 $res = $projectstatic->fetch_optionals();
403} elseif (
GETPOST(
'project_ref',
'alpha')) {
404 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
405 $projectidforalltimes = $projectstatic->id;
409 $result = $projectstatic->fetch(
$object->fk_project);
412if ($id <= 0 && $projectidforalltimes == 0) {
413 $allprojectforuser = $user->id;
416if ($action ==
'confirm_generateinvoice') {
417 if (!empty($projectstatic->socid)) {
418 $projectstatic->fetch_thirdparty();
421 if (!($projectstatic->thirdparty->id > 0)) {
422 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
424 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
425 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
426 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
428 $tmpinvoice =
new Facture($db);
429 $tmptimespent =
new Task($db);
430 $tmpproduct =
new Product($db);
431 $fuser =
new User($db);
436 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
439 $prodDurationHoursBase = 1.0;
440 $product_data_cache = array();
442 $tmpproduct->fetch($idprod);
448 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
449 if ($prodDurationHoursBase < 0) {
451 $langs->load(
"errors");
455 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
457 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
458 $txtva = $dataforprice[
'tva_tx'];
459 $localtax1 = $dataforprice[
'localtax1'];
460 $localtax2 = $dataforprice[
'localtax2'];
462 $prodDurationHoursBase = 1;
470 $tmpinvoice->socid = $projectstatic->thirdparty->id;
472 $tmpinvoice->fk_project = $projectstatic->id;
473 $tmpinvoice->cond_reglement_id = $condidproject;
474 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
475 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
478 $tmpinvoice->fetch($invoiceToUse);
480 $result = $tmpinvoice->create($user);
488 if ($generateinvoicemode ==
'onelineperuser') {
489 $arrayoftasks = array();
490 foreach ($toselect as $key => $value) {
492 $object->fetchTimeSpent($value);
493 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
494 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
497 foreach ($arrayoftasks as $userid => $data) {
498 $fuser->fetch($userid);
499 $username = $fuser->getFullName($langs);
501 foreach ($data as $fk_product => $timespent_data) {
503 $qtyhour = $timespent_data[
'timespent'] / 3600;
504 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
510 } elseif ($idprod <= 0) {
513 $pu_ht = $fuser->thm;
518 if ($timespent_data[
'timespent']) {
519 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
524 $prodDurationHours = $prodDurationHoursBase;
525 $idprodline = $idprod;
528 $localtax1line = $localtax1;
529 $localtax2line = $localtax2;
532 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
533 if (!array_key_exists($fk_product, $product_data_cache)) {
534 $result = $tmpproduct->fetch($fk_product);
539 $prodDurationHours = $tmpproduct->getProductDurationHours();
540 if ($prodDurationHours < 0) {
542 $langs->load(
"errors");
546 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
548 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
549 $txtvaline = $dataforprice[
'tva_tx'];
550 $localtax1line = $dataforprice[
'localtax1'];
551 $localtax2line = $dataforprice[
'localtax2'];
553 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
555 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
556 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
557 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
558 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
559 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
561 $idprodline = $fk_product;
565 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
572 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
573 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
574 $result = $db->query($sql);
582 } elseif ($generateinvoicemode ==
'onelineperperiod') {
583 $arrayoftasks = array();
585 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
586 foreach ($toselect as $key => $value) {
588 $object->fetchTimeSpent($value);
590 $ftask =
new Task($db);
593 $fuser->fetch(
$object->timespent_fk_user);
594 $username = $fuser->getFullName($langs);
596 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
597 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
598 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
601 if (!empty($withdetail)) {
602 if (!empty(
$object->timespent_withhour)) {
609 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
610 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
613 foreach ($arrayoftasks as $timespent_id => $value) {
614 $userid = $value[
'user'];
618 $qtyhour = $value[
'timespent'] / 3600;
622 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
626 $prodDurationHours = $prodDurationHoursBase;
627 $idprodline = $idprod;
630 $localtax1line = $localtax1;
631 $localtax2line = $localtax2;
633 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
634 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
635 $result = $tmpproduct->fetch($value[
'fk_product']);
640 $prodDurationHours = $tmpproduct->getProductDurationHours();
641 if ($prodDurationHours < 0) {
643 $langs->load(
"errors");
647 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
649 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
650 $txtvaline = $dataforprice[
'tva_tx'];
651 $localtax1line = $dataforprice[
'localtax1'];
652 $localtax2line = $dataforprice[
'localtax2'];
654 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
656 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
657 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
658 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
659 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
660 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
662 $idprodline = $value[
'fk_product'];
664 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
672 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
673 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
674 $result = $db->query($sql);
681 } elseif ($generateinvoicemode ==
'onelinepertask') {
682 $arrayoftasks = array();
683 foreach ($toselect as $key => $value) {
685 $object->fetchTimeSpent($value);
687 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
688 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
691 foreach ($arrayoftasks as $task_id => $data) {
692 $ftask =
new Task($db);
693 $ftask->fetch($task_id);
695 foreach ($data as $fk_product => $timespent_data) {
696 $qtyhour = $timespent_data[
'timespent'] / 3600;
697 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
700 $prodDurationHours = $prodDurationHoursBase;
701 $idprodline = $idprod;
704 $localtax1line = $localtax1;
705 $localtax2line = $localtax2;
707 if (!empty($fk_product) && $fk_product !== $idprod) {
708 if (!array_key_exists($fk_product, $product_data_cache)) {
709 $result = $tmpproduct->fetch($fk_product);
714 $prodDurationHours = $tmpproduct->getProductDurationHours();
715 if ($prodDurationHours < 0) {
717 $langs->load(
"errors");
721 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
723 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
724 $txtvaline = $dataforprice[
'tva_tx'];
725 $localtax1line = $dataforprice[
'localtax1'];
726 $localtax2line = $dataforprice[
'localtax2'];
728 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
730 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
731 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
732 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
733 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
734 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
736 $idprodline = $fk_product;
740 if ($idprodline > 0) {
742 $pu_ht_for_task = $pu_htline;
745 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
747 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
753 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
755 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
761 $lineName = $ftask->ref .
' - ' . $ftask->label;
762 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0, null, $pa_ht);
771 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
772 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
773 $result = $db->query($sql);
786 $urltoinvoice = $tmpinvoice->getNomUrl(0);
787 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
788 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
800if ($action ==
'confirm_generateinter') {
801 $langs->load(
'interventions');
803 if (!empty($projectstatic->socid)) {
804 $projectstatic->fetch_thirdparty();
807 if (!($projectstatic->thirdparty->id > 0)) {
808 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
810 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
811 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
812 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
815 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
817 $tmptimespent =
new Task($db);
818 $fuser =
new User($db);
824 $tmpinter->socid = $projectstatic->thirdparty->id;
826 $tmpinter->fk_project = $projectstatic->id;
827 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
830 $tmpinter->fetch($interToUse);
832 $result = $tmpinter->create($user);
840 $arrayoftasks = array();
841 foreach ($toselect as $key => $value) {
843 $object->fetchTimeSpent($value);
846 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
847 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
848 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
849 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
852 foreach ($arrayoftasks as $timespent_id => $value) {
853 $ftask =
new Task($db);
854 $ftask->fetch($value[
'id']);
856 $qtyhour = $value[
'timespent'] / 3600;
857 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
860 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
865 $urltointer = $tmpinter->getNomUrl(0);
866 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
867 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
884$form =
new Form($db);
887$userstatic =
new User($db);
889$arrayofselected = is_array($toselect) ? $toselect : array();
891$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
892if (!empty($withproject)) {
893 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
899if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
903 if ($projectidforalltimes > 0) {
904 $result = $projectstatic->fetch($projectidforalltimes);
905 if (!empty($projectstatic->socid)) {
906 $projectstatic->fetch_thirdparty();
908 $res = $projectstatic->fetch_optionals();
909 } elseif (
$object->fetch($id, $ref) >= 0) {
910 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
913 $result = $projectstatic->fetch(
$object->fk_project);
914 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
915 $projectstatic->fetchComments();
917 if (!empty($projectstatic->socid)) {
918 $projectstatic->fetch_thirdparty();
920 $res = $projectstatic->fetch_optionals();
922 $object->project = clone $projectstatic;
925 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
926 $linktocreatetime =
'';
928 if ($projectstatic->id > 0) {
931 if (empty($id) || $tab ==
'timespent') {
938 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
940 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
942 $param .=
'&search_user=' . ((int) $search_user);
945 $param .=
'&search_month=' . ((int) $search_month);
948 $param .=
'&search_year=' . ((int) $search_year);
953 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
955 $morehtmlref =
'<div class="refidno">';
957 $morehtmlref .= $projectstatic->title;
959 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
960 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
962 $morehtmlref .=
'</div>';
965 if (!$user->hasRight(
'projet',
'all',
'lire')) {
966 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
967 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0') .
")";
970 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
972 print
'<div class="fichecenter">';
973 print
'<div class="fichehalfleft">';
974 print
'<div class="underbanner clearboth"></div>';
976 print
'<table class="border tableforfield centpercent">';
980 print
'<tr><td class="tdtop">';
981 print $langs->trans(
"Usage");
985 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
986 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
987 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
991 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
992 $htmltext = $langs->trans(
"ProjectFollowTasks");
993 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
997 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"' :
'')) .
'"> ';
998 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
999 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1002 if (isModEnabled(
'eventorganization')) {
1003 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"' :
'')) .
'"> ';
1004 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1005 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1011 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1012 if ($projectstatic->public) {
1013 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1014 print $langs->trans(
'SharedProject');
1016 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1017 print $langs->trans(
'PrivateProject');
1022 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1023 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1024 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency) .
'</span>';
1029 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1031 print($start ? $start :
'?');
1034 print($end ? $end :
'?');
1035 if ($projectstatic->hasDelay()) {
1044 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1050 print
'<div class="fichehalfright">';
1051 print
'<div class="underbanner clearboth"></div>';
1053 print
'<table class="border tableforfield centpercent">';
1056 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1061 if (isModEnabled(
'category')) {
1062 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1063 print $form->showCategories($projectstatic->id,
'project', 1);
1072 print
'<div class="clearboth"></div>';
1082 $linktocreatetimeBtnStatus = 0;
1083 $linktocreatetimeUrl =
'';
1084 $linktocreatetimeHelpText =
'';
1085 if ($user->hasRight(
'projet',
'time')) {
1086 if ($projectstatic->public || $userRead > 0) {
1087 $linktocreatetimeBtnStatus = 1;
1089 if (!empty($projectidforalltimes)) {
1091 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1092 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1095 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1096 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1099 $linktocreatetimeBtnStatus = -2;
1100 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1103 $linktocreatetimeBtnStatus = -2;
1104 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1107 $paramsbutton = array(
'morecss' =>
'reposition');
1108 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1111 $massactionbutton =
'';
1112 $arrayofmassactions = array();
1114 if ($projectstatic->id > 0) {
1116 if ($projectstatic->usage_bill_time) {
1117 $arrayofmassactions = array(
1118 'generateinvoice' => $langs->trans(
"GenerateBill"),
1122 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1123 $langs->load(
"interventions");
1124 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1128 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1129 $arrayofmassactions = array();
1131 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1136 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1138 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1140 if ($action ==
'deleteline') {
1141 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1142 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1145 $param = ($withproject ?
'&withproject=1' :
'');
1146 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1147 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1149 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1150 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1151 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1153 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1159 if (empty($withproject)) {
1160 $morehtmlref .=
'<div class="refidno">';
1161 $morehtmlref .= $langs->trans(
"Project") .
': ';
1162 $morehtmlref .= $projectstatic->getNomUrl(1);
1163 $morehtmlref .=
'<br>';
1166 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1167 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1168 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1170 $morehtmlref .=
'</div>';
1173 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1175 print
'<div class="fichecenter">';
1176 print
'<div class="fichehalfleft">';
1178 print
'<div class="underbanner clearboth"></div>';
1179 print
'<table class="border centpercent tableforfield">';
1182 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1183 if (
$object->fk_task_parent > 0) {
1184 $tasktmp =
new Task($db);
1185 $tasktmp->fetch(
$object->fk_task_parent);
1186 print $tasktmp->getNomUrl(1);
1191 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1193 print($start ? $start :
'?');
1196 print($end ? $end :
'?');
1203 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1204 if (
$object->planned_workload) {
1212 print
'<div class="fichehalfright">';
1214 print
'<div class="underbanner clearboth"></div>';
1215 print
'<table class="border tableforfield centpercent">';
1218 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1223 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1224 if (
$object->planned_workload) {
1225 $tmparray =
$object->getSummaryOfTimeSpent();
1226 if ($tmparray[
'total_duration'] > 0) {
1227 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1232 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1243 print
'<div class="clearboth"></div>';
1247 if ($action ==
'deleteline') {
1248 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1249 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1254 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1256 $hookmanager->initHooks(array(
'tasktimelist'));
1260 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1262 $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);
1263 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1267 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1268 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1269 if (empty($reshook)) {
1270 $formconfirm .= $hookmanager->resPrint;
1271 } elseif ($reshook > 0) {
1272 $formconfirm = $hookmanager->resPrint;
1279 $arrayfields = array();
1280 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1281 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1282 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1283 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1284 if (! empty($allprojectforuser)) {
1285 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1286 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1288 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1289 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1291 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1292 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1293 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1294 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1296 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1297 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1298 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' => 1,
'enabled' => (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1300 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1303 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1306 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1307 $param .=
'&contextpage=' . urlencode($contextpage);
1309 if ($limit > 0 && $limit != $conf->liste_limit) {
1310 $param .=
'&limit='.((int) $limit);
1312 if ($search_month > 0) {
1313 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1315 if ($search_year > 0) {
1316 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1318 if (!empty($search_user)) {
1319 $param .=
'&search_user='.urlencode($search_user);
1321 if ($search_task_ref !=
'') {
1322 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1324 if ($search_company !=
'') {
1325 $param .=
'&$search_company=' . urlencode($search_company);
1327 if ($search_company_alias !=
'') {
1328 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1330 if ($search_project_ref !=
'') {
1331 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1333 if ($search_project_label !=
'') {
1334 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1336 if ($search_task_label !=
'') {
1337 $param .=
'&search_task_label=' . urlencode($search_task_label);
1339 if ($search_note !=
'') {
1340 $param .=
'&search_note=' . urlencode($search_note);
1342 if ($search_duration !=
'') {
1343 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1345 if ($optioncss !=
'') {
1346 $param .=
'&optioncss=' . urlencode($optioncss);
1348 if ($search_date_startday) {
1349 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1351 if ($search_date_startmonth) {
1352 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1354 if ($search_date_startyear) {
1355 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1357 if ($search_date_endday) {
1358 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1360 if ($search_date_endmonth) {
1361 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1363 if ($search_date_endyear) {
1364 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1366 if ($search_timespent_starthour) {
1367 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1369 if ($search_timespent_startmin) {
1370 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1372 if ($search_timespent_endhour) {
1373 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1375 if ($search_timespent_endmin) {
1376 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1384 $param .=
'&id=' . urlencode((
string) ($id));
1387 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1390 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1393 $parameters = array(
'param' => &$param);
1394 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1395 $param .= $hookmanager->resPrint;
1397 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1398 if ($optioncss !=
'') {
1399 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1401 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1402 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1403 if ($action ==
'editline') {
1404 print
'<input type="hidden" name="action" value="updateline">';
1405 } elseif ($action ==
'splitline') {
1406 print
'<input type="hidden" name="action" value="updatesplitline">';
1407 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1408 print
'<input type="hidden" name="action" value="addtimespent">';
1409 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1410 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1411 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1412 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1414 print
'<input type="hidden" name="action" value="list">';
1416 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1417 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1419 print
'<input type="hidden" name="id" value="' . $id .
'">';
1420 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1421 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1422 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1423 print
'<input type="hidden" name="page_y" value="">';
1426 if ($massaction ==
'generateinvoice') {
1427 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1428 print
'<table class="noborder centerpercent">';
1430 print
'<td class="titlefield">';
1431 print $langs->trans(
'DateInvoice');
1434 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1440 print $langs->trans(
'Mode');
1444 'onelineperuser' =>
'OneLinePerUser',
1445 'onelinepertask' =>
'OneLinePerTask',
1446 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1448 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1449 print
"\n" .
'<script type="text/javascript">';
1451 $(document).ready(function () {
1452 setDetailVisibility();
1453 $("#generateinvoicemode").change(function() {
1454 setDetailVisibility();
1456 function setDetailVisibility() {
1457 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1458 if (generateinvoicemode=="onelineperperiod") {
1459 $("#detail_time_duration").show();
1461 $("#detail_time_duration").hide();
1466 print
'</script>' .
"\n";
1467 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1471 if (isModEnabled(
"service")) {
1474 print $langs->trans(
'ServiceToUseOnLines');
1477 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1482 print
'<td class="titlefield">';
1483 print $langs->trans(
'InvoiceToUse');
1486 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1490 print
'<td class="titlefield">';
1491 print $langs->trans(
"CustomerRelativeDiscount");
1494 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1497 print
'<tr class="newinvoicedetail">';
1498 print
'<td class="titlefield">';
1499 print $langs->trans(
"PaymentConditions");
1502 print $form->getSelectConditionsPaiements($projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1516 print
'<div class="center">';
1517 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1518 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1522 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1523 print
'<div class="center">';
1524 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1528 } elseif ($massaction ==
'generateinter') {
1530 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1532 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1534 print
'<table class="noborder centpercent">';
1536 print
'<td class="titlefield">';
1537 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1541 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1546 print
'<div class="center">';
1547 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1548 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1552 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1553 print
'<div class="center">';
1554 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1561 $parameters = array(
1562 'toselect' => $toselect,
1563 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1566 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1570 print $hookmanager->resPrint;
1578 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1579 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1581 $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,";
1582 $sql .=
" t.fk_product,";
1583 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1584 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1585 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1586 $sql .=
" p.fk_soc,s.name_alias,";
1587 $sql .=
" t.invoice_line_id";
1589 $parameters = array();
1590 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1591 $sql .= $hookmanager->resPrint;
1592 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1596 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1597 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1598 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1599 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1600 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1601 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1602 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1603 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1606 $parameters = array();
1607 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1608 $sql .= $hookmanager->resPrint;
1609 $sql .=
" WHERE elementtype = 'task'";
1610 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1611 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1615 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1616 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1618 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1620 $sql .=
" AND t.fk_element =".((int)
$object->id);
1621 } elseif (!empty($projectidforalltimes)) {
1623 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1624 } elseif (!empty($allprojectforuser)) {
1626 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1627 $search_user = $user->id;
1629 if ($search_user > 0) {
1630 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1637 if ($search_task_ref) {
1640 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1641 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1643 if ($search_company) {
1646 if ($search_company_alias) {
1650 if ($search_project_ref) {
1653 if ($search_project_label) {
1656 if ($search_task_label) {
1659 if ($search_user > 0) {
1662 if (!empty($search_product_ref)) {
1665 if ($search_valuebilled ==
'1') {
1666 $sql .=
' AND t.invoice_id > 0';
1668 if ($search_valuebilled ==
'0') {
1669 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1672 if ($search_date_start) {
1673 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1675 if ($search_date_end) {
1676 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1679 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1680 if ($search_timespent_starthour || $search_timespent_startmin) {
1681 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1682 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1683 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1686 if ($search_timespent_endhour || $search_timespent_endmin) {
1687 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1688 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1689 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1693 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1696 $parameters = array();
1697 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1698 $sql .= $hookmanager->resPrint;
1701 $nbtotalofrecords =
'';
1704 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1705 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1706 $resql = $db->query($sqlforcount);
1708 $objforcount = $db->fetch_object($resql);
1709 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1714 if (($page * $limit) > $nbtotalofrecords) {
1722 $sql .= $db->order($sortfield, $sortorder);
1724 $sql .= $db->plimit($limit + 1, $offset);
1727 $resql = $db->query($sql);
1733 $num = $db->num_rows($resql);
1736 if (!empty($projectidforalltimes)) {
1737 print
'<!-- List of time spent for project -->' .
"\n";
1739 $title = $langs->trans(
"ListTaskTimeUserProject");
1741 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1743 print
'<!-- List of time spent -->' .
"\n";
1745 $title = $langs->trans(
"ListTaskTimeForTask");
1747 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1752 $row = $db->fetch_object($resql);
1764 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1765 print
'<!-- table to add time spent -->' .
"\n";
1767 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
1770 print
'<div class="div-table-responsive-no-min">';
1771 print
'<table class="noborder nohover centpercent">';
1773 print
'<tr class="liste_titre">';
1774 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1775 if (!empty($allprojectforuser)) {
1776 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1779 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1781 print
'<td>' . $langs->trans(
"By") .
'</td>';
1782 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1783 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1784 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1788 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1789 print
'<td>'.$langs->trans(
"Product").
'</td>';
1793 $parameters = array(
'mode' =>
'create');
1794 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1795 print $hookmanager->resPrint;
1799 print
'<tr class="oddeven nohover">';
1802 print
'<td class="maxwidthonsmartphone">';
1804 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1807 if (!empty($allprojectforuser)) {
1816 print
'<td class="maxwidthonsmartphone">';
1817 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1822 print
'<td class="maxwidthonsmartphone nowraponall">';
1823 $contactsofproject = $projectstatic->getListContactId(
'internal');
1824 if (count($contactsofproject) > 0) {
1825 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1826 if (in_array($user->id, $contactsofproject)) {
1827 $userid = $user->id;
1829 $userid = $contactsofproject[0];
1832 if ($projectstatic->public) {
1833 $contactsofproject = array();
1835 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1838 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1845 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1849 print
'<td class="nowraponall">';
1850 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1851 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1852 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1854 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1858 print
'<td class="nowrap">';
1859 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1867 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1868 print
'<td class="nowraponall">';
1870 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'', null, 1);
1876 $parameters = array(
'mode' =>
'create');
1877 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1878 print $hookmanager->resPrint;
1880 print
'<td class="center">';
1881 $form->buttonsSaveCancel();
1882 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1883 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1892 $moreforfilter =
'';
1894 $parameters = array();
1895 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1896 if (empty($reshook)) {
1897 $moreforfilter .= $hookmanager->resPrint;
1899 $moreforfilter = $hookmanager->resPrint;
1902 if (!empty($moreforfilter)) {
1903 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1904 print $moreforfilter;
1908 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1909 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1910 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1912 print
'<div class="div-table-responsive">';
1913 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1917 print
'<tr class="liste_titre_filter">';
1920 print
'<td class="liste_titre center">';
1921 $searchpicto = $form->showFilterButtons(
'left');
1926 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1927 print
'<td class="liste_titre left">';
1928 print
'<div class="nowrapfordate">';
1929 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1931 print
'<div class="nowrapfordate">';
1932 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1937 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1938 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1942 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1943 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1946 if (!empty($allprojectforuser)) {
1947 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1948 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1950 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1951 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1955 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1956 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1957 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1959 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1960 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1964 if (!empty($arrayfields[
'author'][
'checked'])) {
1965 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>';
1968 if (!empty($arrayfields[
't.note'][
'checked'])) {
1969 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1972 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1974 print
'<td class="liste_titre right">';
1976 $durationtouse_start =
'';
1977 if ($search_timespent_starthour || $search_timespent_startmin) {
1978 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1980 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1981 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1984 $durationtouse_end =
'';
1985 if ($search_timespent_endhour || $search_timespent_endmin) {
1986 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1988 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
1989 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1995 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1996 print
'<td class="liste_titre right"></td>';
1999 if (!empty($arrayfields[
'value'][
'checked'])) {
2000 print
'<td class="liste_titre"></td>';
2003 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2004 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2012 $parameters = array(
'arrayfields' => $arrayfields);
2013 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2014 print $hookmanager->resPrint;
2017 print
'<td class="liste_titre center">';
2018 $searchpicto = $form->showFilterButtons();
2022 print
'</tr>' .
"\n";
2025 $totalarray = array();
2026 $totalarray[
'nbfield'] = 0;
2030 print
'<tr class="liste_titre">';
2032 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2033 $totalarray[
'nbfield']++;
2035 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2036 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2037 $totalarray[
'nbfield']++;
2039 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2040 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2041 $totalarray[
'nbfield']++;
2043 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2044 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2045 $totalarray[
'nbfield']++;
2047 if (!empty($allprojectforuser)) {
2048 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2050 $totalarray[
'nbfield']++;
2052 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2053 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2054 $totalarray[
'nbfield']++;
2057 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2058 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2059 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2060 $totalarray[
'nbfield']++;
2062 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2063 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2064 $totalarray[
'nbfield']++;
2067 if (!empty($arrayfields[
'author'][
'checked'])) {
2068 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2069 $totalarray[
'nbfield']++;
2071 if (!empty($arrayfields[
't.note'][
'checked'])) {
2072 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2073 $totalarray[
'nbfield']++;
2075 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2076 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2077 $totalarray[
'nbfield']++;
2079 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2080 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2081 $totalarray[
'nbfield']++;
2084 if (!empty($arrayfields[
'value'][
'checked'])) {
2085 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2086 $totalarray[
'nbfield']++;
2088 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2089 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2090 $totalarray[
'nbfield']++;
2097 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2098 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2099 print $hookmanager->resPrint;
2101 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2102 $totalarray[
'nbfield']++;
2106 $tasktmp =
new Task($db);
2107 $tmpinvoice =
new Facture($db);
2110 $param .=
'&page='.((int) $page);
2112 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2116 $savnbfield = $totalarray[
'nbfield'];
2117 $totalarray = array();
2118 $totalarray[
'nbfield'] = 0;
2120 foreach ($tasks as $task_time) {
2125 $date1 = $db->jdate($task_time->element_date);
2126 $date2 = $db->jdate($task_time->element_datehour);
2130 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2134 print
'<td class="center nowraponall">';
2135 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2136 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2137 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2139 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2140 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2141 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2142 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' :
'').
'">';
2143 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2147 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' :
'') .
'">';
2148 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2152 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' :
'').
'">';
2153 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2156 if ($massactionbutton || $massaction) {
2158 if (in_array($task_time->rowid, $arrayofselected)) {
2162 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2168 $totalarray[
'nbfield']++;
2173 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2174 print
'<td class="nowrap">';
2175 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2176 if (empty($task_time->element_date_withhour)) {
2177 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2179 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2182 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2186 $totalarray[
'nbfield']++;
2191 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2192 print
'<td class="tdoverflowmax125">';
2193 if ($task_time->fk_soc > 0) {
2194 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2195 $tmpsociete =
new Societe($db);
2196 $tmpsociete->fetch($task_time->fk_soc);
2197 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2199 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2201 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2205 $totalarray[
'nbfield']++;
2210 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2211 if ($task_time->fk_soc > 0) {
2212 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2213 $tmpsociete =
new Societe($db);
2214 $tmpsociete->fetch($task_time->fk_soc);
2215 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2217 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2219 $valtoshow = $tmpsociete->name_alias;
2221 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2225 $totalarray[
'nbfield']++;
2230 if (!empty($allprojectforuser)) {
2231 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2232 print
'<td class="nowraponall">';
2233 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2234 $tmpproject =
new Project($db);
2235 $tmpproject->fetch($task_time->fk_projet);
2236 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2238 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2240 print $tmpproject->getNomUrl(1);
2243 $totalarray[
'nbfield']++;
2246 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2247 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2248 $tmpproject =
new Project($db);
2249 $tmpproject->fetch($task_time->fk_projet);
2250 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2252 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2254 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2258 $totalarray[
'nbfield']++;
2264 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2265 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2266 print
'<td class="nowrap">';
2267 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2268 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2270 $tasktmp->id = $task_time->fk_element;
2271 $tasktmp->ref = $task_time->ref;
2272 $tasktmp->label = $task_time->label;
2273 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2277 $totalarray[
'nbfield']++;
2280 } elseif ($action !==
'createtime') {
2281 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
2285 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2286 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2287 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2291 $totalarray[
'nbfield']++;
2297 if (!empty($arrayfields[
'author'][
'checked'])) {
2298 print
'<td class="minwidth100 tdoverflowmax125">';
2299 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2302 $object->fetch($task_time->fk_element);
2304 $contactsoftask =
$object->getListContactId(
'internal');
2305 if (!in_array($task_time->fk_user, $contactsoftask)) {
2306 $contactsoftask[] = $task_time->fk_user;
2308 if (count($contactsoftask) > 0) {
2309 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2310 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2312 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2315 $userstatic->id = $task_time->fk_user;
2316 $userstatic->lastname = $task_time->lastname;
2317 $userstatic->firstname = $task_time->firstname;
2318 $userstatic->photo = $task_time->photo;
2319 $userstatic->gender = $task_time->gender;
2320 $userstatic->status = $task_time->user_status;
2322 print $userstatic->getNomUrl(-1);
2326 $totalarray[
'nbfield']++;
2331 if (!empty($arrayfields[
't.note'][
'checked'])) {
2332 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2333 print
'<td class="small">';
2334 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2337 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2342 $totalarray[
'nbfield']++;
2344 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2345 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2349 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2350 print
'<td class="right nowraponall">';
2351 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2352 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2353 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2359 $totalarray[
'nbfield']++;
2362 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2364 if (empty($totalarray[
'val'][
't.element_duration'])) {
2365 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2367 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2370 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2372 if (empty($totalarray[
'totalduration'])) {
2373 $totalarray[
'totalduration'] = $task_time->element_duration;
2375 $totalarray[
'totalduration'] += $task_time->element_duration;
2380 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2381 print
'<td class="nowraponall">';
2382 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2384 print $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', 0,
'',
null, 1);
2385 } elseif (!empty($task_time->fk_product)) {
2387 $resultFetch = $product->fetch($task_time->fk_product);
2388 if ($resultFetch < 0) {
2391 print $product->getNomUrl(1);
2396 $totalarray[
'nbfield']++;
2401 if (!empty($arrayfields[
'value'][
'checked'])) {
2402 $langs->load(
"salaries");
2403 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2405 print
'<td class="nowraponall right">';
2406 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2407 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2411 $totalarray[
'nbfield']++;
2414 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2416 if (empty($totalarray[
'val'][
'value'])) {
2417 $totalarray[
'val'][
'value'] = $value;
2419 $totalarray[
'val'][
'value'] += $value;
2422 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2424 if (empty($totalarray[
'totalvalue'])) {
2425 $totalarray[
'totalvalue'] = $value;
2427 $totalarray[
'totalvalue'] += $value;
2432 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2433 print
'<td class="center">';
2435 if ($projectstatic->usage_bill_time) {
2436 if ($task_time->invoice_id) {
2437 $result = $tmpinvoice->fetch($task_time->invoice_id);
2439 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2440 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2442 print $tmpinvoice->getNomUrl(1);
2443 if (!empty($task_time->invoice_line_id)) {
2445 $invoiceLine->fetch($task_time->invoice_line_id);
2446 if (!empty($invoiceLine->id)) {
2447 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2448 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2454 print $langs->trans(
"No");
2457 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2462 $totalarray[
'nbfield']++;
2472 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2473 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2474 print $hookmanager->resPrint;
2478 print
'<td class="center nowraponall">';
2479 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2480 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2481 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2483 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2484 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2485 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2486 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' :
'').
'">';
2487 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2491 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' :
'') .
'">';
2492 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2496 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' :
'').
'">';
2497 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2500 if ($massactionbutton || $massaction) {
2502 if (in_array($task_time->rowid, $arrayofselected)) {
2506 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2512 $totalarray[
'nbfield']++;
2521 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2522 print
'<!-- first line -->';
2523 print
'<tr class="oddeven">';
2531 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2532 print
'<td class="nowrap">';
2533 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2534 if (empty($task_time->element_date_withhour)) {
2535 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2537 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2540 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2546 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2547 print
'<td class="nowrap">';
2552 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2553 print
'<td class="nowrap">';
2558 if (!empty($allprojectforuser)) {
2559 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2560 print
'<td class="nowrap">';
2566 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2567 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2568 print
'<td class="nowrap">';
2569 $tasktmp->id = $task_time->fk_element;
2570 $tasktmp->ref = $task_time->ref;
2571 $tasktmp->label = $task_time->label;
2572 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2578 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2579 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2580 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2587 if (!empty($arrayfields[
'author'][
'checked'])) {
2588 print
'<td class="nowraponall">';
2589 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2591 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2594 $contactsoftask =
$object->getListContactId(
'internal');
2595 if (!in_array($task_time->fk_user, $contactsoftask)) {
2596 $contactsoftask[] = $task_time->fk_user;
2598 if (count($contactsoftask) > 0) {
2599 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2600 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2602 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2605 $userstatic->id = $task_time->fk_user;
2606 $userstatic->lastname = $task_time->lastname;
2607 $userstatic->firstname = $task_time->firstname;
2608 $userstatic->photo = $task_time->photo;
2609 $userstatic->status = $task_time->user_status;
2610 print $userstatic->getNomUrl(-1);
2616 if (!empty($arrayfields[
't.note'][
'checked'])) {
2617 print
'<td class="tdoverflowmax300">';
2618 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2619 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2624 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2625 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2629 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2630 print
'<td class="right">';
2631 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2632 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2633 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2641 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2642 print
'<td class="nowraponall tdoverflowmax125">';
2647 if (!empty($arrayfields[
'value'][
'checked'])) {
2648 print
'<td class="right">';
2649 print
'<span class="amount">';
2650 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2651 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2657 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2658 print
'<td class="right">';
2659 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2660 if (isset($task_time->total_ht)) {
2661 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2672 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2673 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2674 print $hookmanager->resPrint;
2678 print
'<td class="center nowraponall">';
2687 print
'<!-- second line --><tr class="oddeven">';
2691 print
'<td class="center nowraponall">';
2696 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2697 print
'<td class="nowrap">';
2698 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2699 if (empty($task_time->element_date_withhour)) {
2700 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2702 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2705 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2711 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2712 print
'<td class="nowrap">';
2717 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2718 print
'<td class="nowrap">';
2723 if (!empty($allprojectforuser)) {
2724 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2725 print
'<td class="nowrap">';
2731 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2732 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2733 print
'<td class="nowrap">';
2734 $tasktmp->id = $task_time->fk_element;
2735 $tasktmp->ref = $task_time->ref;
2736 $tasktmp->label = $task_time->label;
2737 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2743 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2744 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2745 print
'<td class="nowrap">';
2752 if (!empty($arrayfields[
'author'][
'checked'])) {
2753 print
'<td class="nowraponall tdoverflowmax100">';
2754 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2756 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2759 $contactsoftask =
$object->getListContactId(
'internal');
2760 if (!in_array($task_time->fk_user, $contactsoftask)) {
2761 $contactsoftask[] = $task_time->fk_user;
2763 if (count($contactsoftask) > 0) {
2764 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2765 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2767 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2770 $userstatic->id = $task_time->fk_user;
2771 $userstatic->lastname = $task_time->lastname;
2772 $userstatic->firstname = $task_time->firstname;
2773 $userstatic->photo = $task_time->photo;
2774 $userstatic->status = $task_time->user_status;
2775 print $userstatic->getNomUrl(-1);
2781 if (!empty($arrayfields[
't.note'][
'checked'])) {
2782 print
'<td class="small tdoverflowmax300"">';
2783 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2784 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2789 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2790 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2794 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2795 print
'<td class="right">';
2796 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2797 print
'<input type="hidden" name="old_duration_2" value="0">';
2798 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2806 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2807 print
'<td class="nowraponall tdoverflowmax125">';
2812 if (!empty($arrayfields[
'value'][
'checked'])) {
2813 print
'<td class="right">';
2814 print
'<span class="amount">';
2816 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2822 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2823 print
'<td class="right">';
2824 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2825 if (isset($task_time->total_ht)) {
2826 print
'<span class="amount">';
2827 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2839 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2840 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2841 print $hookmanager->resPrint;
2845 print
'<td class="center nowraponall">';
2857 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2858 print
'<tr class="liste_total">';
2860 while ($i < $totalarray[
'nbfield']) {
2863 if ($num < $limit && empty($offset)) {
2864 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2866 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2868 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2869 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2870 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2871 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2880 if (!count($tasks)) {
2881 $totalnboffields = 1;
2882 foreach ($arrayfields as $value) {
2883 if (!empty($value[
'checked'])) {
2887 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2888 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2892 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2893 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2894 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage interventions.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.