31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formintervention.class.php';
42 $langsLoad=array(
'projects',
'bills',
'orders',
'companies');
44 $langsLoad[]=
'eventorganization';
47 $langs->loadLangs($langsLoad);
49 $action =
GETPOST(
'action',
'alpha');
50 $massaction =
GETPOST(
'massaction',
'alpha');
51 $confirm =
GETPOST(
'confirm',
'alpha');
52 $cancel =
GETPOST(
'cancel',
'alpha');
53 $toselect =
GETPOST(
'toselect',
'array');
54 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
55 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $optioncss =
GETPOST(
'optioncss',
'alpha');
57 $mode =
GETPOST(
'mode',
'alpha');
60 $projectid =
GETPOST(
'projectid',
'int');
62 $withproject =
GETPOST(
'withproject',
'int');
63 $project_ref =
GETPOST(
'project_ref',
'alpha');
66 $search_day =
GETPOST(
'search_day',
'int');
67 $search_month =
GETPOST(
'search_month',
'int');
68 $search_year =
GETPOST(
'search_year',
'int');
69 $search_datehour =
'';
70 $search_datewithhour =
'';
71 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
72 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
73 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
74 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
75 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
76 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
77 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
78 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
79 $search_note =
GETPOST(
'search_note',
'alpha');
80 $search_duration =
GETPOST(
'search_duration',
'int');
81 $search_value =
GETPOST(
'search_value',
'int');
82 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
83 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
84 $search_user =
GETPOST(
'search_user',
'int');
85 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
86 $search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
87 $search_company =
GETPOST(
'$search_company',
'alpha');
88 $search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
89 $search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
90 $search_project_label =
GETPOST(
'$search_project_label',
'alpha');
91 $search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
92 $search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
93 $search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
94 $search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
96 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
97 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
98 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
100 if (empty($page) || $page == -1) {
103 $offset = $limit * $page;
104 $pageprev = $page - 1;
105 $pagenext = $page + 1;
107 $sortfield =
't.task_date,t.task_datehour,t.rowid';
110 $sortorder =
'DESC,DESC,DESC';
113 $childids = $user->getAllChildIds(1);
117 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
119 $object =
new Task($db);
121 $projectstatic =
new Project($db);
124 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
125 $extrafields->fetch_name_optionals_label($object->table_element);
128 if ($id > 0 || $ref) {
129 $object->fetch($id, $ref);
136 if (!$user->rights->projet->lire) {
140 if ($object->fk_project > 0) {
141 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
145 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
146 $search_user = $user->id;
156 if (
GETPOST(
'cancel',
'alpha')) {
159 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
163 $parameters = array(
'socid'=>$socid,
'projectid'=>$projectid);
164 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
169 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
172 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
177 $search_datehour =
'';
178 $search_datewithhour =
'';
180 $search_duration =
'';
182 $search_date_creation =
'';
183 $search_date_update =
'';
184 $search_date_startday =
'';
185 $search_date_startmonth =
'';
186 $search_date_startyear =
'';
187 $search_date_endday =
'';
188 $search_date_endmonth =
'';
189 $search_date_endyear =
'';
190 $search_date_start =
'';
191 $search_date_end =
'';
192 $search_task_ref =
'';
193 $search_company =
'';
194 $search_company_alias =
'';
195 $search_project_ref =
'';
196 $search_project_label =
'';
197 $search_task_label =
'';
199 $search_valuebilled =
'';
200 $search_product_ref =
'';
202 $search_array_options = array();
203 $search_timespent_starthour =
'';
204 $search_timespent_startmin =
'';
205 $search_timespent_endhour =
'';
206 $search_timespent_endmin =
'';
210 if ($action ==
'addtimespent' && $user->rights->projet->time) {
213 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
214 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
215 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
216 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
219 if (!
GETPOST(
"userid",
'int')) {
220 $langs->load(
"errors");
221 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
227 $object->fetch($id, $ref);
230 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
231 $action =
'createtime';
234 $object->fetch(
GETPOST(
'taskid',
'int'));
239 $object->fetch_projet();
241 if (empty($object->project->statut)) {
242 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
243 $action =
'createtime';
246 $object->timespent_note =
GETPOST(
"timespent_note",
'alpha');
247 if (
GETPOST(
'progress',
'int') > 0) {
248 $object->progress =
GETPOST(
'progress',
'int');
250 $object->timespent_duration =
GETPOSTINT(
"timespent_durationhour") * 60 * 60;
251 $object->timespent_duration += (
GETPOSTINT(
'timespent_durationmin') ?
GETPOSTINT(
'timespent_durationmin') : 0) * 60;
253 $object->timespent_date =
dol_mktime(
GETPOST(
"timehour",
'int'),
GETPOST(
"timemin",
'int'), 0,
GETPOST(
"timemonth",
'int'),
GETPOST(
"timeday",
'int'),
GETPOST(
"timeyear",
'int'));
254 $object->timespent_withhour = 1;
258 $object->timespent_fk_user =
GETPOST(
"userid",
'int');
259 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
260 $result = $object->addTimeSpent($user);
271 $action =
'createtime';
273 $action =
'createtime';
278 if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire) {
281 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
282 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
287 if (
GETPOST(
'taskid',
'int') != $id) {
288 $id_temp =
GETPOST(
'taskid',
'int');
291 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
294 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
295 $result = $object->delTimeSpent($user);
298 $object->fetch($id_temp, $ref);
300 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
301 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
302 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
303 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
304 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
306 $object->timespent_withhour = 1;
310 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
311 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
314 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
315 $result = $object->addTimeSpent($user);
324 $object->fetch($id, $ref);
326 $object->timespent_id =
GETPOST(
"lineid",
'int');
327 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
328 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
329 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
330 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
331 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
332 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
333 $object->timespent_withhour = 1;
337 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
338 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
341 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
342 $result = $object->updateTimeSpent($user);
357 if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
358 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
360 if (in_array($object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
361 $result = $object->delTimeSpent($user);
364 $langs->load(
"errors");
375 if (!empty($project_ref) && !empty($withproject)) {
376 if ($projectstatic->fetch(0, $project_ref) > 0) {
377 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
378 if (count($tasksarray) > 0) {
379 $id = $tasksarray[0]->id;
381 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
388 $projectidforalltimes = 0;
389 if (
GETPOST(
'projectid',
'int') > 0) {
390 $projectidforalltimes =
GETPOST(
'projectid',
'int');
392 $result = $projectstatic->fetch($projectidforalltimes);
393 if (!empty($projectstatic->socid)) {
394 $projectstatic->fetch_thirdparty();
396 $res = $projectstatic->fetch_optionals();
397 } elseif (
GETPOST(
'project_ref',
'alpha')) {
398 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
399 $projectidforalltimes = $projectstatic->id;
403 $result = $projectstatic->fetch($object->fk_project);
406 if ($id <= 0 && $projectidforalltimes == 0) {
407 $allprojectforuser = $user->id;
410 if ($action ==
'confirm_generateinvoice') {
411 if (!empty($projectstatic->socid)) {
412 $projectstatic->fetch_thirdparty();
415 if (!($projectstatic->thirdparty->id > 0)) {
416 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
418 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
419 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
420 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
422 $tmpinvoice =
new Facture($db);
423 $tmptimespent =
new Task($db);
424 $tmpproduct =
new Product($db);
425 $fuser =
new User($db);
428 $idprod =
GETPOST(
'productid',
'int');
429 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
430 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
432 $prodDurationHoursBase = 1.0;
433 $product_data_cache = array();
435 $tmpproduct->fetch($idprod);
441 $prodDurationHoursBase=$tmpproduct->getProductDurationHours();
442 if ($prodDurationHoursBase<0) {
444 $langs->load(
"errors");
448 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
450 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
451 $txtva = $dataforprice[
'tva_tx'];
452 $localtax1 = $dataforprice[
'localtax1'];
453 $localtax2 = $dataforprice[
'localtax2'];
455 $prodDurationHoursBase = 1;
463 $tmpinvoice->socid = $projectstatic->thirdparty->id;
464 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
465 $tmpinvoice->fk_project = $projectstatic->id;
466 $tmpinvoice->cond_reglement_id = $projectstatic->thirdparty->cond_reglement_id;
467 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
468 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
471 $tmpinvoice->fetch($invoiceToUse);
473 $result = $tmpinvoice->create($user);
481 if ($generateinvoicemode ==
'onelineperuser') {
482 $arrayoftasks = array();
483 foreach ($toselect as $key => $value) {
485 $object->fetchTimeSpent($value);
486 $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
487 $arrayoftasks[$object->timespent_fk_user][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
490 foreach ($arrayoftasks as $userid => $data) {
491 $fuser->fetch($userid);
492 $username = $fuser->getFullName($langs);
494 foreach ($data as $fk_product => $timespent_data) {
496 $qtyhour = $timespent_data[
'timespent'] / 3600;
497 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
505 $pu_ht = $fuser->thm;
510 if ($timespent_data[
'timespent']) {
511 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
516 $prodDurationHours = $prodDurationHoursBase;
520 $localtax1line = $localtax1;
521 $localtax2line = $localtax2;
524 if (!empty($fk_product) && $fk_product !== $idprod) {
525 if (!array_key_exists($fk_product, $product_data_cache)) {
526 $result = $tmpproduct->fetch($fk_product);
531 $prodDurationHours = $tmpproduct->getProductDurationHours();
532 if ($prodDurationHours < 0) {
534 $langs->load(
"errors");
538 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
540 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
541 $txtvaline = $dataforprice[
'tva_tx'];
542 $localtax1line = $dataforprice[
'localtax1'];
543 $localtax2line = $dataforprice[
'localtax2'];
545 $product_data_cache[$fk_product] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
547 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
548 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
549 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
550 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
551 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
553 $idprodline=$fk_product;
557 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username).
' : '.$qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
564 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
565 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
566 $result = $db->query($sql);
574 } elseif ($generateinvoicemode ==
'onelineperperiod') {
575 $arrayoftasks = array();
577 $withdetail=
GETPOST(
'detail_time_duration',
'alpha');
578 foreach ($toselect as $key => $value) {
580 $object->fetchTimeSpent($value);
582 $ftask =
new Task($db);
583 $ftask->fetch($object->id);
585 $fuser->fetch($object->timespent_fk_user);
586 $username = $fuser->getFullName($langs);
588 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
589 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
590 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref.
' - '.$ftask->label.
' - '.$username.($object->timespent_note ?
' - '.$object->timespent_note :
'');
591 if (!empty($withdetail)) {
592 if (
isModEnabled(
'fckeditor') && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
593 $arrayoftasks[$object->timespent_id][
'note'] .=
"<br/>";
595 $arrayoftasks[$object->timespent_id][
'note'] .=
"\n";
598 if (!empty($object->timespent_withhour)) {
599 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour);
601 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date);
603 $arrayoftasks[$object->timespent_id][
'note'] .=
' - '.$langs->trans(
"Duration").
': '.
convertSecondToTime($object->timespent_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
605 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
606 $arrayoftasks[$object->timespent_id][
'fk_product'] = $object->timespent_fk_product;
609 foreach ($arrayoftasks as $timespent_id => $value) {
610 $userid = $value[
'user'];
614 $qtyhour = $value[
'timespent'] / 3600;
618 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
622 $prodDurationHours = $prodDurationHoursBase;
626 $localtax1line = $localtax1;
627 $localtax2line = $localtax2;
629 if (!empty($value[
'fk_product']) && $value[
'fk_product']!==$idprod) {
630 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
631 $result = $tmpproduct->fetch($value[
'fk_product']);
636 $prodDurationHours = $tmpproduct->getProductDurationHours();
637 if ($prodDurationHours < 0) {
639 $langs->load(
"errors");
643 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
645 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
646 $txtvaline = $dataforprice[
'tva_tx'];
647 $localtax1line = $dataforprice[
'localtax1'];
648 $localtax2line = $dataforprice[
'localtax2'];
650 $product_data_cache[$value[
'fk_product']] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
652 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
653 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
654 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
655 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
656 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
658 $idprodline=$value[
'fk_product'];
660 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
668 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'projet_task_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
669 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
670 $result = $db->query($sql);
677 } elseif ($generateinvoicemode ==
'onelinepertask') {
678 $arrayoftasks = array();
679 foreach ($toselect as $key => $value) {
681 $object->fetchTimeSpent($value);
683 $arrayoftasks[$object->id][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
684 $arrayoftasks[$object->id][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
687 foreach ($arrayoftasks as $task_id => $data) {
688 $ftask =
new Task($db);
689 $ftask->fetch($task_id);
691 foreach ($data as $fk_product=>$timespent_data) {
692 $qtyhour = $timespent_data[
'timespent'] / 3600;
693 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
696 $prodDurationHours = $prodDurationHoursBase;
700 $localtax1line = $localtax1;
701 $localtax2line = $localtax2;
703 if (!empty($fk_product) && $fk_product!==$idprod) {
704 if (!array_key_exists($fk_product, $product_data_cache)) {
705 $result = $tmpproduct->fetch($fk_product);
710 $prodDurationHours = $tmpproduct->getProductDurationHours();
711 if ($prodDurationHours < 0) {
713 $langs->load(
"errors");
717 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
719 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
720 $txtvaline = $dataforprice[
'tva_tx'];
721 $localtax1line = $dataforprice[
'localtax1'];
722 $localtax2line = $dataforprice[
'localtax2'];
724 $product_data_cache[$fk_product] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
726 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
727 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
728 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
729 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
730 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
732 $idprodline=$fk_product;
736 if ($idprodline > 0) {
738 $pu_ht_for_task = $pu_htline;
740 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
741 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
743 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
748 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
749 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
751 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
757 $lineName = $ftask->ref .
' - ' . $ftask->label;
758 $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task,
price2num($qtyhour / $prodDurationHours,
'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), 0, $date_start, $date_end, 0, 0,
'',
'HT', 0, 1, -1, 0,
'', 0, 0,
null, $pa_ht);
767 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'projet_task_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
768 $sql .=
' WHERE rowid IN (' . $db->sanitize(join(
',', $toselect)) .
')';
769 $result = $db->query($sql);
782 $urltoinvoice = $tmpinvoice->getNomUrl(0);
783 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
784 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
796 if ($action ==
'confirm_generateinter') {
797 $langs->load(
'interventions');
799 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
801 if (!($projectstatic->thirdparty->id > 0)) {
802 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
804 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
805 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
806 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
809 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
811 $tmptimespent =
new Task($db);
812 $fuser =
new User($db);
815 $interToUse =
GETPOST(
'interid',
'int');
818 $tmpinter->socid = $projectstatic->thirdparty->id;
819 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
820 $tmpinter->fk_project = $projectstatic->id;
821 $tmpinter->description = $projectstatic->title . ( !empty($projectstatic->description) ?
'-' . $projectstatic->label :
'' );
824 $tmpinter->fetch($interToUse);
826 $result = $tmpinter->create($user);
834 $arrayoftasks = array();
835 foreach ($toselect as $key => $value) {
837 $object->fetchTimeSpent($value);
839 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
840 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
841 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
842 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
843 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
846 foreach ($arrayoftasks as $timespent_id => $value) {
847 $ftask =
new Task($db);
848 $ftask->fetch($value[
'id']);
850 $qtyhour = $value[
'timespent'] / 3600;
851 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
854 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . ( !empty($value[
'note']) ?
' - ' . $value[
'note'] :
'' ), $value[
'date'], $value[
'timespent']);
859 $urltointer = $tmpinter->getNomUrl(0);
860 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
861 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
879 $userstatic =
new User($db);
881 $arrayofselected = is_array($toselect) ? $toselect : array();
883 $title = $object->ref .
' - ' . $langs->trans(
"TimeSpent");
884 if (!empty($withproject)) {
885 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
891 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
895 if ($projectidforalltimes > 0) {
896 $result = $projectstatic->fetch($projectidforalltimes);
897 if (!empty($projectstatic->socid)) {
898 $projectstatic->fetch_thirdparty();
900 $res = $projectstatic->fetch_optionals();
901 } elseif ($object->fetch($id, $ref) >= 0) {
902 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
903 $object->fetchComments();
905 $result = $projectstatic->fetch($object->fk_project);
906 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
907 $projectstatic->fetchComments();
909 if (!empty($projectstatic->socid)) {
910 $projectstatic->fetch_thirdparty();
912 $res = $projectstatic->fetch_optionals();
914 $object->project = clone $projectstatic;
917 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
918 $linktocreatetime =
'';
920 if ($projectstatic->id > 0) {
923 if (empty($id) || $tab ==
'timespent') {
930 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
932 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
934 $param .=
'&search_user='.((int) $search_user);
937 $param .=
'&search_month='.((int) $search_month);
940 $param .=
'&search_year='.((int) $search_year);
945 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
947 $morehtmlref =
'<div class="refidno">';
949 $morehtmlref .= $projectstatic->title;
951 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
952 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
954 $morehtmlref .=
'</div>';
957 if (empty($user->rights->projet->all->lire)) {
958 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
959 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
962 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
964 print
'<div class="fichecenter">';
965 print
'<div class="fichehalfleft">';
966 print
'<div class="underbanner clearboth"></div>';
968 print
'<table class="border tableforfield centpercent">';
971 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
972 print
'<tr><td class="tdtop">';
973 print $langs->trans(
"Usage");
976 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
977 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
978 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
979 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
982 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
983 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
984 $htmltext = $langs->trans(
"ProjectFollowTasks");
985 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
988 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
989 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"' :
'')).
'"> ';
990 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
991 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
995 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"' :
'')).
'"> ';
996 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
997 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1003 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1004 if ($projectstatic->public) {
1005 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1006 print $langs->trans(
'SharedProject');
1008 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1009 print $langs->trans(
'PrivateProject');
1014 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1015 if (strcmp($projectstatic->budget_amount,
'')) {
1016 print
'<span class="amount">'.price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
1021 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1023 print ($start ? $start :
'?');
1026 print ($end ? $end :
'?');
1027 if ($projectstatic->hasDelay()) {
1034 $savobject = $object;
1035 $object = $projectstatic;
1036 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1037 $object = $savobject;
1042 print
'<div class="fichehalfright">';
1043 print
'<div class="underbanner clearboth"></div>';
1045 print
'<table class="border tableforfield centpercent">';
1048 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1049 print nl2br($projectstatic->description);
1054 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1055 print
$form->showCategories($projectstatic->id,
'project', 1);
1064 print
'<div class="clearboth"></div>';
1072 $linktocreatetimeBtnStatus = 0;
1073 $linktocreatetimeUrl =
'';
1074 $linktocreatetimeHelpText =
'';
1075 if (!empty($user->rights->projet->time)) {
1076 if ($projectstatic->public || $userRead > 0) {
1077 $linktocreatetimeBtnStatus = 1;
1079 if (!empty($projectidforalltimes)) {
1081 $backtourl = $_SERVER[
'PHP_SELF'].
'?projectid='.$projectstatic->id.($withproject ?
'&withproject=1' :
'');
1082 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').
'&projectid='.$projectstatic->id.
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
1085 $backtourl = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($withproject ?
'&withproject=1' :
'');
1086 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').($object->id > 0 ?
'&id='.$object->id :
'&projectid='.$projectstatic->id).
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
1089 $linktocreatetimeBtnStatus = -2;
1090 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1093 $linktocreatetimeBtnStatus = -2;
1094 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1097 $paramsbutton = array(
'morecss'=>
'reposition');
1098 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1101 $massactionbutton =
'';
1102 $arrayofmassactions = array();
1104 if ($projectstatic->id > 0) {
1106 if ($projectstatic->usage_bill_time) {
1107 $arrayofmassactions = array(
1108 'generateinvoice'=>$langs->trans(
"GenerateBill"),
1112 if (
isModEnabled(
'ficheinter') && $user->rights->ficheinter->creer) {
1113 $langs->load(
"interventions");
1114 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1118 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1119 $arrayofmassactions = array();
1121 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1124 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1126 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1128 if ($action ==
'deleteline') {
1129 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);
1132 $param = ($withproject ?
'&withproject=1' :
'');
1133 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1135 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1136 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1137 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
1139 $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
1145 if (empty($withproject)) {
1146 $morehtmlref .=
'<div class="refidno">';
1147 $morehtmlref .= $langs->trans(
"Project").
': ';
1148 $morehtmlref .= $projectstatic->getNomUrl(1);
1149 $morehtmlref .=
'<br>';
1152 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
1153 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1154 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1156 $morehtmlref .=
'</div>';
1159 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1161 print
'<div class="fichecenter">';
1162 print
'<div class="fichehalfleft">';
1164 print
'<div class="underbanner clearboth"></div>';
1165 print
'<table class="border centpercent tableforfield">';
1168 print
'<tr><td>'.$langs->trans(
"ChildOfTask").
'</td><td>';
1169 if ($object->fk_task_parent > 0) {
1170 $tasktmp =
new Task($db);
1171 $tasktmp->fetch($object->fk_task_parent);
1172 print $tasktmp->getNomUrl(1);
1177 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"Deadline").
'</td><td>';
1179 print ($start ? $start :
'?');
1182 print ($end ? $end :
'?');
1183 if ($object->hasDelay()) {
1189 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
1190 if ($object->planned_workload) {
1198 print
'<div class="fichehalfright">';
1200 print
'<div class="underbanner clearboth"></div>';
1201 print
'<table class="border tableforfield centpercent">';
1204 print
'<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td>';
1205 print $object->progress !=
'' ? $object->progress.
' %' :
'';
1209 print
'<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td>';
1210 if ($object->planned_workload) {
1211 $tmparray = $object->getSummaryOfTimeSpent();
1212 if ($tmparray[
'total_duration'] > 0) {
1213 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
1218 print
'<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
1229 print
'<div class="clearboth"></div>';
1235 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1236 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1237 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);
1241 $hookmanager->initHooks(array(
'tasktimelist'));
1245 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1246 $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);
1250 $parameters = array(
'formConfirm' =>
$formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1251 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1252 if (empty($reshook)) {
1254 } elseif ($reshook > 0) {
1262 $arrayfields = array();
1263 $arrayfields[
't.task_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1264 $arrayfields[
'p.fk_soc'] = array(
'label'=>$langs->trans(
"ThirdParty"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1',
'checked'=>1);
1265 $arrayfields[
's.name_alias'] = array(
'label'=>$langs->trans(
"AliasNameShort"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1');
1266 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1267 if (! empty($allprojectforuser)) {
1268 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1269 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1271 $arrayfields[
't.task_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1272 $arrayfields[
't.task_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1274 $arrayfields[
'author'] = array(
'label'=>$langs->trans(
"By"),
'checked'=>1);
1275 $arrayfields[
't.note'] = array(
'label'=>$langs->trans(
"Note"),
'checked'=>1);
1276 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1277 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1279 $arrayfields[
't.task_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1280 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
1281 $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));
1283 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
1288 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1289 $param .=
'&contextpage='.urlencode($contextpage);
1291 if ($limit > 0 && $limit != $conf->liste_limit) {
1292 $param .=
'&limit='.urlencode($limit);
1294 if ($search_month > 0) {
1295 $param .=
'&search_month='.urlencode($search_month);
1297 if ($search_year > 0) {
1298 $param .=
'&search_year='.urlencode($search_year);
1300 if ($search_user > 0) {
1301 $param .=
'&search_user='.urlencode($search_user);
1303 if ($search_task_ref !=
'') {
1304 $param .=
'&search_task_ref='.urlencode($search_task_ref);
1306 if ($search_company !=
'') {
1307 $param .=
'&$search_company='.urlencode($search_company);
1309 if ($search_company_alias !=
'') {
1310 $param .=
'&$search_company_alias='.urlencode($search_company_alias);
1312 if ($search_project_ref !=
'') {
1313 $param .=
'&$search_project_ref='.urlencode($search_project_ref);
1315 if ($search_project_label !=
'') {
1316 $param .=
'&$search_project_label='.urlencode($search_project_label);
1318 if ($search_task_label !=
'') {
1319 $param .=
'&search_task_label='.urlencode($search_task_label);
1321 if ($search_note !=
'') {
1322 $param .=
'&search_note='.urlencode($search_note);
1324 if ($search_duration !=
'') {
1325 $param .=
'&search_field2='.urlencode($search_duration);
1327 if ($optioncss !=
'') {
1328 $param .=
'&optioncss='.urlencode($optioncss);
1330 if ($search_date_startday) {
1331 $param .=
'&search_date_startday='.urlencode($search_date_startday);
1333 if ($search_date_startmonth) {
1334 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
1336 if ($search_date_startyear) {
1337 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
1339 if ($search_date_endday) {
1340 $param .=
'&search_date_endday='.urlencode($search_date_endday);
1342 if ($search_date_endmonth) {
1343 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
1345 if ($search_date_endyear) {
1346 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
1348 if ($search_timespent_starthour) {
1349 $param .=
'&search_timespent_duration_starthour='.urlencode($search_timespent_starthour);
1351 if ($search_timespent_startmin) {
1352 $param .=
'&search_timespent_duration_startmin='.urlencode($search_timespent_startmin);
1354 if ($search_timespent_endhour) {
1355 $param .=
'&search_timespent_duration_endhour='.urlencode($search_timespent_endhour);
1357 if ($search_timespent_endmin) {
1358 $param .=
'&search_timespent_duration_endmin='.urlencode($search_timespent_endmin);
1366 $param .=
'&id='.urlencode($id);
1369 $param .=
'&projectid='.urlencode($projectid);
1372 $param .=
'&withproject='.urlencode($withproject);
1375 $parameters = array();
1376 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1377 $param .= $hookmanager->resPrint;
1379 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1380 if ($optioncss !=
'') {
1381 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1383 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1384 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1385 if ($action ==
'editline') {
1386 print
'<input type="hidden" name="action" value="updateline">';
1387 } elseif ($action ==
'splitline') {
1388 print
'<input type="hidden" name="action" value="updatesplitline">';
1389 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1390 print
'<input type="hidden" name="action" value="addtimespent">';
1391 } elseif ($massaction ==
'generateinvoice' && $user->rights->facture->creer) {
1392 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1393 } elseif ($massaction ==
'generateinter' && $user->rights->ficheinter->creer) {
1394 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1396 print
'<input type="hidden" name="action" value="list">';
1398 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1399 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1401 print
'<input type="hidden" name="id" value="'.$id.
'">';
1402 print
'<input type="hidden" name="projectid" value="'.$projectidforalltimes.
'">';
1403 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
1404 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
1405 print
'<input type="hidden" name="page_y" value="">';
1408 if ($massaction ==
'generateinvoice') {
1409 if ($projectstatic->thirdparty->id > 0) {
1410 print
'<table class="noborder centerpercent">';
1412 print
'<td class="titlefield">';
1413 print $langs->trans(
'DateInvoice');
1416 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1422 print $langs->trans(
'Mode');
1426 'onelineperuser'=>
'OneLinePerUser',
1427 'onelinepertask'=>
'OneLinePerTask',
1428 'onelineperperiod'=>
'OneLinePerTimeSpentLine',
1430 print
$form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1431 print
"\n".
'<script type="text/javascript">';
1433 $(document).ready(function () {
1434 setDetailVisibility();
1435 $("#generateinvoicemode").change(function() {
1436 setDetailVisibility();
1438 function setDetailVisibility() {
1439 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1440 if (generateinvoicemode=="onelineperperiod") {
1441 $("#detail_time_duration").show();
1443 $("#detail_time_duration").hide();
1448 print
'</script>'.
"\n";
1449 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>'.$langs->trans(
'AddDetailDateAndDuration').
'</span>';
1453 if ($conf->service->enabled) {
1456 print $langs->trans(
'ServiceToUseOnLines');
1459 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1465 print
'<td class="titlefield">';
1466 print $langs->trans(
'InvoiceToUse');
1469 $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1483 print
'<div class="center">';
1484 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'GenerateBill').
'"> ';
1485 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1489 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateInvoice").
'</div>';
1490 print
'<div class="center">';
1491 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1495 } elseif ($massaction ==
'generateinter') {
1497 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1499 if ($projectstatic->thirdparty->id > 0) {
1501 print
'<table class="noborder centpercent">';
1503 print
'<td class="titlefield">';
1504 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"').$langs->trans(
'InterToUse');
1508 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1513 print
'<div class="center">';
1514 print
'<input type="submit" class="button" id="createinter" name="createinter" value="'.$langs->trans(
'GenerateInter').
'"> ';
1515 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1519 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateIntervention").
'</div>';
1520 print
'<div class="center">';
1521 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1528 $parameters = array(
1529 'toselect' => $toselect,
1530 'uploaddir' => isset($uploaddir) ? $uploaddir :
null
1533 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1537 print $hookmanager->resPrint;
1545 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1546 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1548 $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,";
1549 $sql .=
" t.fk_product,";
1550 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1551 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1552 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1553 $sql .=
" p.fk_soc,s.name_alias,";
1555 $parameters = array();
1556 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1557 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
1558 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1559 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
1560 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1561 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1562 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1563 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_task";
1564 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1565 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1566 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1569 $parameters = array();
1570 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1571 $sql .= $hookmanager->resPrint;
1572 $sql .=
" WHERE 1 = 1 ";
1573 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1575 $sql .=
" AND t.fk_task =".((int) $object->id);
1576 } elseif (!empty($projectidforalltimes)) {
1578 $sql .=
" AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).
")";
1579 } elseif (!empty($allprojectforuser)) {
1581 if (empty($search_user)) {
1582 $search_user = $user->id;
1584 if ($search_user > 0) $sql .=
" AND t.fk_user = ".((int) $search_user);
1590 if ($search_task_ref) {
1593 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1594 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1596 if ($search_company) {
1599 if ($search_company_alias) {
1603 if ($search_project_ref) {
1606 if ($search_project_label) {
1609 if ($search_task_label) {
1612 if ($search_user > 0) {
1615 if (!empty($search_product_ref)) {
1618 if ($search_valuebilled ==
'1') {
1619 $sql .=
' AND t.invoice_id > 0';
1621 if ($search_valuebilled ==
'0') {
1622 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1625 if ($search_date_start) {
1626 $sql .=
" AND t.task_date >= '".$db->idate($search_date_start).
"'";
1628 if ($search_date_end) {
1629 $sql .=
" AND t.task_date <= '".$db->idate($search_date_end).
"'";
1632 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1633 if ($search_timespent_starthour || $search_timespent_startmin) {
1634 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1635 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1636 $sql .=
" AND t.task_duration >= " . $timespent_duration_start;
1639 if ($search_timespent_endhour || $search_timespent_endmin) {
1640 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1641 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1642 $sql .=
" AND t.task_duration <= " . $timespent_duration_end;
1646 $sql .=
dolSqlDateFilter(
't.task_datehour', $search_day, $search_month, $search_year);
1649 $parameters = array();
1650 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1651 $sql .= $hookmanager->resPrint;
1652 $sql .= $db->order($sortfield, $sortorder);
1656 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1657 $resql = $db->query($sql);
1674 $sql .= $db->plimit($limit + 1, $offset);
1676 $resql = $db->query($sql);
1682 $num = $db->num_rows(
$resql);
1686 if (!empty($projectidforalltimes)) {
1687 print
'<!-- List of time spent for project -->'.
"\n";
1689 $title = $langs->trans(
"ListTaskTimeUserProject");
1691 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1693 print
'<!-- List of time spent -->'.
"\n";
1695 $title = $langs->trans(
"ListTaskTimeForTask");
1697 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1702 $row = $db->fetch_object(
$resql);
1714 if ($action ==
'createtime' && $user->rights->projet->time) {
1715 print
'<!-- table to add time spent -->'.
"\n";
1717 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1720 print
'<div class="div-table-responsive-no-min">';
1721 print
'<table class="noborder nohover centpercent">';
1723 print
'<tr class="liste_titre">';
1724 print
'<td>'.$langs->trans(
"Date").
'</td>';
1725 if (!empty($allprojectforuser)) {
1726 print
'<td>'.$langs->trans(
"Project").
'</td>';
1729 print
'<td>'.$langs->trans(
"Task").
'</td>';
1731 print
'<td>'.$langs->trans(
"By").
'</td>';
1732 print
'<td>'.$langs->trans(
"Note").
'</td>';
1733 print
'<td>'.$langs->trans(
"NewTimeSpent").
'</td>';
1734 print
'<td>'.$langs->trans(
"ProgressDeclared").
'</td>';
1735 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1738 if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1739 print
'<td>'.$langs->trans(
"Product").
'</td>';
1743 $parameters = array(
'mode' =>
'create');
1744 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1745 print $hookmanager->resPrint;
1749 print
'<tr class="oddeven nohover">';
1752 print
'<td class="maxwidthonsmartphone">';
1754 print
$form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1757 if (!empty($allprojectforuser)) {
1766 print
'<td class="maxwidthonsmartphone">';
1767 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1772 print
'<td class="maxwidthonsmartphone nowraponall">';
1773 $contactsofproject = $projectstatic->getListContactId(
'internal');
1774 if (count($contactsofproject) > 0) {
1775 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1776 if (in_array($user->id, $contactsofproject)) {
1777 $userid = $user->id;
1779 $userid = $contactsofproject[0];
1782 if ($projectstatic->public) {
1783 $contactsofproject = array();
1785 print
$form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'maxwidth250');
1788 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).
' '.$langs->trans(
'FirstAddRessourceToAllocateTime');
1795 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.
'">'.(
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'').
'</textarea>';
1799 print
'<td class="nowraponall">';
1800 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1802 $durationtouse = (
GETPOST(
'timespent_durationhour') * 3600 +
GETPOST(
'timespent_durationmin') * 60);
1804 print
$form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1808 print
'<td class="nowrap">';
1809 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1813 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1817 if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1818 print
'<td class="nowrap">';
1819 print
$form->select_produits(
'',
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1825 $parameters = array(
'mode' =>
'create');
1826 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1827 print $hookmanager->resPrint;
1829 print
'<td class="center">';
1830 $form->buttonsSaveCancel();
1831 print
'<input type="submit" name="save" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-add" value="'.$langs->trans(
"Add").
'">';
1832 print
'<input type="submit" name="cancel" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1841 $moreforfilter =
'';
1843 $parameters = array();
1844 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1845 if (empty($reshook)) {
1846 $moreforfilter .= $hookmanager->resPrint;
1848 $moreforfilter = $hookmanager->resPrint;
1851 if (!empty($moreforfilter)) {
1852 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1853 print $moreforfilter;
1857 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1858 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1859 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
1861 print
'<div class="div-table-responsive">';
1862 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1865 print
'<tr class="liste_titre_filter">';
1867 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1868 print
'<td class="liste_titre left">';
1869 print
'<div class="nowrap">';
1870 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1872 print
'<div class="nowrap">';
1873 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1878 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1879 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="'.dol_escape_htmltag($search_company).
'"></td>';
1883 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1884 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1887 if (!empty($allprojectforuser)) {
1888 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1889 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1891 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1892 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="'.dol_escape_htmltag($search_project_label).
'"></td>';
1896 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1897 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1898 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1900 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1901 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1905 if (!empty($arrayfields[
'author'][
'checked'])) {
1906 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>';
1909 if (!empty($arrayfields[
't.note'][
'checked'])) {
1910 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).
'"></td>';
1913 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1915 print
'<td class="liste_titre right">';
1917 $durationtouse_start = 0;
1918 if ($search_timespent_starthour || $search_timespent_startmin) {
1919 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1921 print
'<div class="nowraponall">'.$langs->trans(
'from').
' ';
1922 $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text');
1925 $durationtouse_end = 0;
1926 if ($search_timespent_endhour || $search_timespent_endmin) {
1927 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1929 print
'<div class="nowraponall">'.$langs->trans(
'at').
' ';
1930 $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text');
1936 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1937 print
'<td class="liste_titre right"></td>';
1940 if (!empty($arrayfields[
'value'][
'checked'])) {
1941 print
'<td class="liste_titre"></td>';
1944 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1945 print
'<td class="liste_titre center">'.$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1).
'</td>';
1953 $parameters = array(
'arrayfields'=>$arrayfields);
1954 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1955 print $hookmanager->resPrint;
1957 print
'<td class="liste_titre center">';
1958 $searchpicto =
$form->showFilterButtons();
1963 print
'<tr class="liste_titre">';
1964 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
1965 print_liste_field_titre($arrayfields[
't.task_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_date,t.task_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
1968 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1969 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_date,t.task_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
1971 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1972 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1974 if (!empty($allprojectforuser)) {
1975 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1978 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1979 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
1982 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1983 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
1984 print_liste_field_titre($arrayfields[
't.task_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
1986 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
1987 print_liste_field_titre($arrayfields[
't.task_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
1990 if (!empty($arrayfields[
'author'][
'checked'])) {
1991 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1993 if (!empty($arrayfields[
't.note'][
'checked'])) {
1994 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
1996 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
1997 print_liste_field_titre($arrayfields[
't.task_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.task_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
1999 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2000 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2003 if (!empty($arrayfields[
'value'][
'checked'])) {
2004 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2006 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2007 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2014 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
2015 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
2016 print $hookmanager->resPrint;
2017 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2020 $tasktmp =
new Task($db);
2021 $tmpinvoice =
new Facture($db);
2027 $totalarray = array(
'nbfield'=>0);
2028 foreach ($tasks as $task_time) {
2033 $date1 = $db->jdate($task_time->task_date);
2034 $date2 = $db->jdate($task_time->task_datehour);
2036 print
'<tr class="oddeven">';
2039 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
2040 print
'<td class="nowrap">';
2041 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2042 if (empty($task_time->task_date_withhour)) {
2043 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2045 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2048 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
2052 $totalarray[
'nbfield']++;
2057 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2058 print
'<td class="nowrap">';
2059 if ($task_time->fk_soc > 0) {
2060 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2061 $tmpsociete =
new Societe($db);
2062 $tmpsociete->fetch($task_time->fk_soc);
2063 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2065 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2067 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2071 $totalarray[
'nbfield']++;
2076 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2077 print
'<td class="nowrap">';
2078 if ($task_time->fk_soc > 0) {
2079 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2080 $tmpsociete =
new Societe($db);
2081 $tmpsociete->fetch($task_time->fk_soc);
2082 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2084 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2086 print $tmpsociete->name_alias;
2090 $totalarray[
'nbfield']++;
2095 if (!empty($allprojectforuser)) {
2096 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2097 print
'<td class="nowraponall">';
2098 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2099 $tmpproject =
new Project($db);
2100 $tmpproject->fetch($task_time->fk_projet);
2101 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2103 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2105 print $tmpproject->getNomUrl(1);
2108 $totalarray[
'nbfield']++;
2111 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2112 print
'<td class="nowraponall">';
2113 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2114 $tmpproject =
new Project($db);
2115 $tmpproject->fetch($task_time->fk_projet);
2116 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2118 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2120 print $tmpproject->title;
2123 $totalarray[
'nbfield']++;
2129 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
2130 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2131 print
'<td class="nowrap">';
2132 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2133 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_task,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
2135 $tasktmp->id = $task_time->fk_task;
2136 $tasktmp->ref = $task_time->ref;
2137 $tasktmp->label = $task_time->label;
2138 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2142 $totalarray[
'nbfield']++;
2145 } elseif ($action !==
'createtime') {
2146 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
2150 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
2151 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2152 print
'<td class="nowrap tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2156 $totalarray[
'nbfield']++;
2162 if (!empty($arrayfields[
'author'][
'checked'])) {
2163 print
'<td class="tdoverflowmax100">';
2164 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2165 if (empty($object->id)) {
2166 $object->fetch($id);
2168 $contactsoftask = $object->getListContactId(
'internal');
2169 if (!in_array($task_time->fk_user, $contactsoftask)) {
2170 $contactsoftask[] = $task_time->fk_user;
2172 if (count($contactsoftask) > 0) {
2173 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2174 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
2176 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2179 $userstatic->id = $task_time->fk_user;
2180 $userstatic->lastname = $task_time->lastname;
2181 $userstatic->firstname = $task_time->firstname;
2182 $userstatic->photo = $task_time->photo;
2183 $userstatic->statut = $task_time->user_status;
2184 print $userstatic->getNomUrl(-1);
2188 $totalarray[
'nbfield']++;
2193 if (!empty($arrayfields[
't.note'][
'checked'])) {
2194 print
'<td class="small">';
2195 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2196 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2202 $totalarray[
'nbfield']++;
2204 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2205 print
'<input type="hidden" name="timespent_note_line" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2209 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2210 print
'<td class="right nowraponall">';
2211 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2212 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
2213 print
$form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
2219 $totalarray[
'nbfield']++;
2222 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.task_duration';
2224 if (empty($totalarray[
'val'][
't.task_duration'])) {
2225 $totalarray[
'val'][
't.task_duration'] = $task_time->task_duration;
2227 $totalarray[
'val'][
't.task_duration'] += $task_time->task_duration;
2230 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2232 if (empty($totalarray[
'totalduration'])) {
2233 $totalarray[
'totalduration'] = $task_time->task_duration;
2235 $totalarray[
'totalduration'] += $task_time->task_duration;
2240 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2241 print
'<td class="nowraponall">';
2242 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2243 $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
2244 } elseif (!empty($task_time->fk_product)) {
2246 $resultFetch = $product->fetch($task_time->fk_product);
2247 if ($resultFetch < 0) {
2250 print $product->getNomUrl(1);
2257 if (!empty($arrayfields[
'value'][
'checked'])) {
2258 $langs->load(
"salaries");
2259 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
2261 print
'<td class="nowraponall right">';
2262 print
'<span class="amount" title="'.$langs->trans(
"THM").
': '.
price($task_time->thm).
'">';
2263 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2267 $totalarray[
'nbfield']++;
2270 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2272 if (empty($totalarray[
'val'][
'value'])) {
2273 $totalarray[
'val'][
'value'] = $value;
2275 $totalarray[
'val'][
'value'] += $value;
2278 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2280 if (empty($totalarray[
'totalvalue'])) {
2281 $totalarray[
'totalvalue'] = $value;
2283 $totalarray[
'totalvalue'] += $value;
2288 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2289 print
'<td class="center">';
2290 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
2291 if ($projectstatic->usage_bill_time) {
2292 if ($task_time->invoice_id) {
2293 $result = $tmpinvoice->fetch($task_time->invoice_id);
2295 print $tmpinvoice->getNomUrl(1);
2298 print $langs->trans(
"No");
2301 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
2306 $totalarray[
'nbfield']++;
2316 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'i'=>$i,
'totalarray'=>&$totalarray);
2317 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2318 print $hookmanager->resPrint;
2321 print
'<td class="center nowraponall">';
2322 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2323 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
2324 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2326 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2327 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2328 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2331 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=splitline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2332 print
img_split(
'',
'class="pictofixedwidth"');
2336 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' :
'').
'">';
2337 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2340 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' :
'').
'">';
2341 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2344 if ($massactionbutton || $massaction) {
2346 if (in_array($task_time->rowid, $arrayofselected)) {
2350 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2356 $totalarray[
'nbfield']++;
2364 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2365 print
'<tr class="oddeven">';
2368 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
2369 print
'<td class="nowrap">';
2370 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2371 if (empty($task_time->task_date_withhour)) {
2372 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2374 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2377 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
2383 if (!empty($allprojectforuser)) {
2384 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2385 print
'<td class="nowrap">';
2391 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
2392 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2393 print
'<td class="nowrap">';
2394 $tasktmp->id = $task_time->fk_task;
2395 $tasktmp->ref = $task_time->ref;
2396 $tasktmp->label = $task_time->label;
2397 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2403 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
2404 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2405 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2412 if (!empty($arrayfields[
'author'][
'checked'])) {
2414 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2415 if (empty($object->id)) {
2416 $object->fetch($id);
2418 $contactsoftask = $object->getListContactId(
'internal');
2419 if (!in_array($task_time->fk_user, $contactsoftask)) {
2420 $contactsoftask[] = $task_time->fk_user;
2422 if (count($contactsoftask) > 0) {
2423 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2424 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2426 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2429 $userstatic->id = $task_time->fk_user;
2430 $userstatic->lastname = $task_time->lastname;
2431 $userstatic->firstname = $task_time->firstname;
2432 $userstatic->photo = $task_time->photo;
2433 $userstatic->statut = $task_time->user_status;
2434 print $userstatic->getNomUrl(-1);
2440 if (!empty($arrayfields[
't.note'][
'checked'])) {
2441 print
'<td class="tdoverflowmax300">';
2442 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2443 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2448 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2449 print
'<input type="hidden" name="timespent_note_line" rows="'.ROWS_1.
'" value="'.
dol_escape_htmltag($task_time->note, 0, 1).
'">';
2453 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2454 print
'<td class="right">';
2455 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2456 print
'<input type="hidden" name="old_duration" value="'.$task_time->task_duration.
'">';
2457 print
$form->select_duration(
'new_duration', $task_time->task_duration, 0,
'text');
2465 if (!empty($arrayfields[
'value'][
'checked'])) {
2466 print
'<td class="right">';
2467 print
'<span class="amount">';
2468 $value =
price2num($task_time->thm * $task_time->task_duration / 3600,
'MT', 1);
2469 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2475 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2476 print
'<td class="right">';
2477 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2478 if (isset($task_time->total_ht)) {
2479 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2490 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split1');
2491 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2492 print $hookmanager->resPrint;
2495 print
'<td class="center nowraponall">';
2503 print
'<tr class="oddeven">';
2506 if (!empty($arrayfields[
't.task_date'][
'checked'])) {
2507 print
'<td class="nowrap">';
2508 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2509 if (empty($task_time->task_date_withhour)) {
2510 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2512 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2515 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ?
'dayhour' :
'day'));
2521 if (!empty($allprojectforuser)) {
2522 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2523 print
'<td class="nowrap">';
2529 if (!empty($arrayfields[
't.task_ref'][
'checked'])) {
2530 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2531 print
'<td class="nowrap">';
2532 $tasktmp->id = $task_time->fk_task;
2533 $tasktmp->ref = $task_time->ref;
2534 $tasktmp->label = $task_time->label;
2535 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2541 if (!empty($arrayfields[
't.task_label'][
'checked'])) {
2542 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2543 print
'<td class="nowrap">';
2544 print $task_time->label;
2550 if (!empty($arrayfields[
'author'][
'checked'])) {
2552 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2553 if (empty($object->id)) {
2554 $object->fetch($id);
2556 $contactsoftask = $object->getListContactId(
'internal');
2557 if (!in_array($task_time->fk_user, $contactsoftask)) {
2558 $contactsoftask[] = $task_time->fk_user;
2560 if (count($contactsoftask) > 0) {
2561 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2562 print
$form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2564 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2567 $userstatic->id = $task_time->fk_user;
2568 $userstatic->lastname = $task_time->lastname;
2569 $userstatic->firstname = $task_time->firstname;
2570 $userstatic->photo = $task_time->photo;
2571 $userstatic->statut = $task_time->user_status;
2572 print $userstatic->getNomUrl(-1);
2578 if (!empty($arrayfields[
't.note'][
'checked'])) {
2579 print
'<td class="small tdoverflowmax300"">';
2580 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2581 print
'<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2586 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2587 print
'<input type="hidden" name="timespent_note_line_2" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2591 if (!empty($arrayfields[
't.task_duration'][
'checked'])) {
2592 print
'<td class="right">';
2593 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2594 print
'<input type="hidden" name="old_duration_2" value="0">';
2595 print
$form->select_duration(
'new_duration_2', 0, 0,
'text');
2603 if (!empty($arrayfields[
'value'][
'checked'])) {
2604 print
'<td class="right">';
2605 print
'<span class="amount">';
2607 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2613 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2614 print
'<td class="right">';
2615 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2616 if (isset($task_time->total_ht)) {
2617 print
'<span class="amount">';
2618 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2630 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split2');
2631 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2632 print $hookmanager->resPrint;
2635 print
'<td class="center nowraponall">';
2646 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2647 print
'<tr class="liste_total">';
2649 while ($i < $totalarray[
'nbfield']) {
2652 if ($num < $limit && empty($offset)) {
2653 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
2655 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
2657 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2658 print
'<td class="right">'.convertSecondToTime($totalarray[
'totalduration'],
'allhourmin').
'</td>';
2659 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2660 print
'<td class="right">'.price($totalarray[
'totalvalue']).
'</td>';
2669 if (!count($tasks)) {
2670 $totalnboffields = 1;
2671 foreach ($arrayfields as $value) {
2672 if ($value[
'checked']) {
2676 print
'<tr class="oddeven"><td colspan="'.$totalnboffields.
'">';
2677 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2681 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2682 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2683 print $hookmanager->resPrint;
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
Class to manage interventions.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_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.
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...
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 ...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_error($titlealt='default')
Show error logo.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
$formconfirm
if ($action == 'delbookkeepingyear') {
$nbtotalofrecords
Count total nb of records.
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.