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'));
136$projectstatic =
new Project($db);
139$extrafields->fetch_name_optionals_label($projectstatic->table_element);
140$extrafields->fetch_name_optionals_label(
$object->table_element);
142$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
145if ($id > 0 || $ref) {
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);
185 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
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' &&
GETPOST(
'button_search_x',
'alpha')) {
227if ($action ==
'addtimespent' && $user->hasRight(
'projet',
'time')) {
228 $timespent_durationhour =
GETPOSTINT(
'timespent_durationhour');
229 $timespent_durationmin =
GETPOSTINT(
'timespent_durationmin');
230 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
231 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
235 $langs->load(
"errors");
236 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
245 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
246 $action =
'createtime';
256 if (empty(
$object->project->status)) {
257 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
258 $action =
'createtime';
269 $object->timespent_withhour = 1;
272 $object->timespent_withhour = 0;
277 $result =
$object->addTimeSpent($user);
280 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
282 setEventMessages($langs->trans(
$object->error),
null,
'errors');
288 $action =
'createtime';
292if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'projet',
'lire')) {
293 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
294 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
305 $object->fetchTimeSpent($lineid);
306 $timespentoldowner =
$object->timespent_fk_user;
310 $object->fetch($id_temp, $ref);
312 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
316 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0 && !empty($timespent_date)) {
318 $object->timespent_withhour = 1;
319 } elseif (!empty($timespent_date)) {
320 $object->timespent_date = $timespent_date;
321 $object->timespent_withhour = 0;
332 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
333 $result =
$object->updateTimeSpent($user);
335 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
337 setEventMessages($langs->trans(
$object->error),
null,
'errors');
345 $timespentoldowner =
$object->timespent_fk_user;
347 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
352 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
355 $object->timespent_withhour = 1;
356 } elseif (!empty($timespent_date)) {
357 $object->timespent_date = $timespent_date;
358 $object->timespent_datehour = $timespent_date;
359 $object->timespent_withhour = 0;
372 if ((in_array($timespentoldowner, $childids) || $user->hasRight(
'projet',
'all',
'creer')) && (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer'))) {
373 $result =
$object->updateTimeSpent($user);
376 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
378 setEventMessages($langs->trans(
$object->error),
null,
'errors');
388if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
391 if (in_array(
$object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
392 $result =
$object->delTimeSpent($user);
395 $langs->load(
"errors");
396 setEventMessages($langs->trans(
$object->error),
null,
'errors');
400 setEventMessages($langs->trans(
"RecordDeleted"),
null,
'mesgs');
406if (!empty($project_ref) && !empty($withproject)) {
407 if ($projectstatic->fetch(0, $project_ref) > 0) {
408 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
409 if (count($tasksarray) > 0) {
410 $id = $tasksarray[0]->id;
412 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
419$projectidforalltimes = 0;
421 $projectidforalltimes =
GETPOSTINT(
'projectid');
423 $result = $projectstatic->fetch($projectidforalltimes);
424 if (!empty($projectstatic->socid)) {
425 $projectstatic->fetch_thirdparty();
427 $res = $projectstatic->fetch_optionals();
430 if ($action ==
'update_extras' && $projectstatic->id > 0) {
431 $permissiontoeditextra = $user->hasRight(
'projet',
'creer');
432 if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[$projectstatic->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
433 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[$projectstatic->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
436 if ($permissiontoeditextra) {
437 $projectstatic->oldcopy =
dol_clone($projectstatic, 2);
439 $attribute_name =
GETPOST(
'attribute',
'aZ09');
442 $ret = $extrafields->setOptionalsFromPost(
null, $projectstatic, $attribute_name);
448 $result = $projectstatic->updateExtraField($attribute_name,
'PROJECT_MODIFY');
450 setEventMessages($projectstatic->error, $projectstatic->errors,
'errors');
457 $action =
'edit_extras';
460} elseif (
GETPOST(
'project_ref',
'alpha')) {
461 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
462 $projectidforalltimes = $projectstatic->id;
466 $result = $projectstatic->fetch(
$object->fk_project);
469$allprojectforuser = 0;
471if ($id <= 0 && $projectidforalltimes == 0) {
472 $allprojectforuser = $user->id;
476if ($massaction ==
'exportlines' && !empty($toselect)) {
477 $sql =
"SELECT t.rowid, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.note, t.thm,";
478 $sql .=
" s.nom as thirdparty_name, p.ref as project_ref, p.title as project_label, pt.ref as task_ref, pt.label as task_label,";
479 $sql .=
" u.lastname, u.firstname, u.login, prod.ref as product_ref, inv.ref as invoice_ref";
480 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
481 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
482 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
483 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
484 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
485 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
486 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
487 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
488 $sql .=
" WHERE t.elementtype = 'task'";
489 $sql .=
" AND t.rowid IN (".$db->sanitize(implode(
',', $toselect)).
")";
490 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
491 if (!$user->hasRight(
'projet',
'all',
'lire')) {
492 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0);
493 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
495 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
496 $sql .=
" AND t.fk_element = ".((int)
$object->id);
497 } elseif (!empty($projectidforalltimes)) {
498 $sql .=
" AND pt.fk_projet = ".((int) $projectidforalltimes);
500 $sql .= $db->order(
't.element_date,t.element_datehour,t.rowid',
'ASC,ASC,ASC');
502 $resql = $db->query($sql);
504 require_once DOL_DOCUMENT_ROOT.
'/core/modules/export/export_csvutf8.modules.php';
505 $langs->load(
"salaries");
507 $array_fields = array(
509 'thirdparty_name' =>
'ThirdParty',
510 'project_ref' =>
'RefProject',
511 'project_label' =>
'ProjectLabel',
512 'task_ref' =>
'RefTask',
513 'task_label' =>
'LabelTask',
516 'duration' =>
'Duration',
517 'duration_hours' =>
'DurationInHours',
518 'product_ref' =>
'Product',
521 $array_fields[
'value'] =
'Value';
523 $array_fields[
'invoice_ref'] =
'Invoice';
524 $array_selected = array_fill_keys(array_keys($array_fields),
'1');
527 $filename =
'timespent_'.dol_print_date(
dol_now(),
'dayhourlog').
'.csv';
530 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
532 $exportcsv->open_file(
'php://output', $langs);
533 $exportcsv->write_header($langs);
534 $exportcsv->write_title($array_fields, $array_selected, $langs, array());
535 while ($obj = $db->fetch_object($resql)) {
537 $record->date =
dol_print_date($db->jdate($obj->element_date_withhour ? $obj->element_datehour : $obj->element_date), ($obj->element_date_withhour ?
'dayhour' :
'day'),
'tzuserrel');
538 $record->thirdparty_name = $obj->thirdparty_name;
539 $record->project_ref = $obj->project_ref;
540 $record->project_label = $obj->project_label;
541 $record->task_ref = $obj->task_ref;
542 $record->task_label = $obj->task_label;
544 $record->note = $obj->note;
546 $record->duration_hours =
price2num($obj->element_duration / 3600,
'MS');
547 $record->product_ref = $obj->product_ref;
548 $record->value =
price2num($obj->thm * $obj->element_duration / 3600,
'MT', 1);
549 $record->invoice_ref = $obj->invoice_ref;
550 $exportcsv->write_record($array_selected, $record, $langs, array());
552 $exportcsv->write_footer($langs);
553 $exportcsv->close_file();
559 setEventMessages($db->lasterror(),
null,
'errors');
563if ($action ==
'confirm_generateinvoice' && $user->hasRight(
'facture',
'creer')) {
564 if (!empty($projectstatic->socid)) {
565 $projectstatic->fetch_thirdparty();
568 if (!($projectstatic->thirdparty->id > 0)) {
569 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
571 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
572 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
573 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
575 $tmpinvoice =
new Facture($db);
576 $tmptimespent =
new Task($db);
577 $tmpproduct =
new Product($db);
578 $fuser =
new User($db);
585 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'alphanohtml');
588 $prodDurationHoursBase = 1.0;
589 $product_data_cache = array();
591 $result = $tmpproduct->fetch($idprod);
594 setEventMessages($tmpproduct->error, $tmpproduct->errors,
'errors');
597 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
598 if ($prodDurationHoursBase < 0) {
600 $langs->load(
"errors");
601 setEventMessages(
null, $tmpproduct->errors,
'errors');
604 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
606 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
607 $txtva = $dataforprice[
'tva_tx'];
608 $localtax1 =
get_localtax($txtva, 1, $projectstatic->thirdparty);
609 $localtax2 =
get_localtax($txtva, 2, $projectstatic->thirdparty);
611 $prodDurationHoursBase = 1;
619 $tmpinvoice->socid = $projectstatic->thirdparty->id;
621 $tmpinvoice->fk_project = $projectstatic->id;
622 $tmpinvoice->cond_reglement_id = $condidproject;
623 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
624 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
627 $tmpinvoice->fetch($invoiceToUse);
629 $result = $tmpinvoice->create($user);
632 setEventMessages($tmpinvoice->error, $tmpinvoice->errors,
'errors');
637 if ($generateinvoicemode ==
'onelineperuser') {
638 $arrayoftasks = array();
639 foreach ($toselect as $key => $value) {
641 $object->fetchTimeSpent($value);
642 if (!array_key_exists(
$object->timespent_fk_user, $arrayoftasks)) {
643 $arrayoftasks[
$object->timespent_fk_user] = [
644 (int)
$object->timespent_fk_product => [
'timespent' => 0,
'totalvaluetodivideby3600' => 0]
647 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
648 $arrayoftasks[
$object->timespent_fk_user][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
651 foreach ($arrayoftasks as $userid => $data) {
652 $fuser->fetch($userid);
653 $username = $fuser->getFullName($langs);
655 foreach ($data as $fk_product => $timespent_data) {
657 $qtyhour = $timespent_data[
'timespent'] / 3600;
664 } elseif ($idprod <= 0) {
667 $pu_ht = $fuser->thm;
672 if ($timespent_data[
'timespent']) {
673 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
678 $prodDurationHours = $prodDurationHoursBase;
679 $idprodline = $idprod;
682 $localtax1line = $localtax1;
683 $localtax2line = $localtax2;
686 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
687 if (!array_key_exists($fk_product, $product_data_cache)) {
688 $result = $tmpproduct->fetch($fk_product);
691 setEventMessages($tmpproduct->error, $tmpproduct->errors,
'errors');
693 $prodDurationHours = $tmpproduct->getProductDurationHours();
694 if ($prodDurationHours < 0) {
696 $langs->load(
"errors");
697 setEventMessages(
null, $tmpproduct->errors,
'errors');
702 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
704 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
705 $txtvaline = $dataforprice[
'tva_tx'];
706 $localtax1line = $dataforprice[
'localtax1'];
707 $localtax2line = $dataforprice[
'localtax2'];
709 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
711 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
712 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
713 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
714 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
715 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
717 $idprodline = $fk_product;
724 $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);
727 setEventMessages(
null, $tmpinvoice->errors,
'errors');
731 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
732 $sql .=
' WHERE rowid IN ('.$db->sanitize(implode(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
733 $result = $db->query($sql);
736 setEventMessages($db->lasterror(),
null,
'errors');
741 } elseif ($generateinvoicemode ==
'onelineperperiod') {
742 $arrayoftasks = array();
744 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
745 foreach ($toselect as $key => $value) {
747 $object->fetchTimeSpent($value);
749 $ftask =
new Task($db);
752 $fuser->fetch(
$object->timespent_fk_user);
753 $username = $fuser->getFullName($langs);
755 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
756 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
757 $arrayoftasks[
$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
760 if (!empty($withdetail)) {
761 if (!empty(
$object->timespent_withhour)) {
768 $arrayoftasks[
$object->timespent_id][
'user'] =
$object->timespent_fk_user;
769 $arrayoftasks[
$object->timespent_id][
'fk_product'] =
$object->timespent_fk_product;
772 $pu_ht_saved = $pu_ht;
773 foreach ($arrayoftasks as $timespent_id => $value) {
774 $pu_ht = $pu_ht_saved;
775 $userid = $value[
'user'];
779 $qtyhour = $value[
'timespent'] / 3600;
783 if ($value[
'timespent']) {
784 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
789 $prodDurationHours = $prodDurationHoursBase;
790 $idprodline = $idprod;
793 $localtax1line = $localtax1;
794 $localtax2line = $localtax2;
796 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
797 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
798 $result = $tmpproduct->fetch($value[
'fk_product']);
801 setEventMessages($tmpproduct->error, $tmpproduct->errors,
'errors');
803 $prodDurationHours = $tmpproduct->getProductDurationHours();
804 if ($prodDurationHours < 0) {
806 $langs->load(
"errors");
807 setEventMessages(
null, $tmpproduct->errors,
'errors');
812 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
814 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
815 $txtvaline = $dataforprice[
'tva_tx'];
816 $localtax1line = $dataforprice[
'localtax1'];
817 $localtax2line = $dataforprice[
'localtax2'];
819 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
821 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
822 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
823 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
824 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
825 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
827 $idprodline = $value[
'fk_product'];
833 $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);
836 setEventMessages(
null, $tmpinvoice->errors,
'errors');
841 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
842 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
843 $result = $db->query($sql);
846 setEventMessages($db->lasterror(),
null,
'errors');
850 } elseif ($generateinvoicemode ==
'onelinepertask') {
851 $arrayoftasks = array();
852 foreach ($toselect as $key => $value) {
854 $object->fetchTimeSpent($value);
856 if (!isset($arrayoftasks[
$object->id][(
int)
$object->timespent_fk_product])) {
857 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product] = array(
'timespent' => 0,
'totalvaluetodivideby3600' => 0,
'ids' => array());
859 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'timespent'] +=
$object->timespent_duration;
860 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'totalvaluetodivideby3600'] += (
$object->timespent_duration *
$object->timespent_thm);
863 $arrayoftasks[
$object->id][(int)
$object->timespent_fk_product][
'ids'][] = (
int) $value;
866 foreach ($arrayoftasks as $task_id => $data) {
867 $ftask =
new Task($db);
868 $ftask->fetch($task_id);
870 foreach ($data as $fk_product => $timespent_data) {
871 $qtyhour = $timespent_data[
'timespent'] / 3600;
875 $prodDurationHours = $prodDurationHoursBase;
876 $idprodline = $idprod;
879 $localtax1line = $localtax1;
880 $localtax2line = $localtax2;
882 if (!empty($fk_product) && $fk_product !== $idprod) {
883 if (!array_key_exists($fk_product, $product_data_cache)) {
884 $result = $tmpproduct->fetch($fk_product);
887 setEventMessages($tmpproduct->error, $tmpproduct->errors,
'errors');
889 $prodDurationHours = $tmpproduct->getProductDurationHours();
890 if ($prodDurationHours < 0) {
892 $langs->load(
"errors");
893 setEventMessages(
null, $tmpproduct->errors,
'errors');
898 $dataforprice = $tmpproduct->getSellPrice(
$mysoc, $projectstatic->thirdparty, 0);
900 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
901 $txtvaline = $dataforprice[
'tva_tx'];
902 $localtax1line = $dataforprice[
'localtax1'];
903 $localtax2line = $dataforprice[
'localtax2'];
905 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
907 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
908 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
909 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
910 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
911 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
913 $idprodline = $fk_product;
917 if ($idprodline > 0) {
919 $pu_ht_for_task = $pu_htline;
922 $pu_ht_for_task = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
924 $pa_ht = (float)
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
930 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
932 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
938 $lineName = $ftask->ref .
' - ' . $ftask->label;
939 $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);
942 setEventMessages($tmpinvoice->error, $tmpinvoice->errors,
'errors');
948 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
949 $sql .=
' WHERE rowid IN (' . $db->sanitize(implode(
',', $timespent_data[
'ids'])) .
')';
950 $result = $db->query($sql);
953 setEventMessages($db->lasterror(),
null,
'errors');
963 $urltoinvoice = $tmpinvoice->getNomUrl(0);
964 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
965 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
966 setEventMessages($mesg,
null,
'mesgs');
975if ($action ==
'confirm_generateinter' && $user->hasRight(
'fichinter',
'creer')) {
976 $langs->load(
'interventions');
978 if (!empty($projectstatic->socid)) {
979 $projectstatic->fetch_thirdparty();
982 if (!($projectstatic->thirdparty->id > 0)) {
983 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
985 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
986 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
987 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
990 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
992 $tmptimespent =
new Task($db);
993 $fuser =
new User($db);
999 $tmpinter->socid = $projectstatic->thirdparty->id;
1001 $tmpinter->fk_project = $projectstatic->id;
1002 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->description :
'');
1005 $tmpinter->fetch($interToUse);
1007 $result = $tmpinter->create($user);
1010 setEventMessages($tmpinter->error, $tmpinter->errors,
'errors');
1015 $arrayoftasks = array();
1016 foreach ($toselect as $key => $value) {
1018 $object->fetchTimeSpent($value);
1021 $arrayoftasks[
$object->timespent_id][
'timespent'] =
$object->timespent_duration;
1022 $arrayoftasks[
$object->timespent_id][
'totalvaluetodivideby3600'] =
$object->timespent_duration *
$object->timespent_thm;
1023 $arrayoftasks[
$object->timespent_id][
'note'] =
$object->timespent_note;
1024 $arrayoftasks[
$object->timespent_id][
'date'] =
$object->timespent_datehour;
1027 foreach ($arrayoftasks as $timespent_id => $value) {
1028 $ftask =
new Task($db);
1029 $ftask->fetch($value[
'id']);
1031 $qtyhour = $value[
'timespent'] / 3600;
1035 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), (int) $value[
'date'], $value[
'timespent']);
1040 $timespent->fetch($timespent_id);
1041 $timespent->intervention_id = $tmpinter->id;
1042 $timespent->intervention_line_id = $lineid;
1043 $result = $timespent->update($user);
1046 setEventMessages($timespent->error, $timespent->errors,
'errors');
1053 $urltointer = $tmpinter->getNomUrl(0);
1054 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
1055 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
1056 setEventMessages($mesg,
null,
'mesgs');
1072$form =
new Form($db);
1075$userstatic =
new User($db);
1077$arrayofselected = is_array($toselect) ? $toselect : array();
1079$title =
$object->ref .
' - ' . $langs->trans(
"TimeSpent");
1080if (!empty($withproject)) {
1081 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
1085llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_time');
1088$param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
1090 $param .=
'&search_user=' . ((int) $search_user);
1093 $param .=
'&search_month=' . ((int) $search_month);
1096 $param .=
'&search_year=' . ((int) $search_year);
1100if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
1102 if ($projectidforalltimes > 0) {
1103 $result = $projectstatic->fetch($projectidforalltimes);
1104 if (!empty($projectstatic->socid)) {
1105 $projectstatic->fetch_thirdparty();
1107 $res = $projectstatic->fetch_optionals();
1108 } elseif (
$object->fetch($id, $ref) > 0) {
1112 $result = $projectstatic->fetch(
$object->fk_project);
1113 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
1114 $projectstatic->fetchComments();
1116 if (!empty($projectstatic->socid)) {
1117 $projectstatic->fetch_thirdparty();
1119 $res = $projectstatic->fetch_optionals();
1121 $object->project = clone $projectstatic;
1124 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
1125 $linktocreatetime =
'';
1127 if ($projectstatic->id > 0) {
1130 if (empty($id) || $tab ==
'timespent') {
1137 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
1141 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1143 $morehtmlref =
'<div class="refidno">';
1145 $morehtmlref .= $projectstatic->title;
1147 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
1148 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
1150 $morehtmlref .=
'</div>';
1153 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1154 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
1155 $projectstatic->next_prev_filter =
"rowid:IN:" . $db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1158 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1160 print
'<div class="fichecenter">';
1161 print
'<div class="fichehalfleft">';
1162 print
'<div class="underbanner clearboth"></div>';
1164 print
'<table class="border tableforfield centpercent">';
1168 print
'<tr><td class="tdtop">';
1169 print $langs->trans(
"Usage");
1173 print
'<input type="checkbox" disabled name="usage_opportunity"' . (
GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
1174 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1175 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1179 print
'<input type="checkbox" disabled name="usage_task"' . (
GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
1180 $htmltext = $langs->trans(
"ProjectFollowTasks");
1181 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1185 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"' :
'')) .
'"> ';
1186 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1187 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1191 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"' :
'')) .
'"> ';
1192 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1193 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1199 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1200 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1201 print
'<span class="amount">' .
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency) .
'</span>';
1206 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1208 print($start ? $start :
'?');
1211 print($end ? $end :
'?');
1212 if ($projectstatic->hasDelay()) {
1213 print img_warning(
"Late");
1218 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1219 if ($projectstatic->public) {
1220 print img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1221 print $langs->trans(
'SharedProject');
1223 print img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1224 print $langs->trans(
'PrivateProject');
1235 $forcefieldid =
'projectid';
1236 $moreparam =
'&withproject=1';
1237 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1238 unset($forcefieldid, $moreparam);
1244 print
'<div class="fichehalfright">';
1245 print
'<div class="underbanner clearboth"></div>';
1247 print
'<table class="border tableforfield centpercent">';
1251 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1252 print $form->showCategories($projectstatic->id,
'project', 1);
1257 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1258 if ($projectstatic->description) {
1259 print
'<tr><td class="nottitleforfield" colspan="2">';
1260 print
'<div class="longmessagecut">';
1261 print dolPrintHTML($projectstatic->description);
1271 print
'<div class="clearboth"></div>';
1279 $linktocreatetimeBtnStatus = 0;
1280 $linktocreatetimeUrl =
'';
1281 $linktocreatetimeHelpText =
'';
1282 if ($user->hasRight(
'projet',
'time')) {
1283 if ($projectstatic->public || $userRead > 0) {
1284 $linktocreatetimeBtnStatus = 1;
1286 if (!empty($projectidforalltimes)) {
1288 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1289 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1292 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id . ($withproject ?
'&withproject=1' :
'');
1293 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . (
$object->id > 0 ?
'&id=' .
$object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1296 $linktocreatetimeBtnStatus = -2;
1297 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1300 $linktocreatetimeBtnStatus = -2;
1301 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1304 $paramsbutton = array(
'morecss' =>
'reposition');
1305 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1308 $massactionbutton =
'';
1309 $arrayofmassactions = array();
1311 if ($projectstatic->id > 0) {
1313 if ($projectstatic->usage_bill_time) {
1314 $arrayofmassactions = array(
1315 'generateinvoice' => img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"GenerateBill"),
1319 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1320 $langs->load(
"interventions");
1321 $arrayofmassactions[
'generateinter'] = img_picto(
'',
'intervention',
'class="pictofixedwidth"').$langs->trans(
"GenerateInter");
1324 $arrayofmassactions[
'exportlines'] = img_picto(
'',
'download',
'class="pictofixedwidth"').$langs->trans(
"ExportLinesToFile");
1325 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1326 $arrayofmassactions = array();
1328 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1335 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1337 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1339 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
1340 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1342 if ($action ==
'deleteline') {
1343 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . (
$object->id > 0 ?
"id=" .
$object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOSTINT(
"lineid") . $param;
1344 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1347 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1348 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1349 $object->next_prev_filter =
"fk_projet:IN:" . $db->sanitize($projectsListId);
1351 $object->next_prev_filter =
"fk_projet:=:" . ((int) $projectstatic->id);
1357 if (empty($withproject)) {
1358 $morehtmlref .=
'<div class="refidno">';
1359 $morehtmlref .= $langs->trans(
"Project") .
': ';
1360 $morehtmlref .= $projectstatic->getNomUrl(1);
1361 $morehtmlref .=
'<br>';
1364 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1365 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1366 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1368 $morehtmlref .=
'</div>';
1371 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1373 print
'<div class="fichecenter">';
1374 print
'<div class="fichehalfleft">';
1376 print
'<div class="underbanner clearboth"></div>';
1377 print
'<table class="border centpercent tableforfield">';
1380 print
'<tr><td>' . $langs->trans(
"ParentTask") .
'</td><td>';
1381 if (
$object->fk_task_parent > 0) {
1382 $tasktmp =
new Task($db);
1383 $tasktmp->fetch(
$object->fk_task_parent);
1384 print $tasktmp->getNomUrl(1);
1389 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1391 print($start ? $start :
'?');
1394 print($end ? $end :
'?');
1396 print img_warning(
"Late");
1401 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1402 if (
$object->planned_workload) {
1410 print
'<div class="fichehalfright">';
1412 print
'<div class="underbanner clearboth"></div>';
1413 print
'<table class="border tableforfield centpercent">';
1416 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1421 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1422 if (
$object->planned_workload) {
1423 $tmparray =
$object->getSummaryOfTimeSpent();
1424 if ($tmparray[
'total_duration'] > 0) {
1425 print round($tmparray[
'total_duration'] /
$object->planned_workload * 100, 2) .
' %';
1430 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1441 print
'<div class="clearboth"></div>';
1445 if ($action ==
'deleteline') {
1446 $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;
1447 $formconfirm .= $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1452 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1453 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1454 if (empty($reshook)) {
1455 $formconfirm .= $hookmanager->resPrint;
1456 } elseif ($reshook > 0) {
1457 $formconfirm = $hookmanager->resPrint;
1461 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1463 $hookmanager->initHooks(array(
'tasktimelist'));
1469 $arrayfields = array();
1470 $arrayfields[
't.element_date'] = array(
'label' => $langs->trans(
"Date"),
'checked' =>
'1');
1471 $arrayfields[
'p.fk_soc'] = array(
'label' => $langs->trans(
"ThirdParty"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1',
'checked' =>
'1');
1472 $arrayfields[
's.name_alias'] = array(
'label' => $langs->trans(
"AliasNameShort"),
'type' =>
'integer:Societe:/societe/class/societe.class.php:1');
1473 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1474 if (! empty($allprojectforuser)) {
1475 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' =>
'1'];
1476 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' =>
'1'];
1478 $arrayfields[
't.element_ref'] = array(
'label' => $langs->trans(
"RefTask"),
'checked' =>
'1');
1479 $arrayfields[
't.element_label'] = array(
'label' => $langs->trans(
"LabelTask"),
'checked' =>
'1');
1481 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' =>
'1');
1482 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1');
1483 $arrayfields[
't.tms'] = array(
'label' => $langs->trans(
"DateModification"),
'checked' =>
'0');
1484 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1485 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' =>
'1');
1487 $arrayfields[
't.element_duration'] = array(
'label' => $langs->trans(
"Duration"),
'checked' =>
'1');
1488 $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));
1489 $arrayfields[
'value'] = array(
'label' => $langs->trans(
"Value"),
'checked' =>
'1',
'enabled' => (
string) (
int)
isModEnabled(
"salaries"));
1490 $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));
1492 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1497 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1498 $param .=
'&contextpage=' . urlencode($contextpage);
1500 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1501 $param .=
'&limit='.((int) $limit);
1504 $param .=
'&id='.((int) $id);
1506 if ($search_month > 0) {
1507 $param .=
'&search_month=' . urlencode((
string) ($search_month));
1509 if ($search_year > 0) {
1510 $param .=
'&search_year=' . urlencode((
string) ($search_year));
1512 if (!empty($search_user)) {
1513 $param .=
'&search_user='.urlencode($search_user);
1515 if ($search_task_ref !=
'') {
1516 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1518 if ($search_company !=
'') {
1519 $param .=
'&search_company=' . urlencode($search_company);
1521 if ($search_company_alias !=
'') {
1522 $param .=
'&search_company_alias=' . urlencode($search_company_alias);
1524 if ($search_project_ref !=
'') {
1525 $param .=
'&search_project_ref=' . urlencode($search_project_ref);
1527 if ($search_project_label !=
'') {
1528 $param .=
'&search_project_label=' . urlencode($search_project_label);
1530 if ($search_task_label !=
'') {
1531 $param .=
'&search_task_label=' . urlencode($search_task_label);
1533 if ($search_note !=
'') {
1534 $param .=
'&search_note=' . urlencode($search_note);
1536 if ($search_duration !=
'') {
1537 $param .=
'&search_field2=' . urlencode((
string) ($search_duration));
1539 if ($optioncss !=
'') {
1540 $param .=
'&optioncss=' . urlencode($optioncss);
1542 if ($search_date_startday) {
1543 $param .=
'&search_date_startday=' . urlencode((
string) ($search_date_startday));
1545 if ($search_date_startmonth) {
1546 $param .=
'&search_date_startmonth=' . urlencode((
string) ($search_date_startmonth));
1548 if ($search_date_startyear) {
1549 $param .=
'&search_date_startyear=' . urlencode((
string) ($search_date_startyear));
1551 if ($search_date_endday) {
1552 $param .=
'&search_date_endday=' . urlencode((
string) ($search_date_endday));
1554 if ($search_date_endmonth) {
1555 $param .=
'&search_date_endmonth=' . urlencode((
string) ($search_date_endmonth));
1557 if ($search_date_endyear) {
1558 $param .=
'&search_date_endyear=' . urlencode((
string) ($search_date_endyear));
1560 if ($search_timespent_starthour) {
1561 $param .=
'&search_timespent_duration_starthour=' . urlencode((
string) ($search_timespent_starthour));
1563 if ($search_timespent_startmin) {
1564 $param .=
'&search_timespent_duration_startmin=' . urlencode((
string) ($search_timespent_startmin));
1566 if ($search_timespent_endhour) {
1567 $param .=
'&search_timespent_duration_endhour=' . urlencode((
string) ($search_timespent_endhour));
1569 if ($search_timespent_endmin) {
1570 $param .=
'&search_timespent_duration_endmin=' . urlencode((
string) ($search_timespent_endmin));
1573 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1575 $param .=
'&id=' . urlencode((
string) ($id));
1578 $param .=
'&projectid=' . urlencode((
string) ($projectid));
1581 $param .=
'&withproject=' . urlencode((
string) ($withproject));
1584 $parameters = array(
'param' => &$param);
1585 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1586 $param .= $hookmanager->resPrint;
1588 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1589 if ($optioncss !=
'') {
1590 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1592 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1593 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1594 if ($action ==
'editline') {
1595 print
'<input type="hidden" name="action" value="updateline">';
1596 } elseif ($action ==
'splitline') {
1597 print
'<input type="hidden" name="action" value="updatesplitline">';
1598 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1599 print
'<input type="hidden" name="action" value="addtimespent">';
1600 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1601 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1602 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1603 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1605 print
'<input type="hidden" name="action" value="list">';
1607 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1608 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1612 print
'<input type="hidden" name="id" value="' . ((int) $id) .
'">';
1613 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1614 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1615 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1616 print
'<input type="hidden" name="page_y" value="">';
1619 if ($massaction ==
'generateinvoice') {
1620 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1621 print
'<table class="noborder centerpercent">';
1623 print
'<td class="titlefield">';
1624 print $langs->trans(
'DateInvoice');
1627 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1633 print $langs->trans(
'Mode');
1637 'onelineperuser' =>
'OneLinePerUser',
1638 'onelinepertask' =>
'OneLinePerTask',
1639 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1641 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1642 print
"\n" .
'<script type="text/javascript">';
1644 $(document).ready(function () {
1645 setDetailVisibility();
1646 $("#generateinvoicemode").change(function() {
1647 setDetailVisibility();
1649 function setDetailVisibility() {
1650 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1651 if (generateinvoicemode=="onelineperperiod") {
1652 $("#detail_time_duration").show();
1654 $("#detail_time_duration").hide();
1659 print
'</script>' .
"\n";
1660 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1667 print $langs->trans(
'ServiceToUseOnLines');
1670 $form->select_produits(0,
'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1675 print
'<td class="titlefield">';
1676 print $langs->trans(
'InvoiceToUse');
1679 print $form->selectInvoiceForTimeProject($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1683 print
'<td class="titlefield">';
1684 print $langs->trans(
"CustomerRelativeDiscount");
1687 print
'<input type="text" size="5" name="remiseproject" value="'.$projectstatic->thirdparty->remise_percent.
'">%';
1690 print
'<tr class="newinvoicedetail">';
1691 print
'<td class="titlefield">';
1692 print $langs->trans(
"PaymentConditions");
1695 print $form->getSelectConditionsPaiements((
int) $projectstatic->thirdparty->cond_reglement_id,
'condidproject');
1709 print
'<div class="center">';
1710 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1711 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1715 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1716 print
'<div class="center">';
1717 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1721 } elseif ($massaction ==
'generateinter') {
1723 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1725 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1727 print
'<table class="noborder centpercent">';
1729 print
'<td class="titlefield">';
1730 print img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1734 print $forminter->select_interventions($projectstatic->thirdparty->id, 0,
'interid', 24, $langs->trans(
'NewInter'),
true);
1739 print
'<div class="center">';
1740 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1741 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1745 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1746 print
'<div class="center">';
1747 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1754 $parameters = array(
1755 'toselect' => $toselect,
1756 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1759 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1761 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1763 print $hookmanager->resPrint;
1771 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1772 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1775 if ($projectstatic->usage_bill_time) {
1776 $arrayfields[
'valuebilled'][
'checked'] = 1;
1779 $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,";
1780 $sql .=
" t.fk_product, t.invoice_line_id, t.import_key, t.datec, t.tms,";
1781 $sql .=
" pt.rowid as taskid, pt.ref, pt.label, pt.fk_projet, pt.billable,";
1782 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.gender, u.statut as user_status,";
1783 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1784 $sql .=
" p.fk_soc, s.name_alias";
1785 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1786 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1787 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1791 $parameters = array();
1792 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1793 $sql .= $hookmanager->resPrint;
1794 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1798 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1799 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1800 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1801 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1802 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1803 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON pt.rowid = efpt.fk_object";
1804 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1805 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1806 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1809 $parameters = array();
1810 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1811 $sql .= $hookmanager->resPrint;
1812 $sql .=
" WHERE elementtype = 'task'";
1813 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1814 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1818 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
1819 $sql .=
" AND p.rowid IN (".$db->sanitize($projectsListId).
")";
1821 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1823 $sql .=
" AND t.fk_element =".((int)
$object->id);
1824 } elseif (!empty($projectidforalltimes)) {
1826 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize((
string) $projectidforalltimes) .
")";
1827 } elseif (!empty($allprojectforuser)) {
1829 if (empty($search_user) && !empty($arrayfields[
'author'][
'checked'])) {
1830 $search_user = $user->id;
1832 if ($search_user > 0) {
1833 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1840 if ($search_task_ref) {
1843 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1844 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1846 if ($search_company) {
1849 if ($search_company_alias) {
1853 if ($search_project_ref) {
1856 if ($search_project_label) {
1859 if ($search_task_label) {
1862 if ($search_user > 0) {
1865 if (!empty($search_product_ref)) {
1868 if ($search_valuebilled ==
'1') {
1869 $sql .=
' AND t.invoice_id > 0';
1871 if ($search_valuebilled ==
'0') {
1872 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1875 if ($search_date_start) {
1876 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1878 if ($search_date_end) {
1879 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1882 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1883 if ($search_timespent_starthour || $search_timespent_startmin) {
1884 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1885 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1886 $sql .=
" AND t.element_duration >= " . ((int) $timespent_duration_start);
1889 if ($search_timespent_endhour || $search_timespent_endmin) {
1890 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1891 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1892 $sql .=
" AND t.element_duration <= " . ((int) $timespent_duration_end);
1896 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1899 $extrafieldsobjectkey =
'projet_task';
1900 $extrafieldsobjectprefix =
'efpt.';
1901 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1904 $parameters = array();
1905 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1906 $sql .= $hookmanager->resPrint;
1909 $nbtotalofrecords =
'';
1912 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1913 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1914 $resql = $db->query($sqlforcount);
1916 $objforcount = $db->fetch_object($resql);
1917 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1919 dol_print_error($db);
1922 if (($page * $limit) > (
int) $nbtotalofrecords) {
1930 $sql .= $db->order($sortfield, $sortorder);
1932 $sql .= $db->plimit($limit + 1, $offset);
1935 $resql = $db->query($sql);
1937 dol_print_error($db);
1941 $num = $db->num_rows($resql);
1944 if (!empty($projectidforalltimes)) {
1945 print
'<!-- List of time spent for project -->' .
"\n";
1947 $title = $langs->trans(
"ListTaskTimeUserProject");
1949 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1951 print
'<!-- List of time spent -->' .
"\n";
1953 $title = $langs->trans(
"ListTaskTimeForTask");
1955 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1960 $obj = $db->fetch_object($resql);
1968 dol_print_error($db);
1974 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1975 print
'<!-- table to add time spent -->' .
"\n";
1977 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
1980 print
'<div class="div-table-responsive-no-min">';
1981 print
'<table class="noborder nohover centpercent">';
1983 print
'<tr class="liste_titre">';
1984 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1985 if (!empty($allprojectforuser)) {
1986 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1989 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1991 print
'<td>' . $langs->trans(
"By") .
'</td>';
1992 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1993 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1994 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1998 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1999 print
'<td>'.$langs->trans(
"Product").
'</td>';
2003 $parameters = array(
'mode' =>
'create');
2004 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2005 print $hookmanager->resPrint;
2009 print
'<tr class="oddeven nohover">';
2012 print
'<td class="maxwidthonsmartphone">';
2014 print $form->selectDate($newdate,
'time', (
$conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
2017 if (!empty($allprojectforuser)) {
2026 print
'<td class="maxwidthonsmartphone">';
2027 $nboftasks = $formproject->selectTasks(-1,
GETPOSTINT(
'taskid'),
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth300', (
string) $projectstatic->id,
'progress');
2032 print
'<td class="maxwidthonsmartphone nowraponall">';
2033 $contactsofproject = $projectstatic->getListContactId(
'internal');
2034 if (count($contactsofproject) > 0) {
2035 print img_object(
'',
'user',
'class="hideonsmartphone"');
2036 if (in_array($user->id, $contactsofproject)) {
2037 $userid = $user->id;
2039 $userid = $contactsofproject[0];
2042 if ($projectstatic->public) {
2043 $contactsofproject = array();
2045 print $form->select_dolusers((
GETPOSTINT(
'userid') ?
GETPOSTINT(
'userid') : $userid),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
2048 print img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
2055 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
2059 print
'<td class="nowraponall">';
2060 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
2062 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
2064 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
2068 print
'<td class="nowrap">';
2069 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') :
$object->progress,
'progress', 0, 5, 0, 100, 1);
2077 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
2078 print
'<td class="nowraponall">';
2079 print img_picto(
'',
'service');
2080 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);
2086 $parameters = array(
'mode' =>
'create');
2087 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2088 print $hookmanager->resPrint;
2090 print
'<td class="center">';
2091 $form->buttonsSaveCancel();
2092 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
2093 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
2102 $moreforfilter =
'';
2104 $parameters = array();
2105 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
2106 if (empty($reshook)) {
2107 $moreforfilter .= $hookmanager->resPrint;
2109 $moreforfilter = $hookmanager->resPrint;
2112 if (!empty($moreforfilter)) {
2113 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
2114 print $moreforfilter;
2118 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
2119 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
2120 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
2123 if ($projectstatic->usage_bill_time) {
2124 $arrayfields[
'valuebilled'][
'checked'] = 1;
2127 print
'<!-- Liste of time spent -->'.
"\n";
2128 print
'<div class="div-table-responsive">';
2129 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
2133 print
'<tr class="liste_titre_filter">';
2135 if (
$conf->main_checkbox_left_column) {
2136 print
'<td class="liste_titre center">';
2137 $searchpicto = $form->showFilterButtons(
'left');
2142 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2143 print
'<td class="liste_titre left">';
2144 print
'<div class="nowrapfordate paddingright">';
2145 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
2147 print
'<div class="nowrapfordate">';
2148 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
2153 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2154 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
2158 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2159 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
2162 if (!empty($allprojectforuser)) {
2163 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2164 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
2166 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2167 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
2171 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2172 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2173 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
2175 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2176 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
2180 if (!empty($arrayfields[
'author'][
'checked'])) {
2181 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>';
2184 if (!empty($arrayfields[
't.note'][
'checked'])) {
2185 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
2188 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2189 print
'<td class="liste_titre"></td>';
2192 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2194 print
'<td class="liste_titre right">';
2196 $durationtouse_start =
'';
2197 if ($search_timespent_starthour || $search_timespent_startmin) {
2198 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
2200 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'fromhour') .
'</span> ';
2201 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
2204 $durationtouse_end =
'';
2205 if ($search_timespent_endhour || $search_timespent_endmin) {
2206 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
2208 print
'<div class="nowraponall"><span class="opacitymedium">' . $langs->trans(
'tohour') .
'</span> ';
2209 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
2215 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2216 print
'<td class="liste_titre"></td>';
2219 if (!empty($arrayfields[
'value'][
'checked'])) {
2220 print
'<td class="liste_titre"></td>';
2223 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2224 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
2228 $extrafieldsobjectkey =
'projet_task';
2229 $extrafieldsobjectprefix =
'ef.';
2230 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2232 $parameters = array(
'arrayfields' => $arrayfields);
2233 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2234 print $hookmanager->resPrint;
2236 if (!
$conf->main_checkbox_left_column) {
2237 print
'<td class="liste_titre center">';
2238 $searchpicto = $form->showFilterButtons();
2242 print
'</tr>' .
"\n";
2244 print
'<script type="text/javascript">
2245 $(document).on("keydown", "tr.liste_titre_filter input", function (e) {
2246 if (e.which === 13) {
2248 $(this).closest("form").find("button[name=\"button_search_x\"]").first().trigger("click");
2254 $totalarray = array();
2255 $totalarray[
'nbfield'] = 0;
2259 print
'<tr class="liste_titre">';
2260 if (
$conf->main_checkbox_left_column) {
2261 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2262 $totalarray[
'nbfield']++;
2264 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2265 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2266 $totalarray[
'nbfield']++;
2268 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2269 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2270 $totalarray[
'nbfield']++;
2272 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2274 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2275 $totalarray[
'nbfield']++;
2277 if (!empty($allprojectforuser)) {
2278 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2279 print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'p.ref',
'', $param,
'', $sortfield, $sortorder);
2280 $totalarray[
'nbfield']++;
2282 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2283 print_liste_field_titre($arrayfields[
'p.project_label'][
'label'], $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2284 $totalarray[
'nbfield']++;
2287 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2288 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2289 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2290 $totalarray[
'nbfield']++;
2292 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2293 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2294 $totalarray[
'nbfield']++;
2297 if (!empty($arrayfields[
'author'][
'checked'])) {
2298 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2299 $totalarray[
'nbfield']++;
2301 if (!empty($arrayfields[
't.note'][
'checked'])) {
2302 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2303 $totalarray[
'nbfield']++;
2305 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2306 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
't.tms',
'', $param,
'', $sortfield, $sortorder);
2307 $totalarray[
'nbfield']++;
2309 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2310 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2311 $totalarray[
'nbfield']++;
2313 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2314 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2315 $totalarray[
'nbfield']++;
2318 if (!empty($arrayfields[
'value'][
'checked'])) {
2319 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2320 $totalarray[
'nbfield']++;
2322 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2323 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2324 $totalarray[
'nbfield']++;
2327 $extrafieldsobjectkey =
'projet_task';
2328 $extrafieldsobjectprefix =
'ef.';
2329 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2331 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2332 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2333 print $hookmanager->resPrint;
2334 if (!
$conf->main_checkbox_left_column) {
2335 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2336 $totalarray[
'nbfield']++;
2340 $tasktmp =
new Task($db);
2341 $tmpinvoice =
new Facture($db);
2344 $param .=
'&page='.((int) $page);
2346 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
2350 $savnbfield = $totalarray[
'nbfield'];
2351 $totalarray = array();
2352 $totalarray[
'nbfield'] = 0;
2354 foreach ($tasks as $task_time) {
2360 $invoiced = $task_time->invoice_id ? true :
false;
2362 $date1 = $db->jdate($task_time->element_date);
2363 $date2 = $db->jdate($task_time->element_datehour);
2367 print
'<tr data-rowid="'.$task_time->rowid.
'" class="oddeven">';
2370 if (
$conf->main_checkbox_left_column) {
2371 print
'<td class="center nowraponall">';
2372 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2373 print
'<input type="hidden" name="lineid" value="' .
GETPOSTINT(
'lineid') .
'">';
2375 print
'<input type="hidden" name="id" value="' .
$id .
'">';
2377 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2379 print
'<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2380 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2381 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2382 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' :
'').
'">';
2383 print img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2387 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' :
'') .
'">';
2388 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2392 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' :
'').
'">';
2393 print img_delete(
'default',
'class="pictodelete paddingleft"');
2396 if ($massactionbutton || $massaction) {
2398 if (in_array($task_time->rowid, $arrayofselected)) {
2404 $disabled = ((isset($arrayofmassactions[
'generateinvoice']) || isset($arrayofmassactions[
'generateinter'])) && (intval($task_time->billable) != 1 || $invoiced));
2405 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2409 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2410 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2419 $totalarray[
'nbfield']++;
2424 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2425 print
'<td class="nowrap">';
2426 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2427 if (empty($task_time->element_date_withhour)) {
2428 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 4, 3, 2,
"timespent_date", 1, 0);
2430 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 2, 1, 2,
"timespent_date", 1, 0);
2433 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2437 $totalarray[
'nbfield']++;
2442 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2443 print
'<td class="tdoverflowmax125">';
2444 if ($task_time->fk_soc > 0) {
2445 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2446 $tmpsociete =
new Societe($db);
2447 $tmpsociete->fetch($task_time->fk_soc);
2448 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2450 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2452 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2456 $totalarray[
'nbfield']++;
2461 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2463 if ($task_time->fk_soc > 0) {
2464 if (empty(
$conf->cache[
'thirdparty'][$task_time->fk_soc])) {
2465 $tmpsociete =
new Societe($db);
2466 $tmpsociete->fetch($task_time->fk_soc);
2467 $conf->cache[
'thirdparty'][$task_time->fk_soc] = $tmpsociete;
2469 $tmpsociete =
$conf->cache[
'thirdparty'][$task_time->fk_soc];
2471 $valtoshow = $tmpsociete->name_alias;
2473 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2477 $totalarray[
'nbfield']++;
2481 if (!empty($allprojectforuser)) {
2483 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2484 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2485 $tmpproject =
new Project($db);
2486 $tmpproject->fetch($task_time->fk_projet);
2487 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2489 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2491 print
'<td class="nowraponall">';
2492 print $tmpproject->getNomUrl(1);
2495 $totalarray[
'nbfield']++;
2499 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2500 if (empty(
$conf->cache[
'project'][$task_time->fk_projet])) {
2501 $tmpproject =
new Project($db);
2502 $tmpproject->fetch($task_time->fk_projet);
2503 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2505 $tmpproject =
$conf->cache[
'project'][$task_time->fk_projet];
2507 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).
'">';
2508 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2509 print dolPrintHTML($tmpproject->title);
2511 print $tmpproject->getNomUrl(1,
'', -1);
2515 $totalarray[
'nbfield']++;
2521 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2522 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2523 print
'<td class="nowrap">';
2524 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2525 $formproject->selectTasks(-1,
GETPOSTINT(
'taskid') ?
GETPOSTINT(
'taskid') : $task_time->fk_element,
'taskid', 0, 0,
'1', 1, 0, 0,
'maxwidth250', (string) $projectstatic->id,
'');
2527 $tasktmp->id = $task_time->fk_element;
2528 $tasktmp->ref = $task_time->ref;
2529 $tasktmp->label = $task_time->label;
2530 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2534 $totalarray[
'nbfield']++;
2537 } elseif ($action !==
'createtime') {
2538 print
'<input type="hidden" name="taskid" value="' .
$id .
'">';
2542 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2543 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2544 print
'<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).
'">';
2545 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2546 print
'<span class="spantitle">'.dolPrintHTML($task_time->label).
'</span>';
2548 $tasktmp->id = $task_time->fk_element;
2549 $tasktmp->ref = $task_time->ref;
2550 $tasktmp->label = $task_time->label;
2551 print $tasktmp->getNomUrl(1,
'withproject',
'time', -1);
2555 $totalarray[
'nbfield']++;
2561 if (!empty($arrayfields[
'author'][
'checked'])) {
2562 print
'<td class="tdoverflowmax125">';
2563 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2566 $object->fetch($task_time->fk_element);
2568 $contactsoftask =
$object->getListContactId(
'internal');
2569 if (!in_array($task_time->fk_user, $contactsoftask)) {
2570 $contactsoftask[] = $task_time->fk_user;
2572 if (count($contactsoftask) > 0) {
2573 print img_object(
'',
'user',
'class="pictofixedwidth hideonsmartphone"');
2574 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'minwidth100 maxwidth100');
2576 print img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2579 $userstatic->id = $task_time->fk_user;
2580 $userstatic->lastname = $task_time->lastname;
2581 $userstatic->firstname = $task_time->firstname;
2582 $userstatic->photo = $task_time->photo;
2583 $userstatic->gender = $task_time->gender;
2584 $userstatic->status = $task_time->user_status;
2586 print $userstatic->getNomUrl(-1);
2590 $totalarray[
'nbfield']++;
2595 if (!empty($arrayfields[
't.note'][
'checked'])) {
2596 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2597 print
'<td class="small">';
2598 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2601 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2606 $totalarray[
'nbfield']++;
2608 } elseif ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2609 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2613 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2614 print
'<td class="nowraponall">';
2618 $totalarray[
'nbfield']++;
2623 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2624 print
'<td class="right nowraponall">';
2625 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2626 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2627 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2633 $totalarray[
'nbfield']++;
2636 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2638 if (empty($totalarray[
'val'][
't.element_duration'])) {
2639 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2641 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2644 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2646 if (empty($totalarray[
'totalduration'])) {
2647 $totalarray[
'totalduration'] = $task_time->element_duration;
2649 $totalarray[
'totalduration'] += $task_time->element_duration;
2654 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2655 print
'<td class="nowraponall">';
2656 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2657 print img_picto(
'',
'service');
2658 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);
2659 } elseif (!empty($task_time->fk_product)) {
2661 $resultFetch = $product->fetch($task_time->fk_product);
2662 if ($resultFetch < 0) {
2663 setEventMessages($product->error, $product->errors,
'errors');
2665 print $product->getNomUrl(1);
2670 $totalarray[
'nbfield']++;
2675 if (!empty($arrayfields[
'value'][
'checked'])) {
2676 $langs->load(
"salaries");
2677 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2679 print
'<td class="nowraponall right">';
2680 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2681 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2685 $totalarray[
'nbfield']++;
2688 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2690 if (empty($totalarray[
'val'][
'value'])) {
2691 $totalarray[
'val'][
'value'] = $value;
2693 $totalarray[
'val'][
'value'] += $value;
2696 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2698 if (empty($totalarray[
'totalvalue'])) {
2699 $totalarray[
'totalvalue'] = $value;
2701 $totalarray[
'totalvalue'] += $value;
2706 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2707 print
'<td class="center">';
2709 if ($projectstatic->usage_bill_time) {
2710 if ($task_time->invoice_id) {
2711 $result = $tmpinvoice->fetch($task_time->invoice_id);
2713 if ($user->hasRight(
'facture',
'lire')) {
2714 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2715 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid' => $projectstatic->id));
2717 print $tmpinvoice->getNomUrl(1);
2718 if (!empty($task_time->invoice_line_id)) {
2720 $invoiceLine->fetch($task_time->invoice_line_id);
2721 if (!empty($invoiceLine->id)) {
2722 print
'<br><span class="small opacitymedium">'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2723 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2729 print $langs->trans(
"Yes");
2734 if (intval($task_time->billable) == 1) {
2735 print $langs->trans(
"No");
2737 print $langs->trans(
"Disabled");
2741 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2746 $totalarray[
'nbfield']++;
2752 $extrafieldsobjectkey =
'projet_task';
2753 $extrafieldsobjectprefix =
'ef.';
2754 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2757 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2758 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2759 print $hookmanager->resPrint;
2762 if (!
$conf->main_checkbox_left_column) {
2763 print
'<td class="center nowraponall">';
2764 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2765 print
'<input type="hidden" name="lineid" value="'.GETPOSTINT(
'lineid').
'">';
2766 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2768 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2769 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2770 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2771 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' :
'').
'">';
2772 print img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2776 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' :
'') .
'">';
2777 print
img_split(
'',
'class="pictofixedwidth paddingleft"');
2781 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' :
'').
'">';
2782 print img_delete(
'default',
'class="pictodelete paddingleft"');
2785 if ($massactionbutton || $massaction) {
2787 if (in_array($task_time->rowid, $arrayofselected)) {
2793 $disabled = ((isset($arrayofmassactions[
'generateinvoice']) || isset($arrayofmassactions[
'generateinter'])) && (intval($task_time->billable) != 1 || $invoiced));
2794 $ctrl =
'<input '.($disabled ?
'disabled' :
'').
' id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2798 print
'<span id="cbsp'. $task_time->rowid .
'">'.$ctrl.
'</span>';
2799 print
'<script>$("#cbsp' . $task_time->rowid .
'").dblclick(()=>{ $("#cb' . $task_time->rowid .
'").removeAttr("disabled") })</script>';
2808 $totalarray[
'nbfield']++;
2817 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2818 print
'<!-- first line -->';
2819 print
'<tr class="oddeven">';
2822 if (
$conf->main_checkbox_left_column) {
2827 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2828 print
'<td class="nowrap">';
2829 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2830 if (empty($task_time->element_date_withhour)) {
2831 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2833 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2836 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2842 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2843 print
'<td class="nowrap">';
2848 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2849 print
'<td class="nowrap">';
2854 if (!empty($allprojectforuser)) {
2855 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2856 print
'<td class="nowrap">';
2862 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2863 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2864 print
'<td class="nowrap">';
2865 $tasktmp->id = $task_time->fk_element;
2866 $tasktmp->ref = $task_time->ref;
2867 $tasktmp->label = $task_time->label;
2868 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2874 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2875 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2876 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2877 print
'<span class="spantitle">'.dol_escape_htmltag($task_time->label).
'</span>';
2883 if (!empty($arrayfields[
'author'][
'checked'])) {
2884 print
'<td class="nowraponall">';
2885 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2887 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
2890 $contactsoftask =
$object->getListContactId(
'internal');
2891 if (!in_array($task_time->fk_user, $contactsoftask)) {
2892 $contactsoftask[] = $task_time->fk_user;
2894 if (count($contactsoftask) > 0) {
2895 print img_object(
'',
'user',
'class="hideonsmartphone"');
2896 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
null, 0,
'', $contactsoftask);
2898 print img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2901 $userstatic->id = $task_time->fk_user;
2902 $userstatic->lastname = $task_time->lastname;
2903 $userstatic->firstname = $task_time->firstname;
2904 $userstatic->photo = $task_time->photo;
2905 $userstatic->status = $task_time->user_status;
2906 print $userstatic->getNomUrl(-1);
2912 if (!empty($arrayfields[
't.note'][
'checked'])) {
2913 print
'<td class="tdoverflowmax300">';
2914 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2915 print
'<textarea name="timespent_note_line" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2920 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2921 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_2 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2925 if (!empty($arrayfields[
't.tms'][
'checked'])) {
2926 print
'<td class="nowraponall">';
2931 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2932 print
'<td class="right">';
2933 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
2934 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2935 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2943 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2944 print
'<td class="nowraponall tdoverflowmax125">';
2949 if (!empty($arrayfields[
'value'][
'checked'])) {
2950 print
'<td class="right">';
2951 print
'<span class="amount">';
2952 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2953 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
2959 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2960 print
'<td class="right">';
2961 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2962 if (isset($task_time->total_ht)) {
2963 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
2970 $extrafieldsobjectkey =
'projet_task';
2971 $extrafieldsobjectprefix =
'ef.';
2972 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2975 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2976 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2977 print $hookmanager->resPrint;
2980 if (!
$conf->main_checkbox_left_column) {
2981 print
'<td class="center nowraponall">';
2990 print
'<!-- second line --><tr class="oddeven">';
2993 if (
$conf->main_checkbox_left_column) {
2994 print
'<td class="center nowraponall">';
2999 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
3000 print
'<td class="nowraponall">';
3001 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3002 if (empty($task_time->element_date_withhour)) {
3003 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
3005 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
3008 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
3014 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
3020 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
3026 if (!empty($allprojectforuser)) {
3027 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
3034 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
3035 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
3036 print
'<td class="nowraponall">';
3037 $tasktmp->id = $task_time->fk_element;
3038 $tasktmp->ref = $task_time->ref;
3039 $tasktmp->label = $task_time->label;
3040 print $tasktmp->getNomUrl(1,
'withproject',
'time');
3046 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
3047 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
3048 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).
'">';
3049 print
'<span class="spantitle">'.dol_escape_htmltag($task_time->label).
'</span>';
3055 if (!empty($arrayfields[
'author'][
'checked'])) {
3056 print
'<td class="nowraponall tdoverflowmax100">';
3057 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3059 $idTask = (!empty($id)) ? $id : $task_time->fk_element;
3062 $contactsoftask =
$object->getListContactId(
'internal');
3063 if (!in_array($task_time->fk_user, $contactsoftask)) {
3064 $contactsoftask[] = $task_time->fk_user;
3066 if (count($contactsoftask) > 0) {
3067 print img_object(
'',
'user',
'class="hideonsmartphone"');
3068 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
null, 0,
'', $contactsoftask);
3070 print img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
3073 $userstatic->id = $task_time->fk_user;
3074 $userstatic->lastname = $task_time->lastname;
3075 $userstatic->firstname = $task_time->firstname;
3076 $userstatic->photo = $task_time->photo;
3077 $userstatic->status = $task_time->user_status;
3078 print $userstatic->getNomUrl(-1);
3084 if (!empty($arrayfields[
't.note'][
'checked'])) {
3085 print
'<td class="small tdoverflowmax300"">';
3086 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3087 print
'<textarea name="timespent_note_line_2" class="centpercentimp" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
3092 } elseif ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3093 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
3097 if (!empty($arrayfields[
't.tms'][
'checked'])) {
3098 print
'<td class="nowraponall">';
3104 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
3105 print
'<td class="right">';
3106 if ($action ==
'splitline' &&
GETPOSTINT(
'lineid') == $task_time->rowid) {
3107 print
'<input type="hidden" name="old_duration_2" value="0">';
3108 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
3116 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
3117 print
'<td class="nowraponall tdoverflowmax125">';
3122 if (!empty($arrayfields[
'value'][
'checked'])) {
3123 print
'<td class="right">';
3124 print
'<span class="amount nowraponall">';
3126 print
price($value, 1, $langs, 1, -1, -1,
$conf->currency);
3133 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
3134 print
'<td class="right">';
3135 if (isset($task_time->total_ht)) {
3136 $valuebilled =
price2num($task_time->total_ht,
'', 1);
3137 print
'<span class="amount nowraponall small">';
3138 print
price($valuebilled, 1, $langs, 1, -1, -1,
$conf->currency);
3146 $extrafieldsobjectkey =
'projet_task';
3147 $extrafieldsobjectprefix =
'ef.';
3148 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
3151 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
3152 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
3153 print $hookmanager->resPrint;
3156 if (!
$conf->main_checkbox_left_column) {
3157 print
'<td class="center nowraponall">';
3169 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
3170 print
'<tr class="liste_total">';
3172 while ($i < $totalarray[
'nbfield']) {
3175 if ($num < $limit && empty($offset)) {
3176 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
3178 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
3180 } elseif (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
3181 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
3182 } elseif (isset($totalarray[
'totalvaluefield']) && $totalarray[
'totalvaluefield'] == $i) {
3183 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
3192 if (!count($tasks)) {
3193 $totalnboffields = 1;
3194 foreach ($arrayfields as $value) {
3195 if (!empty($value[
'checked'])) {
3199 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
3200 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
3204 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3205 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3206 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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to build export files with format CSV utf-8.
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_now($mode='gmt')
Return date for now.
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 ...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_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).
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.
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,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
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.