28 require
"../../main.inc.php";
29 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
39 $langs->loadLangs(array(
'projects',
'users',
'companies'));
41 $action =
GETPOST(
'action',
'aZ09');
42 $mode =
GETPOST(
"mode",
'alpha');
44 $taskid =
GETPOST(
'taskid',
'int');
46 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'perweekcard';
49 if ($mode ==
'mine') {
55 $hookmanager->initHooks(array(
'timesheetperweekcard'));
68 $week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
73 $search_usertoprocessid =
GETPOST(
'search_usertoprocessid',
'int');
74 $search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
75 $search_task_label =
GETPOST(
'search_task_label',
'alpha');
76 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
77 $search_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
78 $search_declared_progress =
GETPOST(
'search_declared_progress',
'alpha');
80 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
81 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
85 $prev = $startdayarray;
86 $prev_year = $prev[
'prev_year'];
87 $prev_month = $prev[
'prev_month'];
88 $prev_day = $prev[
'prev_day'];
89 $first_day = $prev[
'first_day'];
90 $first_month = $prev[
'first_month'];
91 $first_year = $prev[
'first_year'];
92 $week = $prev[
'week'];
95 $next_year = $next[
'year'];
96 $next_month = $next[
'month'];
97 $next_day = $next[
'day'];
100 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
101 $firstdaytoshowgmt =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'gmt');
103 if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
104 $usertoprocess = $user;
105 $search_usertoprocessid = $usertoprocess->id;
106 } elseif ($search_usertoprocessid > 0) {
107 $usertoprocess =
new User($db);
108 $usertoprocess->fetch($search_usertoprocessid);
109 $search_usertoprocessid = $usertoprocess->id;
111 $usertoprocess =
new User($db);
114 $object =
new Task($db);
120 $extrafields->fetch_name_optionals_label($object->table_element);
123 $arrayfields = array();
132 $arrayfields[
't.planned_workload'] = array(
'label'=>
'PlannedWorkload',
'checked'=>1,
'enabled'=>1,
'position'=>5);
133 $arrayfields[
't.progress'] = array(
'label'=>
'ProgressDeclared',
'checked'=>1,
'enabled'=>1,
'position'=>10);
134 $arrayfields[
'timeconsumed'] = array(
'label'=>
'TimeConsumed',
'checked'=>1,
'enabled'=>1,
'position'=>15);
142 if (!empty($extrafields->attributes[
'projet_task'][
'label']) && is_array($extrafields->attributes[
'projet_task'][
'label']) && count($extrafields->attributes[
'projet_task'][
'label']) > 0) {
143 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
144 if (!empty($extrafields->attributes[
'projet_task'][
'list'][$key])) {
145 $arrayfields[
"efpt.".$key] = array(
'label'=>$extrafields->attributes[
'projet_task'][
'label'][$key],
'checked'=>(($extrafields->attributes[
'projet_task'][
'list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[
'projet_task'][
'pos'][$key],
'enabled'=>(abs((
int) $extrafields->attributes[
'projet_task'][
'list'][$key]) != 3 && $extrafields->attributes[
'projet_task'][
'perms'][$key]));
151 $search_array_options = array();
152 $search_array_options_project = $extrafields->getOptionalsFromPost(
'projet',
'',
'search_');
153 $search_array_options_task = $extrafields->getOptionalsFromPost(
'projet_task',
'',
'search_task_');
162 $parameters = array(
'id' => $id,
'taskid' => $taskid,
'projectid' => $projectid);
163 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
168 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
171 $search_usertoprocessid = $user->id;
172 $search_task_ref =
'';
173 $search_task_label =
'';
174 $search_project_ref =
'';
175 $search_thirdparty =
'';
176 $search_declared_progress =
'';
178 $search_array_options_project = array();
179 $search_array_options_task = array();
182 $usertoprocess = $user;
184 if (
GETPOST(
"button_search_x",
'alpha') ||
GETPOST(
"button_search.x",
'alpha') ||
GETPOST(
"button_search",
'alpha')) {
188 if (
GETPOST(
'submitdateselect')) {
196 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
198 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'assigntask') &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
199 $action =
'assigntask';
202 $result = $object->fetch($taskid, $ref);
207 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
211 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
216 $idfortaskuser = $usertoprocess->id;
217 $result = $object->add_contact($idfortaskuser,
GETPOST(
"type"),
'internal');
219 if ($result >= 0 || $result == -2) {
221 $sql =
'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.
'element_contact as ec, '.MAIN_DB_PREFIX.
'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
222 $sql .=
' AND ec.fk_socpeople = '.((int) $idfortaskuser).
" AND ec.element_id = ".((int) $object->fk_project).
" AND tc.element = 'project' AND source = 'internal'";
223 $resql = $db->query(
$sql);
225 $obj = $db->fetch_object($resql);
228 $project->fetch($object->fk_project);
230 $listofprojcontact = $project->liste_type_contact(
'internal');
232 if (count($listofprojcontact)) {
233 $tmparray = array_keys($listofprojcontact);
234 $typeforprojectcontact = reset($tmparray);
235 $result = $project->add_contact($idfortaskuser, $typeforprojectcontact,
'internal');
246 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
247 $langs->load(
"errors");
248 setEventMessages($langs->trans(
"ErrorTaskAlreadyAssigned"),
null,
'warnings');
262 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
264 if (empty($timetoadd)) {
267 foreach ($timetoadd as $tmptaskid => $tmpvalue) {
268 $updateoftaskdone = 0;
269 foreach ($tmpvalue as $key => $val) {
270 $amountoadd = $timetoadd[$tmptaskid][$key];
271 if (!empty($amountoadd)) {
272 $tmpduration = explode(
':', $amountoadd);
274 if (!empty($tmpduration[0])) {
275 $newduration += ($tmpduration[0] * 3600);
277 if (!empty($tmpduration[1])) {
278 $newduration += ($tmpduration[1] * 60);
280 if (!empty($tmpduration[2])) {
281 $newduration += ($tmpduration[2]);
284 if ($newduration > 0) {
285 $object->fetch($tmptaskid);
288 $object->progress =
GETPOST($tmptaskid.
'progress',
'int');
290 unset($object->progress);
293 $object->timespent_duration = $newduration;
294 $object->timespent_fk_user = $usertoprocess->id;
296 $object->timespent_datehour = $object->timespent_date;
297 $object->timespent_note = $object->description;
299 $result = $object->addTimeSpent($user);
311 if (!$updateoftaskdone) {
312 $object->fetch($tmptaskid);
315 if ($object->progress !=
GETPOST($tmptaskid.
'progress',
'int')) {
316 $object->progress =
GETPOST($tmptaskid.
'progress',
'int');
317 $result = $object->update($user);
331 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
332 $param .= ($projectid ?
'id='.urlencode($projectid) :
'');
333 $param .= ($search_usertoprocessid ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
334 $param .= ($day ?
'&day='.urlencode($day) :
'').($month ?
'&month='.urlencode($month) :
'').($year ?
'&year='.urlencode($year) :
'');
335 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
336 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
337 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
338 $param .= ($search_declared_progress ?
'&search_declared_progress='.urlencode($search_declared_progress) :
'');
339 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
340 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
347 $search_array_options = $search_array_options_task;
348 $search_options_pattern =
'search_task_options_';
349 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
352 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.$param);
367 $projectstatic =
new Project($db);
369 $taskstatic =
new Task($db);
370 $thirdpartystatic =
new Societe($db);
373 $title = $langs->trans(
"TimeSpent");
375 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1);
378 $project->fetch($id);
379 $project->fetch_thirdparty();
382 $onlyopenedproject = 1;
383 $morewherefilter =
'';
385 if ($search_project_ref) {
386 $morewherefilter .=
natural_search(array(
"p.ref",
"p.title"), $search_project_ref);
388 if ($search_task_ref) {
391 if ($search_task_label) {
392 $morewherefilter .=
natural_search(array(
"t.ref",
"t.label"), $search_task_label);
394 if ($search_thirdparty) {
397 if ($search_declared_progress) {
398 $morewherefilter .=
natural_search(
"t.progress", $search_declared_progress, 1);
401 $sql = &$morewherefilter;
409 $search_array_options = $search_array_options_task;
410 $extrafieldsobjectprefix =
'efpt.';
411 $search_options_pattern =
'search_task_options_';
412 $extrafieldsobjectkey =
'projet_task';
413 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
415 $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields);
416 if ($morewherefilter) {
417 $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0,
'', $onlyopenedproject,
'', ($search_usertoprocessid ? $search_usertoprocessid : 0));
419 $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,
null, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
420 $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(
null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
426 llxHeader(
"", $title,
"",
'',
'',
'', array(
'/core/js/timesheet.js'));
431 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
432 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
433 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
434 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
435 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
436 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
438 $search_array_options = $search_array_options_project;
439 $search_options_pattern =
'search_options_';
440 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
442 $search_array_options = $search_array_options_task;
443 $search_options_pattern =
'search_task_options_';
444 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
447 $nav =
'<a class="inline-block valignmiddle" href="?year='.$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
'">'.
img_previous($langs->trans(
"Previous")).
"</a>\n";
448 $nav .=
' <span id="month_name">'.dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week.
" </span>\n";
449 $nav .=
'<a class="inline-block valignmiddle" href="?year='.$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
'">'.
img_next($langs->trans(
"Next")).
"</a>\n";
450 $nav .=
' '.$form->selectDate(-1,
'', 0, 0, 2,
"addtime", 1, 1).
' ';
451 $nav .=
' <button type="submit" name="submitdateselect" value="x" class="nobordertransp button_search_x"><span class="fa fa-search"></span></button>';
455 print
'<form name="addtime" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
456 print
'<input type="hidden" name="token" value="'.newToken().
'">';
457 print
'<input type="hidden" name="action" value="addtime">';
458 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
459 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
460 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
461 print
'<input type="hidden" name="day" value="'.$day.
'">';
462 print
'<input type="hidden" name="month" value="'.$month.
'">';
463 print
'<input type="hidden" name="year" value="'.$year.
'">';
466 print
dol_get_fiche_head($head,
'inputperweek', $langs->trans(
'TimeSpent'), -1, $picto);
469 print
'<div class="hideonsmartphone opacitymedium">';
470 if ($mine || ($usertoprocess->id == $user->id)) {
471 print $langs->trans(
"MyTasksDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
473 if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
474 if ($user->rights->projet->all->lire && !$socid) {
475 print $langs->trans(
"ProjectsDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
477 print $langs->trans(
"ProjectsPublicTaskDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
481 if ($mine || ($usertoprocess->id == $user->id)) {
482 print $langs->trans(
"OnlyYourTaskAreVisible").
'<br>';
484 print $langs->trans(
"AllTaskVisibleButEditIfYouAreAssigned").
'<br>';
490 print
'<div class="floatright right'.($conf->dol_optimize_smallscreen ?
' centpercent' :
'').
'">'.$nav.
'</div>';
492 print
'<div class="colorbacktimesheet float valignmiddle">';
493 $titleassigntask = $langs->transnoentities(
"AssignTaskToMe");
494 if ($usertoprocess->id != $user->id) {
495 $titleassigntask = $langs->transnoentities(
"AssignTaskToUser", $usertoprocess->getFullName($langs));
497 print
'<div class="taskiddiv inline-block">';
498 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
499 $formproject->selectTasks($socid ? $socid : -1, $taskid,
'taskid', 32, 0,
'-- '.$langs->trans(
"ChooseANotYetAssignedTask").
' --', 1, 0, 0,
'',
'',
'all', $usertoprocess);
502 print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position', 0,
'maxwidth150onsmartphone');
503 print
'<input type="submit" class="button valignmiddle smallonsmartphone small" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).
'">';
506 print
'<div class="clearboth" style="padding-bottom: 20px;"></div>';
509 $startday =
dol_mktime(12, 0, 0, $startdayarray[
'first_month'], $startdayarray[
'first_day'], $startdayarray[
'first_year']);
511 $numendworkingday = 0;
512 $numstartworkingday = 0;
514 $isavailable = array();
517 $numstartworkingday = 1;
518 $numendworkingday = 5;
520 if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
521 $tmparray = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
522 if (count($tmparray) >= 2) {
523 $numstartworkingday = $tmparray[0];
524 $numendworkingday = $tmparray[1];
528 for ($idw = 0; $idw < 7; $idw++) {
534 $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck);
535 $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser;
537 $test =
num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code);
539 $isavailable[$dayinloopfromfirstdaytoshow] = array(
'morning'=>
false,
'afternoon'=>
false,
'morning_reason'=>
'public_holiday',
'afternoon_reason'=>
'public_holiday');
558 $moreforfilter .=
'<div class="divsearchfield">';
559 $moreforfilter .=
'<div class="inline-block hideonsmartphone"></div>';
560 $includeonly =
'hierarchyme';
561 if (empty($user->rights->user->user->lire)) {
562 $includeonly = array($user->id);
564 $moreforfilter .=
img_picto($langs->trans(
'Filter').
' '.$langs->trans(
'User'),
'user',
'class="paddingright pictofixedwidth"').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id,
'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0,
null, 0, $includeonly,
null, 0, 0, 0,
'', 0,
'',
'maxwidth200');
565 $moreforfilter .=
'</div>';
567 if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
568 $moreforfilter .=
'<div class="divsearchfield">';
569 $moreforfilter .=
'<div class="inline-block"></div>';
570 $moreforfilter .=
img_picto($langs->trans(
'Filter').
' '.$langs->trans(
'Project'),
'project',
'class="paddingright pictofixedwidth"').
'<input type="text" name="search_project_ref" class="maxwidth100" value="'.
dol_escape_htmltag($search_project_ref).
'">';
571 $moreforfilter .=
'</div>';
573 $moreforfilter .=
'<div class="divsearchfield">';
574 $moreforfilter .=
'<div class="inline-block"></div>';
575 $moreforfilter .=
img_picto($langs->trans(
'Filter').
' '.$langs->trans(
'ThirdParty'),
'company',
'class="paddingright pictofixedwidth"').
'<input type="text" name="search_thirdparty" class="maxwidth100" value="'.
dol_escape_htmltag($search_thirdparty).
'">';
576 $moreforfilter .=
'</div>';
579 if (!empty($moreforfilter)) {
580 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
581 print $moreforfilter;
582 $parameters = array();
583 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
584 print $hookmanager->resPrint;
589 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
591 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
595 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
598 if (!empty($arrayfields[
't.progress'][
'checked'])) {
601 foreach ($arrayfields as $key => $val) {
602 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
607 print
'<div class="div-table-responsive">';
608 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
610 print
'<tr class="liste_titre_filter">';
611 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
612 print
'<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
614 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
615 print
'<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).
'"></td>';
617 print
'<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
619 $search_options_pattern =
'search_task_options_';
620 $extrafieldsobjectkey =
'projet_task';
621 $extrafieldsobjectprefix =
'efpt.';
622 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
623 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
624 print
'<td class="liste_titre"></td>';
626 if (!empty($arrayfields[
't.progress'][
'checked'])) {
627 print
'<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).
'"></td>';
629 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
630 print
'<td class="liste_titre"></td>';
631 print
'<td class="liste_titre"></td>';
633 for ($idw = 0; $idw < 7; $idw++) {
634 print
'<td class="liste_titre"></td>';
637 print
'<td class="liste_titre nowrap right">';
638 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
643 print
'<tr class="liste_titre">';
644 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
645 print
'<th>'.$langs->trans(
"Project").
'</th>';
647 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
648 print
'<th>'.$langs->trans(
"ThirdParty").
'</th>';
650 print
'<th>'.$langs->trans(
"Task").
'</th>';
652 $extrafieldsobjectkey =
'projet_task';
653 $extrafieldsobjectprefix =
'efpt.';
654 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
655 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
656 print
'<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans(
"PlannedWorkload")).
'">'.$langs->trans(
"PlannedWorkload").
'</th>';
658 if (!empty($arrayfields[
't.progress'][
'checked'])) {
659 print
'<th class="right minwidth75 maxwidth100" title="'.dol_escape_htmltag($langs->trans(
"ProgressDeclared")).
'">'.$langs->trans(
"ProgressDeclared").
'</th>';
661 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
662 print
'<th class="right maxwidth100">'.$langs->trans(
"TimeSpent").
'<br>';
663 print
'<span class="nowraponall">';
664 print
'<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.
'/theme/common/everybody.png"></span>';
665 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"Everybody").
'</span>';
668 print
'<th class="right maxwidth75 maxwidth100">'.$langs->trans(
"TimeSpent").($usertoprocess->firstname ?
'<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-2).
'<span class="opacitymedium paddingleft">'.
dol_trunc($usertoprocess->firstname, 10).
'</span></span>' :
'').
'</th>';
670 for ($idw = 0; $idw < 7; $idw++) {
674 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
675 $cssweekend =
'weekend';
681 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
682 $cssonholiday .=
'onholidayallday ';
683 } elseif (!$isavailable[$tmpday][
'morning']) {
684 $cssonholiday .=
'onholidaymorning ';
685 } elseif (!$isavailable[$tmpday][
'afternoon']) {
686 $cssonholiday .=
'onholidayafternoon ';
689 print
'<th width="6%" class="center bold hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
691 print
'<br>'.dol_print_date($dayinloopfromfirstdaytoshow,
'dayreduceformat').
'</th>';
694 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
699 $colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
701 if ($conf->use_javascript_ajax) {
702 print
'<tr class="liste_total">';
703 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
704 print $langs->trans(
"Total");
705 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"ExpectedWorkedHours").
': <strong>'.
price($usertoprocess->weeklyhours, 1, $langs, 0, 0).
'</strong></span>';
707 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
708 print
'<td class="liste_total"></td>';
709 print
'<td class="liste_total"></td>';
711 for ($idw = 0; $idw < 7; $idw++) {
713 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
714 $cssweekend =
'weekend';
720 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
721 $cssonholiday .=
'onholidayallday ';
722 } elseif (!$isavailable[$tmpday][
'morning']) {
723 $cssonholiday .=
'onholidaymorning ';
724 } elseif (!$isavailable[$tmpday][
'afternoon']) {
725 $cssonholiday .=
'onholidayafternoon ';
727 print
'<td class="liste_total hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'" align="center"><div class="totalDay'.$idw.
'"> </div></td>';
729 print
'<td class="liste_total center"><div class="totalDayAll"> </div></td>';
736 $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
737 if (count($tasksarray) > 0) {
744 $totalforvisibletasks =
projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
750 $listofdistinctprojectid = array();
751 if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
752 foreach ($tasksarraywithoutfilter as $tmptask) {
753 $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
757 $totalforeachday = array();
758 foreach ($listofdistinctprojectid as $tmpprojectid) {
759 $projectstatic->id = $tmpprojectid;
760 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id);
761 for ($idw = 0; $idw < 7; $idw++) {
763 $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
772 if (count($totalforeachday)) {
773 for ($idw = 0; $idw < 7; $idw++) {
775 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
776 if ($timeonothertasks) {
785 print
'<tr class="oddeven othertaskwithtime">';
786 print
'<td colspan="'.($colspan + $addcolspan).
'" class="opacitymedium">';
787 print $langs->trans(
"OtherFilteredTasks");
789 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
790 print
'<td class="liste_total"></td>';
791 print
'<td class="liste_total"></td>';
793 for ($idw = 0; $idw < 7; $idw++) {
795 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
796 $cssweekend =
'weekend';
799 print
'<td class="center hide'.$idw.
' '.($cssweekend ?
' '.$cssweekend :
'').
'">';
801 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
802 if ($timeonothertasks) {
803 print
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.
']" name="task[-1]['.$idw.
']" value="';
809 print
' <td class="liste_total"></td>';
813 if ($conf->use_javascript_ajax) {
814 print
'<tr class="liste_total">';
815 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
816 print $langs->trans(
"Total");
817 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"ExpectedWorkedHours").
': <strong>'.
price($usertoprocess->weeklyhours, 1, $langs, 0, 0).
'</strong></span>';
819 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
820 print
'<td class="liste_total"></td>';
821 print
'<td class="liste_total"></td>';
824 for ($idw = 0; $idw < 7; $idw++) {
826 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
827 $cssweekend =
'weekend';
833 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
834 $cssonholiday .=
'onholidayallday ';
835 } elseif (!$isavailable[$tmpday][
'morning']) {
836 $cssonholiday .=
'onholidaymorning ';
837 } elseif (!$isavailable[$tmpday][
'afternoon']) {
838 $cssonholiday .=
'onholidayafternoon ';
841 print
'<td class="liste_total hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'" align="center"><div class="totalDay'.$idw.
'"> </div></td>';
843 print
'<td class="liste_total center"><div class="totalDayAll"> </div></td>';
847 print
'<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans(
"NoAssignedTasks").
'</span></td></tr>';
852 print
'<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).
'"/>'.
"\n";
854 print
$form->buttonsSaveCancel(
"Save",
'');
856 print
'</form>'.
"\n\n";
858 $modeinput =
'hours';
860 if ($conf->use_javascript_ajax) {
861 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
862 print
'<script type="text/javascript">'.
"\n";
863 print
"jQuery(document).ready(function () {\n";
864 print
' jQuery(".timesheetalreadyrecorded").tooltip({
865 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
866 hide: { effect:\'toggle\', delay: 50 },
867 tooltipClass: "mytooltip",
868 content: function () {
869 return \''.dol_escape_js($langs->trans(
"TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).
'\';
875 print ' updateTotal(
'.$idw.',\
''.$modeinput.
'\');
';