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') :
'perdaycard';
49 if ($mode ==
'mine') {
55 $hookmanager->initHooks(array(
'timesheetperdaycard'));
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');
83 $monthofday =
GETPOST(
'addtimemonth');
84 $dayofday =
GETPOST(
'addtimeday');
85 $yearofday =
GETPOST(
'addtimeyear');
92 if ($year && $month && $day) {
93 $daytoparse =
dol_mktime(0, 0, 0, $month, $day, $year);
94 } elseif ($yearofday && $monthofday && $dayofday) {
95 $daytoparse =
dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday);
98 $daytoparsegmt =
dol_now(
'gmt');
99 if ($yearofday && $monthofday && $dayofday) $daytoparsegmt =
dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday,
'gmt');
100 elseif ($year && $month && $day) $daytoparsegmt =
dol_mktime(0, 0, 0, $month, $day, $year,
'gmt');
102 if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
103 $usertoprocess = $user;
104 $search_usertoprocessid = $usertoprocess->id;
105 } elseif ($search_usertoprocessid > 0) {
106 $usertoprocess =
new User($db);
107 $usertoprocess->fetch($search_usertoprocessid);
108 $search_usertoprocessid = $usertoprocess->id;
110 $usertoprocess =
new User($db);
113 $object =
new Task($db);
120 $extrafields->fetch_name_optionals_label($object->table_element);
123 $arrayfields = array();
124 $arrayfields[
't.planned_workload'] = array(
'label'=>
'PlannedWorkload',
'checked'=>1,
'enabled'=>1,
'position'=>0);
125 $arrayfields[
't.progress'] = array(
'label'=>
'ProgressDeclared',
'checked'=>1,
'enabled'=>1,
'position'=>0);
126 $arrayfields[
'timeconsumed'] = array(
'label'=>
'TimeConsumed',
'checked'=>1,
'enabled'=>1,
'position'=>15);
137 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
138 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
139 if (!empty($extrafields->attributes[$object->table_element][
'list'][$key])) {
140 $arrayfields[
"efpt.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element][
'label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element][
'list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element][
'pos'][$key],
'enabled'=>(abs((
int) $extrafields->attributes[$object->table_element][
'list'][$key]) != 3 && $extrafields->attributes[$object->table_element][
'perms'][$key]));
147 $search_array_options_project = $extrafields->getOptionalsFromPost($project->table_element,
'',
'search_');
148 $search_array_options_task = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_task_');
155 $parameters = array(
'id' => $id,
'taskid' => $taskid,
'projectid' => $projectid);
156 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
161 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
164 $search_usertoprocessid = $user->id;
165 $search_task_ref =
'';
166 $search_task_label =
'';
167 $search_project_ref =
'';
168 $search_thirdparty =
'';
169 $search_declared_progress =
'';
171 $search_array_options_project = array();
172 $search_array_options_task = array();
175 $usertoprocess = $user;
177 if (
GETPOST(
"button_search_x",
'alpha') ||
GETPOST(
"button_search.x",
'alpha') ||
GETPOST(
"button_search",
'alpha')) {
181 if (
GETPOST(
'submitdateselect')) {
189 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
191 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'assigntask') &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
192 $action =
'assigntask';
195 $result = $object->fetch($taskid, $ref);
200 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
204 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
208 $idfortaskuser = $usertoprocess->id;
209 $result = $object->add_contact($idfortaskuser,
GETPOST(
"type"),
'internal');
211 if ($result >= 0 || $result == -2) {
213 $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';
214 $sql .=
' AND ec.fk_socpeople = '.((int) $idfortaskuser).
" AND ec.element_id = ".((int) $object->fk_project).
" AND tc.element = 'project' AND source = 'internal'";
215 $resql = $db->query($sql);
217 $obj = $db->fetch_object(
$resql);
220 $project->fetch($object->fk_project);
222 $listofprojcontact = $project->liste_type_contact(
'internal');
224 if (count($listofprojcontact)) {
225 $tmparray = array_keys($listofprojcontact);
226 $typeforprojectcontact = reset($tmparray);
227 $result = $project->add_contact($idfortaskuser, $typeforprojectcontact,
'internal');
238 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
239 $langs->load(
"errors");
240 setEventMessages($langs->trans(
"ErrorTaskAlreadyAssigned"),
null,
'warnings');
254 if ($action ==
'addtime' && $user->rights->projet->lire &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
255 $timespent_duration = array();
257 if (is_array($_POST)) {
258 foreach ($_POST as $key => $time) {
259 if (intval($time) > 0) {
262 if (preg_match(
"/([0-9]+)duration(hour|min)/", $key, $matches)) {
266 if ($matches[2] ==
'hour') {
267 $timespent_duration[$id] += $time * 60 * 60;
271 if ($matches[2] ==
'min') {
272 $timespent_duration[$id] += $time * 60;
280 if (count($timespent_duration) > 0) {
281 foreach ($timespent_duration as $key => $val) {
282 $object->fetch($key);
283 $taskid = $object->id;
286 $object->progress =
GETPOST($taskid.
'progress',
'int');
288 unset($object->progress);
291 $object->timespent_duration = $val;
292 $object->timespent_fk_user = $usertoprocess->id;
293 $object->timespent_note =
GETPOST($key.
'note');
294 if (
GETPOST($key.
"hour",
'int') !=
'' &&
GETPOST($key.
"hour",
'int') >= 0) {
295 $object->timespent_datehour =
dol_mktime(
GETPOST($key.
"hour",
'int'),
GETPOST($key.
"min",
'int'), 0, $monthofday, $dayofday, $yearofday);
296 $object->timespent_withhour = 1;
298 $object->timespent_datehour =
dol_mktime(12, 0, 0, $monthofday, $dayofday, $yearofday);
300 $object->timespent_date = $object->timespent_datehour;
302 if ($object->timespent_date > 0) {
303 $result = $object->addTimeSpent($user);
321 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.($projectid ?
'id='.$projectid :
'').($search_usertoprocessid ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'').($mode ?
'&mode='.$mode :
'').
'&year='.$yearofday.
'&month='.$monthofday.
'&day='.$dayofday);
339 $projectstatic =
new Project($db);
341 $taskstatic =
new Task($db);
342 $thirdpartystatic =
new Societe($db);
346 $prev_year = $prev[
'year'];
347 $prev_month = $prev[
'mon'];
348 $prev_day = $prev[
'mday'];
351 $next_year = $next[
'year'];
352 $next_month = $next[
'mon'];
353 $next_day = $next[
'mday'];
355 $title = $langs->trans(
"TimeSpent");
357 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1);
360 $project->fetch($id);
361 $project->fetch_thirdparty();
364 $onlyopenedproject = 1;
365 $morewherefilter =
'';
367 if ($search_project_ref) {
368 $morewherefilter .=
natural_search(array(
"p.ref",
"p.title"), $search_project_ref);
370 if ($search_task_ref) {
373 if ($search_task_label) {
374 $morewherefilter .=
natural_search(array(
"t.ref",
"t.label"), $search_task_label);
376 if ($search_thirdparty) {
379 if ($search_declared_progress) {
380 $morewherefilter .=
natural_search(
"t.progress", $search_declared_progress, 1);
383 $sql = &$morewherefilter;
391 $search_array_options = $search_array_options_task;
392 $extrafieldsobjectprefix =
'efpt.';
393 $search_options_pattern =
'search_task_options_';
394 $extrafieldsobjectkey =
'projet_task';
395 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
397 $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields);
398 if ($morewherefilter) {
399 $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0,
'', $onlyopenedproject,
'', ($search_usertoprocessid ? $search_usertoprocessid : 0));
401 $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,
null, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
402 $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(
null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
407 llxHeader(
"", $title,
"",
'',
'',
'', array(
'/core/js/timesheet.js'));
412 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
413 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
414 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode($search_usertoprocessid) :
'');
415 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
416 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
417 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
425 $search_array_options = $search_array_options_task;
426 $search_options_pattern =
'search_task_options_';
427 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
430 $nav =
'<a class="inline-block valignmiddle" href="?year='.$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
'">'.
img_previous($langs->trans(
"Previous")).
"</a>\n";
432 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"day").
" </span>\n";
433 $nav .=
'<a class="inline-block valignmiddle" href="?year='.$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
'">'.
img_next($langs->trans(
"Next")).
"</a>\n";
434 $nav .=
' '.$form->selectDate(-1,
'', 0, 0, 2,
"addtime", 1, 1).
' ';
435 $nav .=
' <button type="submit" name="button_search_x" value="x" class="bordertransp nobordertransp button_search"><span class="fa fa-search"></span></button>';
439 print
'<form name="addtime" method="POST" action="'.$_SERVER[
"PHP_SELF"].($project->id > 0 ?
'?id='.$project->id :
'').
'">';
440 print
'<input type="hidden" name="token" value="'.newToken().
'">';
441 print
'<input type="hidden" name="action" value="addtime">';
442 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
443 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
444 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
446 print
'<input type="hidden" name="addtimeyear" value="'.$tmp[
'year'].
'">';
447 print
'<input type="hidden" name="addtimemonth" value="'.$tmp[
'mon'].
'">';
448 print
'<input type="hidden" name="addtimeday" value="'.$tmp[
'mday'].
'">';
451 print
dol_get_fiche_head($head,
'inputperday', $langs->trans(
'TimeSpent'), -1, $picto);
454 print
'<div class="hideonsmartphone opacitymedium">';
455 if ($mine || ($usertoprocess->id == $user->id)) {
456 print $langs->trans(
"MyTasksDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
458 if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
459 if ($user->rights->projet->all->lire && !$socid) {
460 print $langs->trans(
"ProjectsDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
462 print $langs->trans(
"ProjectsPublicTaskDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
466 if ($mine || ($usertoprocess->id == $user->id)) {
467 print $langs->trans(
"OnlyYourTaskAreVisible").
'<br>';
469 print $langs->trans(
"AllTaskVisibleButEditIfYouAreAssigned").
'<br>';
476 print
'<div class="floatright right'.($conf->dol_optimize_smallscreen ?
' centpercent' :
'').
'">'.$nav.
'</div>';
478 print
'<div class="colorbacktimesheet float valignmiddle">';
479 $titleassigntask = $langs->transnoentities(
"AssignTaskToMe");
480 if ($usertoprocess->id != $user->id) {
481 $titleassigntask = $langs->transnoentities(
"AssignTaskToUser", $usertoprocess->getFullName($langs));
483 print
'<div class="taskiddiv inline-block">';
484 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
485 $formproject->selectTasks($socid ? $socid : -1, $taskid,
'taskid', 32, 0,
'-- '.$langs->trans(
"ChooseANotYetAssignedTask").
' --', 1, 0, 0,
'',
'',
'all', $usertoprocess);
488 print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'rowid', 0,
'maxwidth150onsmartphone');
489 print
'<input type="submit" class="button valignmiddle smallonsmartphone small" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).
'">';
492 print
'<div class="clearboth" style="padding-bottom: 20px;"></div>';
508 $moreforfilter .=
'<div class="divsearchfield">';
509 $moreforfilter .=
'<div class="inline-block hideonsmartphone"></div>';
510 $includeonly =
'hierarchyme';
511 if (empty($user->rights->user->user->lire)) {
512 $includeonly = array($user->id);
514 $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');
515 $moreforfilter .=
'</div>';
517 if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
518 $moreforfilter .=
'<div class="divsearchfield">';
519 $moreforfilter .=
'<div class="inline-block"></div>';
520 $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).
'">';
521 $moreforfilter .=
'</div>';
523 $moreforfilter .=
'<div class="divsearchfield">';
524 $moreforfilter .=
'<div class="inline-block"></div>';
525 $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).
'">';
526 $moreforfilter .=
'</div>';
529 if (!empty($moreforfilter)) {
530 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
531 print $moreforfilter;
532 $parameters = array();
533 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
534 print $hookmanager->resPrint;
538 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
539 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
543 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
546 if (!empty($arrayfields[
't.progress'][
'checked'])) {
549 foreach ($arrayfields as $key => $val) {
550 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
555 print
'<div class="div-table-responsive">';
556 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
558 print
'<tr class="liste_titre_filter">';
559 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
560 print
'<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
562 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
563 print
'<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).
'"></td>';
565 print
'<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
567 $search_options_pattern =
'search_task_options_';
568 $extrafieldsobjectkey =
'projet_task';
569 $extrafieldsobjectprefix =
'efpt.';
570 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
571 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
572 print
'<td class="liste_titre"></td>';
574 if (!empty($arrayfields[
't.progress'][
'checked'])) {
575 print
'<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).
'"></td>';
577 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
578 print
'<td class="liste_titre"></td>';
579 print
'<td class="liste_titre"></td>';
581 print
'<td class="liste_titre"></td>';
582 print
'<td class="liste_titre"></td>';
583 print
'<td class="liste_titre"></td>';
585 print
'<td class="liste_titre nowrap right">';
586 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
591 print
'<tr class="liste_titre">';
592 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
593 print
'<th>'.$langs->trans(
"Project").
'</th>';
595 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
596 print
'<th>'.$langs->trans(
"ThirdParty").
'</th>';
598 print
'<th>'.$langs->trans(
"Task").
'</th>';
600 $extrafieldsobjectkey =
'projet_task';
601 $extrafieldsobjectprefix =
'efpt.';
602 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
603 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
604 print
'<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans(
"PlannedWorkload")).
'">'.$langs->trans(
"PlannedWorkload").
'</th>';
606 if (!empty($arrayfields[
't.progress'][
'checked'])) {
607 print
'<th class="right minwidth75 maxwidth100 title="'.dol_escape_htmltag($langs->trans(
"ProgressDeclared")).
'">'.$langs->trans(
"ProgressDeclared").
'</th>';
609 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
610 print
'<th class="right maxwidth100">'.$langs->trans(
"TimeSpent").
'<br>';
611 print
'<span class="nowraponall">';
612 print
'<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.
'/theme/common/everybody.png"></span>';
613 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"Everybody").
'</span>';
616 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>';
618 print
'<th class="center leftborder">'.$langs->trans(
"HourStart").
'</td>';
621 $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
623 $numendworkingday = 0;
624 $numstartworkingday = 0;
626 $isavailable = array();
629 $numstartworkingday = 1;
630 $numendworkingday = 5;
632 if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
633 $tmparray = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
634 if (count($tmparray) >= 2) {
635 $numstartworkingday = $tmparray[0];
636 $numendworkingday = $tmparray[1];
641 $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck);
642 $isavailable[$daytoparse] = $isavailablefordayanduser;
644 $test =
num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code);
646 $isavailable[$daytoparse] = array(
'morning'=>
false,
'afternoon'=>
false,
'morning_reason'=>
'public_holiday',
'afternoon_reason'=>
'public_holiday');
651 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
654 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
655 $cssweekend =
'weekend';
661 if (!$isavailable[$daytoparse][
'morning'] && !$isavailable[$daytoparse][
'afternoon']) {
662 $cssonholiday .=
'onholidayallday ';
663 } elseif (!$isavailable[$daytoparse][
'morning']) {
664 $cssonholiday .=
'onholidaymorning ';
665 } elseif (!$isavailable[$daytoparse][
'afternoon']) {
666 $cssonholiday .=
'onholidayafternoon ';
669 print
'<th class="center'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">'.$langs->trans(
"Duration").
'</th>';
670 print
'<th class="center">'.$langs->trans(
"Note").
'</th>';
672 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
676 $colspan = 2 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
678 if ($conf->use_javascript_ajax) {
679 print
'<tr class="liste_total">';
680 print
'<td class="liste_total" colspan="'.($colspan - 1 + $addcolspan).
'">';
681 print $langs->trans(
"Total");
683 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
684 print
'<td class="liste_total"></td>';
685 print
'<td class="liste_total"></td>';
687 print
'<td class="liste_total leftborder">';
691 print
'<td class="liste_total center'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'"><div class="totalDay0"> </div></td>';
693 print
'<td class="liste_total"></td>';
694 print
'<td class="liste_total"></td>';
699 if (count($tasksarray) > 0) {
706 $totalforvisibletasks =
projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0, $arrayfields, $extrafields);
712 $listofdistinctprojectid = array();
713 if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
714 foreach ($tasksarraywithoutfilter as $tmptask) {
715 $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
719 $totalforeachday = array();
720 foreach ($listofdistinctprojectid as $tmpprojectid) {
721 $projectstatic->id = $tmpprojectid;
722 $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id);
723 for ($idw = 0; $idw < 7; $idw++) {
725 $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
732 if (count($totalforeachday)) {
733 $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]);
734 if ($timeonothertasks) {
741 print
'<tr class="oddeven othertaskwithtime">';
742 print
'<td colspan="'.($colspan - 1).
'" class="opacitymedium">';
743 print $langs->trans(
"OtherFilteredTasks");
745 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
746 print
'<td class="liste_total"></td>';
747 print
'<td class="liste_total"></td>';
749 print
'<td class="leftborder"></td>';
750 print
'<td class="center">';
751 $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]);
754 print
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled="" id="timespent[-1][0]" name="task[-1][0]" value="';
755 if ($timeonothertasks) {
761 print
' <td class="liste_total"></td>';
762 print
' <td class="liste_total"></td>';
766 if ($conf->use_javascript_ajax) {
767 print
'<tr class="liste_total">';
768 print
'<td class="liste_total" colspan="'.($colspan - 1 + $addcolspan).
'">';
769 print $langs->trans(
"Total");
771 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
772 print
'<td class="liste_total"></td>';
773 print
'<td class="liste_total"></td>';
775 print
'<td class="liste_total leftborder">';
779 print
'<td class="liste_total center'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'"><div class="totalDay0"> </div></td>';
781 print
'<td class="liste_total"></td>
782 <td class="liste_total"></td>
786 print
'<tr><td colspan="14"><span class="opacitymedium">'.$langs->trans(
"NoAssignedTasks").
'</span></td></tr>';
791 print
'<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).
'"/>'.
"\n";
793 print
'<div class="center">';
794 print
'<input type="submit" name="button_addtime" class="button button-save"'.(!empty($disabledtask) ?
' disabled' :
'').
' value="'.$langs->trans(
"Save").
'">';
799 if (!empty($conf->use_javascript_ajax)) {
800 $modeinput =
'hours';
801 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
802 print
'<script type="text/javascript">'.
"\n";
803 print
"jQuery(document).ready(function () {\n";
804 print
" updateTotal(0,\''.$modeinput.'\');\n";
805 print
' jQuery(".timesheetalreadyrecorded").tooltip({
806 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
807 hide: { effect:\'toggle\', delay: 50 },
808 tooltipClass: "mytooltip",
809 content: function () {
810 return \''.dol_escape_js($langs->trans(
"TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).
'\';
813 print " jQuery('.inputhour, .inputminute
').bind('keyup
', function(e) { updateTotal(0, '".$modeinput."') });";
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class of the module paid holiday.
const STATUS_APPROVED
Approved.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
num_public_holiday($timestampStart, $timestampEnd, $country_code='', $lastday=0, $includesaturday=-1, $includesunday=-1, $includefriday=-1, $includemonday=-1)
Return the number of non working days including Friday, Saturday and Sunday (or not) between 2 dates ...
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a pertime intput mode.
project_timesheet_prepare_head($mode, $fuser=null)
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.