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_date_startday =
GETPOST(
'search_date_startday',
'int');
71 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
72 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
73 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
74 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
75 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
76 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
77 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78 $search_note =
GETPOST(
'search_note',
'alpha');
79 $search_duration =
GETPOST(
'search_duration',
'int');
80 $search_value =
GETPOST(
'search_value',
'int');
81 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
82 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
83 $search_user =
GETPOST(
'search_user',
'int');
84 $search_valuebilled =
GETPOST(
'search_valuebilled',
'int');
85 $search_product_ref =
GETPOST(
'search_product_ref',
'alpha');
86 $search_company =
GETPOST(
'$search_company',
'alpha');
87 $search_company_alias =
GETPOST(
'$search_company_alias',
'alpha');
88 $search_project_ref =
GETPOST(
'$search_project_ref',
'alpha');
89 $search_project_label =
GETPOST(
'$search_project_label',
'alpha');
90 $search_timespent_starthour =
GETPOSTINT(
"search_timespent_duration_starthour");
91 $search_timespent_startmin =
GETPOSTINT(
"search_timespent_duration_startmin");
92 $search_timespent_endhour =
GETPOSTINT(
"search_timespent_duration_endhour");
93 $search_timespent_endmin =
GETPOSTINT(
"search_timespent_duration_endmin");
95 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
96 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
97 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
99 if (empty($page) || $page == -1) {
102 $offset = $limit * $page;
103 $pageprev = $page - 1;
104 $pagenext = $page + 1;
106 $sortfield =
't.element_date,t.element_datehour,t.rowid';
109 $sortorder =
'DESC,DESC,DESC';
112 $childids = $user->getAllChildIds(1);
116 $hookmanager->initHooks(array(
'projecttasktime',
'globalcard'));
118 $object =
new Task($db);
120 $projectstatic =
new Project($db);
123 $extrafields->fetch_name_optionals_label($projectstatic->table_element);
124 $extrafields->fetch_name_optionals_label($object->table_element);
127 if ($id > 0 || $ref) {
128 $object->fetch($id, $ref);
135 if (!$user->rights->projet->lire) {
139 if ($object->fk_project > 0) {
140 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
144 if (empty($projectid) && !$user->hasRight(
'projet',
'all',
'lire')) {
145 $search_user = $user->id;
154 if (
GETPOST(
'cancel',
'alpha')) {
157 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_generateinvoice' && $massaction !=
'confirm_generateinter') {
161 $parameters = array(
'socid' => $socid,
'projectid' => $projectid);
162 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167 include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
170 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
175 $search_duration =
'';
177 $search_date_startday =
'';
178 $search_date_startmonth =
'';
179 $search_date_startyear =
'';
180 $search_date_endday =
'';
181 $search_date_endmonth =
'';
182 $search_date_endyear =
'';
183 $search_date_start =
'';
184 $search_date_end =
'';
185 $search_task_ref =
'';
186 $search_company =
'';
187 $search_company_alias =
'';
188 $search_project_ref =
'';
189 $search_project_label =
'';
190 $search_task_label =
'';
192 $search_valuebilled =
'';
193 $search_product_ref =
'';
195 $search_array_options = array();
196 $search_timespent_starthour =
'';
197 $search_timespent_startmin =
'';
198 $search_timespent_endhour =
'';
199 $search_timespent_endmin =
'';
203 if ($action ==
'addtimespent' && $user->rights->projet->time) {
206 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
207 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
208 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
209 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
212 if (!
GETPOST(
"userid",
'int')) {
213 $langs->load(
"errors");
214 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
220 $object->fetch($id, $ref);
223 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
224 $action =
'createtime';
227 $object->fetch(
GETPOST(
'taskid',
'int'));
232 $object->fetch_projet();
234 if (empty($object->project->statut)) {
235 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
236 $action =
'createtime';
239 $object->timespent_note =
GETPOST(
"timespent_note",
'alpha');
240 if (
GETPOST(
'progress',
'int') > 0) {
241 $object->progress =
GETPOST(
'progress',
'int');
243 $object->timespent_duration =
GETPOSTINT(
"timespent_durationhour") * 60 * 60;
244 $object->timespent_duration += (
GETPOSTINT(
'timespent_durationmin') ?
GETPOSTINT(
'timespent_durationmin') : 0) * 60;
246 $object->timespent_date =
dol_mktime(
GETPOST(
"timehour",
'int'),
GETPOST(
"timemin",
'int'), 0,
GETPOST(
"timemonth",
'int'),
GETPOST(
"timeday",
'int'),
GETPOST(
"timeyear",
'int'));
247 $object->timespent_withhour = 1;
251 $object->timespent_fk_user =
GETPOST(
"userid",
'int');
252 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
254 $result = $object->addTimeSpent($user);
266 $action =
'createtime';
268 $action =
'createtime';
273 if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire) {
276 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
277 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
282 if (
GETPOST(
'taskid',
'int') != $id) {
283 $id_temp =
GETPOST(
'taskid',
'int');
286 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
289 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
290 $result = $object->delTimeSpent($user);
293 $object->fetch($id_temp, $ref);
295 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
296 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
297 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
298 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
299 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
301 $object->timespent_withhour = 1;
305 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
306 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
307 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
308 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
311 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
312 $result = $object->addTimeSpent($user);
321 $object->fetch($id, $ref);
323 $object->timespent_id =
GETPOST(
"lineid",
'int');
324 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
325 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
326 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
327 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
328 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
329 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
330 $object->timespent_withhour = 1;
334 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
335 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
336 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
337 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
340 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
341 $result = $object->updateTimeSpent($user);
356 if ($action ==
'confirm_deleteline' && $confirm ==
"yes" && ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer'))) {
357 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
359 if (in_array($object->timespent_fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
360 $result = $object->delTimeSpent($user);
363 $langs->load(
"errors");
374 if (!empty($project_ref) && !empty($withproject)) {
375 if ($projectstatic->fetch(0, $project_ref) > 0) {
376 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
377 if (count($tasksarray) > 0) {
378 $id = $tasksarray[0]->id;
380 header(
"Location: " . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'') . (empty($mode) ?
'' :
'&mode=' . $mode));
387 $projectidforalltimes = 0;
388 if (
GETPOST(
'projectid',
'int') > 0) {
389 $projectidforalltimes =
GETPOST(
'projectid',
'int');
391 $result = $projectstatic->fetch($projectidforalltimes);
392 if (!empty($projectstatic->socid)) {
393 $projectstatic->fetch_thirdparty();
395 $res = $projectstatic->fetch_optionals();
396 } elseif (
GETPOST(
'project_ref',
'alpha')) {
397 $projectstatic->fetch(0,
GETPOST(
'project_ref',
'alpha'));
398 $projectidforalltimes = $projectstatic->id;
402 $result = $projectstatic->fetch($object->fk_project);
405 if ($id <= 0 && $projectidforalltimes == 0) {
406 $allprojectforuser = $user->id;
409 if ($action ==
'confirm_generateinvoice') {
410 if (!empty($projectstatic->socid)) {
411 $projectstatic->fetch_thirdparty();
414 if (!($projectstatic->thirdparty->id > 0)) {
415 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateInvoice"),
null,
'errors');
417 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
418 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
419 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
421 $tmpinvoice =
new Facture($db);
422 $tmptimespent =
new Task($db);
423 $tmpproduct =
new Product($db);
424 $fuser =
new User($db);
427 $idprod =
GETPOST(
'productid',
'int');
428 $generateinvoicemode =
GETPOST(
'generateinvoicemode',
'string');
429 $invoiceToUse =
GETPOST(
'invoiceid',
'int');
431 $prodDurationHoursBase = 1.0;
432 $product_data_cache = array();
434 $tmpproduct->fetch($idprod);
440 $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
441 if ($prodDurationHoursBase < 0) {
443 $langs->load(
"errors");
447 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
449 $pu_ht = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
450 $txtva = $dataforprice[
'tva_tx'];
451 $localtax1 = $dataforprice[
'localtax1'];
452 $localtax2 = $dataforprice[
'localtax2'];
454 $prodDurationHoursBase = 1;
462 $tmpinvoice->socid = $projectstatic->thirdparty->id;
463 $tmpinvoice->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
464 $tmpinvoice->fk_project = $projectstatic->id;
465 $tmpinvoice->cond_reglement_id = $projectstatic->thirdparty->cond_reglement_id;
466 $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id;
467 $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account;
470 $tmpinvoice->fetch($invoiceToUse);
472 $result = $tmpinvoice->create($user);
480 if ($generateinvoicemode ==
'onelineperuser') {
481 $arrayoftasks = array();
482 foreach ($toselect as $key => $value) {
484 $object->fetchTimeSpent($value);
485 $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
486 $arrayoftasks[$object->timespent_fk_user][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
489 foreach ($arrayoftasks as $userid => $data) {
490 $fuser->fetch($userid);
491 $username = $fuser->getFullName($langs);
493 foreach ($data as $fk_product => $timespent_data) {
495 $qtyhour = $timespent_data[
'timespent'] / 3600;
496 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
504 $pu_ht = $fuser->thm;
509 if ($timespent_data[
'timespent']) {
510 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
515 $prodDurationHours = $prodDurationHoursBase;
516 $idprodline = $idprod;
519 $localtax1line = $localtax1;
520 $localtax2line = $localtax2;
523 if (!empty($fk_product) && $fk_product !== $idprod) {
524 if (!array_key_exists($fk_product, $product_data_cache)) {
525 $result = $tmpproduct->fetch($fk_product);
530 $prodDurationHours = $tmpproduct->getProductDurationHours();
531 if ($prodDurationHours < 0) {
533 $langs->load(
"errors");
537 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
539 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
540 $txtvaline = $dataforprice[
'tva_tx'];
541 $localtax1line = $dataforprice[
'localtax1'];
542 $localtax2line = $dataforprice[
'localtax2'];
544 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
546 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
547 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
548 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
549 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
550 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
552 $idprodline = $fk_product;
556 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
563 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
564 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
565 $result = $db->query(
$sql);
573 } elseif ($generateinvoicemode ==
'onelineperperiod') {
574 $arrayoftasks = array();
576 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
577 foreach ($toselect as $key => $value) {
579 $object->fetchTimeSpent($value);
581 $ftask =
new Task($db);
582 $ftask->fetch($object->id);
584 $fuser->fetch($object->timespent_fk_user);
585 $username = $fuser->getFullName($langs);
587 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
588 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
589 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
590 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $object->timespent_note);
592 if (!empty($withdetail)) {
593 if (!empty($object->timespent_withhour)) {
594 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour));
596 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date));
598 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $langs->trans(
"Duration") .
': ' .
convertSecondToTime($object->timespent_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY));
600 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
601 $arrayoftasks[$object->timespent_id][
'fk_product'] = $object->timespent_fk_product;
604 foreach ($arrayoftasks as $timespent_id => $value) {
605 $userid = $value[
'user'];
609 $qtyhour = $value[
'timespent'] / 3600;
613 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
617 $prodDurationHours = $prodDurationHoursBase;
618 $idprodline = $idprod;
621 $localtax1line = $localtax1;
622 $localtax2line = $localtax2;
624 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
625 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
626 $result = $tmpproduct->fetch($value[
'fk_product']);
631 $prodDurationHours = $tmpproduct->getProductDurationHours();
632 if ($prodDurationHours < 0) {
634 $langs->load(
"errors");
638 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
640 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
641 $txtvaline = $dataforprice[
'tva_tx'];
642 $localtax1line = $dataforprice[
'localtax1'];
643 $localtax2line = $dataforprice[
'localtax2'];
645 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
647 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
648 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
649 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
650 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
651 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
653 $idprodline = $value[
'fk_product'];
655 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
663 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
664 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
665 $result = $db->query(
$sql);
672 } elseif ($generateinvoicemode ==
'onelinepertask') {
673 $arrayoftasks = array();
674 foreach ($toselect as $key => $value) {
676 $object->fetchTimeSpent($value);
678 $arrayoftasks[$object->id][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
679 $arrayoftasks[$object->id][(
int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
682 foreach ($arrayoftasks as $task_id => $data) {
683 $ftask =
new Task($db);
684 $ftask->fetch($task_id);
686 foreach ($data as $fk_product => $timespent_data) {
687 $qtyhour = $timespent_data[
'timespent'] / 3600;
688 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
691 $prodDurationHours = $prodDurationHoursBase;
692 $idprodline = $idprod;
695 $localtax1line = $localtax1;
696 $localtax2line = $localtax2;
698 if (!empty($fk_product) && $fk_product !== $idprod) {
699 if (!array_key_exists($fk_product, $product_data_cache)) {
700 $result = $tmpproduct->fetch($fk_product);
705 $prodDurationHours = $tmpproduct->getProductDurationHours();
706 if ($prodDurationHours < 0) {
708 $langs->load(
"errors");
712 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
714 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
715 $txtvaline = $dataforprice[
'tva_tx'];
716 $localtax1line = $dataforprice[
'localtax1'];
717 $localtax2line = $dataforprice[
'localtax2'];
719 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
721 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
722 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
723 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
724 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
725 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
727 $idprodline = $fk_product;
731 if ($idprodline > 0) {
733 $pu_ht_for_task = $pu_htline;
735 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
736 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
738 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
743 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
744 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
746 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
752 $lineName = $ftask->ref .
' - ' . $ftask->label;
753 $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);
762 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
763 $sql .=
' WHERE rowid IN (' . $db->sanitize(join(
',', $toselect)) .
')';
764 $result = $db->query(
$sql);
777 $urltoinvoice = $tmpinvoice->getNomUrl(0);
778 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
779 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
791 if ($action ==
'confirm_generateinter') {
792 $langs->load(
'interventions');
794 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
796 if (!($projectstatic->thirdparty->id > 0)) {
797 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
799 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
800 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
801 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
804 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
806 $tmptimespent =
new Task($db);
807 $fuser =
new User($db);
810 $interToUse =
GETPOST(
'interid',
'int');
813 $tmpinter->socid = $projectstatic->thirdparty->id;
814 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
815 $tmpinter->fk_project = $projectstatic->id;
816 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
819 $tmpinter->fetch($interToUse);
821 $result = $tmpinter->create($user);
829 $arrayoftasks = array();
830 foreach ($toselect as $key => $value) {
832 $object->fetchTimeSpent($value);
834 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
835 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
836 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
837 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
838 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
841 foreach ($arrayoftasks as $timespent_id => $value) {
842 $ftask =
new Task($db);
843 $ftask->fetch($value[
'id']);
845 $qtyhour = $value[
'timespent'] / 3600;
846 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
849 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
854 $urltointer = $tmpinter->getNomUrl(0);
855 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
856 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
876 $userstatic =
new User($db);
878 $arrayofselected = is_array($toselect) ? $toselect : array();
880 $title = $object->ref .
' - ' . $langs->trans(
"TimeSpent");
881 if (!empty($withproject)) {
882 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
888 if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
892 if ($projectidforalltimes > 0) {
893 $result = $projectstatic->fetch($projectidforalltimes);
894 if (!empty($projectstatic->socid)) {
895 $projectstatic->fetch_thirdparty();
897 $res = $projectstatic->fetch_optionals();
898 } elseif ($object->fetch($id, $ref) >= 0) {
899 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
900 $object->fetchComments();
902 $result = $projectstatic->fetch($object->fk_project);
903 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
904 $projectstatic->fetchComments();
906 if (!empty($projectstatic->socid)) {
907 $projectstatic->fetch_thirdparty();
909 $res = $projectstatic->fetch_optionals();
911 $object->project = clone $projectstatic;
914 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
915 $linktocreatetime =
'';
917 if ($projectstatic->id > 0) {
920 if (empty($id) || $tab ==
'timespent') {
927 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
929 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
931 $param .=
'&search_user=' . ((int) $search_user);
934 $param .=
'&search_month=' . ((int) $search_month);
937 $param .=
'&search_year=' . ((int) $search_year);
942 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
943 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
944 $tmpurl = preg_replace(
'/__SOCID__/', $projectstatic->socid, $tmpurl);
945 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
947 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
950 $morehtmlref =
'<div class="refidno">';
952 $morehtmlref .= $projectstatic->title;
954 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
955 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
957 $morehtmlref .=
'</div>';
960 if (empty($user->rights->projet->all->lire)) {
961 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
962 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? join(
',', array_keys($objectsListId)) :
'0') .
")";
965 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
967 print
'<div class="fichecenter">';
968 print
'<div class="fichehalfleft">';
969 print
'<div class="underbanner clearboth"></div>';
971 print
'<table class="border tableforfield centpercent">';
974 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
975 print
'<tr><td class="tdtop">';
976 print $langs->trans(
"Usage");
979 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
980 print
'<input type="checkbox" disabled name="usage_opportunity"' . (
GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
981 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
982 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
985 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
986 print
'<input type="checkbox" disabled name="usage_task"' . (
GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
987 $htmltext = $langs->trans(
"ProjectFollowTasks");
988 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
991 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
992 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"' :
'')) .
'"> ';
993 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
994 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
998 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"' :
'')) .
'"> ';
999 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1000 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1006 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1007 if ($projectstatic->public) {
1008 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1009 print $langs->trans(
'SharedProject');
1011 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1012 print $langs->trans(
'PrivateProject');
1017 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1018 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1019 print
'<span class="amount">' .
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency) .
'</span>';
1024 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1026 print ($start ? $start :
'?');
1029 print ($end ? $end :
'?');
1030 if ($projectstatic->hasDelay()) {
1037 $savobject = $object;
1038 $object = $projectstatic;
1039 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1040 $object = $savobject;
1045 print
'<div class="fichehalfright">';
1046 print
'<div class="underbanner clearboth"></div>';
1048 print
'<table class="border tableforfield centpercent">';
1051 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1057 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1058 print
$form->showCategories($projectstatic->id,
'project', 1);
1067 print
'<div class="clearboth"></div>';
1077 $linktocreatetimeBtnStatus = 0;
1078 $linktocreatetimeUrl =
'';
1079 $linktocreatetimeHelpText =
'';
1080 if (!empty($user->rights->projet->time)) {
1081 if ($projectstatic->public || $userRead > 0) {
1082 $linktocreatetimeBtnStatus = 1;
1084 if (!empty($projectidforalltimes)) {
1086 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1087 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1090 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id . ($withproject ?
'&withproject=1' :
'');
1091 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . ($object->id > 0 ?
'&id=' . $object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' .
newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1094 $linktocreatetimeBtnStatus = -2;
1095 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1098 $linktocreatetimeBtnStatus = -2;
1099 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1102 $paramsbutton = array(
'morecss' =>
'reposition');
1103 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1106 $massactionbutton =
'';
1107 $arrayofmassactions = array();
1109 if ($projectstatic->id > 0) {
1111 if ($projectstatic->usage_bill_time) {
1112 $arrayofmassactions = array(
1113 'generateinvoice' => $langs->trans(
"GenerateBill"),
1117 if (
isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'creer')) {
1118 $langs->load(
"interventions");
1119 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1123 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1124 $arrayofmassactions = array();
1126 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1131 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1133 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1135 if ($action ==
'deleteline') {
1136 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1137 print
$form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1140 $param = ($withproject ?
'&withproject=1' :
'');
1141 $param .= ($param ?
'&' :
'') .
'id=' . $object->id;
1142 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1144 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1145 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1146 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1148 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1154 if (empty($withproject)) {
1155 $morehtmlref .=
'<div class="refidno">';
1156 $morehtmlref .= $langs->trans(
"Project") .
': ';
1157 $morehtmlref .= $projectstatic->getNomUrl(1);
1158 $morehtmlref .=
'<br>';
1161 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1162 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1163 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1165 $morehtmlref .=
'</div>';
1168 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1170 print
'<div class="fichecenter">';
1171 print
'<div class="fichehalfleft">';
1173 print
'<div class="underbanner clearboth"></div>';
1174 print
'<table class="border centpercent tableforfield">';
1177 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1178 if ($object->fk_task_parent > 0) {
1179 $tasktmp =
new Task($db);
1180 $tasktmp->fetch($object->fk_task_parent);
1181 print $tasktmp->getNomUrl(1);
1186 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1188 print ($start ? $start :
'?');
1191 print ($end ? $end :
'?');
1192 if ($object->hasDelay()) {
1198 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1199 if ($object->planned_workload) {
1207 print
'<div class="fichehalfright">';
1209 print
'<div class="underbanner clearboth"></div>';
1210 print
'<table class="border tableforfield centpercent">';
1213 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1214 print $object->progress !=
'' ? $object->progress .
' %' :
'';
1218 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1219 if ($object->planned_workload) {
1220 $tmparray = $object->getSummaryOfTimeSpent();
1221 if ($tmparray[
'total_duration'] > 0) {
1222 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2) .
' %';
1227 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1238 print
'<div class="clearboth"></div>';
1242 if ($action ==
'deleteline') {
1243 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1244 print
$form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1249 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1251 $hookmanager->initHooks(array(
'tasktimelist'));
1255 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1257 $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);
1258 $formconfirm =
$form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1262 $parameters = array(
'formConfirm' =>
$formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1263 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1264 if (empty($reshook)) {
1266 } elseif ($reshook > 0) {
1274 $arrayfields = array();
1275 $arrayfields[
't.element_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1276 $arrayfields[
'p.fk_soc'] = array(
'label'=>$langs->trans(
"ThirdParty"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1',
'checked'=>1);
1277 $arrayfields[
's.name_alias'] = array(
'label'=>$langs->trans(
"AliasNameShort"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1');
1278 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1279 if (! empty($allprojectforuser)) {
1280 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1281 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1283 $arrayfields[
't.element_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1284 $arrayfields[
't.element_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1286 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1287 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1288 if (
isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1289 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1291 $arrayfields[
't.element_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1292 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>
isModEnabled(
"salaries"));
1293 $arrayfields[
'valuebilled'] = array(
'label'=>$langs->trans(
"Billed"),
'checked'=>1,
'enabled'=>(((
getDolGlobalInt(
'PROJECT_HIDE_TASKS') || !
getDolGlobalInt(
'PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
1295 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1300 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1301 $param .=
'&contextpage=' . urlencode($contextpage);
1303 if ($limit > 0 && $limit != $conf->liste_limit) {
1304 $param .=
'&limit='.((int) $limit);
1306 if ($search_month > 0) {
1307 $param .=
'&search_month=' . urlencode($search_month);
1309 if ($search_year > 0) {
1310 $param .=
'&search_year=' . urlencode($search_year);
1312 if (!empty($search_user)) {
1313 $param .=
'&search_user='.urlencode($search_user);
1315 if ($search_task_ref !=
'') {
1316 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1318 if ($search_company !=
'') {
1319 $param .=
'&$search_company=' . urlencode($search_company);
1321 if ($search_company_alias !=
'') {
1322 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1324 if ($search_project_ref !=
'') {
1325 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1327 if ($search_project_label !=
'') {
1328 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1330 if ($search_task_label !=
'') {
1331 $param .=
'&search_task_label=' . urlencode($search_task_label);
1333 if ($search_note !=
'') {
1334 $param .=
'&search_note=' . urlencode($search_note);
1336 if ($search_duration !=
'') {
1337 $param .=
'&search_field2=' . urlencode($search_duration);
1339 if ($optioncss !=
'') {
1340 $param .=
'&optioncss=' . urlencode($optioncss);
1342 if ($search_date_startday) {
1343 $param .=
'&search_date_startday=' . urlencode($search_date_startday);
1345 if ($search_date_startmonth) {
1346 $param .=
'&search_date_startmonth=' . urlencode($search_date_startmonth);
1348 if ($search_date_startyear) {
1349 $param .=
'&search_date_startyear=' . urlencode($search_date_startyear);
1351 if ($search_date_endday) {
1352 $param .=
'&search_date_endday=' . urlencode($search_date_endday);
1354 if ($search_date_endmonth) {
1355 $param .=
'&search_date_endmonth=' . urlencode($search_date_endmonth);
1357 if ($search_date_endyear) {
1358 $param .=
'&search_date_endyear=' . urlencode($search_date_endyear);
1360 if ($search_timespent_starthour) {
1361 $param .=
'&search_timespent_duration_starthour=' . urlencode($search_timespent_starthour);
1363 if ($search_timespent_startmin) {
1364 $param .=
'&search_timespent_duration_startmin=' . urlencode($search_timespent_startmin);
1366 if ($search_timespent_endhour) {
1367 $param .=
'&search_timespent_duration_endhour=' . urlencode($search_timespent_endhour);
1369 if ($search_timespent_endmin) {
1370 $param .=
'&search_timespent_duration_endmin=' . urlencode($search_timespent_endmin);
1378 $param .=
'&id=' . urlencode($id);
1381 $param .=
'&projectid=' . urlencode($projectid);
1384 $param .=
'&withproject=' . urlencode($withproject);
1387 $parameters = array();
1388 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1389 $param .= $hookmanager->resPrint;
1391 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1392 if ($optioncss !=
'') {
1393 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1395 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1396 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1397 if ($action ==
'editline') {
1398 print
'<input type="hidden" name="action" value="updateline">';
1399 } elseif ($action ==
'splitline') {
1400 print
'<input type="hidden" name="action" value="updatesplitline">';
1401 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1402 print
'<input type="hidden" name="action" value="addtimespent">';
1403 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1404 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1405 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1406 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1408 print
'<input type="hidden" name="action" value="list">';
1410 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1411 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1413 print
'<input type="hidden" name="id" value="' . $id .
'">';
1414 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1415 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1416 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1417 print
'<input type="hidden" name="page_y" value="">';
1420 if ($massaction ==
'generateinvoice') {
1421 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1422 print
'<table class="noborder centerpercent">';
1424 print
'<td class="titlefield">';
1425 print $langs->trans(
'DateInvoice');
1428 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1434 print $langs->trans(
'Mode');
1438 'onelineperuser' =>
'OneLinePerUser',
1439 'onelinepertask' =>
'OneLinePerTask',
1440 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1442 print
$form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1443 print
"\n" .
'<script type="text/javascript">';
1445 $(document).ready(function () {
1446 setDetailVisibility();
1447 $("#generateinvoicemode").change(function() {
1448 setDetailVisibility();
1450 function setDetailVisibility() {
1451 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1452 if (generateinvoicemode=="onelineperperiod") {
1453 $("#detail_time_duration").show();
1455 $("#detail_time_duration").hide();
1460 print
'</script>' .
"\n";
1461 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1468 print $langs->trans(
'ServiceToUseOnLines');
1471 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1477 print
'<td class="titlefield">';
1478 print $langs->trans(
'InvoiceToUse');
1481 print
$form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1495 print
'<div class="center">';
1496 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1497 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1501 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1502 print
'<div class="center">';
1503 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1507 } elseif ($massaction ==
'generateinter') {
1509 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1511 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1513 print
'<table class="noborder centpercent">';
1515 print
'<td class="titlefield">';
1516 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1520 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1525 print
'<div class="center">';
1526 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1527 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1531 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1532 print
'<div class="center">';
1533 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1540 $parameters = array(
1541 'toselect' => $toselect,
1542 'uploaddir' => isset($uploaddir) ? $uploaddir :
null
1545 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1549 print $hookmanager->resPrint;
1557 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1558 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1560 $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,";
1561 $sql .=
" t.fk_product,";
1562 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1563 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1564 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1565 $sql .=
" p.fk_soc,s.name_alias,";
1566 $sql .=
" t.invoice_line_id";
1568 $parameters = array();
1569 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1570 $sql .= $hookmanager->resPrint;
1571 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
1575 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1576 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1577 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1578 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1579 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1580 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1581 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1582 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1585 $parameters = array();
1586 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1587 $sql .= $hookmanager->resPrint;
1588 $sql .=
" WHERE elementtype = 'task'";
1589 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1590 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1592 $sql .=
" AND t.fk_element =".((int) $object->id);
1593 } elseif (!empty($projectidforalltimes)) {
1595 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1596 } elseif (!empty($allprojectforuser)) {
1598 if (empty($search_user)) {
1599 $search_user = $user->id;
1601 if ($search_user > 0)
$sql .=
" AND t.fk_user = " . ((int) $search_user);
1607 if ($search_task_ref) {
1610 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1613 if ($search_company) {
1616 if ($search_company_alias) {
1620 if ($search_project_ref) {
1623 if ($search_project_label) {
1626 if ($search_task_label) {
1629 if ($search_user > 0) {
1632 if (!empty($search_product_ref)) {
1635 if ($search_valuebilled ==
'1') {
1636 $sql .=
' AND t.invoice_id > 0';
1638 if ($search_valuebilled ==
'0') {
1639 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1642 if ($search_date_start) {
1643 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1645 if ($search_date_end) {
1646 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1649 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1650 if ($search_timespent_starthour || $search_timespent_startmin) {
1651 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1652 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1653 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1656 if ($search_timespent_endhour || $search_timespent_endmin) {
1657 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1658 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1659 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1666 $parameters = array();
1667 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1668 $sql .= $hookmanager->resPrint;
1671 $nbtotalofrecords =
'';
1674 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
1675 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1676 $resql = $db->query($sqlforcount);
1678 $objforcount = $db->fetch_object($resql);
1679 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1684 if (($page * $limit) > $nbtotalofrecords) {
1692 $sql .= $db->order($sortfield, $sortorder);
1694 $sql .= $db->plimit($limit + 1, $offset);
1697 $resql = $db->query(
$sql);
1703 $num = $db->num_rows($resql);
1706 if (!empty($projectidforalltimes)) {
1707 print
'<!-- List of time spent for project -->' .
"\n";
1709 $title = $langs->trans(
"ListTaskTimeUserProject");
1711 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1713 print
'<!-- List of time spent -->' .
"\n";
1715 $title = $langs->trans(
"ListTaskTimeForTask");
1717 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1722 $row = $db->fetch_object($resql);
1734 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1735 print
'<!-- table to add time spent -->' .
"\n";
1737 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
1740 print
'<div class="div-table-responsive-no-min">';
1741 print
'<table class="noborder nohover centpercent">';
1743 print
'<tr class="liste_titre">';
1744 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1745 if (!empty($allprojectforuser)) {
1746 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1749 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1751 print
'<td>' . $langs->trans(
"By") .
'</td>';
1752 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1753 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1754 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1755 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1758 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1759 print
'<td>'.$langs->trans(
"Product").
'</td>';
1763 $parameters = array(
'mode' =>
'create');
1764 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1765 print $hookmanager->resPrint;
1769 print
'<tr class="oddeven nohover">';
1772 print
'<td class="maxwidthonsmartphone">';
1774 print
$form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1777 if (!empty($allprojectforuser)) {
1786 print
'<td class="maxwidthonsmartphone">';
1787 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1792 print
'<td class="maxwidthonsmartphone nowraponall">';
1793 $contactsofproject = $projectstatic->getListContactId(
'internal');
1794 if (count($contactsofproject) > 0) {
1795 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1796 if (in_array($user->id, $contactsofproject)) {
1797 $userid = $user->id;
1799 $userid = $contactsofproject[0];
1802 if ($projectstatic->public) {
1803 $contactsofproject = array();
1805 print
$form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1808 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1815 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1819 print
'<td class="nowraponall">';
1820 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1822 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1824 print
$form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1828 print
'<td class="nowrap">';
1829 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1833 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1837 if (
isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1838 print
'<td class="nowraponall">';
1840 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);
1846 $parameters = array(
'mode' =>
'create');
1847 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1848 print $hookmanager->resPrint;
1850 print
'<td class="center">';
1851 $form->buttonsSaveCancel();
1852 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1853 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1862 $moreforfilter =
'';
1864 $parameters = array();
1865 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1866 if (empty($reshook)) {
1867 $moreforfilter .= $hookmanager->resPrint;
1869 $moreforfilter = $hookmanager->resPrint;
1872 if (!empty($moreforfilter)) {
1873 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1874 print $moreforfilter;
1878 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1879 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1880 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
1882 print
'<div class="div-table-responsive">';
1883 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1887 print
'<tr class="liste_titre_filter">';
1890 print
'<td class="liste_titre center">';
1891 $searchpicto =
$form->showFilterButtons(
'left');
1896 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1897 print
'<td class="liste_titre left">';
1898 print
'<div class="nowrap">';
1899 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1901 print
'<div class="nowrap">';
1902 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1907 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1908 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1912 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1913 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1916 if (!empty($allprojectforuser)) {
1917 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1918 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1920 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1921 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1925 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1926 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1927 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1929 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1930 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1934 if (!empty($arrayfields[
'author'][
'checked'])) {
1935 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>';
1938 if (!empty($arrayfields[
't.note'][
'checked'])) {
1939 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1942 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1944 print
'<td class="liste_titre right">';
1946 $durationtouse_start =
'';
1947 if ($search_timespent_starthour || $search_timespent_startmin) {
1948 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1950 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1951 print
$form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1954 $durationtouse_end =
'';
1955 if ($search_timespent_endhour || $search_timespent_endmin) {
1956 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1958 print
'<div class="nowraponall">' . $langs->trans(
'at') .
' ';
1959 print
$form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1965 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1966 print
'<td class="liste_titre right"></td>';
1969 if (!empty($arrayfields[
'value'][
'checked'])) {
1970 print
'<td class="liste_titre"></td>';
1973 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1974 print
'<td class="liste_titre center">' .
$form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
1982 $parameters = array(
'arrayfields' => $arrayfields);
1983 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1984 print $hookmanager->resPrint;
1987 print
'<td class="liste_titre center">';
1988 $searchpicto =
$form->showFilterButtons();
1992 print
'</tr>' .
"\n";
1994 $totalarray = array();
1995 $totalarray[
'nbfield'] = 0;
1999 print
'<tr class="liste_titre">';
2001 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2002 $totalarray[
'nbfield']++;
2004 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2005 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2006 $totalarray[
'nbfield']++;
2008 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2009 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2010 $totalarray[
'nbfield']++;
2012 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2013 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2014 $totalarray[
'nbfield']++;
2016 if (!empty($allprojectforuser)) {
2017 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2019 $totalarray[
'nbfield']++;
2021 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2022 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2023 $totalarray[
'nbfield']++;
2026 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2027 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2028 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2029 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2032 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2033 $totalarray[
'nbfield']++;
2036 if (!empty($arrayfields[
'author'][
'checked'])) {
2037 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2038 $totalarray[
'nbfield']++;
2040 if (!empty($arrayfields[
't.note'][
'checked'])) {
2041 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2042 $totalarray[
'nbfield']++;
2044 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2045 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2046 $totalarray[
'nbfield']++;
2048 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2049 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2050 $totalarray[
'nbfield']++;
2053 if (!empty($arrayfields[
'value'][
'checked'])) {
2054 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2055 $totalarray[
'nbfield']++;
2057 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2058 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2059 $totalarray[
'nbfield']++;
2066 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2067 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
2068 print $hookmanager->resPrint;
2070 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2071 $totalarray[
'nbfield']++;
2075 $tasktmp =
new Task($db);
2076 $tmpinvoice =
new Facture($db);
2082 $savnbfield = $totalarray[
'nbfield'];
2083 $totalarray = array();
2084 $totalarray[
'nbfield'] = 0;
2086 foreach ($tasks as $task_time) {
2091 $date1 = $db->jdate($task_time->element_date);
2092 $date2 = $db->jdate($task_time->element_datehour);
2096 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
2100 print
'<td class="center nowraponall">';
2101 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2102 print
'<input type="hidden" name="lineid" value="' .
GETPOST(
'lineid',
'int') .
'">';
2103 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2105 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2106 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2107 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2110 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' .
newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2111 print
img_split(
'',
'class="pictofixedwidth"');
2115 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2116 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2119 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2120 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2123 if ($massactionbutton || $massaction) {
2125 if (in_array($task_time->rowid, $arrayofselected)) {
2129 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2135 $totalarray[
'nbfield']++;
2139 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2140 print
'<td class="nowrap">';
2141 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2142 if (empty($task_time->element_date_withhour)) {
2143 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2145 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2148 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2152 $totalarray[
'nbfield']++;
2157 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2158 print
'<td class="tdoverflowmax125">';
2159 if ($task_time->fk_soc > 0) {
2160 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2161 $tmpsociete =
new Societe($db);
2162 $tmpsociete->fetch($task_time->fk_soc);
2163 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2165 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2167 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2171 $totalarray[
'nbfield']++;
2176 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2177 if ($task_time->fk_soc > 0) {
2178 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2179 $tmpsociete =
new Societe($db);
2180 $tmpsociete->fetch($task_time->fk_soc);
2181 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2183 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2185 $valtoshow = $tmpsociete->name_alias;
2187 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2191 $totalarray[
'nbfield']++;
2196 if (!empty($allprojectforuser)) {
2197 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2198 print
'<td class="nowraponall">';
2199 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2200 $tmpproject =
new Project($db);
2201 $tmpproject->fetch($task_time->fk_projet);
2202 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2204 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2206 print $tmpproject->getNomUrl(1);
2209 $totalarray[
'nbfield']++;
2212 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2213 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2214 $tmpproject =
new Project($db);
2215 $tmpproject->fetch($task_time->fk_projet);
2216 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2218 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2220 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2224 $totalarray[
'nbfield']++;
2230 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2231 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2232 print
'<td class="nowrap">';
2233 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2234 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
2236 $tasktmp->id = $task_time->fk_element;
2237 $tasktmp->ref = $task_time->ref;
2238 $tasktmp->label = $task_time->label;
2239 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2243 $totalarray[
'nbfield']++;
2246 } elseif ($action !==
'createtime') {
2247 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
2251 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2252 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2253 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2257 $totalarray[
'nbfield']++;
2263 if (!empty($arrayfields[
'author'][
'checked'])) {
2264 print
'<td class="tdoverflowmax100">';
2265 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2266 if (empty($object->id)) {
2267 $object->fetch($id);
2269 $contactsoftask = $object->getListContactId(
'internal');
2270 if (!in_array($task_time->fk_user, $contactsoftask)) {
2271 $contactsoftask[] = $task_time->fk_user;
2273 if (count($contactsoftask) > 0) {
2274 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2275 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
2277 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2280 $userstatic->id = $task_time->fk_user;
2281 $userstatic->lastname = $task_time->lastname;
2282 $userstatic->firstname = $task_time->firstname;
2283 $userstatic->photo = $task_time->photo;
2284 $userstatic->statut = $task_time->user_status;
2285 print $userstatic->getNomUrl(-1);
2289 $totalarray[
'nbfield']++;
2294 if (!empty($arrayfields[
't.note'][
'checked'])) {
2295 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2296 print
'<td class="small">';
2297 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2300 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2305 $totalarray[
'nbfield']++;
2307 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2308 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2312 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2313 print
'<td class="right nowraponall">';
2314 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2315 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2316 print
$form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2322 $totalarray[
'nbfield']++;
2325 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2327 if (empty($totalarray[
'val'][
't.element_duration'])) {
2328 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2330 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2333 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2335 if (empty($totalarray[
'totalduration'])) {
2336 $totalarray[
'totalduration'] = $task_time->element_duration;
2338 $totalarray[
'totalduration'] += $task_time->element_duration;
2343 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2344 print
'<td class="nowraponall tdoverflowmax125">';
2345 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2346 $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');
2347 } elseif (!empty($task_time->fk_product)) {
2349 $resultFetch = $product->fetch($task_time->fk_product);
2350 if ($resultFetch < 0) {
2353 print $product->getNomUrl(1);
2358 $totalarray[
'nbfield']++;
2363 if (!empty($arrayfields[
'value'][
'checked'])) {
2364 $langs->load(
"salaries");
2365 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2367 print
'<td class="nowraponall right">';
2368 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2369 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2373 $totalarray[
'nbfield']++;
2376 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2378 if (empty($totalarray[
'val'][
'value'])) {
2379 $totalarray[
'val'][
'value'] = $value;
2381 $totalarray[
'val'][
'value'] += $value;
2384 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2386 if (empty($totalarray[
'totalvalue'])) {
2387 $totalarray[
'totalvalue'] = $value;
2389 $totalarray[
'totalvalue'] += $value;
2394 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2395 print
'<td class="center">';
2396 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
2397 if ($projectstatic->usage_bill_time) {
2398 if ($task_time->invoice_id) {
2399 $result = $tmpinvoice->fetch($task_time->invoice_id);
2401 if ($action==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2402 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid'=>$projectstatic->id));
2404 print $tmpinvoice->getNomUrl(1);
2405 if (!empty($task_time->invoice_line_id)) {
2407 $invoiceLine->fetch($task_time->invoice_line_id);
2408 if (!empty($invoiceLine->id)) {
2409 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2410 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2416 print $langs->trans(
"No");
2419 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2424 $totalarray[
'nbfield']++;
2434 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2435 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2436 print $hookmanager->resPrint;
2440 print
'<td class="center nowraponall">';
2441 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2442 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
2443 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save small" name="save" value="'.$langs->trans(
"Save").
'">';
2445 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2446 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2447 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2450 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' .
newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2451 print
img_split(
'',
'class="pictofixedwidth"');
2455 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=editline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2456 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2459 print
'<a class="reposition paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?'.($withproject ?
'id='.$task_time->fk_element :
'').
'&action=deleteline&token='.
newToken().
'&lineid='.$task_time->rowid.$param.((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'').
'">';
2460 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2463 if ($massactionbutton || $massaction) {
2465 if (in_array($task_time->rowid, $arrayofselected)) {
2469 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2475 $totalarray[
'nbfield']++;
2484 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2485 print
'<!-- first line -->';
2486 print
'<tr class="oddeven">';
2489 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2490 print
'<td class="nowrap">';
2491 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2492 if (empty($task_time->element_date_withhour)) {
2493 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2495 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2498 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2504 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2505 print
'<td class="nowrap">';
2510 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2511 print
'<td class="nowrap">';
2516 if (!empty($allprojectforuser)) {
2517 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2518 print
'<td class="nowrap">';
2524 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2525 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2526 print
'<td class="nowrap">';
2527 $tasktmp->id = $task_time->fk_element;
2528 $tasktmp->ref = $task_time->ref;
2529 $tasktmp->label = $task_time->label;
2530 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2536 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2537 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2538 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2545 if (!empty($arrayfields[
'author'][
'checked'])) {
2546 print
'<td class="nowraponall">';
2547 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2548 if (empty($object->id)) {
2549 $object->fetch($id);
2551 $contactsoftask = $object->getListContactId(
'internal');
2552 if (!in_array($task_time->fk_user, $contactsoftask)) {
2553 $contactsoftask[] = $task_time->fk_user;
2555 if (count($contactsoftask) > 0) {
2556 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2557 print
$form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2559 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2562 $userstatic->id = $task_time->fk_user;
2563 $userstatic->lastname = $task_time->lastname;
2564 $userstatic->firstname = $task_time->firstname;
2565 $userstatic->photo = $task_time->photo;
2566 $userstatic->statut = $task_time->user_status;
2567 print $userstatic->getNomUrl(-1);
2573 if (!empty($arrayfields[
't.note'][
'checked'])) {
2574 print
'<td class="tdoverflowmax300">';
2575 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2576 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2581 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2582 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2586 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2587 print
'<td class="right">';
2588 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2589 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2590 print
$form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2598 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2599 print
'<td class="nowraponall tdoverflowmax125">';
2604 if (!empty($arrayfields[
'value'][
'checked'])) {
2605 print
'<td class="right">';
2606 print
'<span class="amount">';
2607 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2608 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2614 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2615 print
'<td class="right">';
2616 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2617 if (isset($task_time->total_ht)) {
2618 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2629 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2630 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2631 print $hookmanager->resPrint;
2634 print
'<td class="center nowraponall">';
2642 print
'<!-- second line --><tr class="oddeven">';
2645 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2646 print
'<td class="nowrap">';
2647 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2648 if (empty($task_time->element_date_withhour)) {
2649 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2651 print
$form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2654 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2660 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2661 print
'<td class="nowrap">';
2666 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2667 print
'<td class="nowrap">';
2672 if (!empty($allprojectforuser)) {
2673 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2674 print
'<td class="nowrap">';
2680 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2681 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2682 print
'<td class="nowrap">';
2683 $tasktmp->id = $task_time->fk_element;
2684 $tasktmp->ref = $task_time->ref;
2685 $tasktmp->label = $task_time->label;
2686 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2692 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2693 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2694 print
'<td class="nowrap">';
2701 if (!empty($arrayfields[
'author'][
'checked'])) {
2702 print
'<td class="nowraponall">';
2703 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2704 if (empty($object->id)) {
2705 $object->fetch($id);
2707 $contactsoftask = $object->getListContactId(
'internal');
2708 if (!in_array($task_time->fk_user, $contactsoftask)) {
2709 $contactsoftask[] = $task_time->fk_user;
2711 if (count($contactsoftask) > 0) {
2712 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2713 print
$form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2715 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2718 $userstatic->id = $task_time->fk_user;
2719 $userstatic->lastname = $task_time->lastname;
2720 $userstatic->firstname = $task_time->firstname;
2721 $userstatic->photo = $task_time->photo;
2722 $userstatic->statut = $task_time->user_status;
2723 print $userstatic->getNomUrl(-1);
2729 if (!empty($arrayfields[
't.note'][
'checked'])) {
2730 print
'<td class="small tdoverflowmax300"">';
2731 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2732 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2737 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2738 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2742 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2743 print
'<td class="right">';
2744 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2745 print
'<input type="hidden" name="old_duration_2" value="0">';
2746 print
$form->select_duration(
'new_duration_2', 0, 0,
'text');
2754 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2755 print
'<td class="nowraponall tdoverflowmax125">';
2760 if (!empty($arrayfields[
'value'][
'checked'])) {
2761 print
'<td class="right">';
2762 print
'<span class="amount">';
2764 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2770 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2771 print
'<td class="right">';
2772 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2773 if (isset($task_time->total_ht)) {
2774 print
'<span class="amount">';
2775 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2787 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2788 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2789 print $hookmanager->resPrint;
2792 print
'<td class="center nowraponall">';
2803 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2804 print
'<tr class="liste_total">';
2806 while ($i < $totalarray[
'nbfield']) {
2809 if ($num < $limit && empty($offset)) {
2810 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2812 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2814 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2815 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2816 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2817 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2826 if (!count($tasks)) {
2827 $totalnboffields = 1;
2828 foreach ($arrayfields as $value) {
2829 if (!empty($value[
'checked'])) {
2833 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2834 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2838 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
2839 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2840 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.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
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.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
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.