32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
34require_once DOL_DOCUMENT_ROOT .
'/projet/class/task.class.php';
35require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
36require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
37require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formintervention.class.php';
43$langsLoad = array(
'projects',
'bills',
'orders',
'companies');
44if (isModEnabled(
'eventorganization')) {
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');
98$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
99if (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);
127if ($id > 0 || $ref) {
128 $object->fetch($id, $ref);
135if (!$user->hasRight(
'projet',
'lire')) {
139if ($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;
154if (
GETPOST(
'cancel',
'alpha')) {
157if (!
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);
167include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
170if (
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 =
'';
203if ($action ==
'addtimespent' && $user->hasRight(
'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';
273if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->hasRight(
'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->hasRight(
'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->hasRight(
'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->hasRight(
'projet',
'all',
'creer')) {
341 $result = $object->updateTimeSpent($user);
356if ($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");
374if (!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;
388if (
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);
405if ($id <= 0 && $projectidforalltimes == 0) {
406 $allprojectforuser = $user->id;
409if ($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);
502 } elseif ($idprod <= 0) {
505 $pu_ht = $fuser->thm;
510 if ($timespent_data[
'timespent']) {
511 $pu_ht =
price2num(($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent']),
'MU');
516 $prodDurationHours = $prodDurationHoursBase;
517 $idprodline = $idprod;
520 $localtax1line = $localtax1;
521 $localtax2line = $localtax2;
524 if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) {
525 if (!array_key_exists($fk_product, $product_data_cache)) {
526 $result = $tmpproduct->fetch($fk_product);
531 $prodDurationHours = $tmpproduct->getProductDurationHours();
532 if ($prodDurationHours < 0) {
534 $langs->load(
"errors");
538 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
540 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
541 $txtvaline = $dataforprice[
'tva_tx'];
542 $localtax1line = $dataforprice[
'localtax1'];
543 $localtax2line = $dataforprice[
'localtax2'];
545 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
547 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
548 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
549 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
550 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
551 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
553 $idprodline = $fk_product;
557 $lineid = $tmpinvoice->addline($langs->trans(
"TimeSpentForInvoice", $username) .
' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
564 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
565 $sql .=
' WHERE rowid IN ('.$db->sanitize(join(
',', $toselect)).
') AND fk_user = '.((
int) $userid);
566 $result = $db->query($sql);
574 } elseif ($generateinvoicemode ==
'onelineperperiod') {
575 $arrayoftasks = array();
577 $withdetail =
GETPOST(
'detail_time_duration',
'alpha');
578 foreach ($toselect as $key => $value) {
580 $object->fetchTimeSpent($value);
582 $ftask =
new Task($db);
583 $ftask->fetch($object->id);
585 $fuser->fetch($object->timespent_fk_user);
586 $username = $fuser->getFullName($langs);
588 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
589 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
590 $arrayoftasks[$object->timespent_id][
'note'] = $ftask->ref .
' - ' . $ftask->label .
' - ' . $username;
591 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $object->timespent_note);
593 if (!empty($withdetail)) {
594 if (!empty($object->timespent_withhour)) {
595 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_datehour));
597 $arrayoftasks[$object->timespent_id][
'note'] =
dol_concatdesc($arrayoftasks[$object->timespent_id][
'note'], $langs->trans(
"Date") .
': ' .
dol_print_date($object->timespent_date));
599 $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));
601 $arrayoftasks[$object->timespent_id][
'user'] = $object->timespent_fk_user;
602 $arrayoftasks[$object->timespent_id][
'fk_product'] = $object->timespent_fk_product;
605 foreach ($arrayoftasks as $timespent_id => $value) {
606 $userid = $value[
'user'];
610 $qtyhour = $value[
'timespent'] / 3600;
614 $pu_ht =
price2num($value[
'totalvaluetodivideby3600'] / 3600,
'MU');
618 $prodDurationHours = $prodDurationHoursBase;
619 $idprodline = $idprod;
622 $localtax1line = $localtax1;
623 $localtax2line = $localtax2;
625 if (!empty($value[
'fk_product']) && $value[
'fk_product'] !== $idprod) {
626 if (!array_key_exists($value[
'fk_product'], $product_data_cache)) {
627 $result = $tmpproduct->fetch($value[
'fk_product']);
632 $prodDurationHours = $tmpproduct->getProductDurationHours();
633 if ($prodDurationHours < 0) {
635 $langs->load(
"errors");
639 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
641 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
642 $txtvaline = $dataforprice[
'tva_tx'];
643 $localtax1line = $dataforprice[
'localtax1'];
644 $localtax2line = $dataforprice[
'localtax2'];
646 $product_data_cache[$value[
'fk_product']] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
648 $prodDurationHours = $product_data_cache[$value[
'fk_product']][
'duration'];
649 $pu_htline = empty($product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'pu_ht'];
650 $txtvaline = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'tva_tx'];
651 $localtax1line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax1'];
652 $localtax2line = $product_data_cache[$value[
'fk_product']][
'dataforprice'][
'localtax2'];
654 $idprodline = $value[
'fk_product'];
656 $lineid = $tmpinvoice->addline($value[
'note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
664 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'element_time SET invoice_line_id = '.((int) $lineid).
', invoice_id = '.((int) $tmpinvoice->id);
665 $sql .=
' WHERE rowid = '.((int) $timespent_id).
' AND fk_user = '.((int) $userid);
666 $result = $db->query($sql);
673 } elseif ($generateinvoicemode ==
'onelinepertask') {
674 $arrayoftasks = array();
675 foreach ($toselect as $key => $value) {
677 $object->fetchTimeSpent($value);
679 $arrayoftasks[$object->id][(int) $object->timespent_fk_product][
'timespent'] += $object->timespent_duration;
680 $arrayoftasks[$object->id][(int) $object->timespent_fk_product][
'totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
683 foreach ($arrayoftasks as $task_id => $data) {
684 $ftask =
new Task($db);
685 $ftask->fetch($task_id);
687 foreach ($data as $fk_product => $timespent_data) {
688 $qtyhour = $timespent_data[
'timespent'] / 3600;
689 $qtyhourtext =
convertSecondToTime($timespent_data[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
692 $prodDurationHours = $prodDurationHoursBase;
693 $idprodline = $idprod;
696 $localtax1line = $localtax1;
697 $localtax2line = $localtax2;
699 if (!empty($fk_product) && $fk_product !== $idprod) {
700 if (!array_key_exists($fk_product, $product_data_cache)) {
701 $result = $tmpproduct->fetch($fk_product);
706 $prodDurationHours = $tmpproduct->getProductDurationHours();
707 if ($prodDurationHours < 0) {
709 $langs->load(
"errors");
713 $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
715 $pu_htline = empty($dataforprice[
'pu_ht']) ? 0 : $dataforprice[
'pu_ht'];
716 $txtvaline = $dataforprice[
'tva_tx'];
717 $localtax1line = $dataforprice[
'localtax1'];
718 $localtax2line = $dataforprice[
'localtax2'];
720 $product_data_cache[$fk_product] = array(
'duration' => $prodDurationHours,
'dataforprice' => $dataforprice);
722 $prodDurationHours = $product_data_cache[$fk_product][
'duration'];
723 $pu_htline = empty($product_data_cache[$fk_product][
'dataforprice'][
'pu_ht']) ? 0 : $product_data_cache[$fk_product][
'dataforprice'][
'pu_ht'];
724 $txtvaline = $product_data_cache[$fk_product][
'dataforprice'][
'tva_tx'];
725 $localtax1line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax1'];
726 $localtax2line = $product_data_cache[$fk_product][
'dataforprice'][
'localtax2'];
728 $idprodline = $fk_product;
732 if ($idprodline > 0) {
734 $pu_ht_for_task = $pu_htline;
737 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
739 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU') * $prodDurationHours;
745 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
747 $pa_ht =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
753 $lineName = $ftask->ref .
' - ' . $ftask->label;
754 $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);
763 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'element_time SET invoice_line_id = ' . ((int) $lineid) .
', invoice_id = ' . ((int) $tmpinvoice->id);
764 $sql .=
' WHERE rowid IN (' . $db->sanitize(join(
',', $toselect)) .
')';
765 $result = $db->query($sql);
778 $urltoinvoice = $tmpinvoice->getNomUrl(0);
779 $mesg = $langs->trans(
"InvoiceGeneratedFromTimeSpent",
'{s1}');
780 $mesg = str_replace(
'{s1}', $urltoinvoice, $mesg);
792if ($action ==
'confirm_generateinter') {
793 $langs->load(
'interventions');
795 if (!empty($projectstatic->socid)) {
796 $projectstatic->fetch_thirdparty();
799 if (!($projectstatic->thirdparty->id > 0)) {
800 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
802 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
803 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
804 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
807 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
809 $tmptimespent =
new Task($db);
810 $fuser =
new User($db);
813 $interToUse =
GETPOST(
'interid',
'int');
816 $tmpinter->socid = $projectstatic->thirdparty->id;
817 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
818 $tmpinter->fk_project = $projectstatic->id;
819 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
822 $tmpinter->fetch($interToUse);
824 $result = $tmpinter->create($user);
832 $arrayoftasks = array();
833 foreach ($toselect as $key => $value) {
835 $object->fetchTimeSpent($value);
837 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
838 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
839 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
840 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
841 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
844 foreach ($arrayoftasks as $timespent_id => $value) {
845 $ftask =
new Task($db);
846 $ftask->fetch($value[
'id']);
848 $qtyhour = $value[
'timespent'] / 3600;
849 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
852 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
857 $urltointer = $tmpinter->getNomUrl(0);
858 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
859 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
876$form =
new Form($db);
879$userstatic =
new User($db);
881$arrayofselected = is_array($toselect) ? $toselect : array();
883$title = $object->ref .
' - ' . $langs->trans(
"TimeSpent");
884if (!empty($withproject)) {
885 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
891if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
895 if ($projectidforalltimes > 0) {
896 $result = $projectstatic->fetch($projectidforalltimes);
897 if (!empty($projectstatic->socid)) {
898 $projectstatic->fetch_thirdparty();
900 $res = $projectstatic->fetch_optionals();
901 } elseif ($object->fetch($id, $ref) >= 0) {
902 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty($object->comments)) {
903 $object->fetchComments();
905 $result = $projectstatic->fetch($object->fk_project);
906 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
907 $projectstatic->fetchComments();
909 if (!empty($projectstatic->socid)) {
910 $projectstatic->fetch_thirdparty();
912 $res = $projectstatic->fetch_optionals();
914 $object->project = clone $projectstatic;
917 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
918 $linktocreatetime =
'';
920 if ($projectstatic->id > 0) {
923 if (empty($id) || $tab ==
'timespent') {
930 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
932 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
934 $param .=
'&search_user=' . ((int) $search_user);
937 $param .=
'&search_month=' . ((int) $search_month);
940 $param .=
'&search_year=' . ((int) $search_year);
945 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
947 $morehtmlref =
'<div class="refidno">';
949 $morehtmlref .= $projectstatic->title;
951 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
952 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
954 $morehtmlref .=
'</div>';
957 if (!$user->hasRight(
'projet',
'all',
'lire')) {
958 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
959 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? join(
',', array_keys($objectsListId)) :
'0') .
")";
962 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
964 print
'<div class="fichecenter">';
965 print
'<div class="fichehalfleft">';
966 print
'<div class="underbanner clearboth"></div>';
968 print
'<table class="border tableforfield centpercent">';
972 print
'<tr><td class="tdtop">';
973 print $langs->trans(
"Usage");
977 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
978 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
979 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
983 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
984 $htmltext = $langs->trans(
"ProjectFollowTasks");
985 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
989 print
'<input type="checkbox" disabled name="usage_bill_time"' . (GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_bill_time ?
' checked="checked"' :
'')) .
'"> ';
990 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
991 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
994 if (isModEnabled(
'eventorganization')) {
995 print
'<input type="checkbox" disabled name="usage_organize_event"' . (GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_organize_event ?
' checked="checked"' :
'')) .
'"> ';
996 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
997 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1003 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1004 if ($projectstatic->public) {
1005 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1006 print $langs->trans(
'SharedProject');
1008 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1009 print $langs->trans(
'PrivateProject');
1014 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1015 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1016 print
'<span class="amount">' .
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency) .
'</span>';
1021 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1023 print($start ? $start :
'?');
1026 print($end ? $end :
'?');
1027 if ($projectstatic->hasDelay()) {
1034 $savobject = $object;
1035 $object = $projectstatic;
1036 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1037 $object = $savobject;
1042 print
'<div class="fichehalfright">';
1043 print
'<div class="underbanner clearboth"></div>';
1045 print
'<table class="border tableforfield centpercent">';
1048 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1053 if (isModEnabled(
'categorie')) {
1054 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1055 print $form->showCategories($projectstatic->id,
'project', 1);
1064 print
'<div class="clearboth"></div>';
1074 $linktocreatetimeBtnStatus = 0;
1075 $linktocreatetimeUrl =
'';
1076 $linktocreatetimeHelpText =
'';
1077 if ($user->hasRight(
'projet',
'time')) {
1078 if ($projectstatic->public || $userRead > 0) {
1079 $linktocreatetimeBtnStatus = 1;
1081 if (!empty($projectidforalltimes)) {
1083 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1084 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' . newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1087 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id . ($withproject ?
'&withproject=1' :
'');
1088 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . ($object->id > 0 ?
'&id=' . $object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' . newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1091 $linktocreatetimeBtnStatus = -2;
1092 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1095 $linktocreatetimeBtnStatus = -2;
1096 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1099 $paramsbutton = array(
'morecss' =>
'reposition');
1100 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1103 $massactionbutton =
'';
1104 $arrayofmassactions = array();
1106 if ($projectstatic->id > 0) {
1108 if ($projectstatic->usage_bill_time) {
1109 $arrayofmassactions = array(
1110 'generateinvoice' => $langs->trans(
"GenerateBill"),
1114 if (isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'creer')) {
1115 $langs->load(
"interventions");
1116 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1120 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1121 $arrayofmassactions = array();
1123 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1128 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1130 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1132 if ($action ==
'deleteline') {
1133 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1134 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1137 $param = ($withproject ?
'&withproject=1' :
'');
1138 $param .= ($param ?
'&' :
'') .
'id=' . $object->id;
1139 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1141 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1142 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1143 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1145 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1151 if (empty($withproject)) {
1152 $morehtmlref .=
'<div class="refidno">';
1153 $morehtmlref .= $langs->trans(
"Project") .
': ';
1154 $morehtmlref .= $projectstatic->getNomUrl(1);
1155 $morehtmlref .=
'<br>';
1158 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1159 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1160 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1162 $morehtmlref .=
'</div>';
1165 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1167 print
'<div class="fichecenter">';
1168 print
'<div class="fichehalfleft">';
1170 print
'<div class="underbanner clearboth"></div>';
1171 print
'<table class="border centpercent tableforfield">';
1174 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1175 if ($object->fk_task_parent > 0) {
1176 $tasktmp =
new Task($db);
1177 $tasktmp->fetch($object->fk_task_parent);
1178 print $tasktmp->getNomUrl(1);
1183 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1185 print($start ? $start :
'?');
1188 print($end ? $end :
'?');
1189 if ($object->hasDelay()) {
1195 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1196 if ($object->planned_workload) {
1204 print
'<div class="fichehalfright">';
1206 print
'<div class="underbanner clearboth"></div>';
1207 print
'<table class="border tableforfield centpercent">';
1210 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1211 print $object->progress !=
'' ? $object->progress .
' %' :
'';
1215 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1216 if ($object->planned_workload) {
1217 $tmparray = $object->getSummaryOfTimeSpent();
1218 if ($tmparray[
'total_duration'] > 0) {
1219 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2) .
' %';
1224 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1235 print
'<div class="clearboth"></div>';
1239 if ($action ==
'deleteline') {
1240 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1241 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1246 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1248 $hookmanager->initHooks(array(
'tasktimelist'));
1252 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1254 $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);
1255 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1259 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1260 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1261 if (empty($reshook)) {
1262 $formconfirm .= $hookmanager->resPrint;
1263 } elseif ($reshook > 0) {
1264 $formconfirm = $hookmanager->resPrint;
1271 $arrayfields = array();
1272 $arrayfields[
't.element_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1273 $arrayfields[
'p.fk_soc'] = array(
'label'=>$langs->trans(
"ThirdParty"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1',
'checked'=>1);
1274 $arrayfields[
's.name_alias'] = array(
'label'=>$langs->trans(
"AliasNameShort"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1');
1275 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1276 if (! empty($allprojectforuser)) {
1277 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1278 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1280 $arrayfields[
't.element_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1281 $arrayfields[
't.element_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1283 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1284 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1285 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1286 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1288 $arrayfields[
't.element_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1289 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>isModEnabled(
"salaries"));
1290 $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));
1292 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1297 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1298 $param .=
'&contextpage=' . urlencode($contextpage);
1300 if ($limit > 0 && $limit != $conf->liste_limit) {
1301 $param .=
'&limit='.((int) $limit);
1303 if ($search_month > 0) {
1304 $param .=
'&search_month=' . urlencode($search_month);
1306 if ($search_year > 0) {
1307 $param .=
'&search_year=' . urlencode($search_year);
1309 if (!empty($search_user)) {
1310 $param .=
'&search_user='.urlencode($search_user);
1312 if ($search_task_ref !=
'') {
1313 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1315 if ($search_company !=
'') {
1316 $param .=
'&$search_company=' . urlencode($search_company);
1318 if ($search_company_alias !=
'') {
1319 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1321 if ($search_project_ref !=
'') {
1322 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1324 if ($search_project_label !=
'') {
1325 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1327 if ($search_task_label !=
'') {
1328 $param .=
'&search_task_label=' . urlencode($search_task_label);
1330 if ($search_note !=
'') {
1331 $param .=
'&search_note=' . urlencode($search_note);
1333 if ($search_duration !=
'') {
1334 $param .=
'&search_field2=' . urlencode($search_duration);
1336 if ($optioncss !=
'') {
1337 $param .=
'&optioncss=' . urlencode($optioncss);
1339 if ($search_date_startday) {
1340 $param .=
'&search_date_startday=' . urlencode($search_date_startday);
1342 if ($search_date_startmonth) {
1343 $param .=
'&search_date_startmonth=' . urlencode($search_date_startmonth);
1345 if ($search_date_startyear) {
1346 $param .=
'&search_date_startyear=' . urlencode($search_date_startyear);
1348 if ($search_date_endday) {
1349 $param .=
'&search_date_endday=' . urlencode($search_date_endday);
1351 if ($search_date_endmonth) {
1352 $param .=
'&search_date_endmonth=' . urlencode($search_date_endmonth);
1354 if ($search_date_endyear) {
1355 $param .=
'&search_date_endyear=' . urlencode($search_date_endyear);
1357 if ($search_timespent_starthour) {
1358 $param .=
'&search_timespent_duration_starthour=' . urlencode($search_timespent_starthour);
1360 if ($search_timespent_startmin) {
1361 $param .=
'&search_timespent_duration_startmin=' . urlencode($search_timespent_startmin);
1363 if ($search_timespent_endhour) {
1364 $param .=
'&search_timespent_duration_endhour=' . urlencode($search_timespent_endhour);
1366 if ($search_timespent_endmin) {
1367 $param .=
'&search_timespent_duration_endmin=' . urlencode($search_timespent_endmin);
1375 $param .=
'&id=' . urlencode($id);
1378 $param .=
'&projectid=' . urlencode($projectid);
1381 $param .=
'&withproject=' . urlencode($withproject);
1384 $parameters = array(
'param' => &$param);
1385 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1386 $param .= $hookmanager->resPrint;
1388 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1389 if ($optioncss !=
'') {
1390 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1392 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
1393 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1394 if ($action ==
'editline') {
1395 print
'<input type="hidden" name="action" value="updateline">';
1396 } elseif ($action ==
'splitline') {
1397 print
'<input type="hidden" name="action" value="updatesplitline">';
1398 } elseif ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1399 print
'<input type="hidden" name="action" value="addtimespent">';
1400 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1401 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1402 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1403 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1405 print
'<input type="hidden" name="action" value="list">';
1407 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1408 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1410 print
'<input type="hidden" name="id" value="' . $id .
'">';
1411 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1412 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1413 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1414 print
'<input type="hidden" name="page_y" value="">';
1417 if ($massaction ==
'generateinvoice') {
1418 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1419 print
'<table class="noborder centerpercent">';
1421 print
'<td class="titlefield">';
1422 print $langs->trans(
'DateInvoice');
1425 print $form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1431 print $langs->trans(
'Mode');
1435 'onelineperuser' =>
'OneLinePerUser',
1436 'onelinepertask' =>
'OneLinePerTask',
1437 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1439 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1440 print
"\n" .
'<script type="text/javascript">';
1442 $(document).ready(function () {
1443 setDetailVisibility();
1444 $("#generateinvoicemode").change(function() {
1445 setDetailVisibility();
1447 function setDetailVisibility() {
1448 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1449 if (generateinvoicemode=="onelineperperiod") {
1450 $("#detail_time_duration").show();
1452 $("#detail_time_duration").hide();
1457 print
'</script>' .
"\n";
1458 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1462 if (isModEnabled(
"service")) {
1465 print $langs->trans(
'ServiceToUseOnLines');
1468 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1474 print
'<td class="titlefield">';
1475 print $langs->trans(
'InvoiceToUse');
1478 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1492 print
'<div class="center">';
1493 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1494 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1498 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1499 print
'<div class="center">';
1500 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1504 } elseif ($massaction ==
'generateinter') {
1506 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1508 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1510 print
'<table class="noborder centpercent">';
1512 print
'<td class="titlefield">';
1513 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1517 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1522 print
'<div class="center">';
1523 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1524 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1528 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1529 print
'<div class="center">';
1530 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1537 $parameters = array(
1538 'toselect' => $toselect,
1539 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1542 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1546 print $hookmanager->resPrint;
1554 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1555 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1557 $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,";
1558 $sql .=
" t.fk_product,";
1559 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1560 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1561 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1562 $sql .=
" p.fk_soc,s.name_alias,";
1563 $sql .=
" t.invoice_line_id";
1565 $parameters = array();
1566 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
1567 $sql .= $hookmanager->resPrint;
1568 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1572 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1573 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1574 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1575 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1576 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1577 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1578 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1579 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1582 $parameters = array();
1583 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
1584 $sql .= $hookmanager->resPrint;
1585 $sql .=
" WHERE elementtype = 'task'";
1586 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1587 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1589 $sql .=
" AND t.fk_element =".((int) $object->id);
1590 } elseif (!empty($projectidforalltimes)) {
1592 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1593 } elseif (!empty($allprojectforuser)) {
1595 if (empty($search_user)) {
1596 $search_user = $user->id;
1598 if ($search_user > 0) {
1599 $sql .=
" AND t.fk_user = " . ((int) $search_user);
1606 if ($search_task_ref) {
1609 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1610 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1612 if ($search_company) {
1615 if ($search_company_alias) {
1619 if ($search_project_ref) {
1622 if ($search_project_label) {
1625 if ($search_task_label) {
1628 if ($search_user > 0) {
1631 if (!empty($search_product_ref)) {
1634 if ($search_valuebilled ==
'1') {
1635 $sql .=
' AND t.invoice_id > 0';
1637 if ($search_valuebilled ==
'0') {
1638 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1641 if ($search_date_start) {
1642 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1644 if ($search_date_end) {
1645 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1648 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1649 if ($search_timespent_starthour || $search_timespent_startmin) {
1650 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1651 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1652 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1655 if ($search_timespent_endhour || $search_timespent_endmin) {
1656 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1657 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1658 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1662 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1665 $parameters = array();
1666 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1667 $sql .= $hookmanager->resPrint;
1670 $nbtotalofrecords =
'';
1673 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1674 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1675 $resql = $db->query($sqlforcount);
1677 $objforcount = $db->fetch_object($resql);
1678 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1683 if (($page * $limit) > $nbtotalofrecords) {
1691 $sql .= $db->order($sortfield, $sortorder);
1693 $sql .= $db->plimit($limit + 1, $offset);
1696 $resql = $db->query($sql);
1702 $num = $db->num_rows($resql);
1705 if (!empty($projectidforalltimes)) {
1706 print
'<!-- List of time spent for project -->' .
"\n";
1708 $title = $langs->trans(
"ListTaskTimeUserProject");
1710 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1712 print
'<!-- List of time spent -->' .
"\n";
1714 $title = $langs->trans(
"ListTaskTimeForTask");
1716 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1721 $row = $db->fetch_object($resql);
1733 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1734 print
'<!-- table to add time spent -->' .
"\n";
1736 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
1739 print
'<div class="div-table-responsive-no-min">';
1740 print
'<table class="noborder nohover centpercent">';
1742 print
'<tr class="liste_titre">';
1743 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1744 if (!empty($allprojectforuser)) {
1745 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1748 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1750 print
'<td>' . $langs->trans(
"By") .
'</td>';
1751 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1752 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1753 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1757 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1758 print
'<td>'.$langs->trans(
"Product").
'</td>';
1762 $parameters = array(
'mode' =>
'create');
1763 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1764 print $hookmanager->resPrint;
1768 print
'<tr class="oddeven nohover">';
1771 print
'<td class="maxwidthonsmartphone">';
1773 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1776 if (!empty($allprojectforuser)) {
1785 print
'<td class="maxwidthonsmartphone">';
1786 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1791 print
'<td class="maxwidthonsmartphone nowraponall">';
1792 $contactsofproject = $projectstatic->getListContactId(
'internal');
1793 if (count($contactsofproject) > 0) {
1794 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1795 if (in_array($user->id, $contactsofproject)) {
1796 $userid = $user->id;
1798 $userid = $contactsofproject[0];
1801 if ($projectstatic->public) {
1802 $contactsofproject = array();
1804 print $form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1807 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1814 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1818 print
'<td class="nowraponall">';
1819 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1820 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1821 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1823 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1827 print
'<td class="nowrap">';
1828 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1836 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1837 print
'<td class="nowraponall">';
1839 print $form->select_produits((GETPOSTISSET(
'fk_product')?
GETPOST(
"fk_product",
'int'):
''),
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'', null, 1);
1845 $parameters = array(
'mode' =>
'create');
1846 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1847 print $hookmanager->resPrint;
1849 print
'<td class="center">';
1850 $form->buttonsSaveCancel();
1851 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1852 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1861 $moreforfilter =
'';
1863 $parameters = array();
1864 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1865 if (empty($reshook)) {
1866 $moreforfilter .= $hookmanager->resPrint;
1868 $moreforfilter = $hookmanager->resPrint;
1871 if (!empty($moreforfilter)) {
1872 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1873 print $moreforfilter;
1877 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1878 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1879 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1881 print
'<div class="div-table-responsive">';
1882 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1886 print
'<tr class="liste_titre_filter">';
1889 print
'<td class="liste_titre center">';
1890 $searchpicto = $form->showFilterButtons(
'left');
1895 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1896 print
'<td class="liste_titre left">';
1897 print
'<div class="nowrapfordate">';
1898 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1900 print
'<div class="nowrapfordate">';
1901 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1906 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1907 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1911 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1912 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1915 if (!empty($allprojectforuser)) {
1916 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1917 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1919 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1920 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1924 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1925 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1926 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1928 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1929 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1933 if (!empty($arrayfields[
'author'][
'checked'])) {
1934 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>';
1937 if (!empty($arrayfields[
't.note'][
'checked'])) {
1938 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1941 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1943 print
'<td class="liste_titre right">';
1945 $durationtouse_start =
'';
1946 if ($search_timespent_starthour || $search_timespent_startmin) {
1947 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1949 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1950 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1953 $durationtouse_end =
'';
1954 if ($search_timespent_endhour || $search_timespent_endmin) {
1955 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1957 print
'<div class="nowraponall">' . $langs->trans(
'at') .
' ';
1958 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1964 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1965 print
'<td class="liste_titre right"></td>';
1968 if (!empty($arrayfields[
'value'][
'checked'])) {
1969 print
'<td class="liste_titre"></td>';
1972 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1973 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
1981 $parameters = array(
'arrayfields' => $arrayfields);
1982 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1983 print $hookmanager->resPrint;
1986 print
'<td class="liste_titre center">';
1987 $searchpicto = $form->showFilterButtons();
1991 print
'</tr>' .
"\n";
1993 $totalarray = array();
1994 $totalarray[
'nbfield'] = 0;
1998 print
'<tr class="liste_titre">';
2000 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2001 $totalarray[
'nbfield']++;
2003 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2004 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2005 $totalarray[
'nbfield']++;
2007 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2008 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2009 $totalarray[
'nbfield']++;
2011 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2012 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2013 $totalarray[
'nbfield']++;
2015 if (!empty($allprojectforuser)) {
2016 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2018 $totalarray[
'nbfield']++;
2020 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2021 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2022 $totalarray[
'nbfield']++;
2025 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2026 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2027 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2028 $totalarray[
'nbfield']++;
2030 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2031 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2032 $totalarray[
'nbfield']++;
2035 if (!empty($arrayfields[
'author'][
'checked'])) {
2036 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2037 $totalarray[
'nbfield']++;
2039 if (!empty($arrayfields[
't.note'][
'checked'])) {
2040 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2041 $totalarray[
'nbfield']++;
2043 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2044 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2045 $totalarray[
'nbfield']++;
2047 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2048 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2049 $totalarray[
'nbfield']++;
2052 if (!empty($arrayfields[
'value'][
'checked'])) {
2053 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2054 $totalarray[
'nbfield']++;
2056 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2057 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2058 $totalarray[
'nbfield']++;
2065 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2066 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2067 print $hookmanager->resPrint;
2069 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2070 $totalarray[
'nbfield']++;
2074 $tasktmp =
new Task($db);
2075 $tmpinvoice =
new Facture($db);
2081 $savnbfield = $totalarray[
'nbfield'];
2082 $totalarray = array();
2083 $totalarray[
'nbfield'] = 0;
2085 foreach ($tasks as $task_time) {
2090 $date1 = $db->jdate($task_time->element_date);
2091 $date2 = $db->jdate($task_time->element_datehour);
2095 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
2099 print
'<td class="center nowraponall">';
2100 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2101 print
'<input type="hidden" name="lineid" value="' .
GETPOST(
'lineid',
'int') .
'">';
2102 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2104 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2105 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2106 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2109 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' . newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2110 print
img_split(
'',
'class="pictofixedwidth"');
2114 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' :
'').
'">';
2115 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2118 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' :
'').
'">';
2119 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2122 if ($massactionbutton || $massaction) {
2124 if (in_array($task_time->rowid, $arrayofselected)) {
2128 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2134 $totalarray[
'nbfield']++;
2138 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2139 print
'<td class="nowrap">';
2140 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2141 if (empty($task_time->element_date_withhour)) {
2142 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2144 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2147 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2151 $totalarray[
'nbfield']++;
2156 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2157 print
'<td class="tdoverflowmax125">';
2158 if ($task_time->fk_soc > 0) {
2159 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2160 $tmpsociete =
new Societe($db);
2161 $tmpsociete->fetch($task_time->fk_soc);
2162 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2164 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2166 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2170 $totalarray[
'nbfield']++;
2175 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2176 if ($task_time->fk_soc > 0) {
2177 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2178 $tmpsociete =
new Societe($db);
2179 $tmpsociete->fetch($task_time->fk_soc);
2180 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2182 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2184 $valtoshow = $tmpsociete->name_alias;
2186 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2190 $totalarray[
'nbfield']++;
2195 if (!empty($allprojectforuser)) {
2196 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2197 print
'<td class="nowraponall">';
2198 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2199 $tmpproject =
new Project($db);
2200 $tmpproject->fetch($task_time->fk_projet);
2201 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2203 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2205 print $tmpproject->getNomUrl(1);
2208 $totalarray[
'nbfield']++;
2211 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2212 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2213 $tmpproject =
new Project($db);
2214 $tmpproject->fetch($task_time->fk_projet);
2215 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2217 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2219 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2223 $totalarray[
'nbfield']++;
2229 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2230 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2231 print
'<td class="nowrap">';
2232 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2233 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
2235 $tasktmp->id = $task_time->fk_element;
2236 $tasktmp->ref = $task_time->ref;
2237 $tasktmp->label = $task_time->label;
2238 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2242 $totalarray[
'nbfield']++;
2245 } elseif ($action !==
'createtime') {
2246 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
2250 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2251 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2252 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2256 $totalarray[
'nbfield']++;
2262 if (!empty($arrayfields[
'author'][
'checked'])) {
2263 print
'<td class="tdoverflowmax100">';
2264 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2265 if (empty($object->id)) {
2266 $object->fetch($id);
2268 $contactsoftask = $object->getListContactId(
'internal');
2269 if (!in_array($task_time->fk_user, $contactsoftask)) {
2270 $contactsoftask[] = $task_time->fk_user;
2272 if (count($contactsoftask) > 0) {
2273 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2274 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
2276 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2279 $userstatic->id = $task_time->fk_user;
2280 $userstatic->lastname = $task_time->lastname;
2281 $userstatic->firstname = $task_time->firstname;
2282 $userstatic->photo = $task_time->photo;
2283 $userstatic->status = $task_time->user_status;
2284 print $userstatic->getNomUrl(-1);
2288 $totalarray[
'nbfield']++;
2293 if (!empty($arrayfields[
't.note'][
'checked'])) {
2294 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2295 print
'<td class="small">';
2296 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2299 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2304 $totalarray[
'nbfield']++;
2306 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2307 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2311 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2312 print
'<td class="right nowraponall">';
2313 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2314 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2315 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2321 $totalarray[
'nbfield']++;
2324 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2326 if (empty($totalarray[
'val'][
't.element_duration'])) {
2327 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2329 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2332 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2334 if (empty($totalarray[
'totalduration'])) {
2335 $totalarray[
'totalduration'] = $task_time->element_duration;
2337 $totalarray[
'totalduration'] += $task_time->element_duration;
2342 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2343 print
'<td class="nowraponall">';
2344 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2346 print $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500', 0,
'',
null, 1);
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">';
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, $object, $action);
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->status = $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, $object, $action);
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->status = $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, $object, $action);
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 (isset($totalarray[
'totaldurationfield']) && $totalarray[
'totaldurationfield'] == $i) {
2815 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2816 } elseif (isset($totalarray[
'totalvaluefield']) && $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, $object, $action);
2840 print $hookmanager->resPrint;
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.
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 a 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...
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.
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.
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...
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.