30require
"../../main.inc.php";
39require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
49$langs->loadLangs(array(
'projects',
'users',
'companies'));
51$action =
GETPOST(
'action',
'aZ09');
52$mode =
GETPOST(
"mode",
'alpha');
56$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'timespent';
65$hookmanager->initHooks(array(
'timesheetpermonthcard'));
83$search_usertoprocessid =
GETPOSTINT(
'search_usertoprocessid');
84$search_task_ref =
GETPOST(
'search_task_ref',
'alpha');
85$search_task_label =
GETPOST(
'search_task_label',
'alpha');
86$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
87$search_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
88$search_declared_progress =
GETPOST(
'search_declared_progress',
'alpha');
90$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
91$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
95$prev = $startdayarray;
96$prev_year = $prev[
'year'];
97$prev_month = $prev[
'month'];
101$next_year = $next[
'year'];
102$next_month = $next[
'month'];
105$firstdaytoshow =
dol_mktime(0, 0, 0, $month, 1, $year);
107$TFirstDays[reset($TWeek)] =
'01';
109$TLastDays[end($TWeek)] =
date(
"t", strtotime($year.
'-'.$month.
'-'.$day));
110if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
111 $usertoprocess = $user;
112 $search_usertoprocessid = $usertoprocess->id;
113} elseif ($search_usertoprocessid > 0) {
114 $usertoprocess =
new User(
$db);
115 $usertoprocess->fetch($search_usertoprocessid);
116 $search_usertoprocessid = $usertoprocess->id;
118 $usertoprocess =
new User(
$db);
127$extrafields->fetch_name_optionals_label(
$object->table_element);
130$arrayfields = array();
139$arrayfields[
't.planned_workload'] = array(
'label' =>
'PlannedWorkload',
'checked' =>
'1',
'enabled' =>
'1',
'position' => 5);
140$arrayfields[
't.progress'] = array(
'label' =>
'ProgressDeclared',
'checked' =>
'1',
'enabled' =>
'1',
'position' => 10);
141$arrayfields[
'timeconsumed'] = array(
'label' =>
'TimeConsumed',
'checked' =>
'1',
'enabled' =>
'1',
'position' => 15);
148$extrafieldsobjectkey =
'projet_task';
149$extrafieldsobjectprefix =
'efpt.';
150include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
154$search_array_options = array();
155$search_array_options_project = $extrafields->getOptionalsFromPost(
'projet',
'',
'search_');
156$search_array_options_task = $extrafields->getOptionalsFromPost(
'projet_task',
'',
'search_task_');
165$parameters = array(
'id' => $id,
'taskid' => $taskid,
'projectid' => $projectid,
'TWeek' => $TWeek,
'TFirstDays' => $TFirstDays,
'TLastDays' => $TLastDays);
166$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
172if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
175 $search_usertoprocessid = $user->id;
176 $search_task_ref =
'';
177 $search_task_label =
'';
178 $search_project_ref =
'';
179 $search_thirdparty =
'';
180 $search_declared_progress =
'';
182 $search_array_options_project = array();
183 $search_array_options_task = array();
186 $usertoprocess = $user;
188if (
GETPOST(
"button_search_x",
'alpha') ||
GETPOST(
"button_search.x",
'alpha') ||
GETPOST(
"button_search",
'alpha')) {
192if (
GETPOST(
'submitdateselect')) {
200include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
202if ($action ==
'addtime' && $user->hasRight(
'projet',
'lire') &&
GETPOST(
'assigntask') &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
203 $action =
'assigntask';
206 $result =
$object->fetch($taskid);
211 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Task")),
null,
'errors');
215 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
220 $idfortaskuser = $usertoprocess->id;
221 $result =
$object->add_contact($idfortaskuser,
GETPOST(
"type"),
'internal');
223 if ($result >= 0 || $result == -2) {
225 $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';
226 $sql .=
' AND ec.fk_socpeople = '.((int) $idfortaskuser).
" AND ec.element_id = ".((int)
$object->fk_project).
" AND tc.element = 'project' AND source = 'internal'";
227 $resql =
$db->query($sql);
229 $obj =
$db->fetch_object($resql);
232 $project->fetch(
$object->fk_project);
234 $listofprojcontact = $project->liste_type_contact(
'internal');
236 if (count($listofprojcontact)) {
237 $tmparray = array_keys($listofprojcontact);
238 $typeforprojectcontact = reset($tmparray);
239 $result = $project->add_contact($idfortaskuser, $typeforprojectcontact,
'internal');
250 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
251 $langs->load(
"errors");
252 setEventMessages($langs->trans(
"ErrorTaskAlreadyAssigned"),
null,
'warnings');
266if ($action ==
'addtime' && $user->hasRight(
'projet',
'lire') &&
GETPOST(
'formfilteraction') !=
'listafterchangingselectedfields') {
268 if (empty($timetoadd)) {
271 foreach ($timetoadd as $tmptaskid => $tmpvalue) {
272 $updateoftaskdone = 0;
273 foreach ($tmpvalue as $key => $val) {
274 $amountoadd = $timetoadd[$tmptaskid][$key];
275 if (!empty($amountoadd)) {
276 $tmpduration = explode(
':', $amountoadd);
278 if (!empty($tmpduration[0])) {
279 $newduration += (int) ((
float) $tmpduration[0] * 3600);
281 if (!empty($tmpduration[1])) {
282 $newduration += (int) ((
float) $tmpduration[1] * 60);
284 if (!empty($tmpduration[2])) {
285 $newduration += ((int) $tmpduration[2]);
288 if ($newduration > 0) {
291 if (GETPOSTISSET($tmptaskid.
'progress')) {
297 $object->timespent_duration = $newduration;
298 $object->timespent_fk_user = $usertoprocess->id;
303 $result =
$object->addTimeSpent($user);
315 if (!$updateoftaskdone) {
321 $result =
$object->update($user);
335 $param .= ($mode ?
'&mode='.urlencode($mode) :
'');
336 $param .= ($projectid ?
'id='.urlencode((
string) ($projectid)) :
'');
337 $param .= ($search_usertoprocessid ?
'&search_usertoprocessid='.urlencode((
string) $search_usertoprocessid) :
'');
338 $param .= ($day ?
'&day='.urlencode((
string) ($day)) :
'').($month ?
'&month='.urlencode((
string) ($month)) :
'').($year ?
'&year='.urlencode((
string) ($year)) :
'');
339 $param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
340 $param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode((
string) $search_usertoprocessid) :
'');
341 $param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
342 $param .= ($search_declared_progress ?
'&search_declared_progress='.urlencode($search_declared_progress) :
'');
343 $param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
344 $param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
351 $search_array_options = $search_array_options_task;
352 $search_options_pattern =
'search_task_options_';
353 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
356 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.$param);
378$title = $langs->trans(
"TimeSpent");
380$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1);
383 $project->fetch($id);
384 $project->fetch_thirdparty();
387$onlyopenedproject = 1;
388$morewherefilter =
'';
390if ($search_project_ref) {
391 $morewherefilter .=
natural_search(array(
"p.ref",
"p.title"), $search_project_ref);
393if ($search_task_ref) {
396if ($search_task_label) {
397 $morewherefilter .=
natural_search(array(
"t.ref",
"t.label"), $search_task_label);
399if ($search_thirdparty) {
402if ($search_declared_progress) {
403 $morewherefilter .=
natural_search(
"t.progress", $search_declared_progress, 1);
406$sql = &$morewherefilter;
414$search_array_options = $search_array_options_task;
415$extrafieldsobjectprefix =
'efpt.';
416$search_options_pattern =
'search_task_options_';
417$extrafieldsobjectkey =
'projet_task';
418include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
420$tasksarraywithoutfilter = array();
422$tasksarray = $taskstatic->getTasksArray(
null,
null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, (
string) $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields);
423if ($morewherefilter) {
424 $tasksarraywithoutfilter = $taskstatic->getTasksArray(
null,
null, ($project->id ? $project->id : 0), $socid, 0,
'', (
string) $onlyopenedproject,
'', ($search_usertoprocessid ? $search_usertoprocessid : 0));
426$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,
null, ($project->id ? (
string) $project->id :
'0'), 0, $onlyopenedproject);
427$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(
null, $usertoprocess, ($project->id ? (
string) $project->id :
'0'), 0, $onlyopenedproject);
433llxHeader(
'', $title,
'',
'', 0, 0, array(
'/core/js/timesheet.js'),
'',
'',
'mod-project project-activity page-activity_permonth');
438$param .= ($mode ?
'&mode='.urlencode($mode) :
'');
439$param .= ($search_project_ref ?
'&search_project_ref='.urlencode($search_project_ref) :
'');
440$param .= ($search_usertoprocessid > 0 ?
'&search_usertoprocessid='.urlencode((
string) $search_usertoprocessid) :
'');
441$param .= ($search_thirdparty ?
'&search_thirdparty='.urlencode($search_thirdparty) :
'');
442$param .= ($search_task_ref ?
'&search_task_ref='.urlencode($search_task_ref) :
'');
443$param .= ($search_task_label ?
'&search_task_label='.urlencode($search_task_label) :
'');
445$search_array_options = $search_array_options_project;
446$search_options_pattern =
'search_options_';
447include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
449$search_array_options = $search_array_options_task;
450$search_options_pattern =
'search_task_options_';
451include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
454$nav =
'<a class="inline-block valignmiddle" href="?year='.$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
'">'.
img_previous($langs->trans(
"Previous")).
"</a>\n";
455$nav .=
' <span id="month_name">'.dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%Y").
", ".$langs->trans(
date(
'F', mktime(0, 0, 0, $month, 10))).
" </span>\n";
456$nav .=
'<a class="inline-block valignmiddle" href="?year='.$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
'">'.
img_next($langs->trans(
"Next")).
"</a>\n";
457$nav .=
' '.$form->selectDate(-1,
'', 0, 0, 2,
"addtime", 1, (
$conf->dol_optimize_smallscreen ? 0 : 1)).
' ';
458$nav .=
' <button type="submit" name="submitdateselect" value="x" class="bordertransp nobordertransp button_search_x"><span class="fa fa-search"></span></button>';
462print
'<form name="addtime" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
463print
'<input type="hidden" name="token" value="'.newToken().
'">';
464print
'<input type="hidden" name="action" value="addtime">';
465print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
466print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
467print
'<input type="hidden" name="mode" value="'.$mode.
'">';
468print
'<input type="hidden" name="day" value="'.$day.
'">';
469print
'<input type="hidden" name="month" value="'.$month.
'">';
470print
'<input type="hidden" name="year" value="'.$year.
'">';
473print
dol_get_fiche_head($head,
'inputpermonth', $langs->trans(
'TimeSpent'), -1, $picto);
477if ($mine || ($usertoprocess->id == $user->id)) {
478 $s .= $langs->trans(
"MyTasksDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
480 if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
481 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
482 $s .= $langs->trans(
"ProjectsDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
484 $s .= $langs->trans(
"ProjectsPublicTaskDesc").
'.'.($onlyopenedproject ?
' '.$langs->trans(
"OnlyOpenedProject") :
'').
'<br>';
488if ($mine || ($usertoprocess->id == $user->id)) {
489 $s .= $langs->trans(
"OnlyYourTaskAreVisible");
491 $s .= $langs->trans(
"AllTaskVisibleButEditIfYouAreAssigned");
493print
info_admin($s, 0, 0,
'info',
'nomargintop nomarginbottom hideonsmartphone');
497print
'<div class="'.($conf->dol_optimize_smallscreen ?
'center centpercent' :
'floatright right').
'">'.$nav.
'</div>';
499print
'<div class="colorbacktimesheet valignmiddle'.($conf->dol_optimize_smallscreen ?
' center' :
' float').
'">';
500$titleassigntask = $langs->transnoentities(
"AssignTaskToMe");
501if ($usertoprocess->id != $user->id) {
502 $titleassigntask = $langs->transnoentities(
"AssignTaskToUser", $usertoprocess->getFullName($langs));
504print
'<div class="taskiddiv inline-block">';
505print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
506$formproject->selectTasks($socid ? $socid : -1, $taskid,
'taskid', 32, 0,
'-- '.$langs->trans(
"ChooseANotYetAssignedTask").
' --', 1, 0, 0,
'widthcentpercentminusx maxwidth500',
'',
'all', $usertoprocess);
509print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position', 0,
'maxwidth150onsmartphone');
510print
'<input type="submit" class="button valignmiddle smallonsmartphone small" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).
'">';
513print
'<div class="clearboth" style="padding-bottom: 20px;"></div>';
529$includeonly =
'hierarchyme';
530if (!$user->hasRight(
'user',
'user',
'lire')) {
531 $includeonly = array($user->id);
533$selecteduser = $search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id;
534$moreforfiltertmp = $form->select_dolusers($selecteduser,
'search_usertoprocessid', 0,
null, 0, $includeonly, array(),
'0', 0, 0,
'', 0,
'',
'maxwidth200');
535if ($form->num > 1 || empty(
$conf->dol_optimize_smallscreen)) {
536 $moreforfilter .=
'<div class="divsearchfield">';
537 $moreforfilter .=
'<div class="inline-block hideonsmartphone"></div>';
538 $moreforfilter .=
img_picto($langs->trans(
'Filter').
' '.$langs->trans(
'User'),
'user',
'class="paddingright pictofixedwidth"');
539 $moreforfilter .= $moreforfiltertmp;
540 $moreforfilter .=
'</div>';
542 $moreforfilter .=
'<input type="hidden" name="search_usertoprocessid" value="'.$selecteduser.
'">';
546 $moreforfilter .=
'<div class="divsearchfield">';
547 $moreforfilter .=
'<div class="inline-block"></div>';
548 $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).
'" spellcheck="false">';
549 $moreforfilter .=
'</div>';
551 $moreforfilter .=
'<div class="divsearchfield">';
552 $moreforfilter .=
'<div class="inline-block"></div>';
553 $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).
'" spellcheck="false">';
554 $moreforfilter .=
'</div>';
557if (!empty($moreforfilter)) {
558 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
559 print $moreforfilter;
560 $parameters = array();
561 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
562 print $hookmanager->resPrint;
566$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
568$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
572if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
575if (!empty($arrayfields[
't.progress'][
'checked'])) {
578foreach ($arrayfields as $key => $val) {
579 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
584print
'<div class="div-table-responsive">';
586print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
588print
'<tr class="liste_titre_filter">';
590 print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
593 print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).
'"></td>';
595print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).
'"></td>';
597$search_options_pattern =
'search_task_options_';
598$extrafieldsobjectkey =
'projet_task';
599$extrafieldsobjectprefix =
'efpt.';
600include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
601if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
602 print
'<td class="liste_titre"></td>';
604if (!empty($arrayfields[
't.progress'][
'checked'])) {
605 print
'<td class="liste_titre right"><input type="text" class="width50" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).
'"></td>';
607if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
608 print
'<td class="liste_titre"></td>';
609 print
'<td class="liste_titre"></td>';
611foreach ($TWeek as $week_number) {
612 print
'<td class="liste_titre"></td>';
615print
'<td class="liste_titre nowrap right">';
616$searchpicto = $form->showFilterAndCheckAddButtons(0);
621print
'<tr class="liste_titre">';
623 print
'<th>'.$langs->trans(
"Project").
'</th>';
626 print
'<th>'.$langs->trans(
"ThirdParty").
'</th>';
628print
'<th>'.$langs->trans(
"Task").
'</th>';
631$extrafieldsobjectkey =
'projet_task';
632$extrafieldsobjectprefix =
'efpt.';
633include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
635if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
636 print
'<th class="leftborder plannedworkload maxwidth75 maxwidth100 right">'.$form->textwithpicto($langs->trans(
"PlannedWorkloadShort"), $langs->trans(
"PlannedWorkload")).
'</th>';
638if (!empty($arrayfields[
't.progress'][
'checked'])) {
639 print
'<th class="right maxwidth75">'.$langs->trans(
"ProgressDeclared").
'</th>';
641if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
642 print
'<th class="right maxwidth100">'.$langs->trans(
"TimeSpentSmall").
'<br>';
643 print
'<span class="nowraponall">';
644 print
'<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphotosmall" src="'.DOL_URL_ROOT.
'/theme/common/everybody.png"></span>';
645 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"EverybodySmall").
'</span>';
648 print
'<th class="right maxwidth75">'.$langs->trans(
"TimeSpentSmall").($usertoprocess->firstname ?
'<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-3).
'<span class="opacitymedium paddingleft">'.
dol_trunc($usertoprocess->firstname, 10).
'</span></span>' :
'').
'</th>';
650foreach ($TWeek as $week_number) {
651 print
'<th width="6%" class="center bold hide"><a href="'.DOL_URL_ROOT.
'/projet/activity/perweek.php?year='.$year.
'&month='.$month.
'&day='.$TFirstDays[$week_number].
'">'.$langs->trans(
"WeekShort").
' '.$week_number.
'<br>('.$TFirstDays[$week_number].
'...'.$TLastDays[$week_number].
')</a></th>';
655print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
663$isavailable = array();
667$restrictviewformytask =
getDolGlobalInt(
'PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED', 2);
668if (count($tasksarray) > 0) {
675 $totalforvisibletasks =
projectLinesPerMonth($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $TWeek, $arrayfields);
681 $listofdistinctprojectid = array();
682 if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
683 foreach ($tasksarraywithoutfilter as $tmptask) {
684 $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
688 $totalforeachweek = array();
689 '@phan-var-force array<string,int> $totalforeachweek';
691 foreach ($listofdistinctprojectid as $tmpprojectid) {
692 $projectstatic->id = $tmpprojectid;
693 $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $usertoprocess->id);
694 foreach ($TWeek as $weekNb) {
695 $totalforeachweek[$weekNb] += $projectstatic->monthWorkLoad[$weekNb];
704 if (count($totalforeachweek)) {
705 foreach ($TWeek as $weekNb) {
706 $timeonothertasks = ($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]);
707 if ($timeonothertasks) {
716 print
'<tr class="oddeven othertaskwithtime">';
717 print
'<td colspan="'.$colspan.
'" class="opacitymedium">';
718 print $langs->trans(
"OtherFilteredTasks");
720 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
721 print
'<td class="liste_total"></td>';
723 if (!empty($arrayfields[
't.progress'][
'checked'])) {
724 print
'<td class="liste_total"></td>';
726 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
727 print
'<td class="liste_total"></td>';
728 print
'<td class="liste_total"></td>';
731 foreach ($TWeek as $weekNb) {
733 print
'<td class="center hide'.($j <= 1 ?
' borderleft' :
'').
'">';
735 $timeonothertasks = ($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]);
736 if ($timeonothertasks) {
737 print
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd width50" disabled="" id="timespent[-1]['.$weekNb.
']" name="task[-1]['.$weekNb.
']" value="';
743 print
' <td class="liste_total"></td>';
747 if (
$conf->use_javascript_ajax) {
748 print
'<tr class="liste_total">';
749 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
750 print $langs->trans(
"Total");
751 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"ExpectedWorkedHours").
': <strong>'.
price($usertoprocess->weeklyhours, 1, $langs, 0, 0).
'</strong></span>';
753 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
754 print
'<td class="liste_total"></td>';
755 print
'<td class="liste_total"></td>';
759 foreach ($TWeek as $weekNb) {
761 print
'<td class="liste_total hide'.$weekNb.
' center'.($j <= 1 ?
' borderleft' :
'').
'"><div class="totalDay'.$weekNb.
'">'.
convertSecondToTime($totalforvisibletasks[$weekNb],
'allhourmin').
'</div></td>';
763 print
'<td class="liste_total center"><div class="totalDayAll"> </div></td>
767 $THolidays = array();
768 $totaldayholiday = 0;
769 foreach ($TWeek as $weekNb) {
773 $filter .=
" AND ('".$db->idate($weekstart).
"' BETWEEN cp.date_debut AND cp.date_fin";
774 $filter .=
" OR '".$db->idate($weekend).
"' BETWEEN cp.date_debut AND cp.date_fin)";
775 $holiday->fetchByUser($usertoprocess->id,
'', $filter);
776 $THolidays[$weekNb] = array();
777 $THolidays[$weekNb][
"ids"] = array();
778 $THolidays[$weekNb][
"days"] = 0;
779 foreach ($holiday->holiday as $key => $h) {
780 if (!empty($THolidays[$weekNb][
"ids"]) && in_array($h[
"id"], $THolidays[$weekNb][
"ids"])) {
783 $startweekholiday = (int) (($h[
"date_debut"] <= $weekstart) ? $weekstart : $h[
"date_debut"]);
784 $endweekholiday = (int) (($h[
"date_fin"] >= $weekend) ? $weekend : $h[
"date_fin"]);
785 $halfdays = (int) $h[
"halfday"];
786 $nbdays =
num_open_day($startweekholiday, $endweekholiday, 0, 1, $halfdays, $usertoprocess->country_id);
788 $THolidays[$weekNb][
"ids"][] = $h[
"id"];
789 $THolidays[$weekNb][
"days"] += $nbdays;
790 $totaldayholiday += $nbdays;
795 print
'<tr class="liste_total">';
796 print
'<td class="liste_total" colspan="'.($colspan + $addcolspan).
'">';
797 print $langs->trans(
"Total");
798 print
'<span class="opacitymediumbycolor"> - '.$langs->trans(
"NbUseDaysCP").
': <strong>'.
price($totaldayholiday, 1, $langs, 0, 0).
'</strong></span>';
800 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
801 print
'<td class="liste_total"></td>';
802 print
'<td class="liste_total"></td>';
805 foreach ($TWeek as $weekNb) {
807 print
'<td class="liste_total_holidays '.($THolidays[$weekNb][
"days"] > 0 ?
"onholidayallday" :
"").
' hide'.$weekNb.
' center'.($j <= 1 ?
' borderleft' :
'').
'"><div class="totalDay'.$weekNb.
'holidays">'.$THolidays[$weekNb][
"days"].
'</div></td>';
809 print
'<td class="liste_total_holidays center"><div class="totalDayAllHolidays"> </div></td>
812 print
'<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans(
"NoAssignedTasks").
'</span></td></tr>';
817print
'<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).
'"/>'.
"\n";
818print
'<input type="hidden" id="numberOfFirstLine" name="numberOfFirstLine" value="'.(reset($TWeek)).
'"/>'.
"\n";
820print $form->buttonsSaveCancel(
"Save",
'');
822print
'</form>'.
"\n\n";
826if (
$conf->use_javascript_ajax) {
827 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
828 print
'<script type="text/javascript">'.
"\n";
829 print
"jQuery(document).ready(function () {\n";
830 print
' jQuery(".timesheetalreadyrecorded").tooltip({
831 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
832 hide: { effect:\'toggle\', delay: 50 },
833 tooltipClass: "mytooltip",
834 content: function () {
835 return \''.dol_escape_js($langs->trans(
"TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).
'\';
839 foreach ($TWeek as $week_number) {
840 print " updateTotal(".((int) $week_number).", '".dol_escape_js($modeinput)."');";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
dol_get_prev_month($month, $year)
Return previous month.
getLastDayOfEachWeek($TWeek, $year)
Return array of last day of weeks.
getWeekNumbersOfMonth($month, $year)
Return array of week numbers.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $countryCodeOrId='', $user_id=0)
Function to return number of working days (and text of units) between two dates (working days)
getFirstDayOfEachWeek($TWeek, $year)
Return array of first day of weeks.
dol_get_next_month($month, $year)
Return next month.
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.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $TWeek=array(), $arrayfields=array(), $extrafields=null)
Output a task line into a perday input mode.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
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.