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_');
161 $parameters = array(
'id' => $id,
'taskid' => $taskid,
'projectid' => $projectid);
162 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
170 $search_usertoprocessid = $user->id;
171 $search_task_ref =
'';
172 $search_task_label =
'';
173 $search_project_ref =
'';
174 $search_thirdparty =
'';
175 $search_declared_progress =
'';
177 $search_array_options_project = array();
178 $search_array_options_task = array();
181 $usertoprocess = $user;
183 if (
GETPOST(
"button_search_x",
'alpha') ||
GETPOST(
"button_search.x",
'alpha') ||
GETPOST(
"button_search",
'alpha')) {
187 if (
GETPOST(
'submitdateselect')) {
195 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
197 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'assigntask') &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
198 $action =
'assigntask';
201 $result = $object->fetch($taskid, $ref);
206 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
'',
'errors');
210 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
'',
'errors');
215 $idfortaskuser = $usertoprocess->id;
216 $result = $object->add_contact($idfortaskuser,
GETPOST(
"type"),
'internal');
218 if ($result >= 0 || $result == -2) {
220 $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';
221 $sql .=
' AND ec.fk_socpeople = '.((int) $idfortaskuser).
" AND ec.element_id = ".((int) $object->fk_project).
" AND tc.element = 'project' AND source = 'internal'";
222 $resql = $db->query($sql);
224 $obj = $db->fetch_object(
$resql);
227 $project->fetch($object->fk_project);
229 $listofprojcontact = $project->liste_type_contact(
'internal');
231 if (count($listofprojcontact)) {
232 $typeforprojectcontact = reset(array_keys($listofprojcontact));
233 $result = $project->add_contact($idfortaskuser, $typeforprojectcontact,
'internal');
244 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
245 $langs->load(
"errors");
246 setEventMessages($langs->trans(
"ErrorTaskAlreadyAssigned"),
null,
'warnings');
260 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
262 if (empty($timetoadd)) {
265 foreach ($timetoadd as $taskid => $value) {
266 $updateoftaskdone = 0;
267 foreach ($value as $key => $val) {
268 $amountoadd = $timetoadd[$taskid][$key];
269 if (!empty($amountoadd)) {
270 $tmpduration = explode(
':', $amountoadd);
272 if (!empty($tmpduration[0])) {
273 $newduration += ($tmpduration[0] * 3600);
275 if (!empty($tmpduration[1])) {
276 $newduration += ($tmpduration[1] * 60);
278 if (!empty($tmpduration[2])) {
279 $newduration += ($tmpduration[2]);
282 if ($newduration > 0) {
283 $object->fetch($taskid);
286 $object->progress =
GETPOST($taskid.
'progress',
'int');
288 unset($object->progress);
291 $object->timespent_duration = $newduration;
292 $object->timespent_fk_user = $usertoprocess->id;
294 $object->timespent_datehour = $object->timespent_date;
295 $object->timespent_note = $object->description;
297 $result = $object->addTimeSpent($user);
309 if (!$updateoftaskdone) {
310 $object->fetch($taskid);
313 if ($object->progress !=
GETPOST($taskid.
'progress',
'int')) {
314 $object->progress =
GETPOST($taskid.
'progress',
'int');
315 $result = $object->update($user);
329 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
330 $param .= ($projectid ?
'id='.urlencode($projectid) :
'');
331 $param .= ($search_usertoprocessid ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
332 $param .= ($day ?
'&day='.urlencode($day) :
'').($month ?
'&month='.urlencode($month) :
'').($year ?
'&year='.urlencode($year) :
'');
333 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
334 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
335 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
336 $param .= ($search_declared_progress ?
'&search_declared_progress='.urlencode($search_declared_progress) :
'');
337 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
338 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
345 $search_array_options = $search_array_options_task;
346 $search_options_pattern =
'search_task_options_';
347 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
350 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.$param);
365 $projectstatic =
new Project($db);
367 $taskstatic =
new Task($db);
368 $thirdpartystatic =
new Societe($db);
371 $title = $langs->trans(
"TimeSpent");
373 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1);
376 $project->fetch($id);
377 $project->fetch_thirdparty();
380 $onlyopenedproject = 1;
381 $morewherefilter =
'';
383 if ($search_project_ref) {
384 $morewherefilter .=
natural_search(array(
"p.ref",
"p.title"), $search_project_ref);
386 if ($search_task_ref) {
389 if ($search_task_label) {
390 $morewherefilter .=
natural_search(array(
"t.ref",
"t.label"), $search_task_label);
392 if ($search_thirdparty) {
395 if ($search_declared_progress) {
396 $morewherefilter .=
natural_search(
"t.progress", $search_declared_progress, 1);
399 $sql = &$morewherefilter;
407 $search_array_options = $search_array_options_task;
408 $extrafieldsobjectprefix =
'efpt.';
409 $search_options_pattern =
'search_task_options_';
410 $extrafieldsobjectkey =
'projet_task';
411 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
413 $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields);
414 if ($morewherefilter) {
415 $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0,
'', $onlyopenedproject,
'', ($search_usertoprocessid ? $search_usertoprocessid : 0));
417 $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
418 $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
424 llxHeader(
"", $title,
"",
'',
'',
'', array(
'/core/js/timesheet.js'));
429 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
430 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
431 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
432 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
433 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
434 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
436 $search_array_options = $search_array_options_project;
437 $search_options_pattern =
'search_options_';
438 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
440 $search_array_options = $search_array_options_task;
441 $search_options_pattern =
'search_task_options_';
442 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
445 $nav =
'<a class="inline-block valignmiddle" href="?year='.$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
'">'.
img_previous($langs->trans(
"Previous")).
"</a>\n";
446 $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";
447 $nav .=
'<a class="inline-block valignmiddle" href="?year='.$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
'">'.
img_next($langs->trans(
"Next")).
"</a>\n";
448 $nav .=
' '.$form->selectDate(-1,
'', 0, 0, 2,
"addtime", 1, 1).
' ';
449 $nav .=
' <button type="submit" name="submitdateselect" value="x" class="bordertransp"><span class="fa fa-search"></span></button>';
453 print
'<form name="addtime" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
454 print
'<input type="hidden" name="token" value="'.newToken().
'">';
455 print
'<input type="hidden" name="action" value="addtime">';
456 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
457 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
458 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
459 print
'<input type="hidden" name="day" value="'.$day.
'">';
460 print
'<input type="hidden" name="month" value="'.$month.
'">';
461 print
'<input type="hidden" name="year" value="'.$year.
'">';
464 print
dol_get_fiche_head($head,
'inputperweek', $langs->trans(
'TimeSpent'), -1, $picto);
467 print
'<div class="hideonsmartphone opacitymedium">';
468 if ($mine || ($usertoprocess->id == $user->id)) {
469 print $langs->trans(
"MyTasksDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
471 if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
472 if ($user->rights->projet->all->lire && !$socid) {
473 print $langs->trans(
"ProjectsDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
475 print $langs->trans(
"ProjectsPublicTaskDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
479 if ($mine || ($usertoprocess->id == $user->id)) {
480 print $langs->trans(
"OnlyYourTaskAreVisible").
'<br>';
482 print $langs->trans(
"AllTaskVisibleButEditIfYouAreAssigned").
'<br>';
488 print
'<div class="floatright right'.($conf->dol_optimize_smallscreen ?
' centpercent' :
'').
'">'.$nav.
'</div>';
490 print
'<div class="colorbacktimesheet float valignmiddle">';
491 $titleassigntask = $langs->transnoentities(
"AssignTaskToMe");
492 if ($usertoprocess->id != $user->id) {
493 $titleassigntask = $langs->transnoentities(
"AssignTaskToUser", $usertoprocess->getFullName($langs));
495 print
'<div class="taskiddiv inline-block">';
496 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
497 $formproject->selectTasks($socid ? $socid : -1, $taskid,
'taskid', 32, 0,
'-- '.$langs->trans(
"ChooseANotYetAssignedTask").
' --', 1, 0, 0,
'',
'',
'all', $usertoprocess);
500 print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position', 0,
'maxwidth150onsmartphone');
501 print
'<input type="submit" class="button valignmiddle smallonsmartphone" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).
'">';
504 print
'<div class="clearboth" style="padding-bottom: 20px;"></div>';
507 $startday =
dol_mktime(12, 0, 0, $startdayarray[
'first_month'], $startdayarray[
'first_day'], $startdayarray[
'first_year']);
509 $numendworkingday = 0;
510 $numstartworkingday = 0;
512 $isavailable = array();
515 $numstartworkingday = 1;
516 $numendworkingday = 5;
518 if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
519 $tmparray = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
520 if (count($tmparray) >= 2) {
521 $numstartworkingday = $tmparray[0];
522 $numendworkingday = $tmparray[1];
526 for ($idw = 0; $idw < 7; $idw++) {
532 $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck);
533 $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser;
535 $test =
num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code);
537 $isavailable[$dayinloopfromfirstdaytoshow] = array(
'morning'=>
false,
'afternoon'=>
false,
'morning_reason'=>
'public_holiday',
'afternoon_reason'=>
'public_holiday');
557 $moreforfilter .=
'<div class="divsearchfield">';
558 $moreforfilter .=
'<div class="inline-block hideonsmartphone"></div>';
559 $includeonly =
'hierarchyme';
560 if (empty($user->rights->user->user->lire)) {
561 $includeonly = array($user->id);
563 $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');
564 $moreforfilter .=
'</div>';
566 if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
567 $moreforfilter .=
'<div class="divsearchfield">';
568 $moreforfilter .=
'<div class="inline-block"></div>';
569 $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).
'">';
570 $moreforfilter .=
'</div>';
572 $moreforfilter .=
'<div class="divsearchfield">';
573 $moreforfilter .=
'<div class="inline-block"></div>';
574 $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).
'">';
575 $moreforfilter .=
'</div>';
578 if (!empty($moreforfilter)) {
579 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
580 print $moreforfilter;
581 $parameters = array();
582 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
583 print $hookmanager->resPrint;
588 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
590 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
594 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
597 if (!empty($arrayfields[
't.progress'][
'checked'])) {
600 foreach ($arrayfields as $key => $val) {
601 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
606 print
'<div class="div-table-responsive">';
607 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
609 print
'<tr class="liste_titre_filter">';
610 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
611 print
'<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
613 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
614 print
'<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).
'"></td>';
616 print
'<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
618 $search_options_pattern =
'search_task_options_';
619 $extrafieldsobjectkey =
'projet_task';
620 $extrafieldsobjectprefix =
'efpt.';
621 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
622 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
623 print
'<td class="liste_titre"></td>';
625 if (!empty($arrayfields[
't.progress'][
'checked'])) {
626 print
'<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).
'"></td>';
628 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
629 print
'<td class="liste_titre"></td>';
630 print
'<td class="liste_titre"></td>';
632 for ($idw = 0; $idw < 7; $idw++) {
633 print
'<td class="liste_titre"></td>';
636 print
'<td class="liste_titre nowrap right">';
637 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
642 print
'<tr class="liste_titre">';
643 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
644 print
'<th>'.$langs->trans(
"Project").
'</th>';
646 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
647 print
'<th>'.$langs->trans(
"ThirdParty").
'</th>';
649 print
'<th>'.$langs->trans(
"Task").
'</th>';
651 $extrafieldsobjectkey =
'projet_task';
652 $extrafieldsobjectprefix =
'efpt.';
653 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
654 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
655 print
'<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans(
"PlannedWorkload")).
'">'.$langs->trans(
"PlannedWorkload").
'</th>';
657 if (!empty($arrayfields[
't.progress'][
'checked'])) {
658 print
'<th class="right minwidth75 maxwidth100" title="'.dol_escape_htmltag($langs->trans(
"ProgressDeclared")).
'">'.$langs->trans(
"ProgressDeclared").
'</th>';
660 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
661 print
'<th class="right maxwidth100">'.$langs->trans(
"TimeSpent").
'<br>';
662 print
'<span class="nowraponall">';
663 print
'<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.
'/theme/common/everybody.png"></span>';
664 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"Everybody").
'</span>';
667 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>';
669 for ($idw = 0; $idw < 7; $idw++) {
673 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
674 $cssweekend =
'weekend';
680 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
681 $cssonholiday .=
'onholidayallday ';
682 } elseif (!$isavailable[$tmpday][
'morning']) {
683 $cssonholiday .=
'onholidaymorning ';
684 } elseif (!$isavailable[$tmpday][
'afternoon']) {
685 $cssonholiday .=
'onholidayafternoon ';
688 print
'<th width="6%" class="center bold hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
690 print
'<br>'.dol_print_date($dayinloopfromfirstdaytoshow,
'dayreduceformat').
'</th>';
693 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
698 $colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
700 if ($conf->use_javascript_ajax) {
701 print
'<tr class="liste_total">';
702 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
703 print $langs->trans(
"Total");
704 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"ExpectedWorkedHours").
': <strong>'.
price($usertoprocess->weeklyhours, 1, $langs, 0, 0).
'</strong></span>';
706 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
707 print
'<td class="liste_total"></td>';
708 print
'<td class="liste_total"></td>';
710 for ($idw = 0; $idw < 7; $idw++) {
712 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
713 $cssweekend =
'weekend';
719 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
720 $cssonholiday .=
'onholidayallday ';
721 } elseif (!$isavailable[$tmpday][
'morning']) {
722 $cssonholiday .=
'onholidaymorning ';
723 } elseif (!$isavailable[$tmpday][
'afternoon']) {
724 $cssonholiday .=
'onholidayafternoon ';
726 print
'<td class="liste_total hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'" align="center"><div class="totalDay'.$idw.
'"> </div></td>';
728 print
'<td class="liste_total center"><div class="totalDayAll"> </div></td>';
735 $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
736 if (count($tasksarray) > 0) {
743 $totalforvisibletasks =
projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
749 $listofdistinctprojectid = array();
750 if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
751 foreach ($tasksarraywithoutfilter as $tmptask) {
752 $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
756 $totalforeachday = array();
757 foreach ($listofdistinctprojectid as $tmpprojectid) {
758 $projectstatic->id = $tmpprojectid;
759 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id);
760 for ($idw = 0; $idw < 7; $idw++) {
762 $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
771 if (count($totalforeachday)) {
772 for ($idw = 0; $idw < 7; $idw++) {
774 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
775 if ($timeonothertasks) {
784 print
'<tr class="oddeven othertaskwithtime">';
785 print
'<td colspan="'.($colspan + $addcolspan).
'" class="opacitymedium">';
786 print $langs->trans(
"OtherFilteredTasks");
788 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
789 print
'<td class="liste_total"></td>';
790 print
'<td class="liste_total"></td>';
792 for ($idw = 0; $idw < 7; $idw++) {
794 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
795 $cssweekend =
'weekend';
798 print
'<td class="center hide'.$idw.
' '.($cssweekend ?
' '.$cssweekend :
'').
'">';
800 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
801 if ($timeonothertasks) {
802 print
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.
']" name="task[-1]['.$idw.
']" value="';
808 print
' <td class="liste_total"></td>';
812 if ($conf->use_javascript_ajax) {
813 print
'<tr class="liste_total">';
814 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
815 print $langs->trans(
"Total");
816 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"ExpectedWorkedHours").
': <strong>'.
price($usertoprocess->weeklyhours, 1, $langs, 0, 0).
'</strong></span>';
818 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
819 print
'<td class="liste_total"></td>';
820 print
'<td class="liste_total"></td>';
823 for ($idw = 0; $idw < 7; $idw++) {
825 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
826 $cssweekend =
'weekend';
832 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
833 $cssonholiday .=
'onholidayallday ';
834 } elseif (!$isavailable[$tmpday][
'morning']) {
835 $cssonholiday .=
'onholidaymorning ';
836 } elseif (!$isavailable[$tmpday][
'afternoon']) {
837 $cssonholiday .=
'onholidayafternoon ';
840 print
'<td class="liste_total hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'" align="center"><div class="totalDay'.$idw.
'"> </div></td>';
842 print
'<td class="liste_total center"><div class="totalDayAll"> </div></td>';
846 print
'<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans(
"NoAssignedTasks").
'</span></td></tr>';
851 print
'<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).
'"/>'.
"\n";
853 print
$form->buttonsSaveCancel(
"Save",
'');
855 print
'</form>'.
"\n\n";
857 $modeinput =
'hours';
859 if ($conf->use_javascript_ajax) {
860 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
861 print
'<script type="text/javascript">'.
"\n";
862 print
"jQuery(document).ready(function () {\n";
863 print
' jQuery(".timesheetalreadyrecorded").tooltip({
864 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
865 hide: { effect:\'toggle\', delay: 50 },
866 tooltipClass: "mytooltip",
867 content: function () {
868 return \''.dol_escape_js($langs->trans(
"TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).
'\';
874 print ' updateTotal(
'.$idw.',\
''.$modeinput.
'\');
';