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);
128$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
131if ($id > 0 || $ref) {
139if (!$user->hasRight(
'projet',
'lire')) {
148 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
149 $search_user = $user->id;
158if (
GETPOST(
'cancel',
'alpha')) {
161if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
165$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
166$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
171include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
174if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
179 $search_duration =
'';
180 $search_date_startday =
'';
181 $search_date_startmonth =
'';
182 $search_date_startyear =
'';
183 $search_date_endday =
'';
184 $search_date_endmonth =
'';
185 $search_date_endyear =
'';
186 $search_date_start =
'';
187 $search_date_end =
'';
188 $search_task_ref =
'';
189 $search_company =
'';
190 $search_company_alias =
'';
191 $search_project_ref =
'';
192 $search_project_label =
'';
193 $search_task_label =
'';
195 $search_valuebilled =
'';
196 $search_product_ref =
'';
198 $search_array_options = array();
199 $search_timespent_starthour =
'';
200 $search_timespent_startmin =
'';
201 $search_timespent_endhour =
'';
202 $search_timespent_endmin =
'';
206if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
209 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
210 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
211 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
212 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
216 $langs->load(
"errors");
217 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
226 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
227 $action =
'createtime';
237 if (empty(
$object->project->status)) {
238 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
239 $action =
'createtime';
250 $object->timespent_withhour = 1;
253 $object->timespent_withhour = 0;
258 $result =
$object->addTimeSpent($user);
269 $action =
'createtime';
273if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
276 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
277 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
292 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
293 $result =
$object->delTimeSpent($user);
296 $object->fetch($id_temp, $ref);
298 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
302 if (
GETPOST(
"timelinehour") !=
''
303 &&
GETPOST(
"timelinehour") >= 0
304 && !empty($timespent_date)) {
307 $object->timespent_withhour = 1;
308 } elseif (!empty($timespent_date)) {
309 $object->timespent_date = $timespent_date;
310 $object->timespent_withhour = 0;
318 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
319 $result =
$object->addTimeSpent($user);
332 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
336 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
338 $object->timespent_withhour = 1;
339 } elseif (!empty($timespent_date)) {
340 $object->timespent_date = $timespent_date;
341 $object->timespent_withhour = 0;
349 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
350 $result =
$object->updateTimeSpent($user);
365if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
368 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
369 $result =
$object->delTimeSpent($user);
372 $langs->load(
"errors");
383if (!empty($project_ref) && !empty($withproject)) {
384 if ($projectstatic->fetch(0, $project_ref) > 0) {
385 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
386 if (count($tasksarray) > 0) {
387 $id = $tasksarray[0]->id;
389 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
396$projectidforalltimes = 0;
398 $projectidforalltimes =
GETPOSTINT(
'projectid');
400 $result = $projectstatic->fetch($projectidforalltimes);
401 if (!empty($projectstatic->socid)) {
402 $projectstatic->fetch_thirdparty();
404 $res = $projectstatic->fetch_optionals();
405} elseif (
GETPOST(
'project_ref',
'alpha')) {
406 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
407 $projectidforalltimes = $projectstatic->id;
411 $result = $projectstatic->fetch(
$object->fk_project);
414if ($id <= 0 && $projectidforalltimes == 0) {
415 $allprojectforuser = $user->id;
418if ($action ==
'confirm_generateinvoice') {
419 if (!empty($projectstatic->socid)) {
420 $projectstatic->fetch_thirdparty();
423 if (!($projectstatic->thirdparty->id > 0)) {
424 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
426 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
427 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
428 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
430 $tmpinvoice =
new Facture($db);
431 $tmptimespent =
new Task($db);
432 $tmpproduct =
new Product($db);
433 $fuser =
new User($db);
438 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
441 $prodDurationHoursBase = 1.0;
442 $product_data_cache = array();
444 $tmpproduct->fetch($idprod);
450 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
451 if ($prodDurationHoursBase < 0) {
453 $langs->load(
"errors");
457 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
459 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
460 $txtva = $dataforprice[
'tva_tx'];
461 $localtax1 = $dataforprice[
'localtax1'];
462 $localtax2 = $dataforprice[
'localtax2'];
464 $prodDurationHoursBase = 1;
472 $tmpinvoice->socid = $projectstatic->thirdparty->id;
474 $tmpinvoice->fk_project = $projectstatic->id;
475 $tmpinvoice->cond_reglement_id = $condidproject;
476 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
477 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
480 $tmpinvoice->fetch($invoiceToUse);
482 $result = $tmpinvoice->create($user);
490 if ($generateinvoicemode ==
'onelineperuser') {
491 $arrayoftasks = array();
492 foreach ($toselect as $key => $value) {
494 $object->fetchTimeSpent($value);
495 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
496 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
499 foreach ($arrayoftasks as $userid => $data) {
500 $fuser->fetch($userid);
501 $username = $fuser->getFullName($langs);
503 foreach ($data as $fk_product => $timespent_data) {
505 $qtyhour = $timespent_data[
'timespent'] / 3600;
506 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
512 } elseif ($idprod <= 0) {
515 $pu_ht = $fuser->thm;
520 if ($timespent_data[
'timespent']) {
521 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
526 $prodDurationHours = $prodDurationHoursBase;
527 $idprodline = $idprod;
530 $localtax1line = $localtax1;
531 $localtax2line = $localtax2;
534 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
535 if (!array_key_exists($fk_product, $product_data_cache)) {
536 $result = $tmpproduct->fetch($fk_product);
541 $prodDurationHours = $tmpproduct->getProductDurationHours();
542 if ($prodDurationHours < 0) {
544 $langs->load(
"errors");
548 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
550 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
551 $txtvaline = $dataforprice[
'tva_tx'];
552 $localtax1line = $dataforprice[
'localtax1'];
553 $localtax2line = $dataforprice[
'localtax2'];
555 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
557 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
558 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
559 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
560 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
561 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
563 $idprodline = $fk_product;
567 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
574 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
575 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
576 $result = $db->query($sql);
584 } elseif ($generateinvoicemode ==
'onelineperperiod') {
585 $arrayoftasks = array();
587 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
588 foreach ($toselect as $key => $value) {
590 $object->fetchTimeSpent($value);
592 $ftask =
new Task($db);
595 $fuser->fetch(
$object->timespent_fk_user);
596 $username = $fuser->getFullName($langs);
598 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
599 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
600 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
603 if (!empty($withdetail)) {
604 if (!empty(
$object->timespent_withhour)) {
611 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
612 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
615 foreach ($arrayoftasks as $timespent_id => $value) {
616 $userid = $value[
'user'];
620 $qtyhour = $value[
'timespent'] / 3600;
624 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
628 $prodDurationHours = $prodDurationHoursBase;
629 $idprodline = $idprod;
632 $localtax1line = $localtax1;
633 $localtax2line = $localtax2;
635 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
636 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
637 $result = $tmpproduct->fetch($value[
'fk_product']);
642 $prodDurationHours = $tmpproduct->getProductDurationHours();
643 if ($prodDurationHours < 0) {
645 $langs->load(
"errors");
649 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
651 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
652 $txtvaline = $dataforprice[
'tva_tx'];
653 $localtax1line = $dataforprice[
'localtax1'];
654 $localtax2line = $dataforprice[
'localtax2'];
656 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
658 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
659 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
660 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
661 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
662 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
664 $idprodline = $value[
'fk_product'];
666 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), $remiseproject);
674 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
675 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
676 $result = $db->query($sql);
683 } elseif ($generateinvoicemode ==
'onelinepertask') {
684 $arrayoftasks = array();
685 foreach ($toselect as $key => $value) {
687 $object->fetchTimeSpent($value);
689 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
690 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
693 foreach ($arrayoftasks as $task_id => $data) {
694 $ftask =
new Task($db);
695 $ftask->fetch($task_id);
697 foreach ($data as $fk_product => $timespent_data) {
698 $qtyhour = $timespent_data[
'timespent'] / 3600;
699 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
702 $prodDurationHours = $prodDurationHoursBase;
703 $idprodline = $idprod;
706 $localtax1line = $localtax1;
707 $localtax2line = $localtax2;
709 if (!empty($fk_product) && $fk_product !== $idprod) {
710 if (!array_key_exists($fk_product, $product_data_cache)) {
711 $result = $tmpproduct->fetch($fk_product);
716 $prodDurationHours = $tmpproduct->getProductDurationHours();
717 if ($prodDurationHours < 0) {
719 $langs->load(
"errors");
723 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
725 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
726 $txtvaline = $dataforprice[
'tva_tx'];
727 $localtax1line = $dataforprice[
'localtax1'];
728 $localtax2line = $dataforprice[
'localtax2'];
730 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
732 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
733 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
734 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
735 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
736 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
738 $idprodline = $fk_product;
742 if ($idprodline > 0) {
744 $pu_ht_for_task = $pu_htline;
747 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
749 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
755 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
757 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
763 $lineName = $ftask->ref .
' - ' . $ftask->label;
764 $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);
773 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
774 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $toselect)) .
')';
775 $result = $db->query($sql);
788 $urltoinvoice = $tmpinvoice->getNomUrl(0);
789 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
790 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
802if ($action ==
'confirm_generateinter') {
803 $langs->load(
'interventions');
805 if (!empty($projectstatic->socid)) {
806 $projectstatic->fetch_thirdparty();
809 if (!($projectstatic->thirdparty->id > 0)) {
810 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
812 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
813 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
814 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
817 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
819 $tmptimespent =
new Task($db);
820 $fuser =
new User($db);
826 $tmpinter->socid = $projectstatic->thirdparty->id;
828 $tmpinter->fk_project = $projectstatic->id;
829 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
832 $tmpinter->fetch($interToUse);
834 $result = $tmpinter->create($user);
842 $arrayoftasks = array();
843 foreach ($toselect as $key => $value) {
845 $object->fetchTimeSpent($value);
848 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
849 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
850 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
851 $arrayoftasks[
$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s',
$object->timespent_datehour);
854 foreach ($arrayoftasks as $timespent_id => $value) {
855 $ftask =
new Task($db);
856 $ftask->fetch($value[
'id']);
858 $qtyhour = $value[
'timespent'] / 3600;
859 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
862 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
867 $urltointer = $tmpinter->getNomUrl(0);
868 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
869 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
886$form =
new Form($db);
889$userstatic =
new User($db);
891$arrayofselected = is_array($toselect) ? $toselect : array();
893$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
894if (!empty($withproject)) {
895 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
901if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
905 if ($projectidforalltimes > 0) {
906 $result = $projectstatic->fetch($projectidforalltimes);
907 if (!empty($projectstatic->socid)) {
908 $projectstatic->fetch_thirdparty();
910 $res = $projectstatic->fetch_optionals();
911 } elseif (
$object->fetch($id, $ref) >= 0) {
912 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
915 $result = $projectstatic->fetch(
$object->fk_project);
916 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
917 $projectstatic->fetchComments();
919 if (!empty($projectstatic->socid)) {
920 $projectstatic->fetch_thirdparty();
922 $res = $projectstatic->fetch_optionals();
924 $object->project = clone $projectstatic;
927 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
928 $linktocreatetime =
'';
930 if ($projectstatic->id > 0) {
933 if (empty($id) || $tab ==
'timespent') {
940 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
942 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
944 $param .=
'&search_user=' . ((int) $search_user);
947 $param .=
'&search_month=' . ((int) $search_month);
950 $param .=
'&search_year=' . ((int) $search_year);
955 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
957 $morehtmlref =
'<div class="refidno">';
959 $morehtmlref .= $projectstatic->title;
961 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
962 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
964 $morehtmlref .=
'</div>';
967 if (!$user->hasRight(
'projet',
'all',
'lire')) {
968 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
969 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0') .
")";
972 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
974 print
'<div class="fichecenter">';
975 print
'<div class="fichehalfleft">';
976 print
'<div class="underbanner clearboth"></div>';
978 print
'<table class="border tableforfield centpercent">';
982 print
'<tr><td class="tdtop">';
983 print $langs->trans(
"Usage");
987 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
988 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
989 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
993 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
994 $htmltext = $langs->trans(
"ProjectFollowTasks");
995 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
999 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"' :
'')) .
'"> ';
1000 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1001 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1004 if (isModEnabled(
'eventorganization')) {
1005 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"' :
'')) .
'"> ';
1006 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1007 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1013 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1014 if ($projectstatic->public) {
1015 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1016 print $langs->trans(
'SharedProject');
1018 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1019 print $langs->trans(
'PrivateProject');
1024 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1025 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1026 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency) .
'</span>';
1031 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1033 print($start ? $start :
'?');
1036 print($end ? $end :
'?');
1037 if ($projectstatic->hasDelay()) {
1046 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1052 print
'<div class="fichehalfright">';
1053 print
'<div class="underbanner clearboth"></div>';
1055 print
'<table class="border tableforfield centpercent">';
1058 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1063 if (isModEnabled(
'category')) {
1064 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1065 print $form->showCategories($projectstatic->id,
'project', 1);
1074 print
'<div class="clearboth"></div>';
1084 $linktocreatetimeBtnStatus = 0;
1085 $linktocreatetimeUrl =
'';
1086 $linktocreatetimeHelpText =
'';
1087 if ($user->hasRight(
'projet',
'time')) {
1088 if ($projectstatic->public || $userRead > 0) {
1089 $linktocreatetimeBtnStatus = 1;
1091 if (!empty($projectidforalltimes)) {
1093 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1094 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1097 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1098 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1101 $linktocreatetimeBtnStatus = -2;
1102 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1105 $linktocreatetimeBtnStatus = -2;
1106 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1109 $paramsbutton = array(
'morecss' =>
'reposition');
1110 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1113 $massactionbutton =
'';
1114 $arrayofmassactions = array();
1116 if ($projectstatic->id > 0) {
1118 if ($projectstatic->usage_bill_time) {
1119 $arrayofmassactions = array(
1120 'generateinvoice' => $langs->trans(
"GenerateBill"),
1124 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1125 $langs->load(
"interventions");
1126 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1130 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1131 $arrayofmassactions = array();
1133 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1138 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1140 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1142 if ($action ==
'deleteline') {
1143 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1144 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1147 $param = ($withproject ?
'&withproject=1' :
'');
1148 $param .= ($param ?
'&' :
'') .
'id=' .
$object->id;
1149 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1151 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1152 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1153 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1155 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1161 if (empty($withproject)) {
1162 $morehtmlref .=
'<div class="refidno">';
1163 $morehtmlref .= $langs->trans(
"Project") .
': ';
1164 $morehtmlref .= $projectstatic->getNomUrl(1);
1165 $morehtmlref .=
'<br>';
1168 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1169 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1170 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1172 $morehtmlref .=
'</div>';
1175 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1177 print
'<div class="fichecenter">';
1178 print
'<div class="fichehalfleft">';
1180 print
'<div class="underbanner clearboth"></div>';
1181 print
'<table class="border centpercent tableforfield">';
1184 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1185 if (
$object->fk_task_parent > 0) {
1186 $tasktmp =
new Task($db);
1187 $tasktmp->fetch(
$object->fk_task_parent);
1188 print $tasktmp->getNomUrl(1);
1193 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1195 print($start ? $start :
'?');
1198 print($end ? $end :
'?');
1205 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1206 if (
$object->planned_workload) {
1214 print
'<div class="fichehalfright">';
1216 print
'<div class="underbanner clearboth"></div>';
1217 print
'<table class="border tableforfield centpercent">';
1220 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1225 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1226 if (
$object->planned_workload) {
1227 $tmparray =
$object->getSummaryOfTimeSpent();
1228 if ($tmparray[
'total_duration'] > 0) {
1229 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1234 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1245 print
'<div class="clearboth"></div>';
1249 if ($action ==
'deleteline') {
1250 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'');
1251 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1256 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1258 $hookmanager->initHooks(array(
'tasktimelist'));
1262 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1264 $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);
1265 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1269 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1270 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1271 if (empty($reshook)) {
1272 $formconfirm .= $hookmanager->resPrint;
1273 } elseif ($reshook > 0) {
1274 $formconfirm = $hookmanager->resPrint;
1281 $arrayfields = array();
1282 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' => 1);
1283 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' => 1);
1284 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1285 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1286 if (! empty($allprojectforuser)) {
1287 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1288 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1290 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' => 1);
1291 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' => 1);
1293 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1294 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1295 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1296 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1298 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' => 1);
1299 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' => 1,
'enabled' => isModEnabled(
"salaries"));
1300 $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));
1302 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1305 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
1308 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1309 $param .=
'&contextpage=' . urlencode($contextpage);
1311 if ($limit > 0 && $limit != $conf->liste_limit) {
1312 $param .=
'&limit='.((int) $limit);
1314 if ($search_month > 0) {
1315 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1317 if ($search_year > 0) {
1318 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1320 if (!empty($search_user)) {
1321 $param .=
'&search_user='.urlencode($search_user);
1323 if ($search_task_ref !=
'') {
1324 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1326 if ($search_company !=
'') {
1327 $param .=
'&$search_company=' . urlencode($search_company);
1329 if ($search_company_alias !=
'') {
1330 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1332 if ($search_project_ref !=
'') {
1333 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1335 if ($search_project_label !=
'') {
1336 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1338 if ($search_task_label !=
'') {
1339 $param .=
'&search_task_label=' . urlencode($search_task_label);
1341 if ($search_note !=
'') {
1342 $param .=
'&search_note=' . urlencode($search_note);
1344 if ($search_duration !=
'') {
1345 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1347 if ($optioncss !=
'') {
1348 $param .=
'&optioncss=' . urlencode($optioncss);
1350 if ($search_date_startday) {
1351 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1353 if ($search_date_startmonth) {
1354 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1356 if ($search_date_startyear) {
1357 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1359 if ($search_date_endday) {
1360 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1362 if ($search_date_endmonth) {
1363 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1365 if ($search_date_endyear) {
1366 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1368 if ($search_timespent_starthour) {
1369 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1371 if ($search_timespent_startmin) {
1372 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1374 if ($search_timespent_endhour) {
1375 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1377 if ($search_timespent_endmin) {
1378 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1382 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
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";
1588 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1589 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1590 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1594 $parameters = array();
1595 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1596 $sql .= $hookmanager->resPrint;
1597 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1601 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1602 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1603 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1604 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1605 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1606 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1607 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1608 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1609 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1612 $parameters = array();
1613 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1614 $sql .= $hookmanager->resPrint;
1615 $sql .=
" WHERE elementtype = 'task'";
1616 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1617 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1621 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1622 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1624 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1626 $sql .=
" AND t.fk_element =".((int)
$object->id);
1627 } elseif (!empty($projectidforalltimes)) {
1629 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1630 } elseif (!empty($allprojectforuser)) {
1632 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1633 $search_user = $user->id;
1635 if ($search_user > 0) {
1636 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1643 if ($search_task_ref) {
1646 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1647 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1649 if ($search_company) {
1652 if ($search_company_alias) {
1656 if ($search_project_ref) {
1659 if ($search_project_label) {
1662 if ($search_task_label) {
1665 if ($search_user > 0) {
1668 if (!empty($search_product_ref)) {
1671 if ($search_valuebilled ==
'1') {
1672 $sql .=
' AND t.invoice_id > 0';
1674 if ($search_valuebilled ==
'0') {
1675 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1678 if ($search_date_start) {
1679 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1681 if ($search_date_end) {
1682 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1685 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1686 if ($search_timespent_starthour || $search_timespent_startmin) {
1687 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1688 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1689 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1692 if ($search_timespent_endhour || $search_timespent_endmin) {
1693 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1694 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1695 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1699 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1702 $extrafieldsobjectkey =
'projet_task';
1703 $extrafieldsobjectprefix =
'efpt.';
1704 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1707 $parameters = array();
1708 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1709 $sql .= $hookmanager->resPrint;
1712 $nbtotalofrecords =
'';
1715 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1716 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1717 $resql = $db->query($sqlforcount);
1719 $objforcount = $db->fetch_object($resql);
1720 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1725 if (($page * $limit) > $nbtotalofrecords) {
1733 $sql .= $db->order($sortfield, $sortorder);
1735 $sql .= $db->plimit($limit + 1, $offset);
1738 $resql = $db->query($sql);
1744 $num = $db->num_rows($resql);
1747 if (!empty($projectidforalltimes)) {
1748 print
'<!-- List of time spent for project -->' .
"\n";
1750 $title = $langs->trans(
"ListTaskTimeUserProject");
1752 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1754 print
'<!-- List of time spent -->' .
"\n";
1756 $title = $langs->trans(
"ListTaskTimeForTask");
1758 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1763 $row = $db->fetch_object($resql);
1775 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1776 print
'<!-- table to add time spent -->' .
"\n";
1778 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
1781 print
'<div class="div-table-responsive-no-min">';
1782 print
'<table class="noborder nohover centpercent">';
1784 print
'<tr class="liste_titre">';
1785 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1786 if (!empty($allprojectforuser)) {
1787 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1790 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1792 print
'<td>' . $langs->trans(
"By") .
'</td>';
1793 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1794 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1795 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1799 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1800 print
'<td>'.$langs->trans(
"Product").
'</td>';
1804 $parameters = array(
'mode' =>
'create');
1805 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1806 print $hookmanager->resPrint;
1810 print
'<tr class="oddeven nohover">';
1813 print
'<td class="maxwidthonsmartphone">';
1815 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1818 if (!empty($allprojectforuser)) {
1827 print
'<td class="maxwidthonsmartphone">';
1828 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1833 print
'<td class="maxwidthonsmartphone nowraponall">';
1834 $contactsofproject = $projectstatic->getListContactId(
'internal');
1835 if (count($contactsofproject) > 0) {
1836 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1837 if (in_array($user->id, $contactsofproject)) {
1838 $userid = $user->id;
1840 $userid = $contactsofproject[0];
1843 if ($projectstatic->public) {
1844 $contactsofproject = array();
1846 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1849 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1856 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1860 print
'<td class="nowraponall">';
1861 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1862 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1863 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1865 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1869 print
'<td class="nowrap">';
1870 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1878 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1879 print
'<td class="nowraponall">';
1881 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);
1887 $parameters = array(
'mode' =>
'create');
1888 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1889 print $hookmanager->resPrint;
1891 print
'<td class="center">';
1892 $form->buttonsSaveCancel();
1893 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1894 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1903 $moreforfilter =
'';
1905 $parameters = array();
1906 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1907 if (empty($reshook)) {
1908 $moreforfilter .= $hookmanager->resPrint;
1910 $moreforfilter = $hookmanager->resPrint;
1913 if (!empty($moreforfilter)) {
1914 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1915 print $moreforfilter;
1919 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1920 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1921 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1923 print
'<div class="div-table-responsive">';
1924 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1928 print
'<tr class="liste_titre_filter">';
1931 print
'<td class="liste_titre center">';
1932 $searchpicto = $form->showFilterButtons(
'left');
1937 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1938 print
'<td class="liste_titre left">';
1939 print
'<div class="nowrapfordate">';
1940 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1942 print
'<div class="nowrapfordate">';
1943 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1948 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1949 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1953 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1954 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1957 if (!empty($allprojectforuser)) {
1958 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1959 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1961 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1962 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1966 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1967 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1968 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1970 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1971 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1975 if (!empty($arrayfields[
'author'][
'checked'])) {
1976 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>';
1979 if (!empty($arrayfields[
't.note'][
'checked'])) {
1980 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1983 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1985 print
'<td class="liste_titre right">';
1987 $durationtouse_start =
'';
1988 if ($search_timespent_starthour || $search_timespent_startmin) {
1989 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1991 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1992 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1995 $durationtouse_end =
'';
1996 if ($search_timespent_endhour || $search_timespent_endmin) {
1997 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1999 print
'<div class="nowraponall">' . $langs->trans(
'to') .
' ';
2000 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2006 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2007 print
'<td class="liste_titre right"></td>';
2010 if (!empty($arrayfields[
'value'][
'checked'])) {
2011 print
'<td class="liste_titre"></td>';
2014 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2015 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2019 $extrafieldsobjectkey =
'projet_task';
2020 $extrafieldsobjectprefix =
'ef.';
2021 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2023 $parameters = array(
'arrayfields' => $arrayfields);
2024 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2025 print $hookmanager->resPrint;
2028 print
'<td class="liste_titre center">';
2029 $searchpicto = $form->showFilterButtons();
2033 print
'</tr>' .
"\n";
2036 $totalarray = array();
2037 $totalarray[
'nbfield'] = 0;
2041 print
'<tr class="liste_titre">';
2043 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2044 $totalarray[
'nbfield']++;
2046 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2047 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2048 $totalarray[
'nbfield']++;
2050 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2051 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2052 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2055 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2056 $totalarray[
'nbfield']++;
2058 if (!empty($allprojectforuser)) {
2059 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2061 $totalarray[
'nbfield']++;
2063 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2064 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2065 $totalarray[
'nbfield']++;
2068 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2069 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2070 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2071 $totalarray[
'nbfield']++;
2073 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2074 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2075 $totalarray[
'nbfield']++;
2078 if (!empty($arrayfields[
'author'][
'checked'])) {
2079 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2080 $totalarray[
'nbfield']++;
2082 if (!empty($arrayfields[
't.note'][
'checked'])) {
2083 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2084 $totalarray[
'nbfield']++;
2086 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2087 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2088 $totalarray[
'nbfield']++;
2090 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2091 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2092 $totalarray[
'nbfield']++;
2095 if (!empty($arrayfields[
'value'][
'checked'])) {
2096 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2097 $totalarray[
'nbfield']++;
2099 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2100 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2101 $totalarray[
'nbfield']++;
2104 $extrafieldsobjectkey =
'projet_task';
2105 $extrafieldsobjectprefix =
'ef.';
2106 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2108 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2109 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2110 print $hookmanager->resPrint;
2112 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2113 $totalarray[
'nbfield']++;
2117 $tasktmp =
new Task($db);
2118 $tmpinvoice =
new Facture($db);
2121 $param .=
'&page='.((int) $page);
2123 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2127 $savnbfield = $totalarray[
'nbfield'];
2128 $totalarray = array();
2129 $totalarray[
'nbfield'] = 0;
2131 foreach ($tasks as $task_time) {
2136 $date1 = $db->jdate($task_time->element_date);
2137 $date2 = $db->jdate($task_time->element_datehour);
2141 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2145 print
'<td class="center nowraponall">';
2146 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2147 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2148 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2150 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2151 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2152 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2153 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' :
'').
'">';
2154 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2158 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' :
'') .
'">';
2159 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2163 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' :
'').
'">';
2164 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2167 if ($massactionbutton || $massaction) {
2169 if (in_array($task_time->rowid, $arrayofselected)) {
2173 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2179 $totalarray[
'nbfield']++;
2184 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2185 print
'<td class="nowrap">';
2186 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2187 if (empty($task_time->element_date_withhour)) {
2188 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2190 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2193 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2197 $totalarray[
'nbfield']++;
2202 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2203 print
'<td class="tdoverflowmax125">';
2204 if ($task_time->fk_soc > 0) {
2205 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2206 $tmpsociete =
new Societe($db);
2207 $tmpsociete->fetch($task_time->fk_soc);
2208 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2210 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2212 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2216 $totalarray[
'nbfield']++;
2221 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2222 if ($task_time->fk_soc > 0) {
2223 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2224 $tmpsociete =
new Societe($db);
2225 $tmpsociete->fetch($task_time->fk_soc);
2226 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2228 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2230 $valtoshow = $tmpsociete->name_alias;
2232 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2236 $totalarray[
'nbfield']++;
2241 if (!empty($allprojectforuser)) {
2242 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2243 print
'<td class="nowraponall">';
2244 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2245 $tmpproject =
new Project($db);
2246 $tmpproject->fetch($task_time->fk_projet);
2247 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2249 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2251 print $tmpproject->getNomUrl(1);
2254 $totalarray[
'nbfield']++;
2257 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2258 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2259 $tmpproject =
new Project($db);
2260 $tmpproject->fetch($task_time->fk_projet);
2261 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2263 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2265 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2269 $totalarray[
'nbfield']++;
2275 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2276 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2277 print
'<td class="nowrap">';
2278 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2279 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth250', $projectstatic->id,
'');
2281 $tasktmp->id = $task_time->fk_element;
2282 $tasktmp->ref = $task_time->ref;
2283 $tasktmp->label = $task_time->label;
2284 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2288 $totalarray[
'nbfield']++;
2291 } elseif ($action !==
'createtime') {
2292 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
2296 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2297 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2298 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).
'">';
2302 $totalarray[
'nbfield']++;
2308 if (!empty($arrayfields[
'author'][
'checked'])) {
2309 print
'<td class="minwidth100 tdoverflowmax125">';
2310 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2313 $object->fetch($task_time->fk_element);
2315 $contactsoftask =
$object->getListContactId(
'internal');
2316 if (!in_array($task_time->fk_user, $contactsoftask)) {
2317 $contactsoftask[] = $task_time->fk_user;
2319 if (count($contactsoftask) > 0) {
2320 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2321 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2323 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2326 $userstatic->id = $task_time->fk_user;
2327 $userstatic->lastname = $task_time->lastname;
2328 $userstatic->firstname = $task_time->firstname;
2329 $userstatic->photo = $task_time->photo;
2330 $userstatic->gender = $task_time->gender;
2331 $userstatic->status = $task_time->user_status;
2333 print $userstatic->getNomUrl(-1);
2337 $totalarray[
'nbfield']++;
2342 if (!empty($arrayfields[
't.note'][
'checked'])) {
2343 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2344 print
'<td class="small">';
2345 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2348 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2353 $totalarray[
'nbfield']++;
2355 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2356 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2360 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2361 print
'<td class="right nowraponall">';
2362 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2363 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2364 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2370 $totalarray[
'nbfield']++;
2373 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2375 if (empty($totalarray[
'val'][
't.element_duration'])) {
2376 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2378 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2381 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2383 if (empty($totalarray[
'totalduration'])) {
2384 $totalarray[
'totalduration'] = $task_time->element_duration;
2386 $totalarray[
'totalduration'] += $task_time->element_duration;
2391 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2392 print
'<td class="nowraponall">';
2393 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2395 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);
2396 } elseif (!empty($task_time->fk_product)) {
2398 $resultFetch = $product->fetch($task_time->fk_product);
2399 if ($resultFetch < 0) {
2402 print $product->getNomUrl(1);
2407 $totalarray[
'nbfield']++;
2412 if (!empty($arrayfields[
'value'][
'checked'])) {
2413 $langs->load(
"salaries");
2414 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2416 print
'<td class="nowraponall right">';
2417 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2418 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2422 $totalarray[
'nbfield']++;
2425 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2427 if (empty($totalarray[
'val'][
'value'])) {
2428 $totalarray[
'val'][
'value'] = $value;
2430 $totalarray[
'val'][
'value'] += $value;
2433 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2435 if (empty($totalarray[
'totalvalue'])) {
2436 $totalarray[
'totalvalue'] = $value;
2438 $totalarray[
'totalvalue'] += $value;
2443 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2444 print
'<td class="center">';
2446 if ($projectstatic->usage_bill_time) {
2447 if ($task_time->invoice_id) {
2448 $result = $tmpinvoice->fetch($task_time->invoice_id);
2450 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2451 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2453 print $tmpinvoice->getNomUrl(1);
2454 if (!empty($task_time->invoice_line_id)) {
2456 $invoiceLine->fetch($task_time->invoice_line_id);
2457 if (!empty($invoiceLine->id)) {
2458 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2459 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2465 print $langs->trans(
"No");
2468 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2473 $totalarray[
'nbfield']++;
2479 $extrafieldsobjectkey =
'projet_task';
2480 $extrafieldsobjectprefix =
'ef.';
2481 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2484 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2485 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2486 print $hookmanager->resPrint;
2490 print
'<td class="center nowraponall">';
2491 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2492 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2493 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2495 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2496 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2497 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2498 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' :
'').
'">';
2499 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2503 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' :
'') .
'">';
2504 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2508 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' :
'').
'">';
2509 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2512 if ($massactionbutton || $massaction) {
2514 if (in_array($task_time->rowid, $arrayofselected)) {
2518 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2524 $totalarray[
'nbfield']++;
2533 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2534 print
'<!-- first line -->';
2535 print
'<tr class="oddeven">';
2543 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2544 print
'<td class="nowrap">';
2545 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2546 if (empty($task_time->element_date_withhour)) {
2547 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2549 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2552 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2558 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2559 print
'<td class="nowrap">';
2564 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2565 print
'<td class="nowrap">';
2570 if (!empty($allprojectforuser)) {
2571 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2572 print
'<td class="nowrap">';
2578 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2579 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2580 print
'<td class="nowrap">';
2581 $tasktmp->id = $task_time->fk_element;
2582 $tasktmp->ref = $task_time->ref;
2583 $tasktmp->label = $task_time->label;
2584 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2590 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2591 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2592 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2599 if (!empty($arrayfields[
'author'][
'checked'])) {
2600 print
'<td class="nowraponall">';
2601 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2603 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2606 $contactsoftask =
$object->getListContactId(
'internal');
2607 if (!in_array($task_time->fk_user, $contactsoftask)) {
2608 $contactsoftask[] = $task_time->fk_user;
2610 if (count($contactsoftask) > 0) {
2611 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2612 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2614 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2617 $userstatic->id = $task_time->fk_user;
2618 $userstatic->lastname = $task_time->lastname;
2619 $userstatic->firstname = $task_time->firstname;
2620 $userstatic->photo = $task_time->photo;
2621 $userstatic->status = $task_time->user_status;
2622 print $userstatic->getNomUrl(-1);
2628 if (!empty($arrayfields[
't.note'][
'checked'])) {
2629 print
'<td class="tdoverflowmax300">';
2630 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2631 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2636 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2637 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2641 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2642 print
'<td class="right">';
2643 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2644 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2645 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2653 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2654 print
'<td class="nowraponall tdoverflowmax125">';
2659 if (!empty($arrayfields[
'value'][
'checked'])) {
2660 print
'<td class="right">';
2661 print
'<span class="amount">';
2662 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2663 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2669 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2670 print
'<td class="right">';
2671 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2672 if (isset($task_time->total_ht)) {
2673 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2680 $extrafieldsobjectkey =
'projet_task';
2681 $extrafieldsobjectprefix =
'ef.';
2682 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2685 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2686 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2687 print $hookmanager->resPrint;
2691 print
'<td class="center nowraponall">';
2700 print
'<!-- second line --><tr class="oddeven">';
2704 print
'<td class="center nowraponall">';
2709 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2710 print
'<td class="nowrap">';
2711 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2712 if (empty($task_time->element_date_withhour)) {
2713 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2715 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2718 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2724 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2725 print
'<td class="nowrap">';
2730 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2731 print
'<td class="nowrap">';
2736 if (!empty($allprojectforuser)) {
2737 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2738 print
'<td class="nowrap">';
2744 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2745 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2746 print
'<td class="nowrap">';
2747 $tasktmp->id = $task_time->fk_element;
2748 $tasktmp->ref = $task_time->ref;
2749 $tasktmp->label = $task_time->label;
2750 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2756 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2757 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2758 print
'<td class="nowrap">';
2765 if (!empty($arrayfields[
'author'][
'checked'])) {
2766 print
'<td class="nowraponall tdoverflowmax100">';
2767 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2769 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2772 $contactsoftask =
$object->getListContactId(
'internal');
2773 if (!in_array($task_time->fk_user, $contactsoftask)) {
2774 $contactsoftask[] = $task_time->fk_user;
2776 if (count($contactsoftask) > 0) {
2777 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2778 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2780 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2783 $userstatic->id = $task_time->fk_user;
2784 $userstatic->lastname = $task_time->lastname;
2785 $userstatic->firstname = $task_time->firstname;
2786 $userstatic->photo = $task_time->photo;
2787 $userstatic->status = $task_time->user_status;
2788 print $userstatic->getNomUrl(-1);
2794 if (!empty($arrayfields[
't.note'][
'checked'])) {
2795 print
'<td class="small tdoverflowmax300"">';
2796 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2797 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2802 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2803 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2807 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2808 print
'<td class="right">';
2809 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2810 print
'<input type="hidden" name="old_duration_2" value="0">';
2811 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2819 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2820 print
'<td class="nowraponall tdoverflowmax125">';
2825 if (!empty($arrayfields[
'value'][
'checked'])) {
2826 print
'<td class="right">';
2827 print
'<span class="amount">';
2829 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2835 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2836 print
'<td class="right">';
2837 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2838 if (isset($task_time->total_ht)) {
2839 print
'<span class="amount">';
2840 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2848 $extrafieldsobjectkey =
'projet_task';
2849 $extrafieldsobjectprefix =
'ef.';
2850 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2853 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2854 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2855 print $hookmanager->resPrint;
2859 print
'<td class="center nowraponall">';
2871 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2872 print
'<tr class="liste_total">';
2874 while ($i < $totalarray[
'nbfield']) {
2877 if ($num < $limit && empty($offset)) {
2878 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2880 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2882 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2883 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2884 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
2885 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2894 if (!count($tasks)) {
2895 $totalnboffields = 1;
2896 foreach ($arrayfields as $value) {
2897 if (!empty($value[
'checked'])) {
2901 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2902 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2906 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2907 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2908 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.