36require
'../../main.inc.php';
46@phan-var-force ?string $uploaddir
48require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
52require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
53require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
56require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
59$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
61 $langsLoad[] =
'eventorganization';
64$langs->loadLangs($langsLoad);
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array:int');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
73$optioncss =
GETPOST(
'optioncss',
'alpha');
74$mode =
GETPOST(
'mode',
'alpha');
81$project_ref =
GETPOST(
'project_ref',
'alpha');
87$search_date_startday =
GETPOSTINT(
'search_date_startday');
88$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
89$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
90$search_date_endday =
GETPOSTINT(
'search_date_endday');
91$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
92$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
93$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
94$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
95$search_note =
GETPOST(
'search_note',
'alpha');
96$search_duration =
GETPOST(
'search_duration',
'alpha');
97$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
98$search_task_label =
GETPOST(
'search_task_label',
'alpha');
99$search_user =
GETPOST(
'search_user',
'intcomma');
100$search_valuebilled =
GETPOST(
'search_valuebilled',
'intcomma');
101$search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
102$search_company =
GETPOST(
'$search_company',
'alpha');
103$search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
104$search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
105$search_project_label =
GETPOST(
'$search_project_label',
'alpha');
106$search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
107$search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
108$search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
109$search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
112$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
113$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
115if (empty($page) || $page == -1) {
118$offset = $limit * $page;
119$pageprev = $page - 1;
120$pagenext = $page + 1;
122 $sortfield =
't.element_date,t.element_datehour,t.rowid';
125 $sortorder =
'DESC,DESC,DESC';
128$childids = $user->getAllChildIds(1);
132$hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
142$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
145if ($id > 0 || $ref) {
154if (!$user->hasRight(
'projet',
'lire')) {
163 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
164 $search_user = $user->id;
175if (
GETPOST(
'cancel',
'alpha')) {
178if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
182$parameters = array(
'socid' => $socid,
'projectid' => $projectid);
183$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
188include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
191if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
196 $search_duration =
'';
197 $search_date_startday =
'';
198 $search_date_startmonth =
'';
199 $search_date_startyear =
'';
200 $search_date_endday =
'';
201 $search_date_endmonth =
'';
202 $search_date_endyear =
'';
203 $search_date_start =
'';
204 $search_date_end =
'';
205 $search_task_ref =
'';
206 $search_company =
'';
207 $search_company_alias =
'';
208 $search_project_ref =
'';
209 $search_project_label =
'';
210 $search_task_label =
'';
212 $search_valuebilled =
'';
213 $search_product_ref =
'';
215 $search_array_options = array();
216 $search_timespent_starthour =
'';
217 $search_timespent_startmin =
'';
218 $search_timespent_endhour =
'';
219 $search_timespent_endmin =
'';
223if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
224 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
225 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
226 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
227 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
231 $langs->load(
"errors");
232 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
241 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
242 $action =
'createtime';
252 if (empty(
$object->project->status)) {
253 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
254 $action =
'createtime';
265 $object->timespent_withhour = 1;
268 $object->timespent_withhour = 0;
273 $result =
$object->addTimeSpent($user);
284 $action =
'createtime';
288if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
289 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
290 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
301 $object->fetchTimeSpent($lineid);
302 $timespentoldowner =
$object->timespent_fk_user;
306 $object->fetch($id_temp, $ref);
308 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
312 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
314 $object->timespent_withhour = 1;
315 } elseif (!empty($timespent_date)) {
316 $object->timespent_date = $timespent_date;
317 $object->timespent_withhour = 0;
328 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
329 $result =
$object->updateTimeSpent($user);
341 $timespentoldowner =
$object->timespent_fk_user;
343 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
348 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
351 $object->timespent_withhour = 1;
352 } elseif (!empty($timespent_date)) {
353 $object->timespent_date = $timespent_date;
354 $object->timespent_datehour = $timespent_date;
355 $object->timespent_withhour = 0;
368 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
369 $result =
$object->updateTimeSpent($user);
384if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
387 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
388 $result =
$object->delTimeSpent($user);
391 $langs->load(
"errors");
402if (!empty($project_ref) && !empty($withproject)) {
403 if ($projectstatic->fetch(0, $project_ref) > 0) {
404 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
405 if (count($tasksarray) > 0) {
406 $id = $tasksarray[0]->id;
408 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
415$projectidforalltimes = 0;
417 $projectidforalltimes =
GETPOSTINT(
'projectid');
419 $result = $projectstatic->fetch($projectidforalltimes);
420 if (!empty($projectstatic->socid)) {
421 $projectstatic->fetch_thirdparty();
423 $res = $projectstatic->fetch_optionals();
426 if ($action ==
'update_extras' && $projectstatic->id > 0) {
427 $permissiontoeditextra = $user->hasRight(
'projet',
'creer');
428 if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[$projectstatic->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
429 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[$projectstatic->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
432 if ($permissiontoeditextra) {
433 $projectstatic->oldcopy =
dol_clone($projectstatic, 2);
435 $attribute_name =
GETPOST(
'attribute',
'aZ09');
438 $ret = $extrafields->setOptionalsFromPost(
null, $projectstatic, $attribute_name);
444 $result = $projectstatic->updateExtraField($attribute_name,
'PROJECT_MODIFY');
453 $action =
'edit_extras';
456} elseif (
GETPOST(
'project_ref',
'alpha')) {
457 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
458 $projectidforalltimes = $projectstatic->id;
462 $result = $projectstatic->fetch(
$object->fk_project);
465$allprojectforuser = 0;
467if ($id <= 0 && $projectidforalltimes == 0) {
468 $allprojectforuser = $user->id;
471if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
472 if (!empty($projectstatic->socid)) {
473 $projectstatic->fetch_thirdparty();
476 if (!($projectstatic->thirdparty->id > 0)) {
477 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
479 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
480 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
481 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
493 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
496 $prodDurationHoursBase = 1.0;
497 $product_data_cache = array();
499 $result = $tmpproduct->fetch($idprod);
505 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
506 if ($prodDurationHoursBase < 0) {
508 $langs->load(
"errors");
512 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
514 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
515 $txtva = $dataforprice[
'tva_tx'];
516 $localtax1 =
get_localtax($txtva, 1, $projectstatic->thirdparty);
517 $localtax2 =
get_localtax($txtva, 2, $projectstatic->thirdparty);
519 $prodDurationHoursBase = 1;
527 $tmpinvoice->socid = $projectstatic->thirdparty->id;
529 $tmpinvoice->fk_project = $projectstatic->id;
530 $tmpinvoice->cond_reglement_id = $condidproject;
531 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
532 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
535 $tmpinvoice->fetch($invoiceToUse);
537 $result = $tmpinvoice->create($user);
545 if ($generateinvoicemode ==
'onelineperuser') {
546 $arrayoftasks = array();
547 foreach ($toselect as $key => $value) {
549 $object->fetchTimeSpent($value);
550 if (!array_key_exists(
$object->timespent_fk_user, $arrayoftasks)) {
551 $arrayoftasks[
$object->timespent_fk_user] = [
552 (int)
$object->timespent_fk_product => [
'timespent' => 0,
'totalvaluetodivideby3600' => 0]
555 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
556 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
559 foreach ($arrayoftasks as $userid => $data) {
560 $fuser->fetch($userid);
561 $username = $fuser->getFullName($langs);
563 foreach ($data as $fk_product => $timespent_data) {
565 $qtyhour = $timespent_data[
'timespent'] / 3600;
572 } elseif ($idprod <= 0) {
575 $pu_ht = $fuser->thm;
580 if ($timespent_data[
'timespent']) {
581 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
586 $prodDurationHours = $prodDurationHoursBase;
587 $idprodline = $idprod;
590 $localtax1line = $localtax1;
591 $localtax2line = $localtax2;
594 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
595 if (!array_key_exists($fk_product, $product_data_cache)) {
596 $result = $tmpproduct->fetch($fk_product);
601 $prodDurationHours = $tmpproduct->getProductDurationHours();
602 if ($prodDurationHours < 0) {
604 $langs->load(
"errors");
610 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
612 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
613 $txtvaline = $dataforprice[
'tva_tx'];
614 $localtax1line = $dataforprice[
'localtax1'];
615 $localtax2line = $dataforprice[
'localtax2'];
617 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
619 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
620 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
621 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
622 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
623 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
625 $idprodline = $fk_product;
632 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice").
' - '.$username .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
639 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
640 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
641 $result =
$db->query($sql);
649 } elseif ($generateinvoicemode ==
'onelineperperiod') {
650 $arrayoftasks = array();
652 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
653 foreach ($toselect as $key => $value) {
655 $object->fetchTimeSpent($value);
660 $fuser->fetch(
$object->timespent_fk_user);
661 $username = $fuser->getFullName($langs);
663 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
664 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
665 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
668 if (!empty($withdetail)) {
669 if (!empty(
$object->timespent_withhour)) {
676 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
677 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
680 $pu_ht_saved = $pu_ht;
681 foreach ($arrayoftasks as $timespent_id => $value) {
682 $pu_ht = $pu_ht_saved;
683 $userid = $value[
'user'];
687 $qtyhour = $value[
'timespent'] / 3600;
691 if ($value[
'timespent']) {
692 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
697 $prodDurationHours = $prodDurationHoursBase;
698 $idprodline = $idprod;
701 $localtax1line = $localtax1;
702 $localtax2line = $localtax2;
704 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
705 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
706 $result = $tmpproduct->fetch($value[
'fk_product']);
711 $prodDurationHours = $tmpproduct->getProductDurationHours();
712 if ($prodDurationHours < 0) {
714 $langs->load(
"errors");
720 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
722 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
723 $txtvaline = $dataforprice[
'tva_tx'];
724 $localtax1line = $dataforprice[
'localtax1'];
725 $localtax2line = $dataforprice[
'localtax2'];
727 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
729 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
730 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
731 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
732 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
733 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
735 $idprodline = $value[
'fk_product'];
741 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
'',
'', 0, 0, 0,
'HT', 0,
Product::TYPE_SERVICE);
749 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
750 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
751 $result =
$db->query($sql);
758 } elseif ($generateinvoicemode ==
'onelinepertask') {
759 $arrayoftasks = array();
760 foreach ($toselect as $key => $value) {
762 $object->fetchTimeSpent($value);
764 if (!isset($arrayoftasks[
$object->id][(
int)
$object->timespent_fk_product])) {
765 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product] = array(
'timespent' => 0,
'totalvaluetodivideby3600' => 0,
'ids' => array());
767 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
768 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
771 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'ids'][] = (
int) $value;
774 foreach ($arrayoftasks as $task_id => $data) {
776 $ftask->fetch($task_id);
778 foreach ($data as $fk_product => $timespent_data) {
779 $qtyhour = $timespent_data[
'timespent'] / 3600;
783 $prodDurationHours = $prodDurationHoursBase;
784 $idprodline = $idprod;
787 $localtax1line = $localtax1;
788 $localtax2line = $localtax2;
790 if (!empty($fk_product) && $fk_product !== $idprod) {
791 if (!array_key_exists($fk_product, $product_data_cache)) {
792 $result = $tmpproduct->fetch($fk_product);
797 $prodDurationHours = $tmpproduct->getProductDurationHours();
798 if ($prodDurationHours < 0) {
800 $langs->load(
"errors");
806 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
808 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
809 $txtvaline = $dataforprice[
'tva_tx'];
810 $localtax1line = $dataforprice[
'localtax1'];
811 $localtax2line = $dataforprice[
'localtax2'];
813 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
815 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
816 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
817 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
818 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
819 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
821 $idprodline = $fk_product;
825 if ($idprodline > 0) {
827 $pu_ht_for_task = $pu_htline;
830 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
832 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
838 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
840 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
846 $lineName = $ftask->ref .
' - ' . $ftask->label;
847 $lineid = $tmpinvoice->addline($lineName, (
float) $pu_ht_for_task, (
float)
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), (float) $remiseproject,
$date_start, $date_end, 0, 0, 0,
'HT', 0, 1, -1, 0,
'', 0, 0, 0, $pa_ht);
856 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
857 $sql .=
' WHERE rowid IN (' .
$db->sanitize(implode(
',', $timespent_data[
'ids'])) .
')';
858 $result =
$db->query($sql);
871 $urltoinvoice = $tmpinvoice->getNomUrl(0);
872 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
873 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
883if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
884 $langs->load(
'interventions');
886 if (!empty($projectstatic->socid)) {
887 $projectstatic->fetch_thirdparty();
890 if (!($projectstatic->thirdparty->id > 0)) {
891 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
893 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
894 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
895 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
898 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
907 $tmpinter->socid = $projectstatic->thirdparty->id;
909 $tmpinter->fk_project = $projectstatic->id;
910 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->description :
'');
913 $tmpinter->fetch($interToUse);
915 $result = $tmpinter->create($user);
923 $arrayoftasks = array();
924 foreach ($toselect as $key => $value) {
926 $object->fetchTimeSpent($value);
929 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
930 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
931 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
932 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
935 foreach ($arrayoftasks as $timespent_id => $value) {
937 $ftask->fetch($value[
'id']);
939 $qtyhour = $value[
'timespent'] / 3600;
943 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
948 $timespent->fetch($timespent_id);
949 $timespent->intervention_id = $tmpinter->id;
950 $timespent->intervention_line_id = $lineid;
951 $result = $timespent->update($user);
961 $urltointer = $tmpinter->getNomUrl(0);
962 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
963 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
985$arrayofselected = is_array($toselect) ? $toselect : array();
987$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
988if (!empty($withproject)) {
989 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
993llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
996$param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
998 $param .=
'&search_user=' . ((int) $search_user);
1001 $param .=
'&search_month=' . ((int) $search_month);
1004 $param .=
'&search_year=' . ((int) $search_year);
1008if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
1010 if ($projectidforalltimes > 0) {
1011 $result = $projectstatic->fetch($projectidforalltimes);
1012 if (!empty($projectstatic->socid)) {
1013 $projectstatic->fetch_thirdparty();
1015 $res = $projectstatic->fetch_optionals();
1016 } elseif (
$object->fetch($id, $ref) > 0) {
1020 $result = $projectstatic->fetch(
$object->fk_project);
1021 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
1022 $projectstatic->fetchComments();
1024 if (!empty($projectstatic->socid)) {
1025 $projectstatic->fetch_thirdparty();
1027 $res = $projectstatic->fetch_optionals();
1029 $object->project = clone $projectstatic;
1032 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
1033 $linktocreatetime =
'';
1035 if ($projectstatic->id > 0) {
1038 if (empty($id) || $tab ==
'timespent') {
1045 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
1049 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1051 $morehtmlref =
'<div class="refidno">';
1053 $morehtmlref .= $projectstatic->title;
1055 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
1056 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
1058 $morehtmlref .=
'</div>';
1061 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1062 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
1063 $projectstatic->next_prev_filter =
"rowid:IN:" .
$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1066 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1068 print
'<div class="fichecenter">';
1069 print
'<div class="fichehalfleft">';
1070 print
'<div class="underbanner clearboth"></div>';
1072 print
'<table class="border tableforfield centpercent">';
1076 print
'<tr><td class="tdtop">';
1077 print $langs->trans(
"Usage");
1081 print
'<input type="checkbox" disabled name="usage_opportunity"' . (
GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1082 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1083 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1087 print
'<input type="checkbox" disabled name="usage_task"' . (
GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1088 $htmltext = $langs->trans(
"ProjectFollowTasks");
1089 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1093 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"' :
'')) .
'"> ';
1094 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1095 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1099 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"' :
'')) .
'"> ';
1100 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1101 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1107 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1108 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1109 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1114 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1116 print($start ? $start :
'?');
1119 print($end ? $end :
'?');
1120 if ($projectstatic->hasDelay()) {
1126 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1127 if ($projectstatic->public) {
1128 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1129 print $langs->trans(
'SharedProject');
1131 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1132 print $langs->trans(
'PrivateProject');
1143 $forcefieldid =
'projectid';
1144 $moreparam =
'&withproject=1';
1145 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1146 unset($forcefieldid, $moreparam);
1152 print
'<div class="fichehalfright">';
1153 print
'<div class="underbanner clearboth"></div>';
1155 print
'<table class="border tableforfield centpercent">';
1159 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1160 print $form->showCategories($projectstatic->id,
'project', 1);
1165 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1166 if ($projectstatic->description) {
1167 print
'<tr><td class="nottitleforfield" colspan="2">';
1168 print
'<div class="longmessagecut">';
1179 print
'<div class="clearboth"></div>';
1187 $linktocreatetimeBtnStatus = 0;
1188 $linktocreatetimeUrl =
'';
1189 $linktocreatetimeHelpText =
'';
1190 if ($user->hasRight(
'projet',
'time')) {
1191 if ($projectstatic->public || $userRead > 0) {
1192 $linktocreatetimeBtnStatus = 1;
1194 if (!empty($projectidforalltimes)) {
1196 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1197 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1200 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1201 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1204 $linktocreatetimeBtnStatus = -2;
1205 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1208 $linktocreatetimeBtnStatus = -2;
1209 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1212 $paramsbutton = array(
'morecss' =>
'reposition');
1213 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1216 $massactionbutton =
'';
1217 $arrayofmassactions = array();
1219 if ($projectstatic->id > 0) {
1221 if ($projectstatic->usage_bill_time) {
1222 $arrayofmassactions = array(
1223 'generateinvoice' => $langs->trans(
"GenerateBill"),
1227 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1228 $langs->load(
"interventions");
1229 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1232 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1233 $arrayofmassactions = array();
1235 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1242 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1244 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1246 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
1247 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1249 if ($action ==
'deleteline') {
1250 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . $param;
1251 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1254 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1255 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1256 $object->next_prev_filter =
"fk_projet:IN:" .
$db->sanitize($projectsListId);
1258 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1264 if (empty($withproject)) {
1265 $morehtmlref .=
'<div class="refidno">';
1266 $morehtmlref .= $langs->trans(
"Project") .
': ';
1267 $morehtmlref .= $projectstatic->getNomUrl(1);
1268 $morehtmlref .=
'<br>';
1271 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1272 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1273 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1275 $morehtmlref .=
'</div>';
1278 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1280 print
'<div class="fichecenter">';
1281 print
'<div class="fichehalfleft">';
1283 print
'<div class="underbanner clearboth"></div>';
1284 print
'<table class="border centpercent tableforfield">';
1287 print
'<tr><td>' . $langs->trans(
"ParentTask") .
'</td><td>';
1288 if (
$object->fk_task_parent > 0) {
1290 $tasktmp->fetch(
$object->fk_task_parent);
1291 print $tasktmp->getNomUrl(1);
1296 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1298 print($start ? $start :
'?');
1301 print($end ? $end :
'?');
1308 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1309 if (
$object->planned_workload) {
1317 print
'<div class="fichehalfright">';
1319 print
'<div class="underbanner clearboth"></div>';
1320 print
'<table class="border tableforfield centpercent">';
1323 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1328 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1329 if (
$object->planned_workload) {
1330 $tmparray =
$object->getSummaryOfTimeSpent();
1331 if ($tmparray[
'total_duration'] > 0) {
1332 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1337 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1348 print
'<div class="clearboth"></div>';
1352 if ($action ==
'deleteline') {
1353 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($projectstatic->id > 0 ?
'projectid=' . $projectstatic->id : (
$object->id > 0 ?
"id=" .
$object->id :
'')) .
'&lineid=' .
GETPOSTINT(
"lineid") . ($withproject ?
'&withproject=1' :
'').
"&contextpage=" . urlencode($contextpage).$param;
1354 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1359 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1360 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1361 if (empty($reshook)) {
1362 $formconfirm .= $hookmanager->resPrint;
1363 } elseif ($reshook > 0) {
1364 $formconfirm = $hookmanager->resPrint;
1368 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1370 $hookmanager->initHooks(array(
'tasktimelist'));
1376 $arrayfields = array();
1377 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1378 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1379 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1380 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1381 if (! empty($allprojectforuser)) {
1382 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1383 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1385 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1386 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1388 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1389 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1390 $arrayfields[
't.tms'] = array(
'label' => $langs->trans(
"DateModification"),
'checked' =>
'0');
1391 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1392 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1394 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1395 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'0',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1396 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int)
isModEnabled(
"salaries"));
1397 $arrayfields[
'valuebilled'] = array(
'label' => $langs->trans(
"Billed"),
'checked' =>
'1',
'enabled' => (
string) (
int) (((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1399 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1404 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1405 $param .=
'&contextpage=' . urlencode($contextpage);
1407 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1408 $param .=
'&limit='.((int) $limit);
1411 $param .=
'&id='.((int) $id);
1413 if ($search_month > 0) {
1414 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1416 if ($search_year > 0) {
1417 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1419 if (!empty($search_user)) {
1420 $param .=
'&search_user='.urlencode($search_user);
1422 if ($search_task_ref !=
'') {
1423 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1425 if ($search_company !=
'') {
1426 $param .=
'&search_company=' . urlencode($search_company);
1428 if ($search_company_alias !=
'') {
1429 $param .=
'&search_company_alias=' . urlencode($search_company_alias);
1431 if ($search_project_ref !=
'') {
1432 $param .=
'&search_project_ref=' . urlencode($search_project_ref);
1434 if ($search_project_label !=
'') {
1435 $param .=
'&search_project_label=' . urlencode($search_project_label);
1437 if ($search_task_label !=
'') {
1438 $param .=
'&search_task_label=' . urlencode($search_task_label);
1440 if ($search_note !=
'') {
1441 $param .=
'&search_note=' . urlencode($search_note);
1443 if ($search_duration !=
'') {
1444 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1446 if ($optioncss !=
'') {
1447 $param .=
'&optioncss=' . urlencode($optioncss);
1449 if ($search_date_startday) {
1450 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1452 if ($search_date_startmonth) {
1453 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1455 if ($search_date_startyear) {
1456 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1458 if ($search_date_endday) {
1459 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1461 if ($search_date_endmonth) {
1462 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1464 if ($search_date_endyear) {
1465 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1467 if ($search_timespent_starthour) {
1468 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1470 if ($search_timespent_startmin) {
1471 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1473 if ($search_timespent_endhour) {
1474 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1476 if ($search_timespent_endmin) {
1477 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1480 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1482 $param .=
'&id=' . urlencode((
string) ($id));
1485 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1488 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1491 $parameters = array(
'param' => &$param);
1492 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1493 $param .= $hookmanager->resPrint;
1495 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1496 if ($optioncss !=
'') {
1497 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1499 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1500 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1501 if ($action ==
'editline') {
1502 print
'<input type="hidden" name="action" value="updateline">';
1503 } elseif ($action ==
'splitline') {
1504 print
'<input type="hidden" name="action" value="updatesplitline">';
1505 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1506 print
'<input type="hidden" name="action" value="addtimespent">';
1507 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1508 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1509 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1510 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1512 print
'<input type="hidden" name="action" value="list">';
1514 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1515 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1519 print
'<input type="hidden" name="id" value="' . ((int) $id) .
'">';
1520 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1521 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1522 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1523 print
'<input type="hidden" name="page_y" value="">';
1526 if ($massaction ==
'generateinvoice') {
1527 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1528 print
'<table class="noborder centerpercent">';
1530 print
'<td class="titlefield">';
1531 print $langs->trans(
'DateInvoice');
1534 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1540 print $langs->trans(
'Mode');
1544 'onelineperuser' =>
'OneLinePerUser',
1545 'onelinepertask' =>
'OneLinePerTask',
1546 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1548 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1549 print
"\n" .
'<script type="text/javascript">';
1551 $(document).ready(function () {
1552 setDetailVisibility();
1553 $("#generateinvoicemode").change(function() {
1554 setDetailVisibility();
1556 function setDetailVisibility() {
1557 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1558 if (generateinvoicemode=="onelineperperiod") {
1559 $("#detail_time_duration").show();
1561 $("#detail_time_duration").hide();
1566 print
'</script>' .
"\n";
1567 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1574 print $langs->trans(
'ServiceToUseOnLines');
1577 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1582 print
'<td class="titlefield">';
1583 print $langs->trans(
'InvoiceToUse');
1586 print $form->selectInvoiceForTimeProject($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1590 print
'<td class="titlefield">';
1591 print $langs->trans(
"CustomerRelativeDiscount");
1594 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1597 print
'<tr class="newinvoicedetail">';
1598 print
'<td class="titlefield">';
1599 print $langs->trans(
"PaymentConditions");
1602 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1616 print
'<div class="center">';
1617 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1618 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1622 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1623 print
'<div class="center">';
1624 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1628 } elseif ($massaction ==
'generateinter') {
1630 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1632 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1634 print
'<table class="noborder centpercent">';
1636 print
'<td class="titlefield">';
1637 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1641 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1646 print
'<div class="center">';
1647 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1648 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1652 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1653 print
'<div class="center">';
1654 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1661 $parameters = array(
1662 'toselect' => $toselect,
1663 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1666 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1670 print $hookmanager->resPrint;
1678 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1679 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1682 if ($projectstatic->usage_bill_time) {
1683 $arrayfields[
'valuebilled'][
'checked'] = 1;
1686 $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,";
1687 $sql .=
" t.fk_product, t.invoice_line_id, t.import_key, t.datec, t.tms,";
1688 $sql .=
" pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet, pt.billable,";
1689 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1690 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1691 $sql .=
" p.fk_soc, s.name_alias";
1692 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1693 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1694 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1698 $parameters = array();
1699 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1700 $sql .= $hookmanager->resPrint;
1701 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1705 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1706 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1708 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1709 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1710 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1711 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1712 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1713 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1716 $parameters = array();
1717 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1718 $sql .= $hookmanager->resPrint;
1719 $sql .=
" WHERE elementtype = 'task'";
1720 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1721 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1725 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1726 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1728 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1730 $sql .=
" AND t.fk_element =".((int)
$object->id);
1731 } elseif (!empty($projectidforalltimes)) {
1733 $sql .=
" AND pt.fk_projet IN (" .
$db->sanitize((
string) $projectidforalltimes) .
")";
1734 } elseif (!empty($allprojectforuser)) {
1736 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1737 $search_user = $user->id;
1739 if ($search_user > 0) {
1740 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1747 if ($search_task_ref) {
1750 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1751 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1753 if ($search_company) {
1756 if ($search_company_alias) {
1760 if ($search_project_ref) {
1763 if ($search_project_label) {
1766 if ($search_task_label) {
1769 if ($search_user > 0) {
1772 if (!empty($search_product_ref)) {
1775 if ($search_valuebilled ==
'1') {
1776 $sql .=
' AND t.invoice_id > 0';
1778 if ($search_valuebilled ==
'0') {
1779 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1782 if ($search_date_start) {
1783 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1785 if ($search_date_end) {
1786 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1789 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1790 if ($search_timespent_starthour || $search_timespent_startmin) {
1791 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1792 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1793 $sql .=
" AND t.element_duration >= " . ((int) $timespent_duration_start);
1796 if ($search_timespent_endhour || $search_timespent_endmin) {
1797 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1798 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1799 $sql .=
" AND t.element_duration <= " . ((int) $timespent_duration_end);
1803 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1806 $extrafieldsobjectkey =
'projet_task';
1807 $extrafieldsobjectprefix =
'efpt.';
1808 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1811 $parameters = array();
1812 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1813 $sql .= $hookmanager->resPrint;
1816 $nbtotalofrecords =
'';
1819 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1820 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1821 $resql =
$db->query($sqlforcount);
1823 $objforcount =
$db->fetch_object($resql);
1824 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1829 if (($page * $limit) > (
int) $nbtotalofrecords) {
1837 $sql .=
$db->order($sortfield, $sortorder);
1839 $sql .=
$db->plimit($limit + 1, $offset);
1842 $resql =
$db->query($sql);
1848 $num =
$db->num_rows($resql);
1851 if (!empty($projectidforalltimes)) {
1852 print
'<!-- List of time spent for project -->' .
"\n";
1854 $title = $langs->trans(
"ListTaskTimeUserProject");
1856 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1858 print
'<!-- List of time spent -->' .
"\n";
1860 $title = $langs->trans(
"ListTaskTimeForTask");
1862 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1867 $obj =
$db->fetch_object($resql);
1881 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1882 print
'<!-- table to add time spent -->' .
"\n";
1884 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1887 print
'<div class="div-table-responsive-no-min">';
1888 print
'<table class="noborder nohover centpercent">';
1890 print
'<tr class="liste_titre">';
1891 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1892 if (!empty($allprojectforuser)) {
1893 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1896 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1898 print
'<td>' . $langs->trans(
"By") .
'</td>';
1899 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1900 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1901 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1905 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1906 print
'<td>'.$langs->trans(
"Product").
'</td>';
1910 $parameters = array(
'mode' =>
'create');
1911 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1912 print $hookmanager->resPrint;
1916 print
'<tr class="oddeven nohover">';
1919 print
'<td class="maxwidthonsmartphone">';
1921 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1924 if (!empty($allprojectforuser)) {
1933 print
'<td class="maxwidthonsmartphone">';
1934 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
1939 print
'<td class="maxwidthonsmartphone nowraponall">';
1940 $contactsofproject = $projectstatic->getListContactId(
'internal');
1941 if (count($contactsofproject) > 0) {
1942 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1943 if (in_array($user->id, $contactsofproject)) {
1944 $userid = $user->id;
1946 $userid = $contactsofproject[0];
1949 if ($projectstatic->public) {
1950 $contactsofproject = array();
1952 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1955 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1962 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1966 print
'<td class="nowraponall">';
1967 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1969 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1971 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1975 print
'<td class="nowrap">';
1976 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
1984 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1985 print
'<td class="nowraponall">';
1987 print $form->select_produits((
GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
"fk_product") :
''),
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
1993 $parameters = array(
'mode' =>
'create');
1994 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1995 print $hookmanager->resPrint;
1997 print
'<td class="center">';
1998 $form->buttonsSaveCancel();
1999 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
2000 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
2009 $moreforfilter =
'';
2011 $parameters = array();
2012 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
2013 if (empty($reshook)) {
2014 $moreforfilter .= $hookmanager->resPrint;
2016 $moreforfilter = $hookmanager->resPrint;
2019 if (!empty($moreforfilter)) {
2020 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
2021 print $moreforfilter;
2025 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
2026 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
2027 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
2030 if ($projectstatic->usage_bill_time) {
2031 $arrayfields[
'valuebilled'][
'checked'] = 1;
2034 print
'<!-- Liste of time spent -->'.
"\n";
2035 print
'<div class="div-table-responsive">';
2036 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
2040 print
'<tr class="liste_titre_filter">';
2042 if (
$conf->main_checkbox_left_column) {
2043 print
'<td class="liste_titre center">';
2044 $searchpicto = $form->showFilterButtons(
'left');
2049 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2050 print
'<td class="liste_titre left">';
2051 print
'<div class="nowrapfordate paddingright">';
2052 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
2054 print
'<div class="nowrapfordate">';
2055 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
2060 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2061 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
2065 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2066 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
2069 if (!empty($allprojectforuser)) {
2070 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2071 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
2073 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2074 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2078 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2079 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2080 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2082 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2083 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2087 if (!empty($arrayfields[
'author'][
'checked'])) {
2088 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>';
2091 if (!empty($arrayfields[
't.note'][
'checked'])) {
2092 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2095 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2096 print
'<td class="liste_titre"></td>';
2099 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2101 print
'<td class="liste_titre right">';
2103 $durationtouse_start =
'';
2104 if ($search_timespent_starthour || $search_timespent_startmin) {
2105 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2107 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'fromhour') .
'</span> ';
2108 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2111 $durationtouse_end =
'';
2112 if ($search_timespent_endhour || $search_timespent_endmin) {
2113 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2115 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'tohour') .
'</span> ';
2116 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2122 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2123 print
'<td class="liste_titre"></td>';
2126 if (!empty($arrayfields[
'value'][
'checked'])) {
2127 print
'<td class="liste_titre"></td>';
2130 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2131 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2135 $extrafieldsobjectkey =
'projet_task';
2136 $extrafieldsobjectprefix =
'ef.';
2137 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2139 $parameters = array(
'arrayfields' => $arrayfields);
2140 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2141 print $hookmanager->resPrint;
2143 if (!
$conf->main_checkbox_left_column) {
2144 print
'<td class="liste_titre center">';
2145 $searchpicto = $form->showFilterButtons();
2149 print
'</tr>' .
"\n";
2157 print
'<tr class="liste_titre">';
2158 if (
$conf->main_checkbox_left_column) {
2159 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2162 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2163 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2166 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2167 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2170 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2172 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2175 if (!empty($allprojectforuser)) {
2176 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2177 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2180 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2181 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2185 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2186 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2187 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2190 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2191 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2195 if (!empty($arrayfields[
'author'][
'checked'])) {
2196 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2199 if (!empty($arrayfields[
't.note'][
'checked'])) {
2200 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2203 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2204 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
't.tms',
'', $param,
'', $sortfield, $sortorder);
2207 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2208 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2211 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2212 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2216 if (!empty($arrayfields[
'value'][
'checked'])) {
2217 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2220 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2221 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2225 $extrafieldsobjectkey =
'projet_task';
2226 $extrafieldsobjectprefix =
'ef.';
2227 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2229 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2230 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2231 print $hookmanager->resPrint;
2232 if (!
$conf->main_checkbox_left_column) {
2233 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2242 $param .=
'&page='.((int) $page);
2244 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2252 foreach ($tasks as $task_time) {
2258 $invoiced = $task_time->invoice_id ? true :
false;
2260 $date1 =
$db->jdate($task_time->element_date);
2261 $date2 =
$db->jdate($task_time->element_datehour);
2265 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2268 if (
$conf->main_checkbox_left_column) {
2269 print
'<td class="center nowraponall">';
2270 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2271 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2273 print
'<input type="hidden" name="id" value="' .
$id .
'">';
2275 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2277 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2278 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2279 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2280 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' :
'').
'">';
2281 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2285 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' :
'') .
'">';
2286 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2290 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' :
'').
'">';
2291 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2294 if ($massactionbutton || $massaction) {
2296 if (in_array($task_time->rowid, $arrayofselected)) {
2302 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2303 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2307 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2308 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2322 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2323 print
'<td class="nowrap">';
2324 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2325 if (empty($task_time->element_date_withhour)) {
2326 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2328 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2331 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2340 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2341 print
'<td class="tdoverflowmax125">';
2342 if ($task_time->fk_soc > 0) {
2343 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2345 $tmpsociete->fetch($task_time->fk_soc);
2346 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2348 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2350 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2359 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2361 if ($task_time->fk_soc > 0) {
2362 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2364 $tmpsociete->fetch($task_time->fk_soc);
2365 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2367 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2369 $valtoshow = $tmpsociete->name_alias;
2371 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2379 if (!empty($allprojectforuser)) {
2381 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2382 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2384 $tmpproject->fetch($task_time->fk_projet);
2385 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2387 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2389 print
'<td class="nowraponall">';
2390 print $tmpproject->getNomUrl(1);
2397 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2398 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2400 $tmpproject->fetch($task_time->fk_projet);
2401 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2403 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2405 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2406 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2409 print $tmpproject->getNomUrl(1,
'', -1);
2419 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2420 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2421 print
'<td class="nowrap">';
2422 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2423 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (
string) $projectstatic->id,
'');
2425 $tasktmp->id = $task_time->fk_element;
2426 $tasktmp->ref = $task_time->ref;
2427 $tasktmp->label = $task_time->label;
2428 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2435 } elseif ($action !==
'createtime') {
2436 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2440 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2441 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2442 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2443 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2446 $tasktmp->id = $task_time->fk_element;
2447 $tasktmp->ref = $task_time->ref;
2448 $tasktmp->label = $task_time->label;
2449 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2459 if (!empty($arrayfields[
'author'][
'checked'])) {
2460 print
'<td class="tdoverflowmax125">';
2461 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2464 $object->fetch($task_time->fk_element);
2466 $contactsoftask =
$object->getListContactId(
'internal');
2467 if (!in_array($task_time->fk_user, $contactsoftask)) {
2468 $contactsoftask[] = $task_time->fk_user;
2470 if (count($contactsoftask) > 0) {
2471 print
img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2472 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2474 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2477 $userstatic->id = $task_time->fk_user;
2478 $userstatic->lastname = $task_time->lastname;
2479 $userstatic->firstname = $task_time->firstname;
2480 $userstatic->photo = $task_time->photo;
2481 $userstatic->gender = $task_time->gender;
2482 $userstatic->status = $task_time->user_status;
2484 print $userstatic->getNomUrl(-1);
2493 if (!empty($arrayfields[
't.note'][
'checked'])) {
2494 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2495 print
'<td class="small">';
2496 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2499 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2506 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2507 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2511 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2512 print
'<td class="nowraponall">';
2521 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2522 print
'<td class="right nowraponall">';
2523 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2524 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2525 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2536 if (empty(
$totalarray[
'val'][
't.element_duration'])) {
2537 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2539 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2545 $totalarray[
'totalduration'] = $task_time->element_duration;
2547 $totalarray[
'totalduration'] += $task_time->element_duration;
2552 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2553 print
'<td class="nowraponall">';
2554 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2556 print $form->select_produits($task_time->fk_product,
'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', ($user->hasRight(
'produit',
'lire') ? 0 : 1),
'', null, 1);
2557 } elseif (!empty($task_time->fk_product)) {
2559 $resultFetch = $product->fetch($task_time->fk_product);
2560 if ($resultFetch < 0) {
2563 print $product->getNomUrl(1);
2573 if (!empty($arrayfields[
'value'][
'checked'])) {
2574 $langs->load(
"salaries");
2575 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2577 print
'<td class="nowraponall right">';
2578 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2579 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2604 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2605 print
'<td class="center">';
2607 if ($projectstatic->usage_bill_time) {
2608 if ($task_time->invoice_id) {
2609 $result = $tmpinvoice->fetch($task_time->invoice_id);
2611 if ($user->hasRight(
'facture',
'lire')) {
2612 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2613 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2615 print $tmpinvoice->getNomUrl(1);
2616 if (!empty($task_time->invoice_line_id)) {
2618 $invoiceLine->fetch($task_time->invoice_line_id);
2619 if (!empty($invoiceLine->id)) {
2620 print
'<br><span class="small opacitymedium">'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2621 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2627 print $langs->trans(
"Yes");
2632 if (intval($task_time->billable) == 1) {
2633 print $langs->trans(
"No");
2635 print $langs->trans(
"Disabled");
2639 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2650 $extrafieldsobjectkey =
'projet_task';
2651 $extrafieldsobjectprefix =
'ef.';
2652 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2655 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &
$totalarray);
2656 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2657 print $hookmanager->resPrint;
2660 if (!
$conf->main_checkbox_left_column) {
2661 print
'<td class="center nowraponall">';
2662 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2663 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2664 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2666 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2667 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2668 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2669 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' :
'').
'">';
2670 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2674 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' :
'') .
'">';
2675 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2679 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' :
'').
'">';
2680 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2683 if ($massactionbutton || $massaction) {
2685 if (in_array($task_time->rowid, $arrayofselected)) {
2691 $disabled = (intval($task_time->billable) != 1 || $invoiced);
2692 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2696 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2697 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2715 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2716 print
'<!-- first line -->';
2717 print
'<tr class="oddeven">';
2720 if (
$conf->main_checkbox_left_column) {
2725 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2726 print
'<td class="nowrap">';
2727 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2728 if (empty($task_time->element_date_withhour)) {
2729 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2731 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2734 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2740 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2741 print
'<td class="nowrap">';
2746 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2747 print
'<td class="nowrap">';
2752 if (!empty($allprojectforuser)) {
2753 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2754 print
'<td class="nowrap">';
2760 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2761 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2762 print
'<td class="nowrap">';
2763 $tasktmp->id = $task_time->fk_element;
2764 $tasktmp->ref = $task_time->ref;
2765 $tasktmp->label = $task_time->label;
2766 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2772 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2773 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2774 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2781 if (!empty($arrayfields[
'author'][
'checked'])) {
2782 print
'<td class="nowraponall">';
2783 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2785 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2788 $contactsoftask =
$object->getListContactId(
'internal');
2789 if (!in_array($task_time->fk_user, $contactsoftask)) {
2790 $contactsoftask[] = $task_time->fk_user;
2792 if (count($contactsoftask) > 0) {
2793 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2794 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2796 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2799 $userstatic->id = $task_time->fk_user;
2800 $userstatic->lastname = $task_time->lastname;
2801 $userstatic->firstname = $task_time->firstname;
2802 $userstatic->photo = $task_time->photo;
2803 $userstatic->status = $task_time->user_status;
2804 print $userstatic->getNomUrl(-1);
2810 if (!empty($arrayfields[
't.note'][
'checked'])) {
2811 print
'<td class="tdoverflowmax300">';
2812 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2813 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2818 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2819 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2823 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2824 print
'<td class="nowraponall">';
2829 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2830 print
'<td class="right">';
2831 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2832 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2833 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2841 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2842 print
'<td class="nowraponall tdoverflowmax125">';
2847 if (!empty($arrayfields[
'value'][
'checked'])) {
2848 print
'<td class="right">';
2849 print
'<span class="amount">';
2850 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2851 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2857 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2858 print
'<td class="right">';
2859 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2860 if (isset($task_time->total_ht)) {
2861 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2868 $extrafieldsobjectkey =
'projet_task';
2869 $extrafieldsobjectprefix =
'ef.';
2870 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2873 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2874 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2875 print $hookmanager->resPrint;
2878 if (!
$conf->main_checkbox_left_column) {
2879 print
'<td class="center nowraponall">';
2888 print
'<!-- second line --><tr class="oddeven">';
2891 if (
$conf->main_checkbox_left_column) {
2892 print
'<td class="center nowraponall">';
2897 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2898 print
'<td class="nowraponall">';
2899 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2900 if (empty($task_time->element_date_withhour)) {
2901 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2903 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2906 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2912 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2918 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2924 if (!empty($allprojectforuser)) {
2925 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2932 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2933 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2934 print
'<td class="nowraponall">';
2935 $tasktmp->id = $task_time->fk_element;
2936 $tasktmp->ref = $task_time->ref;
2937 $tasktmp->label = $task_time->label;
2938 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2944 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2945 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2946 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
2953 if (!empty($arrayfields[
'author'][
'checked'])) {
2954 print
'<td class="nowraponall tdoverflowmax100">';
2955 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2957 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2960 $contactsoftask =
$object->getListContactId(
'internal');
2961 if (!in_array($task_time->fk_user, $contactsoftask)) {
2962 $contactsoftask[] = $task_time->fk_user;
2964 if (count($contactsoftask) > 0) {
2965 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2966 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
2968 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2971 $userstatic->id = $task_time->fk_user;
2972 $userstatic->lastname = $task_time->lastname;
2973 $userstatic->firstname = $task_time->firstname;
2974 $userstatic->photo = $task_time->photo;
2975 $userstatic->status = $task_time->user_status;
2976 print $userstatic->getNomUrl(-1);
2982 if (!empty($arrayfields[
't.note'][
'checked'])) {
2983 print
'<td class="small tdoverflowmax300"">';
2984 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2985 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2990 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2991 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2995 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2996 print
'<td class="nowraponall">';
3002 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
3003 print
'<td class="right">';
3004 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3005 print
'<input type="hidden" name="old_duration_2" value="0">';
3006 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
3014 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
3015 print
'<td class="nowraponall tdoverflowmax125">';
3020 if (!empty($arrayfields[
'value'][
'checked'])) {
3021 print
'<td class="right">';
3022 print
'<span class="amount nowraponall">';
3024 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
3031 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
3032 print
'<td class="right">';
3033 if (isset($task_time->total_ht)) {
3034 $valuebilled =
price2num($task_time->total_ht,
'', 1);
3035 print
'<span class="amount nowraponall small">';
3036 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
3044 $extrafieldsobjectkey =
'projet_task';
3045 $extrafieldsobjectprefix =
'ef.';
3046 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
3049 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
3050 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
3051 print $hookmanager->resPrint;
3054 if (!
$conf->main_checkbox_left_column) {
3055 print
'<td class="center nowraponall">';
3068 print
'<tr class="liste_total">';
3073 if ($num < $limit && empty($offset)) {
3074 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
3076 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
3090 if (!count($tasks)) {
3091 $totalnboffields = 1;
3092 foreach ($arrayfields as $value) {
3093 if (!empty($value[
'checked'])) {
3097 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
3098 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
3102 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3103 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3104 print $hookmanager->resPrint;
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
$date_start
Variables from include:
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
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_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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, $nodie=0, $mode='')
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.