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->rights->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->rights->projet->time) {
206 $timespent_durationhour =
GETPOST(
'timespent_durationhour',
'int');
207 $timespent_durationmin =
GETPOST(
'timespent_durationmin',
'int');
208 if (empty($timespent_durationhour) && empty($timespent_durationmin)) {
209 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
212 if (!
GETPOST(
"userid",
'int')) {
213 $langs->load(
"errors");
214 setEventMessages($langs->trans(
'ErrorUserNotAssignedToTask'),
null,
'errors');
220 $object->fetch($id, $ref);
223 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
224 $action =
'createtime';
227 $object->fetch(
GETPOST(
'taskid',
'int'));
232 $object->fetch_projet();
234 if (empty($object->project->statut)) {
235 setEventMessages($langs->trans(
"ProjectMustBeValidatedFirst"),
null,
'errors');
236 $action =
'createtime';
239 $object->timespent_note =
GETPOST(
"timespent_note",
'alpha');
240 if (
GETPOST(
'progress',
'int') > 0) {
241 $object->progress =
GETPOST(
'progress',
'int');
243 $object->timespent_duration =
GETPOSTINT(
"timespent_durationhour") * 60 * 60;
244 $object->timespent_duration += (
GETPOSTINT(
'timespent_durationmin') ?
GETPOSTINT(
'timespent_durationmin') : 0) * 60;
246 $object->timespent_date =
dol_mktime(
GETPOST(
"timehour",
'int'),
GETPOST(
"timemin",
'int'), 0,
GETPOST(
"timemonth",
'int'),
GETPOST(
"timeday",
'int'),
GETPOST(
"timeyear",
'int'));
247 $object->timespent_withhour = 1;
251 $object->timespent_fk_user =
GETPOST(
"userid",
'int');
252 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
254 $result = $object->addTimeSpent($user);
266 $action =
'createtime';
268 $action =
'createtime';
273if (($action ==
'updateline' || $action ==
'updatesplitline') && !$cancel && $user->rights->projet->lire) {
276 if (!
GETPOST(
"new_durationhour") && !
GETPOST(
"new_durationmin")) {
277 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Duration")),
null,
'errors');
282 if (
GETPOST(
'taskid',
'int') != $id) {
283 $id_temp =
GETPOST(
'taskid',
'int');
286 $object->fetchTimeSpent(
GETPOST(
'lineid',
'int'));
289 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
290 $result = $object->delTimeSpent($user);
293 $object->fetch($id_temp, $ref);
295 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
296 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
297 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
298 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
299 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
301 $object->timespent_withhour = 1;
305 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
306 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
307 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
308 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
311 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
312 $result = $object->addTimeSpent($user);
321 $object->fetch($id, $ref);
323 $object->timespent_id =
GETPOST(
"lineid",
'int');
324 $object->timespent_note =
GETPOST(
"timespent_note_line",
"alphanohtml");
325 $object->timespent_old_duration =
GETPOST(
"old_duration",
"int");
326 $object->timespent_duration =
GETPOSTINT(
"new_durationhour") * 60 * 60;
327 $object->timespent_duration += (
GETPOSTINT(
"new_durationmin") ?
GETPOSTINT(
'new_durationmin') : 0) * 60;
328 if (
GETPOST(
"timelinehour") !=
'' &&
GETPOST(
"timelinehour") >= 0) {
329 $object->timespent_date =
dol_mktime(
GETPOST(
"timelinehour",
'int'),
GETPOST(
"timelinemin",
'int'), 0,
GETPOST(
"timelinemonth",
'int'),
GETPOST(
"timelineday",
'int'),
GETPOST(
"timelineyear",
'int'));
330 $object->timespent_withhour = 1;
334 $object->timespent_fk_user =
GETPOST(
"userid_line",
'int');
335 $object->timespent_fk_product =
GETPOST(
"fk_product",
'int');
336 $object->timespent_invoiceid =
GETPOST(
"invoiceid",
'int');
337 $object->timespent_invoicelineid =
GETPOST(
"invoicelineid",
'int');
340 if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
341 $result = $object->updateTimeSpent($user);
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;
736 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
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;
744 if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
745 $pu_ht_for_task =
price2num($timespent_data[
'totalvaluetodivideby3600'] / $timespent_data[
'timespent'],
'MU');
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)) $projectstatic->fetch_thirdparty();
797 if (!($projectstatic->thirdparty->id > 0)) {
798 setEventMessages($langs->trans(
"ThirdPartyRequiredToGenerateIntervention"),
null,
'errors');
800 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
801 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
802 include_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
805 require_once DOL_DOCUMENT_ROOT .
'/fichinter/class/fichinter.class.php';
807 $tmptimespent =
new Task($db);
808 $fuser =
new User($db);
811 $interToUse =
GETPOST(
'interid',
'int');
814 $tmpinter->socid = $projectstatic->thirdparty->id;
815 $tmpinter->date =
dol_mktime(
GETPOST(
'rehour',
'int'),
GETPOST(
'remin',
'int'),
GETPOST(
'resec',
'int'),
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
816 $tmpinter->fk_project = $projectstatic->id;
817 $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ?
'-' . $projectstatic->label :
'');
820 $tmpinter->fetch($interToUse);
822 $result = $tmpinter->create($user);
830 $arrayoftasks = array();
831 foreach ($toselect as $key => $value) {
833 $object->fetchTimeSpent($value);
835 $arrayoftasks[$object->timespent_id][
'id'] = $object->id;
836 $arrayoftasks[$object->timespent_id][
'timespent'] = $object->timespent_duration;
837 $arrayoftasks[$object->timespent_id][
'totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
838 $arrayoftasks[$object->timespent_id][
'note'] = $object->timespent_note;
839 $arrayoftasks[$object->timespent_id][
'date'] = date(
'Y-m-d H:i:s', $object->timespent_datehour);
842 foreach ($arrayoftasks as $timespent_id => $value) {
843 $ftask =
new Task($db);
844 $ftask->fetch($value[
'id']);
846 $qtyhour = $value[
'timespent'] / 3600;
847 $qtyhourtext =
convertSecondToTime($value[
'timespent'],
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
850 $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value[
'note']) ?
' - ' . $value[
'note'] :
''), $value[
'date'], $value[
'timespent']);
855 $urltointer = $tmpinter->getNomUrl(0);
856 $mesg = $langs->trans(
"InterventionGeneratedFromTimeSpent",
'{s1}');
857 $mesg = str_replace(
'{s1}', $urltointer, $mesg);
874$form =
new Form($db);
877$userstatic =
new User($db);
879$arrayofselected = is_array($toselect) ? $toselect : array();
881$title = $object->ref .
' - ' . $langs->trans(
"TimeSpent");
882if (!empty($withproject)) {
883 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': ' . $projectstatic->ref :
'');
889if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) {
893 if ($projectidforalltimes > 0) {
894 $result = $projectstatic->fetch($projectidforalltimes);
895 if (!empty($projectstatic->socid)) {
896 $projectstatic->fetch_thirdparty();
898 $res = $projectstatic->fetch_optionals();
899 } elseif ($object->fetch($id, $ref) >= 0) {
900 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
901 $object->fetchComments();
903 $result = $projectstatic->fetch($object->fk_project);
904 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
905 $projectstatic->fetchComments();
907 if (!empty($projectstatic->socid)) {
908 $projectstatic->fetch_thirdparty();
910 $res = $projectstatic->fetch_optionals();
912 $object->project = clone $projectstatic;
915 $userRead = $projectstatic->restrictedProjectArea($user,
'read');
916 $linktocreatetime =
'';
918 if ($projectstatic->id > 0) {
921 if (empty($id) || $tab ==
'timespent') {
928 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
930 $param = ((!empty($mode) && $mode ==
'mine') ?
'&mode=mine' :
'');
932 $param .=
'&search_user=' . ((int) $search_user);
935 $param .=
'&search_month=' . ((int) $search_month);
938 $param .=
'&search_year=' . ((int) $search_year);
943 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
944 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
945 $tmpurl = preg_replace(
'/__SOCID__/', $projectstatic->socid, $tmpurl);
946 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
948 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
951 $morehtmlref =
'<div class="refidno">';
953 $morehtmlref .= $projectstatic->title;
955 if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
956 $morehtmlref .=
'<br>' . $projectstatic->thirdparty->getNomUrl(1,
'project');
958 $morehtmlref .=
'</div>';
961 if (empty($user->rights->projet->all->lire)) {
962 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
963 $projectstatic->next_prev_filter =
"rowid IN (" . $db->sanitize(count($objectsListId) ? join(
',', array_keys($objectsListId)) :
'0') .
")";
966 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
968 print
'<div class="fichecenter">';
969 print
'<div class="fichehalfleft">';
970 print
'<div class="underbanner clearboth"></div>';
972 print
'<table class="border tableforfield centpercent">';
975 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled(
'eventorganization')) {
976 print
'<tr><td class="tdtop">';
977 print $langs->trans(
"Usage");
980 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
981 print
'<input type="checkbox" disabled name="usage_opportunity"' . (GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')) .
'"> ';
982 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
983 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
986 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
987 print
'<input type="checkbox" disabled name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')) .
'"> ';
988 $htmltext = $langs->trans(
"ProjectFollowTasks");
989 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
992 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
993 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"' :
'')) .
'"> ';
994 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
995 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
998 if (isModEnabled(
'eventorganization')) {
999 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"' :
'')) .
'"> ';
1000 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1001 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1007 print
'<tr><td class="titlefield">' . $langs->trans(
"Visibility") .
'</td><td>';
1008 if ($projectstatic->public) {
1009 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1010 print $langs->trans(
'SharedProject');
1012 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1013 print $langs->trans(
'PrivateProject');
1018 print
'<tr><td>' . $langs->trans(
"Budget") .
'</td><td>';
1019 if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
1020 print
'<span class="amount">' .
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency) .
'</span>';
1025 print
'<tr><td>' . $langs->trans(
"Dates") .
'</td><td>';
1027 print ($start ? $start :
'?');
1030 print ($end ? $end :
'?');
1031 if ($projectstatic->hasDelay()) {
1038 $savobject = $object;
1039 $object = $projectstatic;
1040 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
1041 $object = $savobject;
1046 print
'<div class="fichehalfright">';
1047 print
'<div class="underbanner clearboth"></div>';
1049 print
'<table class="border tableforfield centpercent">';
1052 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1057 if (isModEnabled(
'categorie')) {
1058 print
'<tr><td class="valignmiddle">' . $langs->trans(
"Categories") .
'</td><td>';
1059 print $form->showCategories($projectstatic->id,
'project', 1);
1068 print
'<div class="clearboth"></div>';
1078 $linktocreatetimeBtnStatus = 0;
1079 $linktocreatetimeUrl =
'';
1080 $linktocreatetimeHelpText =
'';
1081 if (!empty($user->rights->projet->time)) {
1082 if ($projectstatic->public || $userRead > 0) {
1083 $linktocreatetimeBtnStatus = 1;
1085 if (!empty($projectidforalltimes)) {
1087 $backtourl = $_SERVER[
'PHP_SELF'] .
'?projectid=' . $projectstatic->id . ($withproject ?
'&withproject=1' :
'');
1088 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') .
'&projectid=' . $projectstatic->id .
'&action=createtime&token=' . newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1091 $backtourl = $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id . ($withproject ?
'&withproject=1' :
'');
1092 $linktocreatetimeUrl = $_SERVER[
'PHP_SELF'] .
'?' . ($withproject ?
'withproject=1' :
'') . ($object->id > 0 ?
'&id=' . $object->id :
'&projectid=' . $projectstatic->id) .
'&action=createtime&token=' . newToken() . $param .
'&backtopage=' . urlencode($backtourl);
1095 $linktocreatetimeBtnStatus = -2;
1096 $linktocreatetimeHelpText = $langs->trans(
"NotOwnerOfProject");
1099 $linktocreatetimeBtnStatus = -2;
1100 $linktocreatetimeHelpText = $langs->trans(
"NotEnoughPermissions");
1103 $paramsbutton = array(
'morecss' =>
'reposition');
1104 $linktocreatetime =
dolGetButtonTitle($langs->trans(
'AddTimeSpent'), $linktocreatetimeHelpText,
'fa fa-plus-circle', $linktocreatetimeUrl,
'', $linktocreatetimeBtnStatus, $paramsbutton);
1107 $massactionbutton =
'';
1108 $arrayofmassactions = array();
1110 if ($projectstatic->id > 0) {
1112 if ($projectstatic->usage_bill_time) {
1113 $arrayofmassactions = array(
1114 'generateinvoice' => $langs->trans(
"GenerateBill"),
1118 if (isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'creer')) {
1119 $langs->load(
"interventions");
1120 $arrayofmassactions[
'generateinter'] = $langs->trans(
"GenerateInter");
1124 if (in_array($massaction, array(
'presend',
'predelete',
'generateinvoice',
'generateinter'))) {
1125 $arrayofmassactions = array();
1127 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1132 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1134 print
dol_get_fiche_head($head,
'task_time', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
1136 if ($action ==
'deleteline') {
1137 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1138 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1141 $param = ($withproject ?
'&withproject=1' :
'');
1142 $param .= ($param ?
'&' :
'') .
'id=' . $object->id;
1143 $linkback = $withproject ?
'<a href="' . DOL_URL_ROOT .
'/projet/tasks.php?id=' . $projectstatic->id .
'">' . $langs->trans(
"BackToList") .
'</a>' :
'';
1145 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
1146 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
1147 $object->next_prev_filter =
"fk_projet IN (" . $db->sanitize($projectsListId) .
")";
1149 $object->next_prev_filter =
"fk_projet = " . ((int) $projectstatic->id);
1155 if (empty($withproject)) {
1156 $morehtmlref .=
'<div class="refidno">';
1157 $morehtmlref .= $langs->trans(
"Project") .
': ';
1158 $morehtmlref .= $projectstatic->getNomUrl(1);
1159 $morehtmlref .=
'<br>';
1162 $morehtmlref .= $langs->trans(
"ThirdParty") .
': ';
1163 if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
1164 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
1166 $morehtmlref .=
'</div>';
1169 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
1171 print
'<div class="fichecenter">';
1172 print
'<div class="fichehalfleft">';
1174 print
'<div class="underbanner clearboth"></div>';
1175 print
'<table class="border centpercent tableforfield">';
1178 print
'<tr><td>' . $langs->trans(
"ChildOfTask") .
'</td><td>';
1179 if ($object->fk_task_parent > 0) {
1180 $tasktmp =
new Task($db);
1181 $tasktmp->fetch($object->fk_task_parent);
1182 print $tasktmp->getNomUrl(1);
1187 print
'<tr><td class="titlefield">' . $langs->trans(
"DateStart") .
' - ' . $langs->trans(
"Deadline") .
'</td><td>';
1189 print ($start ? $start :
'?');
1192 print ($end ? $end :
'?');
1193 if ($object->hasDelay()) {
1199 print
'<tr><td>' . $langs->trans(
"PlannedWorkload") .
'</td><td>';
1200 if ($object->planned_workload) {
1208 print
'<div class="fichehalfright">';
1210 print
'<div class="underbanner clearboth"></div>';
1211 print
'<table class="border tableforfield centpercent">';
1214 print
'<tr><td class="titlefield">' . $langs->trans(
"ProgressDeclared") .
'</td><td>';
1215 print $object->progress !=
'' ? $object->progress .
' %' :
'';
1219 print
'<tr><td>' . $langs->trans(
"ProgressCalculated") .
'</td><td>';
1220 if ($object->planned_workload) {
1221 $tmparray = $object->getSummaryOfTimeSpent();
1222 if ($tmparray[
'total_duration'] > 0) {
1223 print round($tmparray[
'total_duration'] / $object->planned_workload * 100, 2) .
' %';
1228 print
'<span class="opacitymedium">' . $langs->trans(
"WorkloadNotDefined") .
'</span>';
1239 print
'<div class="clearboth"></div>';
1243 if ($action ==
'deleteline') {
1244 $urlafterconfirm = $_SERVER[
"PHP_SELF"] .
"?" . ($object->id > 0 ?
"id=" . $object->id :
'projectid=' . $projectstatic->id) .
'&lineid=' .
GETPOST(
"lineid",
'int') . ($withproject ?
'&withproject=1' :
'');
1245 print $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1250 if ($projectstatic->id > 0 || $allprojectforuser > 0) {
1252 $hookmanager->initHooks(array(
'tasktimelist'));
1256 if ($action ==
'deleteline' && !empty($projectidforalltimes)) {
1258 $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);
1259 $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans(
"DeleteATimeSpent"), $langs->trans(
"ConfirmDeleteATimeSpent"),
"confirm_deleteline",
'',
'', 1);
1263 $parameters = array(
'formConfirm' => $formconfirm,
"projectstatic" => $projectstatic,
"withproject" => $withproject);
1264 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1265 if (empty($reshook)) {
1266 $formconfirm .= $hookmanager->resPrint;
1267 } elseif ($reshook > 0) {
1268 $formconfirm = $hookmanager->resPrint;
1275 $arrayfields = array();
1276 $arrayfields[
't.element_date'] = array(
'label'=>$langs->trans(
"Date"),
'checked'=>1);
1277 $arrayfields[
'p.fk_soc'] = array(
'label'=>$langs->trans(
"ThirdParty"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1',
'checked'=>1);
1278 $arrayfields[
's.name_alias'] = array(
'label'=>$langs->trans(
"AliasNameShort"),
'type'=>
'integer:Societe:/societe/class/societe.class.php:1');
1279 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1280 if (! empty($allprojectforuser)) {
1281 $arrayfields[
'p.project_ref'] = [
'label' => $langs->trans(
'RefProject'),
'checked' => 1];
1282 $arrayfields[
'p.project_label'] = [
'label' => $langs->trans(
'ProjectLabel'),
'checked' => 1];
1284 $arrayfields[
't.element_ref'] = array(
'label'=>$langs->trans(
"RefTask"),
'checked'=>1);
1285 $arrayfields[
't.element_label'] = array(
'label'=>$langs->trans(
"LabelTask"),
'checked'=>1);
1287 $arrayfields[
'author'] = array(
'label' => $langs->trans(
"By"),
'checked' => 1);
1288 $arrayfields[
't.note'] = array(
'label' => $langs->trans(
"Note"),
'checked' => 1);
1289 if (isModEnabled(
'service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1290 $arrayfields[
't.fk_product'] = array(
'label' => $langs->trans(
"Product"),
'checked' => 1);
1292 $arrayfields[
't.element_duration'] = array(
'label'=>$langs->trans(
"Duration"),
'checked'=>1);
1293 $arrayfields[
'value'] = array(
'label'=>$langs->trans(
"Value"),
'checked'=>1,
'enabled'=>isModEnabled(
"salaries"));
1294 $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));
1296 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1301 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1302 $param .=
'&contextpage=' . urlencode($contextpage);
1304 if ($limit > 0 && $limit != $conf->liste_limit) {
1305 $param .=
'&limit='.((int) $limit);
1307 if ($search_month > 0) {
1308 $param .=
'&search_month=' . urlencode($search_month);
1310 if ($search_year > 0) {
1311 $param .=
'&search_year=' . urlencode($search_year);
1313 if (!empty($search_user)) {
1314 $param .=
'&search_user='.urlencode($search_user);
1316 if ($search_task_ref !=
'') {
1317 $param .=
'&search_task_ref=' . urlencode($search_task_ref);
1319 if ($search_company !=
'') {
1320 $param .=
'&$search_company=' . urlencode($search_company);
1322 if ($search_company_alias !=
'') {
1323 $param .=
'&$search_company_alias=' . urlencode($search_company_alias);
1325 if ($search_project_ref !=
'') {
1326 $param .=
'&$search_project_ref=' . urlencode($search_project_ref);
1328 if ($search_project_label !=
'') {
1329 $param .=
'&$search_project_label=' . urlencode($search_project_label);
1331 if ($search_task_label !=
'') {
1332 $param .=
'&search_task_label=' . urlencode($search_task_label);
1334 if ($search_note !=
'') {
1335 $param .=
'&search_note=' . urlencode($search_note);
1337 if ($search_duration !=
'') {
1338 $param .=
'&search_field2=' . urlencode($search_duration);
1340 if ($optioncss !=
'') {
1341 $param .=
'&optioncss=' . urlencode($optioncss);
1343 if ($search_date_startday) {
1344 $param .=
'&search_date_startday=' . urlencode($search_date_startday);
1346 if ($search_date_startmonth) {
1347 $param .=
'&search_date_startmonth=' . urlencode($search_date_startmonth);
1349 if ($search_date_startyear) {
1350 $param .=
'&search_date_startyear=' . urlencode($search_date_startyear);
1352 if ($search_date_endday) {
1353 $param .=
'&search_date_endday=' . urlencode($search_date_endday);
1355 if ($search_date_endmonth) {
1356 $param .=
'&search_date_endmonth=' . urlencode($search_date_endmonth);
1358 if ($search_date_endyear) {
1359 $param .=
'&search_date_endyear=' . urlencode($search_date_endyear);
1361 if ($search_timespent_starthour) {
1362 $param .=
'&search_timespent_duration_starthour=' . urlencode($search_timespent_starthour);
1364 if ($search_timespent_startmin) {
1365 $param .=
'&search_timespent_duration_startmin=' . urlencode($search_timespent_startmin);
1367 if ($search_timespent_endhour) {
1368 $param .=
'&search_timespent_duration_endhour=' . urlencode($search_timespent_endhour);
1370 if ($search_timespent_endmin) {
1371 $param .=
'&search_timespent_duration_endmin=' . urlencode($search_timespent_endmin);
1379 $param .=
'&id=' . urlencode($id);
1382 $param .=
'&projectid=' . urlencode($projectid);
1385 $param .=
'&withproject=' . urlencode($withproject);
1388 $parameters = array();
1389 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1390 $param .= $hookmanager->resPrint;
1392 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
1393 if ($optioncss !=
'') {
1394 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1396 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
1397 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1398 if ($action ==
'editline') {
1399 print
'<input type="hidden" name="action" value="updateline">';
1400 } elseif ($action ==
'splitline') {
1401 print
'<input type="hidden" name="action" value="updatesplitline">';
1402 } elseif ($action ==
'createtime' && $user->rights->projet->time) {
1403 print
'<input type="hidden" name="action" value="addtimespent">';
1404 } elseif ($massaction ==
'generateinvoice' && $user->hasRight(
'facture',
'creer')) {
1405 print
'<input type="hidden" name="action" value="confirm_generateinvoice">';
1406 } elseif ($massaction ==
'generateinter' && $user->hasRight(
'ficheinter',
'creer')) {
1407 print
'<input type="hidden" name="action" value="confirm_generateinter">';
1409 print
'<input type="hidden" name="action" value="list">';
1411 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1412 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1414 print
'<input type="hidden" name="id" value="' . $id .
'">';
1415 print
'<input type="hidden" name="projectid" value="' . $projectidforalltimes .
'">';
1416 print
'<input type="hidden" name="withproject" value="' . $withproject .
'">';
1417 print
'<input type="hidden" name="tab" value="' . $tab .
'">';
1418 print
'<input type="hidden" name="page_y" value="">';
1421 if ($massaction ==
'generateinvoice') {
1422 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1423 print
'<table class="noborder centerpercent">';
1425 print
'<td class="titlefield">';
1426 print $langs->trans(
'DateInvoice');
1429 print $form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1435 print $langs->trans(
'Mode');
1439 'onelineperuser' =>
'OneLinePerUser',
1440 'onelinepertask' =>
'OneLinePerTask',
1441 'onelineperperiod' =>
'OneLinePerTimeSpentLine',
1443 print $form->selectarray(
'generateinvoicemode', $tmparray,
'onelineperuser', 0, 0, 0,
'', 1);
1444 print
"\n" .
'<script type="text/javascript">';
1446 $(document).ready(function () {
1447 setDetailVisibility();
1448 $("#generateinvoicemode").change(function() {
1449 setDetailVisibility();
1451 function setDetailVisibility() {
1452 generateinvoicemode = $("#generateinvoicemode option:selected").val();
1453 if (generateinvoicemode=="onelineperperiod") {
1454 $("#detail_time_duration").show();
1456 $("#detail_time_duration").hide();
1461 print
'</script>' .
"\n";
1462 print
'<span style="display:none" id="detail_time_duration"><input type="checkbox" value="detail" name="detail_time_duration"/>' . $langs->trans(
'AddDetailDateAndDuration') .
'</span>';
1466 if (isModEnabled(
"service")) {
1469 print $langs->trans(
'ServiceToUseOnLines');
1472 $form->select_produits(
'',
'productid',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
1478 print
'<td class="titlefield">';
1479 print $langs->trans(
'InvoiceToUse');
1482 print $form->selectInvoice($projectstatic->thirdparty->id,
'',
'invoiceid', 24, 0, $langs->trans(
'NewInvoice'), 1, 0, 0,
'maxwidth500',
'',
'all');
1496 print
'<div class="center">';
1497 print
'<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs->trans(
'GenerateBill') .
'"> ';
1498 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1502 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateInvoice") .
'</div>';
1503 print
'<div class="center">';
1504 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1508 } elseif ($massaction ==
'generateinter') {
1510 print
'<input type="hidden" name="massaction" value="confirm_createinter">';
1512 if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
1514 print
'<table class="noborder centpercent">';
1516 print
'<td class="titlefield">';
1517 print
img_picto(
'',
'intervention',
'class="pictofixedwidth"') . $langs->trans(
'InterToUse');
1521 print $forminter->select_interventions($projectstatic->thirdparty->id,
'',
'interid', 24, $langs->trans(
'NewInter'),
true);
1526 print
'<div class="center">';
1527 print
'<input type="submit" class="button" id="createinter" name="createinter" value="' . $langs->trans(
'GenerateInter') .
'"> ';
1528 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1532 print
'<div class="warning">' . $langs->trans(
"ThirdPartyRequiredToGenerateIntervention") .
'</div>';
1533 print
'<div class="center">';
1534 print
'<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
1541 $parameters = array(
1542 'toselect' => $toselect,
1543 'uploaddir' => isset($uploaddir) ? $uploaddir : null
1546 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
1550 print $hookmanager->resPrint;
1558 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1559 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1561 $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,";
1562 $sql .=
" t.fk_product,";
1563 $sql .=
" pt.ref, pt.label, pt.fk_projet,";
1564 $sql .=
" u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
1565 $sql .=
" il.fk_facture as invoice_id, inv.fk_statut,";
1566 $sql .=
" p.fk_soc,s.name_alias,";
1567 $sql .=
" t.invoice_line_id";
1569 $parameters = array();
1570 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
1571 $sql .= $hookmanager->resPrint;
1572 $sql = preg_replace(
'/,\s*$/',
'', $sql);
1576 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1577 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facturedet as il ON il.rowid = t.invoice_line_id";
1578 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as inv ON inv.rowid = il.fk_facture";
1579 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as prod ON prod.rowid = t.fk_product";
1580 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet_task as pt ON pt.rowid = t.fk_element";
1581 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = pt.fk_projet";
1582 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON t.fk_user = u.rowid";
1583 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
1586 $parameters = array();
1587 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
1588 $sql .= $hookmanager->resPrint;
1589 $sql .=
" WHERE elementtype = 'task'";
1590 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1591 if (empty($projectidforalltimes) && empty($allprojectforuser)) {
1593 $sql .=
" AND t.fk_element =".((int) $object->id);
1594 } elseif (!empty($projectidforalltimes)) {
1596 $sql .=
" AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) .
")";
1597 } elseif (!empty($allprojectforuser)) {
1599 if (empty($search_user)) {
1600 $search_user = $user->id;
1602 if ($search_user > 0) $sql .=
" AND t.fk_user = " . ((int) $search_user);
1608 if ($search_task_ref) {
1611 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1612 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1614 if ($search_company) {
1617 if ($search_company_alias) {
1621 if ($search_project_ref) {
1624 if ($search_project_label) {
1627 if ($search_task_label) {
1630 if ($search_user > 0) {
1633 if (!empty($search_product_ref)) {
1636 if ($search_valuebilled ==
'1') {
1637 $sql .=
' AND t.invoice_id > 0';
1639 if ($search_valuebilled ==
'0') {
1640 $sql .=
' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
1643 if ($search_date_start) {
1644 $sql .=
" AND t.element_date >= '".$db->idate($search_date_start).
"'";
1646 if ($search_date_end) {
1647 $sql .=
" AND t.element_date <= '".$db->idate($search_date_end).
"'";
1650 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1651 if ($search_timespent_starthour || $search_timespent_startmin) {
1652 $timespent_duration_start = $search_timespent_starthour * 60 * 60;
1653 $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60;
1654 $sql .=
" AND t.element_duration >= " . $timespent_duration_start;
1657 if ($search_timespent_endhour || $search_timespent_endmin) {
1658 $timespent_duration_end = $search_timespent_endhour * 60 * 60;
1659 $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60;
1660 $sql .=
" AND t.element_duration <= " . $timespent_duration_end;
1664 $sql .=
dolSqlDateFilter(
't.element_datehour', $search_day, $search_month, $search_year);
1667 $parameters = array();
1668 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1669 $sql .= $hookmanager->resPrint;
1672 $nbtotalofrecords =
'';
1675 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1676 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1677 $resql = $db->query($sqlforcount);
1679 $objforcount = $db->fetch_object($resql);
1680 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1685 if (($page * $limit) > $nbtotalofrecords) {
1693 $sql .= $db->order($sortfield, $sortorder);
1695 $sql .= $db->plimit($limit + 1, $offset);
1698 $resql = $db->query($sql);
1704 $num = $db->num_rows($resql);
1707 if (!empty($projectidforalltimes)) {
1708 print
'<!-- List of time spent for project -->' .
"\n";
1710 $title = $langs->trans(
"ListTaskTimeUserProject");
1712 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1714 print
'<!-- List of time spent -->' .
"\n";
1716 $title = $langs->trans(
"ListTaskTimeForTask");
1718 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'clock', 0, $linktocreatetime,
'', $limit, 0, 0, 1);
1723 $row = $db->fetch_object($resql);
1735 if ($action ==
'createtime' && $user->hasRight(
'projet',
'time')) {
1736 print
'<!-- table to add time spent -->' .
"\n";
1738 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
1741 print
'<div class="div-table-responsive-no-min">';
1742 print
'<table class="noborder nohover centpercent">';
1744 print
'<tr class="liste_titre">';
1745 print
'<td>' . $langs->trans(
"Date") .
'</td>';
1746 if (!empty($allprojectforuser)) {
1747 print
'<td>' . $langs->trans(
"Project") .
'</td>';
1750 print
'<td>' . $langs->trans(
"Task") .
'</td>';
1752 print
'<td>' . $langs->trans(
"By") .
'</td>';
1753 print
'<td>' . $langs->trans(
"Note") .
'</td>';
1754 print
'<td>' . $langs->trans(
"NewTimeSpent") .
'</td>';
1755 print
'<td>' . $langs->trans(
"ProgressDeclared") .
'</td>';
1756 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1759 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1760 print
'<td>'.$langs->trans(
"Product").
'</td>';
1764 $parameters = array(
'mode' =>
'create');
1765 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1766 print $hookmanager->resPrint;
1770 print
'<tr class="oddeven nohover">';
1773 print
'<td class="maxwidthonsmartphone">';
1775 print $form->selectDate($newdate,
'time', ($conf->browser->layout ==
'phone' ? 2 : 1), 1, 2,
"timespent_date", 1, 0);
1778 if (!empty($allprojectforuser)) {
1787 print
'<td class="maxwidthonsmartphone">';
1788 $nboftasks = $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int'),
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'progress');
1793 print
'<td class="maxwidthonsmartphone nowraponall">';
1794 $contactsofproject = $projectstatic->getListContactId(
'internal');
1795 if (count($contactsofproject) > 0) {
1796 print
img_object(
'',
'user',
'class="hideonsmartphone"');
1797 if (in_array($user->id, $contactsofproject)) {
1798 $userid = $user->id;
1800 $userid = $contactsofproject[0];
1803 if ($projectstatic->public) {
1804 $contactsofproject = array();
1806 print $form->select_dolusers((
GETPOST(
'userid',
'int') ?
GETPOST(
'userid',
'int') : $userid),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 0, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth150imp maxwidth200');
1809 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) .
' ' . $langs->trans(
'FirstAddRessourceToAllocateTime');
1816 print
'<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 .
'">' . (
GETPOST(
'timespent_note') ?
GETPOST(
'timespent_note') :
'') .
'</textarea>';
1820 print
'<td class="nowraponall">';
1821 $durationtouse = (
GETPOST(
'timespent_duration') ?
GETPOST(
'timespent_duration') :
'');
1822 if (GETPOSTISSET(
'timespent_durationhour') || GETPOSTISSET(
'timespent_durationmin')) {
1823 $durationtouse = ((int)
GETPOST(
'timespent_durationhour') * 3600 + (int)
GETPOST(
'timespent_durationmin') * 60);
1825 print $form->select_duration(
'timespent_duration', $durationtouse, 0,
'text');
1829 print
'<td class="nowrap">';
1830 print $formother->select_percent(
GETPOST(
'progress') ?
GETPOST(
'progress') : $object->progress,
'progress', 0, 5, 0, 100, 1);
1834 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1838 if (isModEnabled(
"service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
1839 print
'<td class="nowraponall">';
1841 print $form->select_produits(
'',
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 1, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth150', 0,
'',
null, 1);
1847 $parameters = array(
'mode' =>
'create');
1848 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1849 print $hookmanager->resPrint;
1851 print
'<td class="center">';
1852 $form->buttonsSaveCancel();
1853 print
'<input type="submit" name="save" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-add reposition" value="'.$langs->trans(
"Add").
'">';
1854 print
'<input type="submit" name="cancel" class="button buttongen smallpaddingimp marginleftonly margintoponlyshort marginbottomonlyshort button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1863 $moreforfilter =
'';
1865 $parameters = array();
1866 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1867 if (empty($reshook)) {
1868 $moreforfilter .= $hookmanager->resPrint;
1870 $moreforfilter = $hookmanager->resPrint;
1873 if (!empty($moreforfilter)) {
1874 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1875 print $moreforfilter;
1879 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1880 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1881 $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1883 print
'<div class="div-table-responsive">';
1884 print
'<table class="tagtable nobottomiftotal liste' . ($moreforfilter ?
" listwithfilterbefore" :
"") .
'">' .
"\n";
1888 print
'<tr class="liste_titre_filter">';
1891 print
'<td class="liste_titre center">';
1892 $searchpicto = $form->showFilterButtons(
'left');
1897 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
1898 print
'<td class="liste_titre left">';
1899 print
'<div class="nowrap">';
1900 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1902 print
'<div class="nowrap">';
1903 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1908 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1909 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="' .
dol_escape_htmltag($search_company) .
'"></td>';
1913 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1914 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="' .
dol_escape_htmltag($search_company_alias) .
'"></td>';
1917 if (!empty($allprojectforuser)) {
1918 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
1919 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="' .
dol_escape_htmltag($search_project_ref) .
'"></td>';
1921 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
1922 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="' .
dol_escape_htmltag($search_project_label) .
'"></td>';
1926 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
1927 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
1928 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).
'"></td>';
1930 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
1931 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
1935 if (!empty($arrayfields[
'author'][
'checked'])) {
1936 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>';
1939 if (!empty($arrayfields[
't.note'][
'checked'])) {
1940 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="' .
dol_escape_htmltag($search_note) .
'"></td>';
1943 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
1945 print
'<td class="liste_titre right">';
1947 $durationtouse_start =
'';
1948 if ($search_timespent_starthour || $search_timespent_startmin) {
1949 $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
1951 print
'<div class="nowraponall">' . $langs->trans(
'from') .
' ';
1952 print $form->select_duration(
'search_timespent_duration_start', $durationtouse_start, 0,
'text', 0, 1);
1955 $durationtouse_end =
'';
1956 if ($search_timespent_endhour || $search_timespent_endmin) {
1957 $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
1959 print
'<div class="nowraponall">' . $langs->trans(
'at') .
' ';
1960 print $form->select_duration(
'search_timespent_duration_end', $durationtouse_end, 0,
'text', 0, 1);
1966 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
1967 print
'<td class="liste_titre right"></td>';
1970 if (!empty($arrayfields[
'value'][
'checked'])) {
1971 print
'<td class="liste_titre"></td>';
1974 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
1975 print
'<td class="liste_titre center">' . $form->selectyesno(
'search_valuebilled', $search_valuebilled, 1,
false, 1) .
'</td>';
1983 $parameters = array(
'arrayfields' => $arrayfields);
1984 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1985 print $hookmanager->resPrint;
1988 print
'<td class="liste_titre center">';
1989 $searchpicto = $form->showFilterButtons();
1993 print
'</tr>' .
"\n";
1995 $totalarray = array();
1996 $totalarray[
'nbfield'] = 0;
2000 print
'<tr class="liste_titre">';
2002 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
2003 $totalarray[
'nbfield']++;
2005 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2006 print_liste_field_titre($arrayfields[
't.element_date'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2007 $totalarray[
'nbfield']++;
2009 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2010 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_date,t.element_datehour,t.rowid',
'', $param,
'', $sortfield, $sortorder);
2011 $totalarray[
'nbfield']++;
2013 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2014 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2015 $totalarray[
'nbfield']++;
2017 if (!empty($allprojectforuser)) {
2018 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2020 $totalarray[
'nbfield']++;
2022 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2023 print_liste_field_titre(
"ProjectLabel", $_SERVER[
'PHP_SELF'],
'p.title',
'', $param,
'', $sortfield, $sortorder);
2024 $totalarray[
'nbfield']++;
2027 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2028 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2029 print_liste_field_titre($arrayfields[
't.element_ref'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.ref',
'', $param,
'', $sortfield, $sortorder);
2030 $totalarray[
'nbfield']++;
2032 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2033 print_liste_field_titre($arrayfields[
't.element_label'][
'label'], $_SERVER[
'PHP_SELF'],
'pt.label',
'', $param,
'', $sortfield, $sortorder);
2034 $totalarray[
'nbfield']++;
2037 if (!empty($arrayfields[
'author'][
'checked'])) {
2038 print_liste_field_titre($arrayfields[
'author'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
2039 $totalarray[
'nbfield']++;
2041 if (!empty($arrayfields[
't.note'][
'checked'])) {
2042 print_liste_field_titre($arrayfields[
't.note'][
'label'], $_SERVER[
'PHP_SELF'],
't.note',
'', $param,
'', $sortfield, $sortorder);
2043 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2046 print_liste_field_titre($arrayfields[
't.element_duration'][
'label'], $_SERVER[
'PHP_SELF'],
't.element_duration',
'', $param,
'', $sortfield, $sortorder,
'right ');
2047 $totalarray[
'nbfield']++;
2049 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2050 print_liste_field_titre($arrayfields[
't.fk_product'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_product',
'', $param,
'', $sortfield, $sortorder);
2051 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'value'][
'checked'])) {
2055 print_liste_field_titre($arrayfields[
'value'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2056 $totalarray[
'nbfield']++;
2058 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2059 print_liste_field_titre($arrayfields[
'valuebilled'][
'label'], $_SERVER[
'PHP_SELF'],
'il.total_ht',
'', $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
"SelectLinesOfTimeSpentToInvoice"));
2060 $totalarray[
'nbfield']++;
2067 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
2068 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
2069 print $hookmanager->resPrint;
2071 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'width="80"', $sortfield, $sortorder,
'center maxwidthsearch ');
2072 $totalarray[
'nbfield']++;
2076 $tasktmp =
new Task($db);
2077 $tmpinvoice =
new Facture($db);
2083 $savnbfield = $totalarray[
'nbfield'];
2084 $totalarray = array();
2085 $totalarray[
'nbfield'] = 0;
2087 foreach ($tasks as $task_time) {
2092 $date1 = $db->jdate($task_time->element_date);
2093 $date2 = $db->jdate($task_time->element_datehour);
2097 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
2101 print
'<td class="center nowraponall">';
2102 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2103 print
'<input type="hidden" name="lineid" value="' .
GETPOST(
'lineid',
'int') .
'">';
2104 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2106 print
'<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2107 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2108 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2111 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' . newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2112 print
img_split(
'',
'class="pictofixedwidth"');
2116 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' :
'').
'">';
2117 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2120 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' :
'').
'">';
2121 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2124 if ($massactionbutton || $massaction) {
2126 if (in_array($task_time->rowid, $arrayofselected)) {
2130 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2136 $totalarray[
'nbfield']++;
2140 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2141 print
'<td class="nowrap">';
2142 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2143 if (empty($task_time->element_date_withhour)) {
2144 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2146 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2149 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2153 $totalarray[
'nbfield']++;
2158 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2159 print
'<td class="tdoverflowmax125">';
2160 if ($task_time->fk_soc > 0) {
2161 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2162 $tmpsociete =
new Societe($db);
2163 $tmpsociete->fetch($task_time->fk_soc);
2164 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2166 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2168 print $tmpsociete->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2172 $totalarray[
'nbfield']++;
2177 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2178 if ($task_time->fk_soc > 0) {
2179 if (empty($conf->cache[
'thridparty'][$task_time->fk_soc])) {
2180 $tmpsociete =
new Societe($db);
2181 $tmpsociete->fetch($task_time->fk_soc);
2182 $conf->cache[
'thridparty'][$task_time->fk_soc] = $tmpsociete;
2184 $tmpsociete = $conf->cache[
'thridparty'][$task_time->fk_soc];
2186 $valtoshow = $tmpsociete->name_alias;
2188 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).
'">';
2192 $totalarray[
'nbfield']++;
2197 if (!empty($allprojectforuser)) {
2198 if (!empty($arrayfields[
'p.project_ref'][
'checked'])) {
2199 print
'<td class="nowraponall">';
2200 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2201 $tmpproject =
new Project($db);
2202 $tmpproject->fetch($task_time->fk_projet);
2203 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2205 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2207 print $tmpproject->getNomUrl(1);
2210 $totalarray[
'nbfield']++;
2213 if (!empty($arrayfields[
'p.project_label'][
'checked'])) {
2214 if (empty($conf->cache[
'project'][$task_time->fk_projet])) {
2215 $tmpproject =
new Project($db);
2216 $tmpproject->fetch($task_time->fk_projet);
2217 $conf->cache[
'project'][$task_time->fk_projet] = $tmpproject;
2219 $tmpproject = $conf->cache[
'project'][$task_time->fk_projet];
2221 print
'<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).
'">';
2225 $totalarray[
'nbfield']++;
2231 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2232 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2233 print
'<td class="nowrap">';
2234 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2235 $formproject->selectTasks(-1,
GETPOST(
'taskid',
'int') ?
GETPOST(
'taskid',
'int') : $task_time->fk_element,
'taskid', 0, 0, 1, 1, 0, 0,
'maxwidth300', $projectstatic->id,
'');
2237 $tasktmp->id = $task_time->fk_element;
2238 $tasktmp->ref = $task_time->ref;
2239 $tasktmp->label = $task_time->label;
2240 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2244 $totalarray[
'nbfield']++;
2247 } elseif ($action !==
'createtime') {
2248 print
'<input type="hidden" name="taskid" value="' . $id .
'">';
2252 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2253 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2254 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2258 $totalarray[
'nbfield']++;
2264 if (!empty($arrayfields[
'author'][
'checked'])) {
2265 print
'<td class="tdoverflowmax100">';
2266 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2267 if (empty($object->id)) {
2268 $object->fetch($id);
2270 $contactsoftask = $object->getListContactId(
'internal');
2271 if (!in_array($task_time->fk_user, $contactsoftask)) {
2272 $contactsoftask[] = $task_time->fk_user;
2274 if (count($contactsoftask) > 0) {
2275 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2276 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask,
'0', 0, 0,
'', 0,
'',
'maxwidth200');
2278 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2281 $userstatic->id = $task_time->fk_user;
2282 $userstatic->lastname = $task_time->lastname;
2283 $userstatic->firstname = $task_time->firstname;
2284 $userstatic->photo = $task_time->photo;
2285 $userstatic->statut = $task_time->user_status;
2286 print $userstatic->getNomUrl(-1);
2290 $totalarray[
'nbfield']++;
2295 if (!empty($arrayfields[
't.note'][
'checked'])) {
2296 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2297 print
'<td class="small">';
2298 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2301 print
'<td class="small tdoverflowmax150 classfortooltip" title="'.dol_string_onlythesehtmltags(
dol_htmlentitiesbr($task_time->note)).
'">';
2306 $totalarray[
'nbfield']++;
2308 } elseif ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2309 print
'<input type="hidden" name="timespent_note_line" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2313 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2314 print
'<td class="right nowraponall">';
2315 if ($action ==
'editline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2316 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2317 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2323 $totalarray[
'nbfield']++;
2326 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.element_duration';
2328 if (empty($totalarray[
'val'][
't.element_duration'])) {
2329 $totalarray[
'val'][
't.element_duration'] = $task_time->element_duration;
2331 $totalarray[
'val'][
't.element_duration'] += $task_time->element_duration;
2334 $totalarray[
'totaldurationfield'] = $totalarray[
'nbfield'];
2336 if (empty($totalarray[
'totalduration'])) {
2337 $totalarray[
'totalduration'] = $task_time->element_duration;
2339 $totalarray[
'totalduration'] += $task_time->element_duration;
2344 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2345 print
'<td class="nowraponall tdoverflowmax125">';
2346 if ($action ==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2347 $form->select_produits($task_time->fk_product,
'fk_product',
'1', 0, $projectstatic->thirdparty->price_level, 1, 2,
'', 0, array(), $projectstatic->thirdparty->id,
'None', 0,
'maxwidth500');
2348 } elseif (!empty($task_time->fk_product)) {
2350 $resultFetch = $product->fetch($task_time->fk_product);
2351 if ($resultFetch < 0) {
2354 print $product->getNomUrl(1);
2359 $totalarray[
'nbfield']++;
2364 if (!empty($arrayfields[
'value'][
'checked'])) {
2365 $langs->load(
"salaries");
2366 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2368 print
'<td class="nowraponall right">';
2369 print
'<span class="amount" title="' . $langs->trans(
"THM") .
': ' .
price($task_time->thm) .
'">';
2370 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2374 $totalarray[
'nbfield']++;
2377 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'value';
2379 if (empty($totalarray[
'val'][
'value'])) {
2380 $totalarray[
'val'][
'value'] = $value;
2382 $totalarray[
'val'][
'value'] += $value;
2385 $totalarray[
'totalvaluefield'] = $totalarray[
'nbfield'];
2387 if (empty($totalarray[
'totalvalue'])) {
2388 $totalarray[
'totalvalue'] = $value;
2390 $totalarray[
'totalvalue'] += $value;
2395 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2396 print
'<td class="center">';
2397 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
2398 if ($projectstatic->usage_bill_time) {
2399 if ($task_time->invoice_id) {
2400 $result = $tmpinvoice->fetch($task_time->invoice_id);
2402 if ($action==
'editline' && $_GET[
'lineid'] == $task_time->rowid) {
2403 print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id,
'invoiceid',
'invoicelineid',
'maxwidth500', array(
'p.rowid'=>$projectstatic->id));
2405 print $tmpinvoice->getNomUrl(1);
2406 if (!empty($task_time->invoice_line_id)) {
2408 $invoiceLine->fetch($task_time->invoice_line_id);
2409 if (!empty($invoiceLine->id)) {
2410 print
'<br>'.$langs->trans(
'Qty').
':'.$invoiceLine->qty;
2411 print
' '.$langs->trans(
'TotalHT').
':'.
price($invoiceLine->total_ht);
2417 print $langs->trans(
"No");
2420 print
'<span class="opacitymedium">' . $langs->trans(
"NA") .
'</span>';
2425 $totalarray[
'nbfield']++;
2435 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'i' => $i,
'totalarray' => &$totalarray);
2436 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2437 print $hookmanager->resPrint;
2441 print
'<td class="center nowraponall">';
2442 if (($action ==
'editline' || $action ==
'splitline') &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2443 print
'<input type="hidden" name="lineid" value="'.GETPOST(
'lineid',
'int').
'">';
2444 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save small" name="save" value="'.$langs->trans(
"Save").
'">';
2446 print
'<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2447 } elseif ($user->hasRight(
'projet',
'time') || $user->hasRight(
'projet',
'all',
'creer')) {
2448 if (in_array($task_time->fk_user, $childids) || $user->hasRight(
'projet',
'all',
'creer')) {
2451 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=splitline&token=' . newToken() .
'&lineid=' . $task_time->rowid . $param . ((empty($id) || $tab ==
'timespent') ?
'&tab=timespent' :
'') .
'">';
2452 print
img_split(
'',
'class="pictofixedwidth"');
2456 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' :
'').
'">';
2457 print
img_edit(
'default', 0,
'class="pictofixedwidth paddingleft"');
2460 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' :
'').
'">';
2461 print
img_delete(
'default',
'class="pictodelete paddingleft"');
2464 if ($massactionbutton || $massaction) {
2466 if (in_array($task_time->rowid, $arrayofselected)) {
2470 print
'<input id="cb' . $task_time->rowid .
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="' . $task_time->rowid .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
2476 $totalarray[
'nbfield']++;
2485 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2486 print
'<!-- first line -->';
2487 print
'<tr class="oddeven">';
2490 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2491 print
'<td class="nowrap">';
2492 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2493 if (empty($task_time->element_date_withhour)) {
2494 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 3, 3, 2,
"timespent_date", 1, 0);
2496 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline', 1, 1, 2,
"timespent_date", 1, 0);
2499 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2505 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2506 print
'<td class="nowrap">';
2511 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2512 print
'<td class="nowrap">';
2517 if (!empty($allprojectforuser)) {
2518 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2519 print
'<td class="nowrap">';
2525 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2526 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2527 print
'<td class="nowrap">';
2528 $tasktmp->id = $task_time->fk_element;
2529 $tasktmp->ref = $task_time->ref;
2530 $tasktmp->label = $task_time->label;
2531 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2537 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2538 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2539 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($task_time->label).
'">';
2546 if (!empty($arrayfields[
'author'][
'checked'])) {
2547 print
'<td class="nowraponall">';
2548 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2549 if (empty($object->id)) {
2550 $object->fetch($id);
2552 $contactsoftask = $object->getListContactId(
'internal');
2553 if (!in_array($task_time->fk_user, $contactsoftask)) {
2554 $contactsoftask[] = $task_time->fk_user;
2556 if (count($contactsoftask) > 0) {
2557 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2558 print $form->select_dolusers($task_time->fk_user,
'userid_line', 0,
'', 0,
'', $contactsoftask);
2560 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2563 $userstatic->id = $task_time->fk_user;
2564 $userstatic->lastname = $task_time->lastname;
2565 $userstatic->firstname = $task_time->firstname;
2566 $userstatic->photo = $task_time->photo;
2567 $userstatic->statut = $task_time->user_status;
2568 print $userstatic->getNomUrl(-1);
2574 if (!empty($arrayfields[
't.note'][
'checked'])) {
2575 print
'<td class="tdoverflowmax300">';
2576 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2577 print
'<textarea name="timespent_note_line" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2582 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2583 print
'<input type="hidden" name="timespent_note_line" rows="' . ROWS_1 .
'" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2587 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2588 print
'<td class="right">';
2589 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2590 print
'<input type="hidden" name="old_duration" value="'.$task_time->element_duration.
'">';
2591 print $form->select_duration(
'new_duration', $task_time->element_duration, 0,
'text');
2599 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2600 print
'<td class="nowraponall tdoverflowmax125">';
2605 if (!empty($arrayfields[
'value'][
'checked'])) {
2606 print
'<td class="right">';
2607 print
'<span class="amount">';
2608 $value =
price2num($task_time->thm * $task_time->element_duration / 3600,
'MT', 1);
2609 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2615 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2616 print
'<td class="right">';
2617 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2618 if (isset($task_time->total_ht)) {
2619 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2630 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split1');
2631 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2632 print $hookmanager->resPrint;
2635 print
'<td class="center nowraponall">';
2643 print
'<!-- second line --><tr class="oddeven">';
2646 if (!empty($arrayfields[
't.element_date'][
'checked'])) {
2647 print
'<td class="nowrap">';
2648 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2649 if (empty($task_time->element_date_withhour)) {
2650 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 3, 3, 2,
"timespent_date", 1, 0);
2652 print $form->selectDate(($date2 ? $date2 : $date1),
'timeline_2', 1, 1, 2,
"timespent_date", 1, 0);
2655 print
dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ?
'dayhour' :
'day'));
2661 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
2662 print
'<td class="nowrap">';
2667 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2668 print
'<td class="nowrap">';
2673 if (!empty($allprojectforuser)) {
2674 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2675 print
'<td class="nowrap">';
2681 if (!empty($arrayfields[
't.element_ref'][
'checked'])) {
2682 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2683 print
'<td class="nowrap">';
2684 $tasktmp->id = $task_time->fk_element;
2685 $tasktmp->ref = $task_time->ref;
2686 $tasktmp->label = $task_time->label;
2687 print $tasktmp->getNomUrl(1,
'withproject',
'time');
2693 if (!empty($arrayfields[
't.element_label'][
'checked'])) {
2694 if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) {
2695 print
'<td class="nowrap">';
2702 if (!empty($arrayfields[
'author'][
'checked'])) {
2703 print
'<td class="nowraponall">';
2704 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2705 if (empty($object->id)) {
2706 $object->fetch($id);
2708 $contactsoftask = $object->getListContactId(
'internal');
2709 if (!in_array($task_time->fk_user, $contactsoftask)) {
2710 $contactsoftask[] = $task_time->fk_user;
2712 if (count($contactsoftask) > 0) {
2713 print
img_object(
'',
'user',
'class="hideonsmartphone"');
2714 print $form->select_dolusers($task_time->fk_user,
'userid_line_2', 0,
'', 0,
'', $contactsoftask);
2716 print
img_error($langs->trans(
'FirstAddRessourceToAllocateTime')) . $langs->trans(
'FirstAddRessourceToAllocateTime');
2719 $userstatic->id = $task_time->fk_user;
2720 $userstatic->lastname = $task_time->lastname;
2721 $userstatic->firstname = $task_time->firstname;
2722 $userstatic->photo = $task_time->photo;
2723 $userstatic->statut = $task_time->user_status;
2724 print $userstatic->getNomUrl(-1);
2730 if (!empty($arrayfields[
't.note'][
'checked'])) {
2731 print
'<td class="small tdoverflowmax300"">';
2732 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2733 print
'<textarea name="timespent_note_line_2" width="95%" rows="' . ROWS_1 .
'">' .
dol_escape_htmltag($task_time->note, 0, 1) .
'</textarea>';
2738 } elseif ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2739 print
'<input type="hidden" name="timespent_note_line_2" value="' .
dol_escape_htmltag($task_time->note, 0, 1) .
'">';
2743 if (!empty($arrayfields[
't.element_duration'][
'checked'])) {
2744 print
'<td class="right">';
2745 if ($action ==
'splitline' &&
GETPOST(
'lineid',
'int') == $task_time->rowid) {
2746 print
'<input type="hidden" name="old_duration_2" value="0">';
2747 print $form->select_duration(
'new_duration_2', 0, 0,
'text');
2755 if (!empty($arrayfields[
't.fk_product'][
'checked'])) {
2756 print
'<td class="nowraponall tdoverflowmax125">';
2761 if (!empty($arrayfields[
'value'][
'checked'])) {
2762 print
'<td class="right">';
2763 print
'<span class="amount">';
2765 print
price($value, 1, $langs, 1, -1, -1, $conf->currency);
2771 if (!empty($arrayfields[
'valuebilled'][
'checked'])) {
2772 print
'<td class="right">';
2773 $valuebilled =
price2num($task_time->total_ht,
'', 1);
2774 if (isset($task_time->total_ht)) {
2775 print
'<span class="amount">';
2776 print
price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
2788 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $task_time,
'mode' =>
'split2');
2789 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2790 print $hookmanager->resPrint;
2793 print
'<td class="center nowraponall">';
2804 if (isset($totalarray[
'totaldurationfield']) || isset($totalarray[
'totalvaluefield'])) {
2805 print
'<tr class="liste_total">';
2807 while ($i < $totalarray[
'nbfield']) {
2810 if ($num < $limit && empty($offset)) {
2811 print
'<td class="left">' . $langs->trans(
"Total") .
'</td>';
2813 print
'<td class="left">'.$form->textwithpicto($langs->trans(
"Total"), $langs->trans(
"Totalforthispage")).
'</td>';
2815 } elseif ($totalarray[
'totaldurationfield'] == $i) {
2816 print
'<td class="right">' .
convertSecondToTime($totalarray[
'totalduration'],
'allhourmin') .
'</td>';
2817 } elseif ($totalarray[
'totalvaluefield'] == $i) {
2818 print
'<td class="right">' .
price($totalarray[
'totalvalue']) .
'</td>';
2827 if (!count($tasks)) {
2828 $totalnboffields = 1;
2829 foreach ($arrayfields as $value) {
2830 if (!empty($value[
'checked'])) {
2834 print
'<tr class="oddeven"><td colspan="' . $totalnboffields .
'">';
2835 print
'<span class="opacitymedium">' . $langs->trans(
"None") .
'</span>';
2839 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2840 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2841 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 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.