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');
56 $mode =
GETPOST(
'mode',
'alpha');
59 $projectid =
GETPOST(
'projectid',
'int');
61 $withproject =
GETPOST(
'withproject',
'int');
62 $project_ref =
GETPOST(
'project_ref',
'alpha');
65 $search_day =
GETPOST(
'search_day',
'int');
66 $search_month =
GETPOST(
'search_month',
'int');
67 $search_year =
GETPOST(
'search_year',
'int');
68 $search_datehour =
'';
69 $search_datewithhour =
'';
70 $search_note =
GETPOST(
'search_note',
'alpha');
71 $search_duration =
GETPOST(
'search_duration',
'int');
72 $search_value =
GETPOST(
'search_value',
'int');
73 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
74 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
75 $search_user =
GETPOST(
'search_user',
'int');
76 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
78 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
79 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
80 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
82 if (empty($page) || $page == -1) {
85 $offset = $limit * $page;
86 $pageprev = $page - 1;
87 $pagenext = $page + 1;
89 $sortfield =
't.task_date,t.task_datehour,t.rowid';
92 $sortorder =
'DESC,DESC,DESC';
95 $childids = $user->getAllChildIds(1);
99 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
101 $object =
new Task($db);
103 $projectstatic =
new Project($db);
106 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
107 $extrafields->fetch_name_optionals_label($object->table_element);
110 if ($id > 0 || $ref) {
111 $object->fetch($id, $ref);
118 if (!$user->rights->projet->lire) {
122 if ($object->fk_project > 0) {
123 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
127 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
128 $search_user = $user->id;
138 if (
GETPOST(
'cancel',
'alpha')) {
141 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
145 $parameters = array(
'socid'=>$socid,
'projectid'=>$projectid);
146 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
151 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
154 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
159 $search_datehour =
'';
160 $search_datewithhour =
'';
162 $search_duration =
'';
164 $search_date_creation =
'';
165 $search_date_update =
'';
166 $search_task_ref =
'';
167 $search_task_label =
'';
169 $search_valuebilled =
'';
171 $search_array_options = array();
175 if ($action ==
'addtimespent' && $user->rights->projet->time) {
178 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
179 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
180 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
181 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
184 if (!
GETPOST(
"userid",
'int')) {
185 $langs->load(
"errors");
186 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
192 $object->fetch($id, $ref);
195 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
196 $action =
'createtime';
199 $object->fetch(
GETPOST(
'taskid',
'int'));
204 $object->fetch_projet();
206 if (empty($object->project->statut)) {
207 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
208 $action =
'createtime';
211 $object->timespent_note =
GETPOST(
"timespent_note",
'alpha');
212 if (
GETPOST(
'progress',
'int') > 0) {
213 $object->progress =
GETPOST(
'progress',
'int');
215 $object->timespent_duration =
GETPOSTINT(
"timespent_durationhour") * 60 * 60;
216 $object->timespent_duration += (
GETPOSTINT(
'timespent_durationmin') ?
GETPOSTINT(
'timespent_durationmin') : 0) * 60;
218 $object->timespent_date =
dol_mktime(
GETPOST(
"timehour",
'int'),
GETPOST(
"timemin",
'int'), 0,
GETPOST(
"timemonth",
'int'),
GETPOST(
"timeday",
'int'),
GETPOST(
"timeyear",
'int'));
219 $object->timespent_withhour = 1;
223 $object->timespent_fk_user =
GETPOST(
"userid",
'int');
224 $result = $object->addTimeSpent($user);
235 $action =
'createtime';
237 $action =
'createtime';
242 if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire) {
245 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
246 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
251 if (
GETPOST(
'taskid',
'int') != $id) {
252 $id_temp =
GETPOST(
'taskid',
'int');
255 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
258 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
259 $result = $object->delTimeSpent($user);
262 $object->fetch($id_temp, $ref);
264 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
265 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
266 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
267 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
268 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
270 $object->timespent_withhour = 1;
274 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
277 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
278 $result = $object->addTimeSpent($user);
288 $object->fetch($id, $ref);
290 $object->timespent_id =
GETPOST(
"lineid",
'int');
291 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
292 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
293 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
294 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
295 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
296 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
297 $object->timespent_withhour = 1;
301 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
304 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
305 $result = $object->updateTimeSpent($user);
320 if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
321 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
323 if (in_array($object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
324 $result = $object->delTimeSpent($user);
327 $langs->load(
"errors");
338 if (!empty($project_ref) && !empty($withproject)) {
339 if ($projectstatic->fetch(0, $project_ref) > 0) {
340 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
341 if (count($tasksarray) > 0) {
342 $id = $tasksarray[0]->id;
344 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
351 $projectidforalltimes = 0;
352 if (
GETPOST(
'projectid',
'int') > 0) {
353 $projectidforalltimes =
GETPOST(
'projectid',
'int');
355 $result = $projectstatic->fetch($projectidforalltimes);
356 if (!empty($projectstatic->socid)) {
357 $projectstatic->fetch_thirdparty();
359 $res = $projectstatic->fetch_optionals();
360 } elseif (
GETPOST(
'project_ref',
'alpha')) {
361 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
362 $projectidforalltimes = $projectstatic->id;
366 $result = $projectstatic->fetch($object->fk_project);
369 if ($id <= 0 && $projectidforalltimes == 0) {
370 $allprojectforuser = $user->id;
373 if ($action ==
'confirm_generateinvoice') {
374 if (!empty($projectstatic->socid)) {
375 $projectstatic->fetch_thirdparty();
378 if (!($projectstatic->thirdparty->id > 0)) {
379 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
381 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
382 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
383 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
385 $tmpinvoice =
new Facture($db);
386 $tmptimespent =
new Task($db);
387 $tmpproduct =
new Product($db);
388 $fuser =
new User($db);
391 $idprod =
GETPOST(
'productid',
'int');
392 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
393 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
395 $prodDurationHours = 1.0;
397 $tmpproduct->fetch($idprod);
399 if (empty($tmpproduct->duration_value)) {
401 $langs->load(
"errors");
402 setEventMessages($langs->trans(
"ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice"),
null,
'errors');
405 if ($tmpproduct->duration_unit ==
'i') {
406 $prodDurationHours = 1. / 60;
408 if ($tmpproduct->duration_unit ==
'h') {
409 $prodDurationHours = 1.;
411 if ($tmpproduct->duration_unit ==
'd') {
412 $prodDurationHours = 24.;
414 if ($tmpproduct->duration_unit ==
'w') {
415 $prodDurationHours = 24. * 7;
417 if ($tmpproduct->duration_unit ==
'm') {
418 $prodDurationHours = 24. * 30;
420 if ($tmpproduct->duration_unit ==
'y') {
421 $prodDurationHours = 24. * 365;
423 $prodDurationHours *= $tmpproduct->duration_value;
425 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
427 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
428 $txtva = $dataforprice[
'tva_tx'];
429 $localtax1 = $dataforprice[
'localtax1'];
430 $localtax2 = $dataforprice[
'localtax2'];
432 $prodDurationHours = 1;
440 $tmpinvoice->socid = $projectstatic->thirdparty->id;
441 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
442 $tmpinvoice->fk_project = $projectstatic->id;
445 $tmpinvoice->fetch($invoiceToUse);
447 $result = $tmpinvoice->create($user);
455 if ($generateinvoicemode ==
'onelineperuser') {
456 $arrayoftasks = array();
457 foreach ($toselect as $key => $value) {
459 $object->fetchTimeSpent($value);
460 $arrayoftasks[$object->timespent_fk_user][
'timespent'] += $object->timespent_duration;
461 $arrayoftasks[$object->timespent_fk_user][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
464 foreach ($arrayoftasks as $userid => $value) {
465 $fuser->fetch($userid);
466 $pu_ht = $fuser->thm;
467 $username = $fuser->getFullName($langs);
470 $qtyhour = $value[
'timespent'] / 3600;
471 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
481 $pu_ht =
price2num(($value[
'totalvaluetodivideby3600'] / $value[
'timespent']),
'MU');
484 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username).
' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
487 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
488 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
489 $result = $db->query($sql);
496 } elseif ($generateinvoicemode ==
'onelineperperiod') {
497 $arrayoftasks = array();
498 $withdetail=
GETPOST(
'detail_time_duration',
'alpha');
499 foreach ($toselect as $key => $value) {
501 $object->fetchTimeSpent($value);
503 $ftask =
new Task($db);
504 $ftask->fetch($object->id);
506 $fuser->fetch($object->timespent_fk_user);
507 $username = $fuser->getFullName($langs);
509 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
510 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
511 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref.
' - '.$ftask->label.
' - '.$username.($object->timespent_note ?
' - '.$object->timespent_note :
'');
512 if (!empty($withdetail)) {
513 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
514 $arrayoftasks[$object->timespent_id][
'note'] .=
"<br/>";
516 $arrayoftasks[$object->timespent_id][
'note'] .=
"\n";
519 if (!empty($object->timespent_withhour)) {
520 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour);
522 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date);
524 $arrayoftasks[$object->timespent_id][
'note'] .=
' - '.$langs->trans(
"Duration").
': '.
convertSecondToTime($object->timespent_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
526 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
529 foreach ($arrayoftasks as $timespent_id => $value) {
530 $userid = $value[
'user'];
534 $qtyhour = $value[
'timespent'] / 3600;
538 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
542 $lineid = $tmpinvoice->addline($value[
'note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
546 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
547 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
548 $result = $db->query($sql);
555 } elseif ($generateinvoicemode ==
'onelinepertask') {
556 $arrayoftasks = array();
557 foreach ($toselect as $key => $value) {
559 $object->fetchTimeSpent($value);
561 $arrayoftasks[$object->id][
'timespent'] += $object->timespent_duration;
562 $arrayoftasks[$object->id][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
565 foreach ($arrayoftasks as $task_id => $value) {
566 $ftask =
new Task($db);
567 $ftask->fetch($task_id);
569 $qtyhour = $value[
'timespent'] / 3600;
570 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
574 $pu_ht_for_task = $pu_ht;
576 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
577 $pu_ht_for_task =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU') * $prodDurationHours;
579 $pa_ht =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU') * $prodDurationHours;
584 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
585 $pu_ht_for_task =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU');
587 $pa_ht =
price2num($value[
'totalvaluetodivideby3600'] / $value[
'timespent'],
'MU');
593 $lineName = $ftask->ref.
' - '.$ftask->label;
594 $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);
603 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
604 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
')';
605 $result = $db->query($sql);
617 $urltoinvoice = $tmpinvoice->getNomUrl(0);
618 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
619 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
631 if ($action ==
'confirm_generateinter') {
632 $langs->load(
'interventions');
634 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
636 if (!($projectstatic->thirdparty->id > 0)) {
637 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
639 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
640 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
641 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
644 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
646 $tmptimespent =
new Task($db);
647 $fuser =
new User($db);
650 $interToUse =
GETPOST(
'interid',
'int');
653 $tmpinter->socid = $projectstatic->thirdparty->id;
654 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
655 $tmpinter->fk_project = $projectstatic->id;
656 $tmpinter->description = $projectstatic->title . ( ! empty($projectstatic->description) ?
'-' . $projectstatic->label :
'' );
659 $tmpinter->fetch($interToUse);
661 $result = $tmpinter->create($user);
669 $arrayoftasks = array();
670 foreach ($toselect as $key => $value) {
672 $object->fetchTimeSpent($value);
674 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
675 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
676 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
677 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
678 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
681 foreach ($arrayoftasks as $timespent_id => $value) {
682 $ftask =
new Task($db);
683 $ftask->fetch($value[
'id']);
685 $qtyhour = $value[
'timespent'] / 3600;
686 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
689 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . ( ! empty($value[
'note']) ?
' - ' . $value[
'note'] :
'' ), $value[
'date'], $value[
'timespent']);
694 $urltointer = $tmpinter->getNomUrl(0);
695 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
696 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
712 $arrayofselected = is_array($toselect) ? $toselect : array();
719 $userstatic =
new User($db);
721 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
725 if ($projectidforalltimes > 0) {
726 $result = $projectstatic->fetch($projectidforalltimes);
727 if (!empty($projectstatic->socid)) {
728 $projectstatic->fetch_thirdparty();
730 $res = $projectstatic->fetch_optionals();
731 } elseif ($object->fetch($id, $ref) >= 0) {
732 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
733 $object->fetchComments();
735 $result = $projectstatic->fetch($object->fk_project);
736 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
737 $projectstatic->fetchComments();
739 if (!empty($projectstatic->socid)) {
740 $projectstatic->fetch_thirdparty();
742 $res = $projectstatic->fetch_optionals();
744 $object->project = clone $projectstatic;
747 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
748 $linktocreatetime =
'';
750 if ($projectstatic->id > 0) {
753 if (empty($id) || $tab ==
'timespent') {
760 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
762 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
764 $param .=
'&search_user='.((int) $search_user);
767 $param .=
'&search_month='.((int) $search_month);
770 $param .=
'&search_year='.((int) $search_year);
775 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
777 $morehtmlref =
'<div class="refidno">';
779 $morehtmlref .= $projectstatic->title;
781 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
782 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
784 $morehtmlref .=
'</div>';
787 if (empty($user->rights->projet->all->lire)) {
788 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
789 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
792 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
794 print
'<div class="fichecenter">';
795 print
'<div class="fichehalfleft">';
796 print
'<div class="underbanner clearboth"></div>';
798 print
'<table class="border tableforfield centpercent">';
801 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
802 print
'<tr><td class="tdtop">';
803 print $langs->trans(
"Usage");
806 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
807 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
808 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
809 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
812 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
813 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
814 $htmltext = $langs->trans(
"ProjectFollowTasks");
815 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
818 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
819 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"' :
'')).
'"> ';
820 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
821 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
825 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"' :
'')).
'"> ';
826 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
827 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
833 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
834 if ($projectstatic->public) {
835 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
836 print $langs->trans(
'SharedProject');
838 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
839 print $langs->trans(
'PrivateProject');
844 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
846 print ($start ? $start :
'?');
849 print ($end ? $end :
'?');
850 if ($projectstatic->hasDelay()) {
856 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
857 if (strcmp($projectstatic->budget_amount,
'')) {
858 print
'<span class="amount">'.price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
869 print
'<div class="fichehalfright">';
870 print
'<div class="underbanner clearboth"></div>';
872 print
'<table class="border tableforfield centpercent">';
875 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
876 print nl2br($projectstatic->description);
881 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
882 print
$form->showCategories($projectstatic->id,
'project', 1);
891 print
'<div class="clearboth"></div>';
899 $linktocreatetimeBtnStatus = 0;
900 $linktocreatetimeUrl =
'';
901 $linktocreatetimeHelpText =
'';
902 if (!empty($user->rights->projet->time)) {
903 if ($projectstatic->public || $userRead > 0) {
904 $linktocreatetimeBtnStatus = 1;
906 if (!empty($projectidforalltimes)) {
908 $backtourl = $_SERVER[
'PHP_SELF'].
'?projectid='.$projectstatic->id.($withproject ?
'&withproject=1' :
'');
909 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').
'&projectid='.$projectstatic->id.
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
912 $backtourl = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($withproject ?
'&withproject=1' :
'');
913 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').($object->id > 0 ?
'&id='.$object->id :
'&projectid='.$projectstatic->id).
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
916 $linktocreatetimeBtnStatus = -2;
917 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
920 $linktocreatetimeBtnStatus = -2;
921 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
924 $paramsbutton = array(
'morecss'=>
'reposition');
925 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
928 $massactionbutton =
'';
929 $arrayofmassactions = array();
931 if ($projectstatic->id > 0) {
933 if ($projectstatic->usage_bill_time) {
934 $arrayofmassactions = array(
935 'generateinvoice'=>$langs->trans(
"GenerateBill"),
939 if ( ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) {
940 $langs->load(
"interventions");
941 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
945 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
946 $arrayofmassactions = array();
948 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
951 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
953 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
955 if ($action ==
'deleteline') {
956 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);
959 $param = ($withproject ?
'&withproject=1' :
'');
960 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
962 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
963 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
964 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
966 $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
972 if (empty($withproject)) {
973 $morehtmlref .=
'<div class="refidno">';
974 $morehtmlref .= $langs->trans(
"Project").
': ';
975 $morehtmlref .= $projectstatic->getNomUrl(1);
976 $morehtmlref .=
'<br>';
979 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
980 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
981 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
983 $morehtmlref .=
'</div>';
986 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
988 print
'<div class="fichecenter">';
989 print
'<div class="fichehalfleft">';
991 print
'<div class="underbanner clearboth"></div>';
992 print
'<table class="border centpercent tableforfield">';
995 print
'<tr><td>'.$langs->trans(
"ChildOfTask").
'</td><td>';
996 if ($object->fk_task_parent > 0) {
997 $tasktmp =
new Task($db);
998 $tasktmp->fetch($object->fk_task_parent);
999 print $tasktmp->getNomUrl(1);
1004 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"Deadline").
'</td><td>';
1006 print ($start ? $start :
'?');
1009 print ($end ? $end :
'?');
1010 if ($object->hasDelay()) {
1016 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
1017 if ($object->planned_workload) {
1025 print
'<div class="fichehalfright">';
1027 print
'<div class="underbanner clearboth"></div>';
1028 print
'<table class="border tableforfield centpercent">';
1031 print
'<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td>';
1032 print $object->progress !=
'' ? $object->progress.
' %' :
'';
1036 print
'<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td>';
1037 if ($object->planned_workload) {
1038 $tmparray = $object->getSummaryOfTimeSpent();
1039 if ($tmparray[
'total_duration'] > 0) {
1040 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
1045 print
'<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
1056 print
'<div class="clearboth"></div>';
1062 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1063 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1064 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);
1068 $hookmanager->initHooks(array(
'tasktimelist'));
1072 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1073 $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);
1077 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1078 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1079 if (empty($reshook)) {
1081 } elseif ($reshook > 0) {
1089 $arrayfields = array();
1090 $arrayfields[
't.task_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1091 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1092 $arrayfields[
't.task_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1093 $arrayfields[
't.task_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1095 $arrayfields[
'author'] = array(
'label'=>$langs->trans(
"By"),
'checked'=>1);
1096 $arrayfields[
't.note'] = array(
'label'=>$langs->trans(
"Note"),
'checked'=>1);
1097 $arrayfields[
't.task_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1098 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
1099 $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));
1101 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
1106 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1107 $param .=
'&contextpage='.urlencode($contextpage);
1109 if ($limit > 0 && $limit != $conf->liste_limit) {
1110 $param .=
'&limit='.urlencode($limit);
1112 if ($search_month > 0) {
1113 $param .=
'&search_month='.urlencode($search_month);
1115 if ($search_year > 0) {
1116 $param .=
'&search_year='.urlencode($search_year);
1118 if ($search_user > 0) {
1119 $param .=
'&search_user='.urlencode($search_user);
1121 if ($search_task_ref !=
'') {
1122 $param .=
'&search_task_ref='.urlencode($search_task_ref);
1124 if ($search_task_label !=
'') {
1125 $param .=
'&search_task_label='.urlencode($search_task_label);
1127 if ($search_note !=
'') {
1128 $param .=
'&search_note='.urlencode($search_note);
1130 if ($search_duration !=
'') {
1131 $param .=
'&search_field2='.urlencode($search_duration);
1133 if ($optioncss !=
'') {
1134 $param .=
'&optioncss='.urlencode($optioncss);
1141 $param .=
'&id='.urlencode($id);
1144 $param .=
'&projectid='.urlencode($projectid);
1147 $param .=
'&withproject='.urlencode($withproject);
1150 $parameters = array();
1151 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1152 $param .= $hookmanager->resPrint;
1154 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1155 if ($optioncss !=
'') {
1156 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1158 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1159 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1160 if ($action ==
'editline') {
1161 print
'<input type="hidden" name="action" value="updateline">';
1162 } elseif ($action ==
'splitline') {
1163 print
'<input type="hidden" name="action" value="updatesplitline">';
1164 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1165 print
'<input type="hidden" name="action" value="addtimespent">';
1166 } elseif ($massaction ==
'generateinvoice' && $user->rights->facture->lire) {
1167 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1168 } elseif ($massaction ==
'generateinter' && $user->rights->ficheinter->lire) {
1169 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1171 print
'<input type="hidden" name="action" value="list">';
1173 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1174 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1176 print
'<input type="hidden" name="id" value="'.$id.
'">';
1177 print
'<input type="hidden" name="projectid" value="'.$projectidforalltimes.
'">';
1178 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
1179 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
1180 print
'<input type="hidden" name="page_y" value="">';
1183 if ($massaction ==
'generateinvoice') {
1184 if ($projectstatic->thirdparty->id > 0) {
1185 print
'<table class="noborder centerpercent">';
1187 print
'<td class="titlefield">';
1188 print $langs->trans(
'DateInvoice');
1191 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1197 print $langs->trans(
'Mode');
1201 'onelineperuser'=>
'OneLinePerUser',
1202 'onelinepertask'=>
'OneLinePerTask',
1203 'onelineperperiod'=>
'OneLinePerTimeSpentLine',
1205 print
$form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1206 print
"\n".
'<script type="text/javascript">';
1208 $(document).ready(function () {
1209 setDetailVisibility();
1210 $("#generateinvoicemode").change(function() {
1211 setDetailVisibility();
1213 function setDetailVisibility() {
1214 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1215 if (generateinvoicemode=="onelineperperiod") {
1216 $("#detail_time_duration").show();
1218 $("#detail_time_duration").hide();
1223 print
'</script>'.
"\n";
1224 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>'.$langs->trans(
'AddDetailDateAndDuration').
'</span>';
1228 if ($conf->service->enabled) {
1231 print $langs->trans(
'ServiceToUseOnLines');
1234 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1240 print
'<td class="titlefield">';
1241 print $langs->trans(
'InvoiceToUse');
1244 $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1258 print
'<div class="center">';
1259 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'GenerateBill').
'"> ';
1260 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1264 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateInvoice").
'</div>';
1265 print
'<div class="center">';
1266 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1270 } elseif ($massaction ==
'generateinter') {
1272 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1274 if ($projectstatic->thirdparty->id > 0) {
1276 print
'<table class="noborder centpercent">';
1278 print
'<td class="titlefield">';
1279 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"').$langs->trans(
'InterToUse');
1283 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1288 print
'<div class="center">';
1289 print
'<input type="submit" class="button" id="createinter" name="createinter" value="'.$langs->trans(
'GenerateInter').
'"> ';
1290 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1294 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateIntervention").
'</div>';
1295 print
'<div class="center">';
1296 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1303 $parameters = array(
1304 'toselect' => $toselect,
1305 'uploaddir' => isset($uploaddir) ? $uploaddir :
null
1308 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1312 print $hookmanager->resPrint;
1320 $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,";
1321 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1322 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1323 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1325 $parameters = array();
1326 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1327 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
1328 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
1330 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1331 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1333 $parameters = array();
1334 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1335 $sql .= $hookmanager->resPrint;
1336 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"user as u";
1337 $sql .=
" WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
1339 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1341 $sql .=
" AND t.fk_task =".((int) $object->id);
1342 } elseif (!empty($projectidforalltimes)) {
1344 $sql .=
" AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).
")";
1345 } elseif (!empty($allprojectforuser)) {
1347 if (empty($search_user)) {
1348 $search_user = $user->id;
1350 if ($search_user > 0) $sql .=
" AND t.fk_user = ".((int) $search_user);
1356 if ($search_task_ref) {
1359 if ($search_task_label) {
1362 if ($search_user > 0) {
1365 if ($search_valuebilled ==
'1') {
1366 $sql .=
' AND t.invoice_id > 0';
1368 if ($search_valuebilled ==
'0') {
1369 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1372 $sql .=
dolSqlDateFilter(
't.task_datehour', $search_day, $search_month, $search_year);
1375 $parameters = array();
1376 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1377 $sql .= $hookmanager->resPrint;
1378 $sql .= $db->order($sortfield, $sortorder);
1381 $nbtotalofrecords =
'';
1382 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1383 $resql = $db->query($sql);
1390 $nbtotalofrecords = $db->num_rows(
$resql);
1391 if (($page * $limit) > $nbtotalofrecords) {
1397 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
1398 $num = $nbtotalofrecords;
1400 $sql .= $db->plimit($limit + 1, $offset);
1402 $resql = $db->query($sql);
1408 $num = $db->num_rows(
$resql);
1412 if (!empty($projectidforalltimes)) {
1413 print
'<!-- List of time spent for project -->'.
"\n";
1415 $title = $langs->trans(
"ListTaskTimeUserProject");
1417 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1419 print
'<!-- List of time spent -->'.
"\n";
1421 $title = $langs->trans(
"ListTaskTimeForTask");
1423 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1428 $row = $db->fetch_object(
$resql);
1440 if ($action ==
'createtime' && $user->rights->projet->time) {
1441 print
'<!-- table to add time spent -->'.
"\n";
1443 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1446 print
'<div class="div-table-responsive-no-min">';
1447 print
'<table class="noborder nohover centpercent">';
1449 print
'<tr class="liste_titre">';
1450 print
'<td>'.$langs->trans(
"Date").
'</td>';
1451 if (!empty($allprojectforuser)) {
1452 print
'<td>'.$langs->trans(
"Project").
'</td>';
1455 print
'<td>'.$langs->trans(
"Task").
'</td>';
1457 print
'<td>'.$langs->trans(
"By").
'</td>';
1458 print
'<td>'.$langs->trans(
"Note").
'</td>';
1459 print
'<td>'.$langs->trans(
"NewTimeSpent").
'</td>';
1460 print
'<td>'.$langs->trans(
"ProgressDeclared").
'</td>';
1461 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1465 $parameters = array(
'mode' =>
'create');
1466 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1467 print $hookmanager->resPrint;
1471 print
'<tr class="oddeven nohover">';
1474 print
'<td class="maxwidthonsmartphone">';
1476 print
$form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1479 if (!empty($allprojectforuser)) {
1488 print
'<td class="maxwidthonsmartphone">';
1489 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1494 print
'<td class="maxwidthonsmartphone nowraponall">';
1495 $contactsofproject = $projectstatic->getListContactId(
'internal');
1496 if (count($contactsofproject) > 0) {
1497 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1498 if (in_array($user->id, $contactsofproject)) {
1499 $userid = $user->id;
1501 $userid = $contactsofproject[0];
1504 if ($projectstatic->public) {
1505 $contactsofproject = array();
1507 print
$form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'maxwidth250');
1510 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).
' '.$langs->trans(
'FirstAddRessourceToAllocateTime');
1517 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.
'">'.(
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'').
'</textarea>';
1521 print
'<td class="nowraponall">';
1522 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1524 $durationtouse = (
GETPOST(
'timespent_durationhour') * 3600 +
GETPOST(
'timespent_durationmin') * 60);
1526 print
$form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1530 print
'<td class="nowrap">';
1531 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1535 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1541 $parameters = array(
'mode' =>
'create');
1542 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1543 print $hookmanager->resPrint;
1545 print
'<td class="center">';
1546 $form->buttonsSaveCancel();
1547 print
'<input type="submit" name="save" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-add" value="'.$langs->trans(
"Add").
'">';
1548 print
'<input type="submit" name="cancel" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1557 $moreforfilter =
'';
1559 $parameters = array();
1560 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1561 if (empty($reshook)) {
1562 $moreforfilter .= $hookmanager->resPrint;
1564 $moreforfilter = $hookmanager->resPrint;
1567 if (!empty($moreforfilter)) {
1568 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1569 print $moreforfilter;
1573 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1574 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1575 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
1577 print
'<div class="div-table-responsive">';
1578 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1581 print
'<tr class="liste_titre_filter">';
1583 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1584 print
'<td class="liste_titre">';
1585 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
1586 print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.
'">';
1588 print
'<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.
'">';
1589 print $formother->selectyear($search_year,
'search_year', 1, 20, 5);
1592 if (!empty($allprojectforuser)) {
1593 print
'<td class="liste_titre"></td>';
1596 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1597 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1598 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1600 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1601 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1605 if (!empty($arrayfields[
'author'][
'checked'])) {
1606 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>';
1609 if (!empty($arrayfields[
't.note'][
'checked'])) {
1610 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).
'"></td>';
1613 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1614 print
'<td class="liste_titre right"></td>';
1617 if (!empty($arrayfields[
'value'][
'checked'])) {
1618 print
'<td class="liste_titre"></td>';
1621 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1622 print
'<td class="liste_titre center">'.$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1).
'</td>';
1630 $parameters = array(
'arrayfields'=>$arrayfields);
1631 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1632 print $hookmanager->resPrint;
1634 print
'<td class="liste_titre center">';
1635 $searchpicto =
$form->showFilterButtons();
1640 print
'<tr class="liste_titre">';
1641 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
't.task_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_date,t.task_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
1644 if (!empty($allprojectforuser)) {
1647 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1648 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1649 print_liste_field_titre($arrayfields[
't.task_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
1651 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1652 print_liste_field_titre($arrayfields[
't.task_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
1655 if (!empty($arrayfields[
'author'][
'checked'])) {
1656 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1658 if (!empty($arrayfields[
't.note'][
'checked'])) {
1659 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
1661 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1662 print_liste_field_titre($arrayfields[
't.task_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
1664 if (!empty($arrayfields[
'value'][
'checked'])) {
1665 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1667 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1668 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
1675 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1676 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1677 print $hookmanager->resPrint;
1678 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
1681 $tasktmp =
new Task($db);
1682 $tmpinvoice =
new Facture($db);
1688 $totalarray = array();
1689 foreach ($tasks as $task_time) {
1694 $date1 = $db->jdate($task_time->task_date);
1695 $date2 = $db->jdate($task_time->task_datehour);
1697 print
'<tr class="oddeven">';
1700 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1701 print
'<td class="nowrap">';
1702 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1703 if (empty($task_time->task_date_withhour)) {
1704 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1706 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1709 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1713 $totalarray[
'nbfield']++;
1718 if (!empty($allprojectforuser)) {
1719 print
'<td class="nowraponall">';
1720 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
1721 $tmpproject =
new Project($db);
1722 $tmpproject->fetch($task_time->fk_projet);
1723 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
1725 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
1727 print $tmpproject->getNomUrl(1);
1730 $totalarray[
'nbfield']++;
1735 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1736 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1737 print
'<td class="nowrap">';
1738 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1739 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_task,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
1741 $tasktmp->id = $task_time->fk_task;
1742 $tasktmp->ref = $task_time->ref;
1743 $tasktmp->label = $task_time->label;
1744 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1748 $totalarray[
'nbfield']++;
1751 } elseif ($action !==
'createtime') {
1752 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1756 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1757 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1758 print
'<td class="nowrap tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
1762 $totalarray[
'nbfield']++;
1768 if (!empty($arrayfields[
'author'][
'checked'])) {
1769 print
'<td class="tdoverflowmax100">';
1770 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1771 if (empty($object->id)) {
1772 $object->fetch($id);
1774 $contactsoftask = $object->getListContactId(
'internal');
1775 if (!in_array($task_time->fk_user, $contactsoftask)) {
1776 $contactsoftask[] = $task_time->fk_user;
1778 if (count($contactsoftask) > 0) {
1779 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1780 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
1782 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
1785 $userstatic->id = $task_time->fk_user;
1786 $userstatic->lastname = $task_time->lastname;
1787 $userstatic->firstname = $task_time->firstname;
1788 $userstatic->photo = $task_time->photo;
1789 $userstatic->statut = $task_time->user_status;
1790 print $userstatic->getNomUrl(-1);
1794 $totalarray[
'nbfield']++;
1799 if (!empty($arrayfields[
't.note'][
'checked'])) {
1800 print
'<td class="small">';
1801 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1802 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
1808 $totalarray[
'nbfield']++;
1810 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1811 print
'<input type="hidden" name="timespent_note_line" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
1815 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1816 print
'<td class="right nowraponall">';
1817 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1818 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
1819 print
$form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
1825 $totalarray[
'nbfield']++;
1828 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.task_duration';
1830 $totalarray[
'val'][
't.task_duration'] += $task_time->task_duration;
1832 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
1834 $totalarray[
'totalduration'] += $task_time->task_duration;
1838 if (!empty($arrayfields[
'value'][
'checked'])) {
1839 $langs->load(
"salaries");
1840 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
1842 print
'<td class="nowraponall right">';
1843 print
'<span class="amount" title="'.$langs->trans(
"THM").
': '.
price($task_time->thm).
'">';
1844 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
1848 $totalarray[
'nbfield']++;
1851 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
1853 $totalarray[
'val'][
'value'] += $value;
1855 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
1857 $totalarray[
'totalvalue'] += $value;
1861 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1862 print
'<td class="center">';
1863 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1864 if ($projectstatic->usage_bill_time) {
1865 if ($task_time->invoice_id) {
1866 $result = $tmpinvoice->fetch($task_time->invoice_id);
1868 print $tmpinvoice->getNomUrl(1);
1871 print $langs->trans(
"No");
1874 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
1879 $totalarray[
'nbfield']++;
1889 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'i'=>$i,
'totalarray'=>&$totalarray);
1890 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1891 print $hookmanager->resPrint;
1894 print
'<td class="center nowraponall">';
1895 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1896 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
1897 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
1899 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1900 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
1901 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
1904 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=splitline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
1905 print
img_split(
'',
'class="pictofixedwidth"');
1909 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' :
'').
'">';
1910 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
1913 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' :
'').
'">';
1914 print
img_delete(
'default',
'class="pictodelete paddingleft"');
1917 if ($massactionbutton || $massaction) {
1919 if (in_array($task_time->rowid, $arrayofselected)) {
1923 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1929 $totalarray[
'nbfield']++;
1937 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1938 print
'<tr class="oddeven">';
1941 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1942 print
'<td class="nowrap">';
1943 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1944 if (empty($task_time->task_date_withhour)) {
1945 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
1947 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
1950 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
1956 if (!empty($allprojectforuser)) {
1957 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1958 print
'<td class="nowrap">';
1964 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1965 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1966 print
'<td class="nowrap">';
1967 $tasktmp->id = $task_time->fk_task;
1968 $tasktmp->ref = $task_time->ref;
1969 $tasktmp->label = $task_time->label;
1970 print $tasktmp->getNomUrl(1,
'withproject',
'time');
1976 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1977 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1978 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
1985 if (!empty($arrayfields[
'author'][
'checked'])) {
1987 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
1988 if (empty($object->id)) {
1989 $object->fetch($id);
1991 $contactsoftask = $object->getListContactId(
'internal');
1992 if (!in_array($task_time->fk_user, $contactsoftask)) {
1993 $contactsoftask[] = $task_time->fk_user;
1995 if (count($contactsoftask) > 0) {
1996 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1997 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
1999 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2002 $userstatic->id = $task_time->fk_user;
2003 $userstatic->lastname = $task_time->lastname;
2004 $userstatic->firstname = $task_time->firstname;
2005 $userstatic->photo = $task_time->photo;
2006 $userstatic->statut = $task_time->user_status;
2007 print $userstatic->getNomUrl(-1);
2013 if (!empty($arrayfields[
't.note'][
'checked'])) {
2014 print
'<td class="tdoverflowmax300">';
2015 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2016 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2021 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2022 print
'<input type="hidden" name="timespent_note_line" rows="'.ROWS_1.
'" value="'.
dol_escape_htmltag($task_time->note, 0, 1).
'">';
2026 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2027 print
'<td class="right">';
2028 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2029 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
2030 print
$form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
2038 if (!empty($arrayfields[
'value'][
'checked'])) {
2039 print
'<td class="right">';
2040 print
'<span class="amount">';
2041 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
2042 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2048 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2049 print
'<td class="right">';
2050 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2051 if (isset($task_time->total_ht)) {
2052 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2063 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split1');
2064 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2065 print $hookmanager->resPrint;
2068 print
'<td class="center nowraponall">';
2076 print
'<tr class="oddeven">';
2079 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
2080 print
'<td class="nowrap">';
2081 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2082 if (empty($task_time->task_date_withhour)) {
2083 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2085 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2088 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
2094 if (!empty($allprojectforuser)) {
2095 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2096 print
'<td class="nowrap">';
2102 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
2103 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2104 print
'<td class="nowrap">';
2105 $tasktmp->id = $task_time->fk_task;
2106 $tasktmp->ref = $task_time->ref;
2107 $tasktmp->label = $task_time->label;
2108 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2114 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
2115 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2116 print
'<td class="nowrap">';
2117 print $task_time->label;
2123 if (!empty($arrayfields[
'author'][
'checked'])) {
2125 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2126 if (empty($object->id)) {
2127 $object->fetch($id);
2129 $contactsoftask = $object->getListContactId(
'internal');
2130 if (!in_array($task_time->fk_user, $contactsoftask)) {
2131 $contactsoftask[] = $task_time->fk_user;
2133 if (count($contactsoftask) > 0) {
2134 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2135 print
$form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2137 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2140 $userstatic->id = $task_time->fk_user;
2141 $userstatic->lastname = $task_time->lastname;
2142 $userstatic->firstname = $task_time->firstname;
2143 $userstatic->photo = $task_time->photo;
2144 $userstatic->statut = $task_time->user_status;
2145 print $userstatic->getNomUrl(-1);
2151 if (!empty($arrayfields[
't.note'][
'checked'])) {
2152 print
'<td class="small tdoverflowmax300"">';
2153 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2154 print
'<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2159 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2160 print
'<input type="hidden" name="timespent_note_line_2" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2164 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2165 print
'<td class="right">';
2166 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2167 print
'<input type="hidden" name="old_duration_2" value="0">';
2168 print
$form->select_duration(
'new_duration_2', 0, 0,
'text');
2176 if (!empty($arrayfields[
'value'][
'checked'])) {
2177 print
'<td class="right">';
2178 print
'<span class="amount">';
2180 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2186 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2187 print
'<td class="right">';
2188 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2189 if (isset($task_time->total_ht)) {
2190 print
'<span class="amount">';
2191 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2203 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split2');
2204 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2205 print $hookmanager->resPrint;
2208 print
'<td class="center nowraponall">';
2219 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2220 print
'<tr class="liste_total">';
2222 while ($i < $totalarray[
'nbfield']) {
2225 if ($num < $limit && empty($offset)) {
2226 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
2228 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
2230 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2231 print
'<td class="right">'.convertSecondToTime($totalarray[
'totalduration'],
'allhourmin').
'</td>';
2232 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2233 print
'<td class="right">'.price($totalarray[
'totalvalue']).
'</td>';
2242 if (!count($tasks)) {
2243 $totalnboffields = 1;
2244 foreach ($arrayfields as $value) {
2245 if ($value[
'checked']) {
2249 print
'<tr class="oddeven"><td colspan="'.$totalnboffields.
'">';
2250 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2254 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2255 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2256 print $hookmanager->resPrint;