30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formintervention.class.php';
41 $langsLoad=array(
'projects',
'bills',
'orders');
42 if (!empty($conf->eventorganization->enabled)) {
43 $langsLoad[]=
'eventorganization';
46 $langs->loadLangs($langsLoad);
48 $action =
GETPOST(
'action',
'alpha');
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $cancel =
GETPOST(
'cancel',
'alpha');
52 $toselect =
GETPOST(
'toselect',
'array');
53 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
54 $backtopage =
GETPOST(
'backtopage',
'alpha');
55 $optioncss =
GETPOST(
'optioncss',
'alpha');
58 $projectid =
GETPOST(
'projectid',
'int');
60 $withproject =
GETPOST(
'withproject',
'int');
61 $project_ref =
GETPOST(
'project_ref',
'alpha');
64 $search_day =
GETPOST(
'search_day',
'int');
65 $search_month =
GETPOST(
'search_month',
'int');
66 $search_year =
GETPOST(
'search_year',
'int');
67 $search_datehour =
'';
68 $search_datewithhour =
'';
69 $search_note =
GETPOST(
'search_note',
'alpha');
70 $search_duration =
GETPOST(
'search_duration',
'int');
71 $search_value =
GETPOST(
'search_value',
'int');
72 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
73 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
74 $search_user =
GETPOST(
'search_user',
'int');
75 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
77 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
78 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
79 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
81 if (empty($page) || $page == -1) {
84 $offset = $limit * $page;
85 $pageprev = $page - 1;
86 $pagenext = $page + 1;
88 $sortfield =
't.task_date,t.task_datehour,t.rowid';
91 $sortorder =
'DESC,DESC,DESC';
94 $childids = $user->getAllChildIds(1);
98 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
100 $object =
new Task($db);
102 $projectstatic =
new Project($db);
105 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
106 $extrafields->fetch_name_optionals_label($object->table_element);
109 if ($id > 0 || $ref) {
110 $object->fetch($id, $ref);
117 if (!$user->rights->projet->lire) {
121 if ($object->fk_project > 0) {
122 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
126 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
127 $search_user = $user->id;
137 if (
GETPOST(
'cancel',
'alpha')) {
140 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
144 $parameters = array(
'socid'=>$socid,
'projectid'=>$projectid);
145 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
153 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
158 $search_datehour =
'';
159 $search_datewithhour =
'';
161 $search_duration =
'';
163 $search_date_creation =
'';
164 $search_date_update =
'';
165 $search_task_ref =
'';
166 $search_task_label =
'';
168 $search_valuebilled =
'';
170 $search_array_options = array();
174 if ($action ==
'addtimespent' && $user->rights->projet->time) {
177 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
178 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
179 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
180 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")), null,
'errors');
183 if (!
GETPOST(
"userid",
'int')) {
184 $langs->load(
"errors");
185 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'), null,
'errors');
191 $object->fetch($id, $ref);
194 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")), null,
'errors');
195 $action =
'createtime';
198 $object->fetch(
GETPOST(
'taskid',
'int'));
203 $object->fetch_projet();
205 if (empty($object->project->statut)) {
206 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"), null,
'errors');
207 $action =
'createtime';
210 $object->timespent_note =
GETPOST(
"timespent_note",
'alpha');
211 if (
GETPOST(
'progress',
'int') > 0) {
212 $object->progress =
GETPOST(
'progress',
'int');
214 $object->timespent_duration =
GETPOSTINT(
"timespent_durationhour") * 60 * 60;
215 $object->timespent_duration += (
GETPOSTINT(
'timespent_durationmin') ?
GETPOSTINT(
'timespent_durationmin') : 0) * 60;
217 $object->timespent_date =
dol_mktime(
GETPOST(
"timehour",
'int'),
GETPOST(
"timemin",
'int'), 0,
GETPOST(
"timemonth",
'int'),
GETPOST(
"timeday",
'int'),
GETPOST(
"timeyear",
'int'));
218 $object->timespent_withhour = 1;
222 $object->timespent_fk_user =
GETPOST(
"userid",
'int');
223 $result = $object->addTimeSpent($user);
234 $action =
'createtime';
236 $action =
'createtime';
241 if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire) {
244 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
245 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")), null,
'errors');
250 if (
GETPOST(
'taskid',
'int') != $id) {
251 $id_temp =
GETPOST(
'taskid',
'int');
254 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
257 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
258 $result = $object->delTimeSpent($user);
261 $object->fetch($id_temp, $ref);
263 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
264 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
265 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
266 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
267 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
269 $object->timespent_withhour = 1;
273 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
276 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
277 $result = $object->addTimeSpent($user);
287 $object->fetch($id, $ref);
289 $object->timespent_id =
GETPOST(
"lineid",
'int');
290 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
291 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
292 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
293 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
294 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
295 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
296 $object->timespent_withhour = 1;
300 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
303 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
304 $result = $object->updateTimeSpent($user);
319 if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && $user->rights->projet->supprimer) {
320 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
322 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
323 $result = $object->delTimeSpent($user);
326 $langs->load(
"errors");
337 if (!empty($project_ref) && !empty($withproject)) {
338 if ($projectstatic->fetch(0, $project_ref) > 0) {
339 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
340 if (count($tasksarray) > 0) {
341 $id = $tasksarray[0]->id;
343 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
350 $projectidforalltimes = 0;
351 if (
GETPOST(
'projectid',
'int') > 0) {
352 $projectidforalltimes =
GETPOST(
'projectid',
'int');
354 $result = $projectstatic->fetch($projectidforalltimes);
355 if (!empty($projectstatic->socid)) {
356 $projectstatic->fetch_thirdparty();
358 $res = $projectstatic->fetch_optionals();
359 } elseif (
GETPOST(
'project_ref',
'alpha')) {
360 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
361 $projectidforalltimes = $projectstatic->id;
365 $result = $projectstatic->fetch($object->fk_project);
368 if ($id <= 0 && $projectidforalltimes == 0) {
369 $allprojectforuser = $user->id;
372 if ($action ==
'confirm_generateinvoice') {
373 if (!empty($projectstatic->socid)) {
374 $projectstatic->fetch_thirdparty();
377 if (!($projectstatic->thirdparty->id > 0)) {
378 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"), null,
'errors');
380 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
381 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
382 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
384 $tmpinvoice =
new Facture($db);
385 $tmptimespent =
new Task($db);
386 $tmpproduct =
new Product($db);
387 $fuser =
new User($db);
390 $idprod =
GETPOST(
'productid',
'int');
391 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
392 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
394 $prodDurationHours = 1.0;
396 $tmpproduct->fetch($idprod);
398 if (empty($tmpproduct->duration_value)) {
400 $langs->load(
"errors");
401 setEventMessages($langs->trans(
"ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice"), null,
'errors');
404 if ($tmpproduct->duration_unit ==
'i') {
405 $prodDurationHours = 1. / 60;
407 if ($tmpproduct->duration_unit ==
'h') {
408 $prodDurationHours = 1.;
410 if ($tmpproduct->duration_unit ==
'd') {
411 $prodDurationHours = 24.;
413 if ($tmpproduct->duration_unit ==
'w') {
414 $prodDurationHours = 24. * 7;
416 if ($tmpproduct->duration_unit ==
'm') {
417 $prodDurationHours = 24. * 30;
419 if ($tmpproduct->duration_unit ==
'y') {
420 $prodDurationHours = 24. * 365;
422 $prodDurationHours *= $tmpproduct->duration_value;
424 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
426 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
427 $txtva = $dataforprice[
'tva_tx'];
428 $localtax1 = $dataforprice[
'localtax1'];
429 $localtax2 = $dataforprice[
'localtax2'];
431 $prodDurationHours = 1;
439 $tmpinvoice->socid = $projectstatic->thirdparty->id;
440 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
441 $tmpinvoice->fk_project = $projectstatic->id;
444 $tmpinvoice->fetch($invoiceToUse);
446 $result = $tmpinvoice->create($user);
454 if ($generateinvoicemode ==
'onelineperuser') {
455 $arrayoftasks = array();
456 foreach ($toselect as $key => $value) {
458 $object->fetchTimeSpent($value);
459 $arrayoftasks[$object->timespent_fk_user][
'timespent'] += $object->timespent_duration;
460 $arrayoftasks[$object->timespent_fk_user][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
463 foreach ($arrayoftasks as $userid => $value) {
464 $fuser->fetch($userid);
466 $username = $fuser->getFullName($langs);
469 $qtyhour = $value[
'timespent'] / 3600;
470 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
474 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
478 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username).
' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
481 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
482 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((int) $userid);
483 $result = $db->query($sql);
490 } elseif ($generateinvoicemode ==
'onelineperperiod') {
491 $arrayoftasks = array();
492 $withdetail=
GETPOST(
'detail_time_duration',
'alpha');
493 foreach ($toselect as $key => $value) {
495 $object->fetchTimeSpent($value);
497 $ftask =
new Task($db);
498 $ftask->fetch($object->id);
500 $fuser->fetch($object->timespent_fk_user);
501 $username = $fuser->getFullName($langs);
503 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
504 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
505 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref.
' - '.$ftask->label.
' - '.$username.($object->timespent_note ?
' - '.$object->timespent_note :
'');
506 if (!empty($withdetail)) {
507 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
508 $arrayoftasks[$object->timespent_id][
'note'] .=
"<br/>";
510 $arrayoftasks[$object->timespent_id][
'note'] .=
"\n";
513 if (!empty($object->timespent_withhour)) {
514 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour);
516 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date);
518 $arrayoftasks[$object->timespent_id][
'note'] .=
' - '.$langs->trans(
"Duration").
': '.
convertSecondToTime($object->timespent_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
520 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
523 foreach ($arrayoftasks as $timespent_id => $value) {
524 $userid = $value[
'user'];
528 $qtyhour = $value[
'timespent'] / 3600;
532 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
536 $lineid = $tmpinvoice->addline($value[
'note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
540 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
541 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((int) $userid);
542 $result = $db->query($sql);
549 } elseif ($generateinvoicemode ==
'onelinepertask') {
550 $arrayoftasks = array();
551 foreach ($toselect as $key => $value) {
553 $object->fetchTimeSpent($value);
555 $arrayoftasks[$object->id][
'timespent'] += $object->timespent_duration;
556 $arrayoftasks[$object->id][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
559 foreach ($arrayoftasks as $task_id => $value) {
560 $ftask =
new Task($db);
561 $ftask->fetch($task_id);
563 $qtyhour = $value[
'timespent'] / 3600;
564 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
568 $pu_ht_for_task = $pu_ht;
570 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
571 $pu_ht_for_task =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU') * $prodDurationHours;
573 $pa_ht =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU') * $prodDurationHours;
578 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
579 $pu_ht_for_task =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU');
581 $pa_ht =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU');
587 $lineName = $ftask->ref.
' - '.$ftask->label;
588 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0), 0, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0, null, $pa_ht);
597 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
598 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
')';
599 $result = $db->query($sql);
611 $urltoinvoice = $tmpinvoice->getNomUrl(0);
612 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
613 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
625 if ($action ==
'confirm_generateinter') {
626 $langs->load(
'interventions');
628 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
630 if (!($projectstatic->thirdparty->id > 0)) {
631 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"), null,
'errors');
633 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
634 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
635 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
638 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
640 $tmptimespent =
new Task($db);
641 $fuser =
new User($db);
644 $interToUse =
GETPOST(
'interid',
'int');
647 $tmpinter->socid = $projectstatic->thirdparty->id;
648 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
649 $tmpinter->fk_project = $projectstatic->id;
650 $tmpinter->description = $projectstatic->title . ( ! empty($projectstatic->description) ?
'-' . $projectstatic->label :
'' );
653 $tmpinter->fetch($interToUse);
655 $result = $tmpinter->create($user);
663 $arrayoftasks = array();
664 foreach ($toselect as $key => $value) {
666 $object->fetchTimeSpent($value);
668 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
669 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
670 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
671 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
672 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
675 foreach ($arrayoftasks as $timespent_id => $value) {
676 $ftask =
new Task($db);
677 $ftask->fetch($value[
'id']);
679 $qtyhour = $value[
'timespent'] / 3600;
680 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
683 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . ( ! empty($value[
'note']) ?
' - ' . $value[
'note'] :
'' ), $value[
'date'], $value[
'timespent']);
688 $urltointer = $tmpinter->getNomUrl(0);
689 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
690 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
706 $arrayofselected = is_array($toselect) ? $toselect : array();
713 $userstatic =
new User($db);
715 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
719 if ($projectidforalltimes > 0) {
720 $result = $projectstatic->fetch($projectidforalltimes);
721 if (!empty($projectstatic->socid)) {
722 $projectstatic->fetch_thirdparty();
724 $res = $projectstatic->fetch_optionals();
725 } elseif ($object->fetch($id, $ref) >= 0) {
726 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
727 $object->fetchComments();
729 $result = $projectstatic->fetch($object->fk_project);
730 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
731 $projectstatic->fetchComments();
733 if (!empty($projectstatic->socid)) {
734 $projectstatic->fetch_thirdparty();
736 $res = $projectstatic->fetch_optionals();
738 $object->project = clone $projectstatic;
741 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
742 $linktocreatetime =
'';
744 if ($projectstatic->id > 0) {
747 if (empty($id) || $tab ==
'timespent') {
754 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
756 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
758 $param .=
'&search_user='.((int) $search_user);
761 $param .=
'&search_month='.((int) $search_month);
764 $param .=
'&search_year='.((int) $search_year);
769 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
771 $morehtmlref =
'<div class="refidno">';
773 $morehtmlref .= $projectstatic->title;
775 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
776 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
778 $morehtmlref .=
'</div>';
781 if (empty($user->rights->projet->all->lire)) {
782 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
783 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
786 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
788 print
'<div class="fichecenter">';
789 print
'<div class="fichehalfleft">';
790 print
'<div class="underbanner clearboth"></div>';
792 print
'<table class="border tableforfield centpercent">';
795 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
796 print
'<tr><td class="tdtop">';
797 print $langs->trans(
"Usage");
800 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
801 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
802 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
803 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
806 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
807 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
808 $htmltext = $langs->trans(
"ProjectFollowTasks");
809 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
812 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
813 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"' :
'')).
'"> ';
814 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
815 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
819 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"' :
'')).
'"> ';
820 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
821 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
827 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
828 if ($projectstatic->public) {
829 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
830 print $langs->trans(
'SharedProject');
832 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
833 print $langs->trans(
'PrivateProject');
838 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
840 print ($start ? $start :
'?');
843 print ($end ? $end :
'?');
844 if ($projectstatic->hasDelay()) {
850 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
851 if (strcmp($projectstatic->budget_amount,
'')) {
852 print
'<span class="amount">'.price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
863 print
'<div class="fichehalfright">';
864 print
'<div class="underbanner clearboth"></div>';
866 print
'<table class="border tableforfield centpercent">';
869 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
870 print nl2br($projectstatic->description);
875 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
876 print $form->showCategories($projectstatic->id,
'project', 1);
885 print
'<div class="clearboth"></div>';
893 $linktocreatetimeBtnStatus = 0;
894 $linktocreatetimeUrl =
'';
895 $linktocreatetimeHelpText =
'';
896 if (!empty($user->rights->projet->time)) {
897 if ($projectstatic->public || $userRead > 0) {
898 $linktocreatetimeBtnStatus = 1;
900 if (!empty($projectidforalltimes)) {
902 $backtourl = $_SERVER[
'PHP_SELF'].
'?projectid='.$projectstatic->id.($withproject ?
'&withproject=1' :
'');
903 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').
'&projectid='.$projectstatic->id.
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
906 $backtourl = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($withproject ?
'&withproject=1' :
'');
907 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').($object->id > 0 ?
'&id='.$object->id :
'&projectid='.$projectstatic->id).
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
910 $linktocreatetimeBtnStatus = -2;
911 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
914 $linktocreatetimeBtnStatus = -2;
915 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
918 $paramsbutton = array(
'morecss'=>
'reposition');
919 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
922 $massactionbutton =
'';
923 $arrayofmassactions = array();
925 if ($projectstatic->id > 0) {
927 if ($projectstatic->usage_bill_time) {
928 $arrayofmassactions = array(
929 'generateinvoice'=>$langs->trans(
"GenerateBill"),
933 if ( ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) {
934 $langs->load(
"interventions");
935 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
939 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
940 $arrayofmassactions = array();
942 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
945 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
947 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
949 if ($action ==
'deleteline') {
950 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
"lineid",
'int').($withproject ?
'&withproject=1' :
''), $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
953 $param = ($withproject ?
'&withproject=1' :
'');
954 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
956 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
957 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
958 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
960 $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
966 if (empty($withproject)) {
967 $morehtmlref .=
'<div class="refidno">';
968 $morehtmlref .= $langs->trans(
"Project").
': ';
969 $morehtmlref .= $projectstatic->getNomUrl(1);
970 $morehtmlref .=
'<br>';
973 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
974 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
975 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
977 $morehtmlref .=
'</div>';
980 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
982 print
'<div class="fichecenter">';
983 print
'<div class="fichehalfleft">';
985 print
'<div class="underbanner clearboth"></div>';
986 print
'<table class="border centpercent tableforfield">';
989 print
'<tr><td>'.$langs->trans(
"ChildOfTask").
'</td><td>';
990 if ($object->fk_task_parent > 0) {
991 $tasktmp =
new Task($db);
992 $tasktmp->fetch($object->fk_task_parent);
993 print $tasktmp->getNomUrl(1);
998 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"Deadline").
'</td><td>';
1000 print ($start ? $start :
'?');
1003 print ($end ? $end :
'?');
1004 if ($object->hasDelay()) {
1010 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
1011 if ($object->planned_workload) {
1019 print
'<div class="fichehalfright">';
1021 print
'<div class="underbanner clearboth"></div>';
1022 print
'<table class="border tableforfield centpercent">';
1025 print
'<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td>';
1026 print $object->progress !=
'' ? $object->progress.
' %' :
'';
1030 print
'<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td>';
1031 if ($object->planned_workload) {
1032 $tmparray = $object->getSummaryOfTimeSpent();
1033 if ($tmparray[
'total_duration'] > 0) {
1034 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
1039 print
'<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
1050 print
'<div class="clearboth"></div>';
1056 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1057 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1058 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
'lineid',
'int').($withproject ?
'&withproject=1' :
''), $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1062 $hookmanager->initHooks(array(
'tasktimelist'));
1066 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1067 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
'lineid',
'int').($withproject ?
'&withproject=1' :
''), $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1071 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1072 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1073 if (empty($reshook)) {
1075 } elseif ($reshook > 0) {
1083 $arrayfields = array();
1084 $arrayfields[
't.task_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1085 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1086 $arrayfields[
't.task_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1087 $arrayfields[
't.task_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1089 $arrayfields[
'author'] = array(
'label'=>$langs->trans(
"By"),
'checked'=>1);
1090 $arrayfields[
't.note'] = array(
'label'=>$langs->trans(
"Note"),
'checked'=>1);
1091 $arrayfields[
't.task_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1092 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
1093 $arrayfields[
'valuebilled'] = array(
'label'=>$langs->trans(
"Billed"),
'checked'=>1,
'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time));
1095 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
1100 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1101 $param .=
'&contextpage='.urlencode($contextpage);
1103 if ($limit > 0 && $limit != $conf->liste_limit) {
1104 $param .=
'&limit='.urlencode($limit);
1106 if ($search_month > 0) {
1107 $param .=
'&search_month='.urlencode($search_month);
1109 if ($search_year > 0) {
1110 $param .=
'&search_year='.urlencode($search_year);
1112 if ($search_user > 0) {
1113 $param .=
'&search_user='.urlencode($search_user);
1115 if ($search_task_ref !=
'') {
1116 $param .=
'&search_task_ref='.urlencode($search_task_ref);
1118 if ($search_task_label !=
'') {
1119 $param .=
'&search_task_label='.urlencode($search_task_label);
1121 if ($search_note !=
'') {
1122 $param .=
'&search_note='.urlencode($search_note);
1124 if ($search_duration !=
'') {
1125 $param .=
'&search_field2='.urlencode($search_duration);
1127 if ($optioncss !=
'') {
1128 $param .=
'&optioncss='.urlencode($optioncss);
1135 $param .=
'&id='.urlencode($id);
1138 $param .=
'&projectid='.urlencode($projectid);
1141 $param .=
'&withproject='.urlencode($withproject);
1144 $parameters = array();
1145 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1146 $param .= $hookmanager->resPrint;
1148 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1149 if ($optioncss !=
'') {
1150 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1152 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1153 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1154 if ($action ==
'editline') {
1155 print
'<input type="hidden" name="action" value="updateline">';
1156 } elseif ($action ==
'splitline') {
1157 print
'<input type="hidden" name="action" value="updatesplitline">';
1158 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1159 print
'<input type="hidden" name="action" value="addtimespent">';
1160 } elseif ($massaction ==
'generateinvoice' && $user->rights->facture->lire) {
1161 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1162 } elseif ($massaction ==
'generateinter' && $user->rights->ficheinter->lire) {
1163 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1165 print
'<input type="hidden" name="action" value="list">';
1167 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1168 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1170 print
'<input type="hidden" name="id" value="'.$id.
'">';
1171 print
'<input type="hidden" name="projectid" value="'.$projectidforalltimes.
'">';
1172 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
1173 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
1174 print
'<input type="hidden" name="page_y" value="">';
1177 if ($massaction ==
'generateinvoice') {
1178 if ($projectstatic->thirdparty->id > 0) {
1179 print
'<table class="noborder centerpercent">';
1181 print
'<td class="titlefield">';
1182 print $langs->trans(
'DateInvoice');
1185 print $form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1191 print $langs->trans(
'Mode');
1195 'onelineperuser'=>
'OneLinePerUser',
1196 'onelinepertask'=>
'OneLinePerTask',
1197 'onelineperperiod'=>
'OneLinePerTimeSpentLine',
1199 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1200 print
"\n".
'<script type="text/javascript">';
1202 $(document).ready(function () {
1203 setDetailVisibility();
1204 $("#generateinvoicemode").change(function() {
1205 setDetailVisibility();
1207 function setDetailVisibility() {
1208 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1209 if (generateinvoicemode=="onelineperperiod") {
1210 $("#detail_time_duration").show();
1212 $("#detail_time_duration").hide();
1217 print
'</script>'.
"\n";
1218 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>'.$langs->trans(
'AddDetailDateAndDuration').
'</span>';
1222 if ($conf->service->enabled) {
1225 print $langs->trans(
'ServiceToUseOnLines');
1228 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1234 print
'<td class="titlefield">';
1235 print $langs->trans(
'InvoiceToUse');
1238 $form->selectInvoice(
'invoice',
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1252 print
'<div class="center">';
1253 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'GenerateBill').
'"> ';
1254 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1258 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateInvoice").
'</div>';
1259 print
'<div class="center">';
1260 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1264 } elseif ($massaction ==
'generateinter') {
1266 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1268 if ($projectstatic->thirdparty->id > 0) {
1270 print
'<table class="noborder centpercent">';
1272 print
'<td class="titlefield">';
1273 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"').$langs->trans(
'InterToUse');
1277 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1282 print
'<div class="center">';
1283 print
'<input type="submit" class="button" id="createinter" name="createinter" value="'.$langs->trans(
'GenerateInter').
'"> ';
1284 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1288 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateIntervention").
'</div>';
1289 print
'<div class="center">';
1290 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1297 $parameters = array(
1298 'toselect' => $toselect,
1299 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1302 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1306 print $hookmanager->resPrint;
1314 $sql =
"SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,";
1315 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1316 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1317 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1319 $parameters = array();
1320 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1321 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
1322 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1323 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
1324 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1325 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1327 $parameters = array();
1328 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1329 $sql .= $hookmanager->resPrint;
1330 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"user as u";
1331 $sql .=
" WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
1333 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1335 $sql .=
" AND t.fk_task =".((int) $object->id);
1336 } elseif (!empty($projectidforalltimes)) {
1338 $sql .=
" AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).
")";
1339 } elseif (!empty($allprojectforuser)) {
1341 if (empty($search_user)) {
1342 $search_user = $user->id;
1344 $sql .=
" AND t.fk_user = ".((int) $search_user);
1350 if ($search_task_ref) {
1353 if ($search_task_label) {
1356 if ($search_user > 0) {
1359 if ($search_valuebilled ==
'1') {
1360 $sql .=
' AND t.invoice_id > 0';
1362 if ($search_valuebilled ==
'0') {
1363 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1366 $sql .=
dolSqlDateFilter(
't.task_datehour', $search_day, $search_month, $search_year);
1369 $parameters = array();
1370 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1371 $sql .= $hookmanager->resPrint;
1372 $sql .= $db->order($sortfield, $sortorder);
1375 $nbtotalofrecords =
'';
1376 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1377 $resql = $db->query($sql);
1384 $nbtotalofrecords = $db->num_rows(
$resql);
1385 if (($page * $limit) > $nbtotalofrecords) {
1391 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
1392 $num = $nbtotalofrecords;
1394 $sql .= $db->plimit($limit + 1, $offset);
1396 $resql = $db->query($sql);
1402 $num = $db->num_rows(
$resql);
1406 if (!empty($projectidforalltimes)) {
1407 print
'<!-- List of time spent for project -->'.
"\n";
1409 $title = $langs->trans(
"ListTaskTimeUserProject");
1411 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1413 print
'<!-- List of time spent -->'.
"\n";
1415 $title = $langs->trans(
"ListTaskTimeForTask");
1417 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1422 $row = $db->fetch_object(
$resql);
1434 if ($action ==
'createtime' && $user->rights->projet->time) {
1435 print
'<!-- table to add time spent -->'.
"\n";
1437 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1440 print
'<div class="div-table-responsive-no-min">';
1441 print
'<table class="noborder nohover centpercent">';
1443 print
'<tr class="liste_titre">';
1444 print
'<td>'.$langs->trans(
"Date").
'</td>';
1445 if (!empty($allprojectforuser)) {
1446 print
'<td>'.$langs->trans(
"Project").
'</td>';
1449 print
'<td>'.$langs->trans(
"Task").
'</td>';
1451 print
'<td>'.$langs->trans(
"By").
'</td>';
1452 print
'<td>'.$langs->trans(
"Note").
'</td>';
1453 print
'<td>'.$langs->trans(
"NewTimeSpent").
'</td>';
1454 print
'<td>'.$langs->trans(
"ProgressDeclared").
'</td>';
1455 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1459 $parameters = array(
'mode' =>
'create');
1460 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1461 print $hookmanager->resPrint;
1465 print
'<tr class="oddeven nohover">';
1468 print
'<td class="maxwidthonsmartphone">';
1470 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1473 if (!empty($allprojectforuser)) {
1482 print
'<td class="maxwidthonsmartphone">';
1483 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1488 print
'<td class="maxwidthonsmartphone nowraponall">';
1489 $contactsofproject = $projectstatic->getListContactId(
'internal');
1490 if (count($contactsofproject) > 0) {
1491 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1492 if (in_array($user->id, $contactsofproject)) {
1493 $userid = $user->id;
1495 $userid = $contactsofproject[0];
1498 if ($projectstatic->public) {
1499 $contactsofproject = array();
1501 print $form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'maxwidth250');
1504 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).
' '.$langs->trans(
'FirstAddRessourceToAllocateTime');
1511 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.
'">'.(
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'').
'</textarea>';
1515 print
'<td class="nowraponall">';
1516 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1518 $durationtouse = (
GETPOST(
'timespent_durationhour') * 3600 +
GETPOST(
'timespent_durationmin') * 60);
1520 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1524 print
'<td class="nowrap">';
1525 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1529 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1535 $parameters = array(
'mode' =>
'create');
1536 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1537 print $hookmanager->resPrint;
1539 print
'<td class="center">';
1540 $form->buttonsSaveCancel();
1541 print
'<input type="submit" name="save" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-add" value="'.$langs->trans(
"Add").
'">';
1542 print
'<input type="submit" name="cancel" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1551 $moreforfilter =
'';
1553 $parameters = array();
1554 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1555 if (empty($reshook)) {
1556 $moreforfilter .= $hookmanager->resPrint;
1558 $moreforfilter = $hookmanager->resPrint;
1561 if (!empty($moreforfilter)) {
1562 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1563 print $moreforfilter;
1567 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1568 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1569 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1571 print
'<div class="div-table-responsive">';
1572 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1575 print
'<tr class="liste_titre_filter">';
1577 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1578 print
'<td class="liste_titre">';
1579 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
1580 print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.
'">';
1582 print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.
'">';
1583 print $formother->selectyear($search_year,
'search_year', 1, 20, 5);
1586 if (!empty($allprojectforuser)) {
1587 print
'<td class="liste_titre"></td>';
1590 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1591 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1592 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1594 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1595 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1599 if (!empty($arrayfields[
'author'][
'checked'])) {
1600 print
'<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1),
'search_user', 1, null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250').
'</td>';
1603 if (!empty($arrayfields[
't.note'][
'checked'])) {
1604 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).
'"></td>';
1607 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1608 print
'<td class="liste_titre right"></td>';
1611 if (!empty($arrayfields[
'value'][
'checked'])) {
1612 print
'<td class="liste_titre"></td>';
1615 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1616 print
'<td class="liste_titre center">'.$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1).
'</td>';
1624 $parameters = array(
'arrayfields'=>$arrayfields);
1625 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1626 print $hookmanager->resPrint;
1628 print
'<td class="liste_titre center">';
1629 $searchpicto = $form->showFilterButtons();
1634 print
'<tr class="liste_titre">';
1635 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1636 print_liste_field_titre($arrayfields[
't.task_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_date,t.task_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
1638 if (!empty($allprojectforuser)) {
1641 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1642 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1643 print_liste_field_titre($arrayfields[
't.task_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
1645 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
't.task_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
1649 if (!empty($arrayfields[
'author'][
'checked'])) {
1650 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1652 if (!empty($arrayfields[
't.note'][
'checked'])) {
1653 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
1655 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1656 print_liste_field_titre($arrayfields[
't.task_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
1658 if (!empty($arrayfields[
'value'][
'checked'])) {
1659 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1661 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1662 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
1669 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1670 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1671 print $hookmanager->resPrint;
1672 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
1675 $tasktmp =
new Task($db);
1676 $tmpinvoice =
new Facture($db);
1682 $totalarray = array();
1683 foreach ($tasks as $task_time) {
1688 $date1 = $db->jdate($task_time->task_date);
1689 $date2 = $db->jdate($task_time->task_datehour);
1691 print
'<tr class="oddeven">';
1694 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1695 print
'<td class="nowrap">';
1696 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1697 if (empty($task_time->task_date_withhour)) {
1698 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1700 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1703 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1707 $totalarray[
'nbfield']++;
1712 if (!empty($allprojectforuser)) {
1713 print
'<td class="nowraponall">';
1714 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
1715 $tmpproject =
new Project($db);
1716 $tmpproject->fetch($task_time->fk_projet);
1717 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
1719 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
1721 print $tmpproject->getNomUrl(1);
1724 $totalarray[
'nbfield']++;
1729 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1730 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1731 print
'<td class="nowrap">';
1732 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1733 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_task,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
1735 $tasktmp->id = $task_time->fk_task;
1736 $tasktmp->ref = $task_time->ref;
1737 $tasktmp->label = $task_time->label;
1738 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1742 $totalarray[
'nbfield']++;
1745 } elseif ($action !==
'createtime') {
1746 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1750 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1751 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1752 print
'<td class="nowrap tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
1756 $totalarray[
'nbfield']++;
1762 if (!empty($arrayfields[
'author'][
'checked'])) {
1763 print
'<td class="tdoverflowmax100">';
1764 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1765 if (empty($object->id)) {
1766 $object->fetch($id);
1768 $contactsoftask = $object->getListContactId(
'internal');
1769 if (!in_array($task_time->fk_user, $contactsoftask)) {
1770 $contactsoftask[] = $task_time->fk_user;
1772 if (count($contactsoftask) > 0) {
1773 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1774 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
1776 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1779 $userstatic->id = $task_time->fk_user;
1780 $userstatic->lastname = $task_time->lastname;
1781 $userstatic->firstname = $task_time->firstname;
1782 $userstatic->photo = $task_time->photo;
1783 $userstatic->statut = $task_time->user_status;
1784 print $userstatic->getNomUrl(-1);
1788 $totalarray[
'nbfield']++;
1793 if (!empty($arrayfields[
't.note'][
'checked'])) {
1794 print
'<td class="small">';
1795 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1796 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
1802 $totalarray[
'nbfield']++;
1804 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1805 print
'<input type="hidden" name="timespent_note_line" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
1809 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1810 print
'<td class="right nowraponall">';
1811 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1812 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
1813 print $form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
1819 $totalarray[
'nbfield']++;
1822 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.task_duration';
1824 $totalarray[
'val'][
't.task_duration'] += $task_time->task_duration;
1826 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
1828 $totalarray[
'totalduration'] += $task_time->task_duration;
1832 if (!empty($arrayfields[
'value'][
'checked'])) {
1833 $langs->load(
"salaries");
1834 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
1836 print
'<td class="nowraponall right">';
1837 print
'<span class="amount" title="'.$langs->trans(
"THM").
': '.
price($task_time->thm).
'">';
1838 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
1842 $totalarray[
'nbfield']++;
1845 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
1847 $totalarray[
'val'][
'value'] += $value;
1849 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
1851 $totalarray[
'totalvalue'] += $value;
1855 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1856 print
'<td class="center">';
1857 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1858 if ($projectstatic->usage_bill_time) {
1859 if ($task_time->invoice_id) {
1860 $result = $tmpinvoice->fetch($task_time->invoice_id);
1862 print $tmpinvoice->getNomUrl(1);
1865 print $langs->trans(
"No");
1868 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
1873 $totalarray[
'nbfield']++;
1883 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'i'=>$i,
'totalarray'=>&$totalarray);
1884 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1885 print $hookmanager->resPrint;
1888 print
'<td class="center nowraponall">';
1889 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1890 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
1891 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
1893 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1894 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
1895 if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
1898 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=splitline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1899 print
img_split(
'',
'class="pictofixedwidth"');
1903 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_task.
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1904 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
1907 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_task.
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1908 print
img_delete(
'default',
'class="pictodelete paddingleft"');
1911 if ($massactionbutton || $massaction) {
1913 if (in_array($task_time->rowid, $arrayofselected)) {
1917 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1923 $totalarray[
'nbfield']++;
1931 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1932 print
'<tr class="oddeven">';
1935 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1936 print
'<td class="nowrap">';
1937 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1938 if (empty($task_time->task_date_withhour)) {
1939 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1941 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1944 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1950 if (!empty($allprojectforuser)) {
1951 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1952 print
'<td class="nowrap">';
1958 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1959 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1960 print
'<td class="nowrap">';
1961 $tasktmp->id = $task_time->fk_task;
1962 $tasktmp->ref = $task_time->ref;
1963 $tasktmp->label = $task_time->label;
1964 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1970 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1971 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1972 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
1979 if (!empty($arrayfields[
'author'][
'checked'])) {
1981 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1982 if (empty($object->id)) {
1983 $object->fetch($id);
1985 $contactsoftask = $object->getListContactId(
'internal');
1986 if (!in_array($task_time->fk_user, $contactsoftask)) {
1987 $contactsoftask[] = $task_time->fk_user;
1989 if (count($contactsoftask) > 0) {
1990 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1991 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
1993 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1996 $userstatic->id = $task_time->fk_user;
1997 $userstatic->lastname = $task_time->lastname;
1998 $userstatic->firstname = $task_time->firstname;
1999 $userstatic->photo = $task_time->photo;
2000 $userstatic->statut = $task_time->user_status;
2001 print $userstatic->getNomUrl(-1);
2007 if (!empty($arrayfields[
't.note'][
'checked'])) {
2008 print
'<td class="tdoverflowmax300">';
2009 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2010 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2015 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2016 print
'<input type="hidden" name="timespent_note_line" rows="'.ROWS_1.
'" value="'.
dol_escape_htmltag($task_time->note, 0, 1).
'">';
2020 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2021 print
'<td class="right">';
2022 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2023 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
2024 print $form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
2032 if (!empty($arrayfields[
'value'][
'checked'])) {
2033 print
'<td class="right">';
2034 print
'<span class="amount">';
2035 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
2036 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2042 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2043 print
'<td class="right">';
2044 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2045 if (isset($task_time->total_ht)) {
2046 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2057 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split1');
2058 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2059 print $hookmanager->resPrint;
2062 print
'<td class="center nowraponall">';
2070 print
'<tr class="oddeven">';
2073 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
2074 print
'<td class="nowrap">';
2075 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2076 if (empty($task_time->task_date_withhour)) {
2077 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2079 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2082 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
2088 if (!empty($allprojectforuser)) {
2089 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2090 print
'<td class="nowrap">';
2096 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
2097 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2098 print
'<td class="nowrap">';
2099 $tasktmp->id = $task_time->fk_task;
2100 $tasktmp->ref = $task_time->ref;
2101 $tasktmp->label = $task_time->label;
2102 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2108 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
2109 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2110 print
'<td class="nowrap">';
2111 print $task_time->label;
2117 if (!empty($arrayfields[
'author'][
'checked'])) {
2119 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2120 if (empty($object->id)) {
2121 $object->fetch($id);
2123 $contactsoftask = $object->getListContactId(
'internal');
2124 if (!in_array($task_time->fk_user, $contactsoftask)) {
2125 $contactsoftask[] = $task_time->fk_user;
2127 if (count($contactsoftask) > 0) {
2128 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2129 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2131 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2134 $userstatic->id = $task_time->fk_user;
2135 $userstatic->lastname = $task_time->lastname;
2136 $userstatic->firstname = $task_time->firstname;
2137 $userstatic->photo = $task_time->photo;
2138 $userstatic->statut = $task_time->user_status;
2139 print $userstatic->getNomUrl(-1);
2145 if (!empty($arrayfields[
't.note'][
'checked'])) {
2146 print
'<td class="small tdoverflowmax300"">';
2147 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2148 print
'<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2153 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2154 print
'<input type="hidden" name="timespent_note_line_2" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2158 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2159 print
'<td class="right">';
2160 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2161 print
'<input type="hidden" name="old_duration_2" value="0">';
2162 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2170 if (!empty($arrayfields[
'value'][
'checked'])) {
2171 print
'<td class="right">';
2172 print
'<span class="amount">';
2174 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2180 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2181 print
'<td class="right">';
2182 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2183 if (isset($task_time->total_ht)) {
2184 print
'<span class="amount">';
2185 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2197 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split2');
2198 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2199 print $hookmanager->resPrint;
2202 print
'<td class="center nowraponall">';
2213 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2214 print
'<tr class="liste_total">';
2216 while ($i < $totalarray[
'nbfield']) {
2219 if ($num < $limit && empty($offset)) {
2220 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
2222 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
2224 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2225 print
'<td class="right">'.convertSecondToTime($totalarray[
'totalduration'],
'allhourmin').
'</td>';
2226 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2227 print
'<td class="right">'.price($totalarray[
'totalvalue']).
'</td>';
2236 if (!count($tasks)) {
2237 $totalnboffields = 1;
2238 foreach ($arrayfields as $value) {
2239 if ($value[
'checked']) {
2243 print
'<tr class="oddeven"><td colspan="'.$totalnboffields.
'">';
2244 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2248 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2249 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2250 print $hookmanager->resPrint;
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)...
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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.
Class to manage products or services.
Class to manage interventions.
Class to manage Dolibarr users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
img_error($titlealt= 'default')
Show error logo.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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) Si ...
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage invoices.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
img_split($titlealt= 'default', $other= 'class="pictosplit"')
Show split logo.
$formconfirm
if ($action == 'delbookkeepingyear') {
convertSecondToTime($iSecond, $format= 'all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
task_prepare_head($object)
Prepare array with list of tabs.