32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formintervention.class.php';
43 $langsLoad=array(
'projects',
'bills',
'orders',
'companies');
45 $langsLoad[]=
'eventorganization';
48 $langs->loadLangs($langsLoad);
50 $action =
GETPOST(
'action',
'alpha');
51 $massaction =
GETPOST(
'massaction',
'alpha');
52 $confirm =
GETPOST(
'confirm',
'alpha');
53 $cancel =
GETPOST(
'cancel',
'alpha');
54 $toselect =
GETPOST(
'toselect',
'array');
55 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespentlist';
56 $backtopage =
GETPOST(
'backtopage',
'alpha');
57 $optioncss =
GETPOST(
'optioncss',
'alpha');
58 $mode =
GETPOST(
'mode',
'alpha');
61 $projectid =
GETPOST(
'projectid',
'int');
63 $withproject =
GETPOST(
'withproject',
'int');
64 $project_ref =
GETPOST(
'project_ref',
'alpha');
67 $search_day =
GETPOST(
'search_day',
'int');
68 $search_month =
GETPOST(
'search_month',
'int');
69 $search_year =
GETPOST(
'search_year',
'int');
70 $search_datehour =
'';
71 $search_datewithhour =
'';
72 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
73 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
74 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
75 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
76 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
77 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
78 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
79 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
80 $search_note =
GETPOST(
'search_note',
'alpha');
81 $search_duration =
GETPOST(
'search_duration',
'int');
82 $search_value =
GETPOST(
'search_value',
'int');
83 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
84 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
85 $search_user =
GETPOST(
'search_user',
'int');
86 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
87 $search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
88 $search_company =
GETPOST(
'$search_company',
'alpha');
89 $search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
90 $search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
91 $search_project_label =
GETPOST(
'$search_project_label',
'alpha');
92 $search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
93 $search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
94 $search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
95 $search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
97 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
98 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
99 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
101 if (empty($page) || $page == -1) {
104 $offset = $limit * $page;
105 $pageprev = $page - 1;
106 $pagenext = $page + 1;
108 $sortfield =
't.element_date,t.element_datehour,t.rowid';
111 $sortorder =
'DESC,DESC,DESC';
114 $childids = $user->getAllChildIds(1);
118 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
120 $object =
new Task($db);
122 $projectstatic =
new Project($db);
125 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
126 $extrafields->fetch_name_optionals_label($object->table_element);
129 if ($id > 0 || $ref) {
130 $object->fetch($id, $ref);
137 if (!$user->rights->projet->lire) {
141 if ($object->fk_project > 0) {
142 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
146 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
147 $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');
312 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
313 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
316 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
317 $result = $object->addTimeSpent($user);
326 $object->fetch($id, $ref);
328 $object->timespent_id =
GETPOST(
"lineid",
'int');
329 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
330 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
331 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
332 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
333 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
334 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
335 $object->timespent_withhour = 1;
339 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
340 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
341 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
342 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
345 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
346 $result = $object->updateTimeSpent($user);
361 if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
362 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
364 if (in_array($object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
365 $result = $object->delTimeSpent($user);
368 $langs->load(
"errors");
379 if (!empty($project_ref) && !empty($withproject)) {
380 if ($projectstatic->fetch(0, $project_ref) > 0) {
381 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
382 if (count($tasksarray) > 0) {
383 $id = $tasksarray[0]->id;
385 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
392 $projectidforalltimes = 0;
393 if (
GETPOST(
'projectid',
'int') > 0) {
394 $projectidforalltimes =
GETPOST(
'projectid',
'int');
396 $result = $projectstatic->fetch($projectidforalltimes);
397 if (!empty($projectstatic->socid)) {
398 $projectstatic->fetch_thirdparty();
400 $res = $projectstatic->fetch_optionals();
401 } elseif (
GETPOST(
'project_ref',
'alpha')) {
402 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
403 $projectidforalltimes = $projectstatic->id;
407 $result = $projectstatic->fetch($object->fk_project);
410 if ($id <= 0 && $projectidforalltimes == 0) {
411 $allprojectforuser = $user->id;
414 if ($action ==
'confirm_generateinvoice') {
415 if (!empty($projectstatic->socid)) {
416 $projectstatic->fetch_thirdparty();
419 if (!($projectstatic->thirdparty->id > 0)) {
420 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
422 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
423 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
424 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
426 $tmpinvoice =
new Facture($db);
427 $tmptimespent =
new Task($db);
428 $tmpproduct =
new Product($db);
429 $fuser =
new User($db);
432 $idprod =
GETPOST(
'productid',
'int');
433 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
434 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
436 $prodDurationHoursBase = 1.0;
437 $product_data_cache = array();
439 $tmpproduct->fetch($idprod);
445 $prodDurationHoursBase=$tmpproduct->getProductDurationHours();
446 if ($prodDurationHoursBase<0) {
448 $langs->load(
"errors");
452 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
454 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
455 $txtva = $dataforprice[
'tva_tx'];
456 $localtax1 = $dataforprice[
'localtax1'];
457 $localtax2 = $dataforprice[
'localtax2'];
459 $prodDurationHoursBase = 1;
467 $tmpinvoice->socid = $projectstatic->thirdparty->id;
468 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
469 $tmpinvoice->fk_project = $projectstatic->id;
470 $tmpinvoice->cond_reglement_id = $projectstatic->thirdparty->cond_reglement_id;
471 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
472 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
475 $tmpinvoice->fetch($invoiceToUse);
477 $result = $tmpinvoice->create($user);
485 if ($generateinvoicemode ==
'onelineperuser') {
486 $arrayoftasks = array();
487 foreach ($toselect as $key => $value) {
489 $object->fetchTimeSpent($value);
490 $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
491 $arrayoftasks[$object->timespent_fk_user][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
494 foreach ($arrayoftasks as $userid => $data) {
495 $fuser->fetch($userid);
496 $username = $fuser->getFullName($langs);
498 foreach ($data as $fk_product => $timespent_data) {
500 $qtyhour = $timespent_data[
'timespent'] / 3600;
501 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
509 $pu_ht = $fuser->thm;
514 if ($timespent_data[
'timespent']) {
515 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
520 $prodDurationHours = $prodDurationHoursBase;
524 $localtax1line = $localtax1;
525 $localtax2line = $localtax2;
528 if (!empty($fk_product) && $fk_product !== $idprod) {
529 if (!array_key_exists($fk_product, $product_data_cache)) {
530 $result = $tmpproduct->fetch($fk_product);
535 $prodDurationHours = $tmpproduct->getProductDurationHours();
536 if ($prodDurationHours < 0) {
538 $langs->load(
"errors");
542 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
544 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
545 $txtvaline = $dataforprice[
'tva_tx'];
546 $localtax1line = $dataforprice[
'localtax1'];
547 $localtax2line = $dataforprice[
'localtax2'];
549 $product_data_cache[$fk_product] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
551 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
552 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
553 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
554 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
555 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
557 $idprodline=$fk_product;
561 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username).
' : '.$qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
568 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
569 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
570 $result = $db->query(
$sql);
578 } elseif ($generateinvoicemode ==
'onelineperperiod') {
579 $arrayoftasks = array();
581 $withdetail=
GETPOST(
'detail_time_duration',
'alpha');
582 foreach ($toselect as $key => $value) {
584 $object->fetchTimeSpent($value);
586 $ftask =
new Task($db);
587 $ftask->fetch($object->id);
589 $fuser->fetch($object->timespent_fk_user);
590 $username = $fuser->getFullName($langs);
592 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
593 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
594 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref.
' - '.$ftask->label.
' - '.$username.($object->timespent_note ?
' - '.$object->timespent_note :
'');
595 if (!empty($withdetail)) {
596 if (
isModEnabled(
'fckeditor') && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
597 $arrayoftasks[$object->timespent_id][
'note'] .=
"<br/>";
599 $arrayoftasks[$object->timespent_id][
'note'] .=
"\n";
602 if (!empty($object->timespent_withhour)) {
603 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour);
605 $arrayoftasks[$object->timespent_id][
'note'] .= $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date);
607 $arrayoftasks[$object->timespent_id][
'note'] .=
' - '.$langs->trans(
"Duration").
': '.
convertSecondToTime($object->timespent_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
609 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
610 $arrayoftasks[$object->timespent_id][
'fk_product'] = $object->timespent_fk_product;
613 foreach ($arrayoftasks as $timespent_id => $value) {
614 $userid = $value[
'user'];
618 $qtyhour = $value[
'timespent'] / 3600;
622 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
626 $prodDurationHours = $prodDurationHoursBase;
630 $localtax1line = $localtax1;
631 $localtax2line = $localtax2;
633 if (!empty($value[
'fk_product']) && $value[
'fk_product']!==$idprod) {
634 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
635 $result = $tmpproduct->fetch($value[
'fk_product']);
640 $prodDurationHours = $tmpproduct->getProductDurationHours();
641 if ($prodDurationHours < 0) {
643 $langs->load(
"errors");
647 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
649 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
650 $txtvaline = $dataforprice[
'tva_tx'];
651 $localtax1line = $dataforprice[
'localtax1'];
652 $localtax2line = $dataforprice[
'localtax2'];
654 $product_data_cache[$value[
'fk_product']] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
656 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
657 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
658 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
659 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
660 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
662 $idprodline=$value[
'fk_product'];
664 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
672 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
673 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
674 $result = $db->query(
$sql);
681 } elseif ($generateinvoicemode ==
'onelinepertask') {
682 $arrayoftasks = array();
683 foreach ($toselect as $key => $value) {
685 $object->fetchTimeSpent($value);
687 $arrayoftasks[$object->id][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
688 $arrayoftasks[$object->id][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
691 foreach ($arrayoftasks as $task_id => $data) {
692 $ftask =
new Task($db);
693 $ftask->fetch($task_id);
695 foreach ($data as $fk_product=>$timespent_data) {
696 $qtyhour = $timespent_data[
'timespent'] / 3600;
697 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
700 $prodDurationHours = $prodDurationHoursBase;
704 $localtax1line = $localtax1;
705 $localtax2line = $localtax2;
707 if (!empty($fk_product) && $fk_product!==$idprod) {
708 if (!array_key_exists($fk_product, $product_data_cache)) {
709 $result = $tmpproduct->fetch($fk_product);
714 $prodDurationHours = $tmpproduct->getProductDurationHours();
715 if ($prodDurationHours < 0) {
717 $langs->load(
"errors");
721 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
723 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
724 $txtvaline = $dataforprice[
'tva_tx'];
725 $localtax1line = $dataforprice[
'localtax1'];
726 $localtax2line = $dataforprice[
'localtax2'];
728 $product_data_cache[$fk_product] = array(
'duration'=>$prodDurationHours,
'dataforprice'=>$dataforprice);
730 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
731 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
732 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
733 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
734 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
736 $idprodline=$fk_product;
740 if ($idprodline > 0) {
742 $pu_ht_for_task = $pu_htline;
744 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
745 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
747 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
752 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
753 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
755 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
761 $lineName = $ftask->ref .
' - ' . $ftask->label;
762 $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);
771 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
772 $sql .=
' WHERE rowid IN (' . $db->sanitize(join(
',', $toselect)) .
')';
773 $result = $db->query(
$sql);
786 $urltoinvoice = $tmpinvoice->getNomUrl(0);
787 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
788 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
800 if ($action ==
'confirm_generateinter') {
801 $langs->load(
'interventions');
803 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
805 if (!($projectstatic->thirdparty->id > 0)) {
806 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
808 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
809 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
810 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
813 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
815 $tmptimespent =
new Task($db);
816 $fuser =
new User($db);
819 $interToUse =
GETPOST(
'interid',
'int');
822 $tmpinter->socid = $projectstatic->thirdparty->id;
823 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
824 $tmpinter->fk_project = $projectstatic->id;
825 $tmpinter->description = $projectstatic->title . ( !empty($projectstatic->description) ?
'-' . $projectstatic->label :
'' );
828 $tmpinter->fetch($interToUse);
830 $result = $tmpinter->create($user);
838 $arrayoftasks = array();
839 foreach ($toselect as $key => $value) {
841 $object->fetchTimeSpent($value);
843 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
844 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
845 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
846 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
847 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
850 foreach ($arrayoftasks as $timespent_id => $value) {
851 $ftask =
new Task($db);
852 $ftask->fetch($value[
'id']);
854 $qtyhour = $value[
'timespent'] / 3600;
855 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
858 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . ( !empty($value[
'note']) ?
' - ' . $value[
'note'] :
'' ), $value[
'date'], $value[
'timespent']);
863 $urltointer = $tmpinter->getNomUrl(0);
864 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
865 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
885 $userstatic =
new User($db);
887 $arrayofselected = is_array($toselect) ? $toselect : array();
889 $title = $object->ref .
' - ' . $langs->trans(
"TimeSpent");
890 if (!empty($withproject)) {
891 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
897 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
901 if ($projectidforalltimes > 0) {
902 $result = $projectstatic->fetch($projectidforalltimes);
903 if (!empty($projectstatic->socid)) {
904 $projectstatic->fetch_thirdparty();
906 $res = $projectstatic->fetch_optionals();
907 } elseif ($object->fetch($id, $ref) >= 0) {
908 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
909 $object->fetchComments();
911 $result = $projectstatic->fetch($object->fk_project);
912 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
913 $projectstatic->fetchComments();
915 if (!empty($projectstatic->socid)) {
916 $projectstatic->fetch_thirdparty();
918 $res = $projectstatic->fetch_optionals();
920 $object->project = clone $projectstatic;
923 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
924 $linktocreatetime =
'';
926 if ($projectstatic->id > 0) {
929 if (empty($id) || $tab ==
'timespent') {
936 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
938 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
940 $param .=
'&search_user='.((int) $search_user);
943 $param .=
'&search_month='.((int) $search_month);
946 $param .=
'&search_year='.((int) $search_year);
951 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
953 $morehtmlref =
'<div class="refidno">';
955 $morehtmlref .= $projectstatic->title;
957 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
958 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
960 $morehtmlref .=
'</div>';
963 if (empty($user->rights->projet->all->lire)) {
964 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
965 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
968 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
970 print
'<div class="fichecenter">';
971 print
'<div class="fichehalfleft">';
972 print
'<div class="underbanner clearboth"></div>';
974 print
'<table class="border tableforfield centpercent">';
977 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
978 print
'<tr><td class="tdtop">';
979 print $langs->trans(
"Usage");
982 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
983 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
984 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
985 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
988 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
989 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
990 $htmltext = $langs->trans(
"ProjectFollowTasks");
991 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
994 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
995 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"' :
'')).
'"> ';
996 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
997 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1001 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"' :
'')).
'"> ';
1002 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1003 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1009 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1010 if ($projectstatic->public) {
1011 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1012 print $langs->trans(
'SharedProject');
1014 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1015 print $langs->trans(
'PrivateProject');
1020 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1021 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1022 print
'<span class="amount">'.price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
1027 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1029 print ($start ? $start :
'?');
1032 print ($end ? $end :
'?');
1033 if ($projectstatic->hasDelay()) {
1040 $savobject = $object;
1041 $object = $projectstatic;
1042 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1043 $object = $savobject;
1048 print
'<div class="fichehalfright">';
1049 print
'<div class="underbanner clearboth"></div>';
1051 print
'<table class="border tableforfield centpercent">';
1054 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1060 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1061 print
$form->showCategories($projectstatic->id,
'project', 1);
1070 print
'<div class="clearboth"></div>';
1080 $linktocreatetimeBtnStatus = 0;
1081 $linktocreatetimeUrl =
'';
1082 $linktocreatetimeHelpText =
'';
1083 if (!empty($user->rights->projet->time)) {
1084 if ($projectstatic->public || $userRead > 0) {
1085 $linktocreatetimeBtnStatus = 1;
1087 if (!empty($projectidforalltimes)) {
1089 $backtourl = $_SERVER[
'PHP_SELF'].
'?projectid='.$projectstatic->id.($withproject ?
'&withproject=1' :
'');
1090 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').
'&projectid='.$projectstatic->id.
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
1093 $backtourl = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($withproject ?
'&withproject=1' :
'');
1094 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'].
'?'.($withproject ?
'withproject=1' :
'').($object->id > 0 ?
'&id='.$object->id :
'&projectid='.$projectstatic->id).
'&action=createtime&token='.
newToken().$param.
'&backtopage='.urlencode($backtourl);
1097 $linktocreatetimeBtnStatus = -2;
1098 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1101 $linktocreatetimeBtnStatus = -2;
1102 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1105 $paramsbutton = array(
'morecss'=>
'reposition');
1106 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1109 $massactionbutton =
'';
1110 $arrayofmassactions = array();
1112 if ($projectstatic->id > 0) {
1114 if ($projectstatic->usage_bill_time) {
1115 $arrayofmassactions = array(
1116 'generateinvoice'=>$langs->trans(
"GenerateBill"),
1120 if (
isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'creer')) {
1121 $langs->load(
"interventions");
1122 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1126 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1127 $arrayofmassactions = array();
1129 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1134 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1136 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1138 if ($action ==
'deleteline') {
1139 $urlafterconfirm = $_SERVER[
"PHP_SELF"].
"?".($object->id > 0 ?
"id=".$object->id :
'projectid='.$projectstatic->id).
'&lineid='.
GETPOST(
"lineid",
'int').($withproject ?
'&withproject=1' :
'');
1140 print
$form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1143 $param = ($withproject ?
'&withproject=1' :
'');
1144 $param .= ($param ?
'&' :
'').
'id='.$object->id;
1145 $linkback = $withproject ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
1147 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1148 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1149 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
1151 $object->next_prev_filter =
" fk_projet = ".((int) $projectstatic->id);
1157 if (empty($withproject)) {
1158 $morehtmlref .=
'<div class="refidno">';
1159 $morehtmlref .= $langs->trans(
"Project").
': ';
1160 $morehtmlref .= $projectstatic->getNomUrl(1);
1161 $morehtmlref .=
'<br>';
1164 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
1165 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1166 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1168 $morehtmlref .=
'</div>';
1171 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1173 print
'<div class="fichecenter">';
1174 print
'<div class="fichehalfleft">';
1176 print
'<div class="underbanner clearboth"></div>';
1177 print
'<table class="border centpercent tableforfield">';
1180 print
'<tr><td>'.$langs->trans(
"ChildOfTask").
'</td><td>';
1181 if ($object->fk_task_parent > 0) {
1182 $tasktmp =
new Task($db);
1183 $tasktmp->fetch($object->fk_task_parent);
1184 print $tasktmp->getNomUrl(1);
1189 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"Deadline").
'</td><td>';
1191 print ($start ? $start :
'?');
1194 print ($end ? $end :
'?');
1195 if ($object->hasDelay()) {
1201 print
'<tr><td>'.$langs->trans(
"PlannedWorkload").
'</td><td>';
1202 if ($object->planned_workload) {
1210 print
'<div class="fichehalfright">';
1212 print
'<div class="underbanner clearboth"></div>';
1213 print
'<table class="border tableforfield centpercent">';
1216 print
'<tr><td class="titlefield">'.$langs->trans(
"ProgressDeclared").
'</td><td>';
1217 print $object->progress !=
'' ? $object->progress.
' %' :
'';
1221 print
'<tr><td>'.$langs->trans(
"ProgressCalculated").
'</td><td>';
1222 if ($object->planned_workload) {
1223 $tmparray = $object->getSummaryOfTimeSpent();
1224 if ($tmparray[
'total_duration'] > 0) {
1225 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2).
' %';
1230 print
'<span class="opacitymedium">'.$langs->trans(
"WorkloadNotDefined").
'</span>';
1241 print
'<div class="clearboth"></div>';
1247 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1249 $hookmanager->initHooks(array(
'tasktimelist'));
1253 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1255 $urlafterconfirm = $_SERVER[
"PHP_SELF"].
"?".($projectstatic->id > 0 ?
'projectid='.$projectstatic->id : ($object->id > 0 ?
"id=".$object->id :
'')).
'&lineid='.
GETPOST(
'lineid',
'int').($withproject ?
'&withproject=1' :
'').
"&contextpage=".urlencode($contextpage);
1256 $formconfirm =
$form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1260 $parameters = array(
'formConfirm' =>
$formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1261 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1262 if (empty($reshook)) {
1264 } elseif ($reshook > 0) {
1272 $arrayfields = array();
1273 $arrayfields[
't.element_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1274 $arrayfields[
'p.fk_soc'] = array(
'label'=>$langs->trans(
"ThirdParty"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1',
'checked'=>1);
1275 $arrayfields[
's.name_alias'] = array(
'label'=>$langs->trans(
"AliasNameShort"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1');
1276 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1277 if (! empty($allprojectforuser)) {
1278 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1279 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1281 $arrayfields[
't.element_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1282 $arrayfields[
't.element_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1284 $arrayfields[
'author'] = array(
'label'=>$langs->trans(
"By"),
'checked'=>1);
1285 $arrayfields[
't.note'] = array(
'label'=>$langs->trans(
"Note"),
'checked'=>1);
1286 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1287 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1289 $arrayfields[
't.element_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1290 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
1291 $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));
1293 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
1298 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1299 $param .=
'&contextpage='.urlencode($contextpage);
1301 if ($limit > 0 && $limit != $conf->liste_limit) {
1302 $param .=
'&limit='.((int) $limit);
1304 if ($search_month > 0) {
1305 $param .=
'&search_month='.urlencode($search_month);
1307 if ($search_year > 0) {
1308 $param .=
'&search_year='.urlencode($search_year);
1310 if (!empty($search_user)) {
1311 $param .=
'&search_user='.urlencode($search_user);
1313 if ($search_task_ref !=
'') {
1314 $param .=
'&search_task_ref='.urlencode($search_task_ref);
1316 if ($search_company !=
'') {
1317 $param .=
'&$search_company='.urlencode($search_company);
1319 if ($search_company_alias !=
'') {
1320 $param .=
'&$search_company_alias='.urlencode($search_company_alias);
1322 if ($search_project_ref !=
'') {
1323 $param .=
'&$search_project_ref='.urlencode($search_project_ref);
1325 if ($search_project_label !=
'') {
1326 $param .=
'&$search_project_label='.urlencode($search_project_label);
1328 if ($search_task_label !=
'') {
1329 $param .=
'&search_task_label='.urlencode($search_task_label);
1331 if ($search_note !=
'') {
1332 $param .=
'&search_note='.urlencode($search_note);
1334 if ($search_duration !=
'') {
1335 $param .=
'&search_field2='.urlencode($search_duration);
1337 if ($optioncss !=
'') {
1338 $param .=
'&optioncss='.urlencode($optioncss);
1340 if ($search_date_startday) {
1341 $param .=
'&search_date_startday='.urlencode($search_date_startday);
1343 if ($search_date_startmonth) {
1344 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
1346 if ($search_date_startyear) {
1347 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
1349 if ($search_date_endday) {
1350 $param .=
'&search_date_endday='.urlencode($search_date_endday);
1352 if ($search_date_endmonth) {
1353 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
1355 if ($search_date_endyear) {
1356 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
1358 if ($search_timespent_starthour) {
1359 $param .=
'&search_timespent_duration_starthour='.urlencode($search_timespent_starthour);
1361 if ($search_timespent_startmin) {
1362 $param .=
'&search_timespent_duration_startmin='.urlencode($search_timespent_startmin);
1364 if ($search_timespent_endhour) {
1365 $param .=
'&search_timespent_duration_endhour='.urlencode($search_timespent_endhour);
1367 if ($search_timespent_endmin) {
1368 $param .=
'&search_timespent_duration_endmin='.urlencode($search_timespent_endmin);
1376 $param .=
'&id='.urlencode($id);
1379 $param .=
'&projectid='.urlencode($projectid);
1382 $param .=
'&withproject='.urlencode($withproject);
1385 $parameters = array();
1386 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1387 $param .= $hookmanager->resPrint;
1389 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1390 if ($optioncss !=
'') {
1391 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1393 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1394 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1395 if ($action ==
'editline') {
1396 print
'<input type="hidden" name="action" value="updateline">';
1397 } elseif ($action ==
'splitline') {
1398 print
'<input type="hidden" name="action" value="updatesplitline">';
1399 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1400 print
'<input type="hidden" name="action" value="addtimespent">';
1401 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1402 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1403 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1404 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1406 print
'<input type="hidden" name="action" value="list">';
1408 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1409 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1411 print
'<input type="hidden" name="id" value="'.$id.
'">';
1412 print
'<input type="hidden" name="projectid" value="'.$projectidforalltimes.
'">';
1413 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
1414 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
1415 print
'<input type="hidden" name="page_y" value="">';
1418 if ($massaction ==
'generateinvoice') {
1419 if ($projectstatic->thirdparty->id > 0) {
1420 print
'<table class="noborder centerpercent">';
1422 print
'<td class="titlefield">';
1423 print $langs->trans(
'DateInvoice');
1426 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1432 print $langs->trans(
'Mode');
1436 'onelineperuser'=>
'OneLinePerUser',
1437 'onelinepertask'=>
'OneLinePerTask',
1438 'onelineperperiod'=>
'OneLinePerTimeSpentLine',
1440 print
$form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1441 print
"\n".
'<script type="text/javascript">';
1443 $(document).ready(function () {
1444 setDetailVisibility();
1445 $("#generateinvoicemode").change(function() {
1446 setDetailVisibility();
1448 function setDetailVisibility() {
1449 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1450 if (generateinvoicemode=="onelineperperiod") {
1451 $("#detail_time_duration").show();
1453 $("#detail_time_duration").hide();
1458 print
'</script>'.
"\n";
1459 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>'.$langs->trans(
'AddDetailDateAndDuration').
'</span>';
1466 print $langs->trans(
'ServiceToUseOnLines');
1469 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1475 print
'<td class="titlefield">';
1476 print $langs->trans(
'InvoiceToUse');
1479 print
$form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1493 print
'<div class="center">';
1494 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'GenerateBill').
'"> ';
1495 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1499 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateInvoice").
'</div>';
1500 print
'<div class="center">';
1501 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1505 } elseif ($massaction ==
'generateinter') {
1507 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1509 if ($projectstatic->thirdparty->id > 0) {
1511 print
'<table class="noborder centpercent">';
1513 print
'<td class="titlefield">';
1514 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"').$langs->trans(
'InterToUse');
1518 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1523 print
'<div class="center">';
1524 print
'<input type="submit" class="button" id="createinter" name="createinter" value="'.$langs->trans(
'GenerateInter').
'"> ';
1525 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1529 print
'<div class="warning">'.$langs->trans(
"ThirdPartyRequiredToGenerateIntervention").
'</div>';
1530 print
'<div class="center">';
1531 print
'<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans(
'Cancel').
'">';
1538 $parameters = array(
1539 'toselect' => $toselect,
1540 'uploaddir' => isset($uploaddir) ? $uploaddir :
null
1543 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1547 print $hookmanager->resPrint;
1555 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1556 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1558 $sql =
"SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,";
1559 $sql .=
" t.fk_product,";
1560 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1561 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1562 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1563 $sql .=
" p.fk_soc,s.name_alias,";
1564 $sql .=
" t.invoice_line_id";
1566 $parameters = array();
1567 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1568 $sql .= $hookmanager->resPrint;
1569 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
1573 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1574 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1575 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1576 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1577 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1578 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1579 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1580 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1583 $parameters = array();
1584 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1585 $sql .= $hookmanager->resPrint;
1586 $sql .=
" WHERE elementtype='task' ";
1587 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1589 $sql .=
" AND t.fk_element =".((int) $object->id);
1590 } elseif (!empty($projectidforalltimes)) {
1592 $sql .=
" AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).
")";
1593 } elseif (!empty($allprojectforuser)) {
1595 if (empty($search_user)) {
1596 $search_user = $user->id;
1598 if ($search_user > 0)
$sql .=
" AND t.fk_user = ".((int) $search_user);
1604 if ($search_task_ref) {
1607 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1610 if ($search_company) {
1613 if ($search_company_alias) {
1617 if ($search_project_ref) {
1620 if ($search_project_label) {
1623 if ($search_task_label) {
1626 if ($search_user > 0) {
1629 if (!empty($search_product_ref)) {
1632 if ($search_valuebilled ==
'1') {
1633 $sql .=
' AND t.invoice_id > 0';
1635 if ($search_valuebilled ==
'0') {
1636 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1639 if ($search_date_start) {
1640 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1642 if ($search_date_end) {
1643 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1646 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1647 if ($search_timespent_starthour || $search_timespent_startmin) {
1648 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1649 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1650 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1653 if ($search_timespent_endhour || $search_timespent_endmin) {
1654 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1655 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1656 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1663 $parameters = array();
1664 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1665 $sql .= $hookmanager->resPrint;
1668 $nbtotalofrecords =
'';
1671 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
1672 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1673 $resql = $db->query($sqlforcount);
1675 $objforcount = $db->fetch_object($resql);
1676 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1681 if (($page * $limit) > $nbtotalofrecords) {
1689 $sql .= $db->order($sortfield, $sortorder);
1691 $sql .= $db->plimit($limit + 1, $offset);
1694 $resql = $db->query(
$sql);
1700 $num = $db->num_rows($resql);
1703 if (!empty($projectidforalltimes)) {
1704 print
'<!-- List of time spent for project -->'.
"\n";
1706 $title = $langs->trans(
"ListTaskTimeUserProject");
1708 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1710 print
'<!-- List of time spent -->'.
"\n";
1712 $title = $langs->trans(
"ListTaskTimeForTask");
1714 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1719 $row = $db->fetch_object($resql);
1731 if ($action ==
'createtime' && $user->rights->projet->time) {
1732 print
'<!-- table to add time spent -->'.
"\n";
1734 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
1737 print
'<div class="div-table-responsive-no-min">';
1738 print
'<table class="noborder nohover centpercent">';
1740 print
'<tr class="liste_titre">';
1741 print
'<td>'.$langs->trans(
"Date").
'</td>';
1742 if (!empty($allprojectforuser)) {
1743 print
'<td>'.$langs->trans(
"Project").
'</td>';
1746 print
'<td>'.$langs->trans(
"Task").
'</td>';
1748 print
'<td>'.$langs->trans(
"By").
'</td>';
1749 print
'<td>'.$langs->trans(
"Note").
'</td>';
1750 print
'<td>'.$langs->trans(
"NewTimeSpent").
'</td>';
1751 print
'<td>'.$langs->trans(
"ProgressDeclared").
'</td>';
1752 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1755 if (
isModEnabled(
"service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1756 print
'<td>'.$langs->trans(
"Product").
'</td>';
1760 $parameters = array(
'mode' =>
'create');
1761 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1762 print $hookmanager->resPrint;
1766 print
'<tr class="oddeven nohover">';
1769 print
'<td class="maxwidthonsmartphone">';
1771 print
$form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1774 if (!empty($allprojectforuser)) {
1783 print
'<td class="maxwidthonsmartphone">';
1784 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1789 print
'<td class="maxwidthonsmartphone nowraponall">';
1790 $contactsofproject = $projectstatic->getListContactId(
'internal');
1791 if (count($contactsofproject) > 0) {
1792 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1793 if (in_array($user->id, $contactsofproject)) {
1794 $userid = $user->id;
1796 $userid = $contactsofproject[0];
1799 if ($projectstatic->public) {
1800 $contactsofproject = array();
1802 print
$form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'maxwidth200');
1805 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).
' '.$langs->trans(
'FirstAddRessourceToAllocateTime');
1812 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.
'">'.(
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'').
'</textarea>';
1816 print
'<td class="nowraponall">';
1817 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1819 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1821 print
$form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1825 print
'<td class="nowrap">';
1826 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1830 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1834 if (
isModEnabled(
"service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1835 print
'<td class="nowraponall">';
1837 print
$form->select_produits(
'',
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'',
null, 1);
1843 $parameters = array(
'mode' =>
'create');
1844 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1845 print $hookmanager->resPrint;
1847 print
'<td class="center">';
1848 $form->buttonsSaveCancel();
1849 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1850 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1859 $moreforfilter =
'';
1861 $parameters = array();
1862 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1863 if (empty($reshook)) {
1864 $moreforfilter .= $hookmanager->resPrint;
1866 $moreforfilter = $hookmanager->resPrint;
1869 if (!empty($moreforfilter)) {
1870 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1871 print $moreforfilter;
1875 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1876 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1877 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
1879 print
'<div class="div-table-responsive">';
1880 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1884 print
'<tr class="liste_titre_filter">';
1887 print
'<td class="liste_titre center">';
1888 $searchpicto =
$form->showFilterButtons(
'left');
1893 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1894 print
'<td class="liste_titre left">';
1895 print
'<div class="nowrap">';
1896 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1898 print
'<div class="nowrap">';
1899 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1904 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1905 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="'.dol_escape_htmltag($search_company).
'"></td>';
1909 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1910 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1913 if (!empty($allprojectforuser)) {
1914 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1915 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1917 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1918 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="'.dol_escape_htmltag($search_project_label).
'"></td>';
1922 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1923 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1924 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1926 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1927 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1931 if (!empty($arrayfields[
'author'][
'checked'])) {
1932 print
'<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1),
'search_user', 1,
null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth150').
'</td>';
1935 if (!empty($arrayfields[
't.note'][
'checked'])) {
1936 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).
'"></td>';
1939 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1941 print
'<td class="liste_titre right">';
1943 $durationtouse_start =
'';
1944 if ($search_timespent_starthour || $search_timespent_startmin) {
1945 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1947 print
'<div class="nowraponall">'.$langs->trans(
'from').
' ';
1948 print
$form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1951 $durationtouse_end =
'';
1952 if ($search_timespent_endhour || $search_timespent_endmin) {
1953 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1955 print
'<div class="nowraponall">'.$langs->trans(
'at').
' ';
1956 print
$form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1962 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1963 print
'<td class="liste_titre right"></td>';
1966 if (!empty($arrayfields[
'value'][
'checked'])) {
1967 print
'<td class="liste_titre"></td>';
1970 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1971 print
'<td class="liste_titre center">'.$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1).
'</td>';
1979 $parameters = array(
'arrayfields'=>$arrayfields);
1980 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1981 print $hookmanager->resPrint;
1984 print
'<td class="liste_titre center">';
1985 $searchpicto =
$form->showFilterButtons();
1991 $totalarray = array();
1992 $totalarray[
'nbfield'] = 0;
1996 print
'<tr class="liste_titre">';
1998 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1999 $totalarray[
'nbfield']++;
2001 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2002 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2003 $totalarray[
'nbfield']++;
2005 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2006 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2007 $totalarray[
'nbfield']++;
2009 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2010 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2011 $totalarray[
'nbfield']++;
2013 if (!empty($allprojectforuser)) {
2014 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2016 $totalarray[
'nbfield']++;
2018 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2019 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2020 $totalarray[
'nbfield']++;
2023 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2024 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2025 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2026 $totalarray[
'nbfield']++;
2028 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2029 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2030 $totalarray[
'nbfield']++;
2033 if (!empty($arrayfields[
'author'][
'checked'])) {
2034 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2035 $totalarray[
'nbfield']++;
2037 if (!empty($arrayfields[
't.note'][
'checked'])) {
2038 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2039 $totalarray[
'nbfield']++;
2041 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2042 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2043 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2046 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2047 $totalarray[
'nbfield']++;
2050 if (!empty($arrayfields[
'value'][
'checked'])) {
2051 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2052 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2055 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2056 $totalarray[
'nbfield']++;
2063 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
2064 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
2065 print $hookmanager->resPrint;
2067 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2068 $totalarray[
'nbfield']++;
2072 $tasktmp =
new Task($db);
2073 $tmpinvoice =
new Facture($db);
2079 $savnbfield = $totalarray[
'nbfield'];
2080 $totalarray = array();
2081 $totalarray[
'nbfield'] = 0;
2083 foreach ($tasks as $task_time) {
2088 $date1 = $db->jdate($task_time->element_date);
2089 $date2 = $db->jdate($task_time->element_datehour);
2093 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
2097 print
'<td class="center nowraponall">';
2098 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2099 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
2100 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2102 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2103 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2104 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2107 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=splitline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2108 print
img_split(
'',
'class="pictofixedwidth"');
2112 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_element.
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2113 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2116 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_element.
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2117 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2120 if ($massactionbutton || $massaction) {
2122 if (in_array($task_time->rowid, $arrayofselected)) {
2126 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2132 $totalarray[
'nbfield']++;
2136 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2137 print
'<td class="nowrap">';
2138 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2139 if (empty($task_time->element_date_withhour)) {
2140 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2142 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2145 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2149 $totalarray[
'nbfield']++;
2154 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2155 print
'<td class="tdoverflowmax125">';
2156 if ($task_time->fk_soc > 0) {
2157 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2158 $tmpsociete =
new Societe($db);
2159 $tmpsociete->fetch($task_time->fk_soc);
2160 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2162 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2164 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2168 $totalarray[
'nbfield']++;
2173 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2174 if ($task_time->fk_soc > 0) {
2175 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2176 $tmpsociete =
new Societe($db);
2177 $tmpsociete->fetch($task_time->fk_soc);
2178 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2180 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2182 $valtoshow = $tmpsociete->name_alias;
2184 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2188 $totalarray[
'nbfield']++;
2193 if (!empty($allprojectforuser)) {
2194 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2195 print
'<td class="nowraponall">';
2196 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2197 $tmpproject =
new Project($db);
2198 $tmpproject->fetch($task_time->fk_projet);
2199 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2201 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2203 print $tmpproject->getNomUrl(1);
2206 $totalarray[
'nbfield']++;
2209 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2210 print
'<td class="nowraponall">';
2211 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2212 $tmpproject =
new Project($db);
2213 $tmpproject->fetch($task_time->fk_projet);
2214 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2216 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2218 print $tmpproject->title;
2221 $totalarray[
'nbfield']++;
2227 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2228 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2229 print
'<td class="nowrap">';
2230 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2231 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
2233 $tasktmp->id = $task_time->fk_element;
2234 $tasktmp->ref = $task_time->ref;
2235 $tasktmp->label = $task_time->label;
2236 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2240 $totalarray[
'nbfield']++;
2243 } elseif ($action !==
'createtime') {
2244 print
'<input type="hidden" name="taskid" value="'.$id.
'">';
2248 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2249 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2250 print
'<td class="nowrap tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2254 $totalarray[
'nbfield']++;
2260 if (!empty($arrayfields[
'author'][
'checked'])) {
2261 print
'<td class="tdoverflowmax100">';
2262 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2263 if (empty($object->id)) {
2264 $object->fetch($id);
2266 $contactsoftask = $object->getListContactId(
'internal');
2267 if (!in_array($task_time->fk_user, $contactsoftask)) {
2268 $contactsoftask[] = $task_time->fk_user;
2270 if (count($contactsoftask) > 0) {
2271 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2272 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
2274 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2277 $userstatic->id = $task_time->fk_user;
2278 $userstatic->lastname = $task_time->lastname;
2279 $userstatic->firstname = $task_time->firstname;
2280 $userstatic->photo = $task_time->photo;
2281 $userstatic->statut = $task_time->user_status;
2282 print $userstatic->getNomUrl(-1);
2286 $totalarray[
'nbfield']++;
2291 if (!empty($arrayfields[
't.note'][
'checked'])) {
2292 print
'<td class="small">';
2293 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2294 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2300 $totalarray[
'nbfield']++;
2302 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2303 print
'<input type="hidden" name="timespent_note_line" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2307 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2308 print
'<td class="right nowraponall">';
2309 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2310 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2311 print
$form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2317 $totalarray[
'nbfield']++;
2320 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2322 if (empty($totalarray[
'val'][
't.element_duration'])) {
2323 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2325 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2328 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2330 if (empty($totalarray[
'totalduration'])) {
2331 $totalarray[
'totalduration'] = $task_time->element_duration;
2333 $totalarray[
'totalduration'] += $task_time->element_duration;
2338 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2339 print
'<td class="nowraponall tdoverflowmax125">';
2340 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2341 $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');
2342 } elseif (!empty($task_time->fk_product)) {
2344 $resultFetch = $product->fetch($task_time->fk_product);
2345 if ($resultFetch < 0) {
2348 print $product->getNomUrl(1);
2353 $totalarray[
'nbfield']++;
2358 if (!empty($arrayfields[
'value'][
'checked'])) {
2359 $langs->load(
"salaries");
2360 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2362 print
'<td class="nowraponall right">';
2363 print
'<span class="amount" title="'.$langs->trans(
"THM").
': '.
price($task_time->thm).
'">';
2364 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2368 $totalarray[
'nbfield']++;
2371 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2373 if (empty($totalarray[
'val'][
'value'])) {
2374 $totalarray[
'val'][
'value'] = $value;
2376 $totalarray[
'val'][
'value'] += $value;
2379 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2381 if (empty($totalarray[
'totalvalue'])) {
2382 $totalarray[
'totalvalue'] = $value;
2384 $totalarray[
'totalvalue'] += $value;
2389 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2390 print
'<td class="center">';
2391 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
2392 if ($projectstatic->usage_bill_time) {
2393 if ($task_time->invoice_id) {
2394 $result = $tmpinvoice->fetch($task_time->invoice_id);
2396 if ($action==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2397 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid'=>$projectstatic->id));
2399 print $tmpinvoice->getNomUrl(1);
2400 if (!empty($task_time->invoice_line_id)) {
2402 $invoiceLine->fetch($task_time->invoice_line_id);
2403 if (!empty($invoiceLine->id)) {
2404 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2405 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2411 print $langs->trans(
"No");
2414 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
2419 $totalarray[
'nbfield']++;
2429 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'i'=>$i,
'totalarray'=>&$totalarray);
2430 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2431 print $hookmanager->resPrint;
2435 print
'<td class="center nowraponall">';
2436 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2437 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
2438 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save small" name="save" value="'.$langs->trans(
"Save").
'">';
2440 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2441 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2442 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2445 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=splitline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2446 print
img_split(
'',
'class="pictofixedwidth"');
2450 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_element.
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2451 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2454 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$task_time->fk_element.
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2455 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2458 if ($massactionbutton || $massaction) {
2460 if (in_array($task_time->rowid, $arrayofselected)) {
2464 print
'<input id="cb'.$task_time->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2470 $totalarray[
'nbfield']++;
2479 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2480 print
'<!-- first line -->';
2481 print
'<tr class="oddeven">';
2484 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2485 print
'<td class="nowrap">';
2486 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2487 if (empty($task_time->element_date_withhour)) {
2488 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2490 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2493 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2499 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2500 print
'<td class="nowrap">';
2505 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2506 print
'<td class="nowrap">';
2511 if (!empty($allprojectforuser)) {
2512 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2513 print
'<td class="nowrap">';
2519 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2520 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2521 print
'<td class="nowrap">';
2522 $tasktmp->id = $task_time->fk_element;
2523 $tasktmp->ref = $task_time->ref;
2524 $tasktmp->label = $task_time->label;
2525 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2531 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2532 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2533 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2540 if (!empty($arrayfields[
'author'][
'checked'])) {
2541 print
'<td class="nowraponall">';
2542 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2543 if (empty($object->id)) {
2544 $object->fetch($id);
2546 $contactsoftask = $object->getListContactId(
'internal');
2547 if (!in_array($task_time->fk_user, $contactsoftask)) {
2548 $contactsoftask[] = $task_time->fk_user;
2550 if (count($contactsoftask) > 0) {
2551 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2552 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2554 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2557 $userstatic->id = $task_time->fk_user;
2558 $userstatic->lastname = $task_time->lastname;
2559 $userstatic->firstname = $task_time->firstname;
2560 $userstatic->photo = $task_time->photo;
2561 $userstatic->statut = $task_time->user_status;
2562 print $userstatic->getNomUrl(-1);
2568 if (!empty($arrayfields[
't.note'][
'checked'])) {
2569 print
'<td class="tdoverflowmax300">';
2570 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2571 print
'<textarea name="timespent_note_line" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2576 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2577 print
'<input type="hidden" name="timespent_note_line" rows="'.ROWS_1.
'" value="'.
dol_escape_htmltag($task_time->note, 0, 1).
'">';
2581 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2582 print
'<td class="right">';
2583 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2584 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2585 print
$form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2593 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2594 print
'<td class="nowraponall tdoverflowmax125">';
2599 if (!empty($arrayfields[
'value'][
'checked'])) {
2600 print
'<td class="right">';
2601 print
'<span class="amount">';
2602 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2603 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2609 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2610 print
'<td class="right">';
2611 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2612 if (isset($task_time->total_ht)) {
2613 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2624 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split1');
2625 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2626 print $hookmanager->resPrint;
2629 print
'<td class="center nowraponall">';
2637 print
'<!-- second line --><tr class="oddeven">';
2640 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2641 print
'<td class="nowrap">';
2642 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2643 if (empty($task_time->element_date_withhour)) {
2644 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2646 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2649 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2655 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2656 print
'<td class="nowrap">';
2661 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2662 print
'<td class="nowrap">';
2667 if (!empty($allprojectforuser)) {
2668 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2669 print
'<td class="nowrap">';
2675 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2676 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2677 print
'<td class="nowrap">';
2678 $tasktmp->id = $task_time->fk_element;
2679 $tasktmp->ref = $task_time->ref;
2680 $tasktmp->label = $task_time->label;
2681 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2687 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2688 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2689 print
'<td class="nowrap">';
2696 if (!empty($arrayfields[
'author'][
'checked'])) {
2697 print
'<td class="nowraponall">';
2698 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2699 if (empty($object->id)) {
2700 $object->fetch($id);
2702 $contactsoftask = $object->getListContactId(
'internal');
2703 if (!in_array($task_time->fk_user, $contactsoftask)) {
2704 $contactsoftask[] = $task_time->fk_user;
2706 if (count($contactsoftask) > 0) {
2707 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2708 print
$form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2710 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')).$langs->trans(
'FirstAddRessourceToAllocateTime');
2713 $userstatic->id = $task_time->fk_user;
2714 $userstatic->lastname = $task_time->lastname;
2715 $userstatic->firstname = $task_time->firstname;
2716 $userstatic->photo = $task_time->photo;
2717 $userstatic->statut = $task_time->user_status;
2718 print $userstatic->getNomUrl(-1);
2724 if (!empty($arrayfields[
't.note'][
'checked'])) {
2725 print
'<td class="small tdoverflowmax300"">';
2726 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2727 print
'<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_1.
'">'.
dol_escape_htmltag($task_time->note, 0, 1).
'</textarea>';
2732 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2733 print
'<input type="hidden" name="timespent_note_line_2" value="'.dol_escape_htmltag($task_time->note, 0, 1).
'">';
2737 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2738 print
'<td class="right">';
2739 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2740 print
'<input type="hidden" name="old_duration_2" value="0">';
2741 print
$form->select_duration(
'new_duration_2', 0, 0,
'text');
2749 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2750 print
'<td class="nowraponall tdoverflowmax125">';
2755 if (!empty($arrayfields[
'value'][
'checked'])) {
2756 print
'<td class="right">';
2757 print
'<span class="amount">';
2759 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2765 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2766 print
'<td class="right">';
2767 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2768 if (isset($task_time->total_ht)) {
2769 print
'<span class="amount">';
2770 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2782 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$task_time,
'mode' =>
'split2');
2783 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2784 print $hookmanager->resPrint;
2787 print
'<td class="center nowraponall">';
2798 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2799 print
'<tr class="liste_total">';
2801 while ($i < $totalarray[
'nbfield']) {
2804 if ($num < $limit && empty($offset)) {
2805 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
2807 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2809 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2810 print
'<td class="right">'.convertSecondToTime($totalarray[
'totalduration'],
'allhourmin').
'</td>';
2811 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2812 print
'<td class="right">'.price($totalarray[
'totalvalue']).
'</td>';
2821 if (!count($tasks)) {
2822 $totalnboffields = 1;
2823 foreach ($arrayfields as $value) {
2824 if (!empty($value[
'checked'])) {
2828 print
'<tr class="oddeven"><td colspan="'.$totalnboffields.
'">';
2829 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2833 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
2834 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2835 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 invoice lines.
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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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 ...
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
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.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
$formconfirm
if ($action == 'delbookkeepingyear') {
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.