dolibarr 24.0.3
perweek.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
6 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29require "../../main.inc.php";
38require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
45require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
46
47// Load translation files required by the page
48$langs->loadLangs(array('projects', 'users', 'companies'));
49
50$action = GETPOST('action', 'aZ09');
51$mode = GETPOST("mode", 'alpha');
52$id = GETPOSTINT('id');
53$taskid = GETPOSTINT('taskid');
54
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'timespent';
56
57$mine = 0;
58if ($mode == 'mine') {
59 $mine = 1;
60}
61
62$projectid = GETPOSTISSET("id") ? GETPOSTINT("id", 1) : GETPOSTINT("projectid");
63
64$hookmanager->initHooks(array('timesheetperweekcard'));
65
66// Security check
67$socid = 0;
68// For external user, no check is done on company because readability is managed by public status of project and assignment.
69// if ($user->socid > 0) $socid=$user->socid;
70$result = restrictedArea($user, 'projet', $projectid);
71
72$now = dol_now();
73
74$year = GETPOSTINT('reyear') ? GETPOSTINT('reyear') : (GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"));
75$month = GETPOSTINT('remonth') ? GETPOSTINT('remonth') : (GETPOSTINT("month") ? GETPOSTINT("month") : date("m"));
76$day = GETPOSTINT('reday') ? GETPOSTINT('reday') : (GETPOSTINT("day") ? GETPOSTINT("day") : date("d"));
77$week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W");
78
79$day = (int) $day;
80
81//$search_categ = GETPOST("search_categ", 'alpha');
82$search_usertoprocessid = GETPOSTINT('search_usertoprocessid');
83$search_task_ref = GETPOST('search_task_ref', 'alpha');
84$search_task_label = GETPOST('search_task_label', 'alpha');
85$search_project_ref = GETPOST('search_project_ref', 'alpha');
86$search_thirdparty = GETPOST('search_thirdparty', 'alpha');
87$search_declared_progress = GETPOST('search_declared_progress', 'alpha');
88
89$sortfield = GETPOST('sortfield', 'aZ09comma');
90$sortorder = GETPOST('sortorder', 'aZ09comma');
91
92$startdayarray = dol_get_first_day_week($day, $month, $year);
93
94$prev = $startdayarray;
95$prev_year = $prev['prev_year'];
96$prev_month = $prev['prev_month'];
97$prev_day = $prev['prev_day'];
98$first_day = $prev['first_day'];
99$first_month = $prev['first_month'];
100$first_year = $prev['first_year'];
101$week = $prev['week'];
102
103$next = dol_get_next_week($first_day, (int) $week, $first_month, $first_year);
104$next_year = $next['year'];
105$next_month = $next['month'];
106$next_day = $next['day'];
107
108// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
109$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
110$firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
111
112if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
113 $usertoprocess = $user;
114 $search_usertoprocessid = $usertoprocess->id;
115} elseif ($search_usertoprocessid > 0) {
116 $usertoprocess = new User($db);
117 $usertoprocess->fetch($search_usertoprocessid);
118 $search_usertoprocessid = $usertoprocess->id;
119} else {
120 $usertoprocess = new User($db);
121}
122
123$object = new Task($db);
124
125// Extra fields
126$extrafields = new ExtraFields($db);
127
128// fetch optionals attributes and labels
129$extrafields->fetch_name_optionals_label($object->table_element);
130
131// Definition of fields for list
132$arrayfields = array();
133/*$arrayfields=array(
134 // Project
135 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
136 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
137 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
138 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
139 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115),
140 );*/
141$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => '1', 'enabled' => '1', 'position' => 5);
142$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => '1', 'enabled' => '1', 'position' => 10);
143$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => '1', 'enabled' => '1', 'position' => 15);
144/*foreach($object->fields as $key => $val)
145 {
146 // If $val['visible']==0, then we never show the field
147 if (!empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
148 }*/
149// Extra fields
150$extrafieldsobjectkey = 'projet_task';
151$extrafieldsobjectprefix = 'efpt.';
152include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
153
154$arrayfields = dol_sort_array($arrayfields, 'position');
155
156$search_array_options = array();
157$search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_');
158$search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_');
159
160$error = 0;
161
162
163/*
164 * Actions
165 */
166
167$parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid);
168$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
169if ($reshook < 0) {
170 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171}
172// Purge criteria
173if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
174 $action = '';
175 //$search_categ = '';
176 $search_usertoprocessid = $user->id;
177 $search_task_ref = '';
178 $search_task_label = '';
179 $search_project_ref = '';
180 $search_thirdparty = '';
181 $search_declared_progress = '';
182
183 $search_array_options_project = array();
184 $search_array_options_task = array();
185
186 // We redefine $usertoprocess
187 $usertoprocess = $user;
188}
189if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) {
190 $action = '';
191}
192
193if (GETPOST('submitdateselect')) {
194 if (GETPOSTINT('remonth') && GETPOSTINT('reday') && GETPOSTINT('reyear')) {
195 $daytoparse = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
196 }
197
198 $action = '';
199}
200
201include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
202
203// Entering time or assigning a task requires permission to enter time, and the user to process must be me or one of my subordinates
204if ($action == 'addtime' && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { // Test on permission done later
205 $childids = $user->getAllChildIds(1);
206 if (!$user->hasRight('projet', 'time') || (!in_array($usertoprocess->id, $childids) && !$user->hasRight('projet', 'all', 'creer'))) {
208 }
209}
210
211if ($action == 'addtime' && $user->hasRight('projet', 'lire') && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
212 $action = 'assigntask';
213
214 if ($taskid > 0) {
215 $result = $object->fetch($taskid);
216 if ($result <= 0) {
217 $error++;
218 } else {
219 // Check that I can read the project of the task
220 restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
221 }
222 } else {
223 setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors');
224 $error++;
225 }
226 if (!GETPOST('type')) {
227 setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
228 $error++;
229 }
230
231 if (!$error) {
232 $idfortaskuser = $usertoprocess->id;
233 $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
234
235 if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task
236 // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
237 $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';
238 $sql .= ' AND ec.fk_socpeople = '.((int) $idfortaskuser)." AND ec.element_id = ".((int) $object->fk_project)." AND tc.element = 'project' AND source = 'internal'";
239 $resql = $db->query($sql);
240 if ($resql) {
241 $obj = $db->fetch_object($resql);
242 if (!$obj) { // User is not already linked to project, so we will create link to first type
243 $project = new Project($db);
244 $project->fetch($object->fk_project);
245 // Get type
246 $listofprojcontact = $project->liste_type_contact('internal');
247
248 if (count($listofprojcontact)) {
249 $tmparray = array_keys($listofprojcontact);
250 $typeforprojectcontact = reset($tmparray);
251 $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
252 }
253 }
254 } else {
256 }
257 }
258 }
259
260 if ($result < 0) {
261 $error++;
262 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
263 $langs->load("errors");
264 setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings');
265 } else {
266 setEventMessages($object->error, $object->errors, 'errors');
267 }
268 }
269
270 if (!$error) {
271 setEventMessages("TaskAssignedToEnterTime", null);
272 $taskid = 0;
273 }
274
275 $action = '';
276}
277
278if ($action == 'addtime' && $user->hasRight('projet', 'lire') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
279 $timetoadd = GETPOST('task');
280 if (empty($timetoadd)) {
281 setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
282 } else {
283 foreach ($timetoadd as $tmptaskid => $tmpvalue) { // Loop on each task
284 $updateoftaskdone = 0;
285 foreach ($tmpvalue as $key => $val) { // Loop on each day
286 $amountoadd = $timetoadd[$tmptaskid][$key];
287 if (!empty($amountoadd)) {
288 $tmpduration = explode(':', $amountoadd);
289 $newduration = 0;
290 if (!empty($tmpduration[0])) {
291 $newduration += (int) ((float) $tmpduration[0] * 3600);
292 }
293 if (!empty($tmpduration[1])) {
294 $newduration += (int) ((float) $tmpduration[1] * 60);
295 }
296 if (!empty($tmpduration[2])) {
297 $newduration += ((int) $tmpduration[2]);
298 }
299
300 if ($newduration > 0) {
301 if ($object->fetch($tmptaskid) <= 0) {
303 }
304 // Check that I can read the project of the task
305 restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
306
307 if (GETPOSTISSET($tmptaskid.'progress')) {
308 $object->progress = GETPOSTINT($tmptaskid.'progress');
309 } else {
310 unset($object->progress);
311 }
312
313 $object->timespent_duration = $newduration;
314 $object->timespent_fk_user = $usertoprocess->id;
315 $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
316 $object->timespent_datehour = $object->timespent_date;
317 $object->timespent_note = $object->description;
318
319 $result = $object->addTimeSpent($user);
320 if ($result < 0) {
321 setEventMessages($object->error, $object->errors, 'errors');
322 $error++;
323 break;
324 }
325
326 $updateoftaskdone++;
327 }
328 }
329 }
330
331 if (!$updateoftaskdone && GETPOSTISSET($tmptaskid.'progress')) { // Check to update progress if no update were done on task.
332 if ($object->fetch($tmptaskid) <= 0) {
334 }
335 // Check that I can read the project of the task
336 restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
337 //var_dump($object->progress);
338 //var_dump(GETPOST($tmptaskid . 'progress', 'int')); exit;
339 if ($object->progress != GETPOSTINT($tmptaskid.'progress')) {
340 $object->progress = GETPOSTINT($tmptaskid.'progress');
341 $result = $object->update($user);
342 if ($result < 0) {
343 setEventMessages($object->error, $object->errors, 'errors');
344 $error++;
345 break;
346 }
347 }
348 }
349 }
350
351 if (!$error) {
352 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
353
354 $param = '';
355 $param .= ($mode ? '&mode='.urlencode($mode) : '');
356 $param .= ($projectid ? 'id='.urlencode((string) ($projectid)) : '');
357 $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode((string) $search_usertoprocessid) : '');
358 $param .= ($day ? '&day='.urlencode((string) ($day)) : '').($month ? '&month='.urlencode((string) ($month)) : '').($year ? '&year='.urlencode((string) ($year)) : '');
359 $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
360 $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode((string) $search_usertoprocessid) : '');
361 $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
362 $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : '');
363 $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
364 $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
365
366 /*$search_array_options=$search_array_options_project;
367 $search_options_pattern='search_options_';
368 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
369 */
370
371 $search_array_options = $search_array_options_task;
372 $search_options_pattern = 'search_task_options_';
373 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
374
375 // Redirect to avoid submit twice on back
376 header('Location: '.$_SERVER["PHP_SELF"].'?'.$param);
377 exit;
378 }
379 }
380}
381
382
383/*
384 * View
385 */
386
387$form = new Form($db);
388$formother = new FormOther($db);
389$formcompany = new FormCompany($db);
390$formproject = new FormProjets($db);
391$projectstatic = new Project($db);
392$project = new Project($db);
393$taskstatic = new Task($db);
394$thirdpartystatic = new Societe($db);
395$holiday = new Holiday($db);
396
397$title = $langs->trans("TimeSpent");
398
399$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project
400//var_dump($projectsListId);
401if ($id) {
402 $project->fetch($id);
403 $project->fetch_thirdparty();
404}
405
406$onlyopenedproject = 1; // or -1
407$morewherefilter = '';
408
409if ($search_project_ref) {
410 $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref);
411}
412if ($search_task_ref) {
413 $morewherefilter .= natural_search("t.ref", $search_task_ref);
414}
415if ($search_task_label) {
416 $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label);
417}
418if ($search_thirdparty) {
419 $morewherefilter .= natural_search("s.nom", $search_thirdparty);
420}
421if ($search_declared_progress) {
422 $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1);
423}
424
425$sql = &$morewherefilter;
426
427/*$search_array_options = $search_array_options_project;
428 $extrafieldsobjectprefix='efp.';
429 $search_options_pattern='search_options_';
430 $extrafieldsobjectkey='projet';
431 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
432 */
433$search_array_options = $search_array_options_task;
434$extrafieldsobjectprefix = 'efpt.';
435$search_options_pattern = 'search_task_options_';
436$extrafieldsobjectkey = 'projet_task';
437include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
438
439$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, 0, $search_array_options_task, 1);// We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
440
441$tasksarraywithoutfilter = array();
442if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks
443 $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', (string) $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
444}
445$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? (string) $project->id : '0'), 0, (int) $onlyopenedproject);
446$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? (string) $project->id : '0'), 0, (int) $onlyopenedproject);
447//var_dump($tasksarray);
448//var_dump($projectsrole);
449//var_dump($taskrole);
450
451
452llxHeader("", $title, "", '', 0, 0, array('/core/js/timesheet.js'), '', '', 'mod-project project-activity page-activity_perweek');
453
454
455$param = '';
456$param .= ($mode ? '&mode='.urlencode($mode) : '');
457$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
458$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode((string) $search_usertoprocessid) : '');
459$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
460$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
461$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
462
463$search_array_options = $search_array_options_project;
464$search_options_pattern = 'search_options_';
465include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
466
467$search_array_options = $search_array_options_task;
468$search_options_pattern = 'search_task_options_';
469include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
470
471// Show navigation bar
472$nav = '<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
473$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";
474$nav .= '<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
475$nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, ($conf->dol_optimize_smallscreen ? 0 : 1)).' ';
476$nav .= ' <button type="submit" name="submitdateselect" value="x" class="nobordertransp button_search_x"><span class="fa fa-search"></span></button>';
477
478$picto = 'clock';
479
480print '<form name="addtime" method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
481print '<input type="hidden" name="token" value="'.newToken().'">';
482print '<input type="hidden" name="action" value="addtime">';
483print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
484print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
485print '<input type="hidden" name="mode" value="'.$mode.'">';
486print '<input type="hidden" name="day" value="'.$day.'">';
487print '<input type="hidden" name="month" value="'.$month.'">';
488print '<input type="hidden" name="year" value="'.$year.'">';
489
490$head = project_timesheet_prepare_head($mode, $usertoprocess);
491print dol_get_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, $picto);
492
493// Show description of content
494$s = '';
495if ($mine || ($usertoprocess->id == $user->id)) {
496 $s .= $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
497} else {
498 if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
499 if ($user->hasRight('projet', 'all', 'lire') && !$socid) {
500 $s .= $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
501 } else {
502 $s .= $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
503 }
504 }
505}
506if ($mine || ($usertoprocess->id == $user->id)) {
507 $s .= $langs->trans("OnlyYourTaskAreVisible");
508} else {
509 $s .= $langs->trans("AllTaskVisibleButEditIfYouAreAssigned");
510}
511print info_admin($s, 0, 0, 'info', 'nomargintop nomarginbottom hideonsmartphone');
512
513print dol_get_fiche_end();
514
515print '<div class="'.($conf->dol_optimize_smallscreen ? 'center centpercent' : 'floatright right').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
516
517print '<div class="colorbacktimesheet valignmiddle'.($conf->dol_optimize_smallscreen ? ' center' : ' float').'">';
518$titleassigntask = $langs->transnoentities("AssignTaskToMe");
519if ($usertoprocess->id != $user->id) {
520 $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
521}
522print '<div class="taskiddiv inline-block">';
523print img_picto('', 'projecttask', 'class="pictofixedwidth"');
524$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, 'widthcentpercentminusx maxwidth500', '', 'all', $usertoprocess);
525print '</div>';
526print ' ';
527print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone');
528print '<input type="submit" class="button valignmiddle smallonsmartphone small" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
529print '</div>';
530
531print '<div class="clearboth" style="padding-bottom: 20px;"></div>';
532
533
534$startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
535
536$numendworkingday = 0;
537$numstartworkingday = 0;
538// Get if user is available or not for each day
539$isavailable = array();
540
541// Assume from Monday to Friday if conf empty or badly formed
542$numstartworkingday = 1;
543$numendworkingday = 5;
544
545if (getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS')) {
546 $tmparray = explode('-', getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS'));
547 if (count($tmparray) >= 2) {
548 $numstartworkingday = $tmparray[0];
549 $numendworkingday = $tmparray[1];
550 }
551}
552
553for ($idw = 0; $idw < 7; $idw++) {
554 $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
555 $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
556
557 $statusofholidaytocheck = Holiday::STATUS_APPROVED;
558
559 $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, (string) $statusofholidaytocheck);
560 $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day
561
562 $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code);
563 if ($test) {
564 $isavailable[$dayinloopfromfirstdaytoshow] = array('morning' => false, 'afternoon' => false, 'morning_reason' => 'public_holiday', 'afternoon_reason' => 'public_holiday');
565 }
566}
567
568
569
570$moreforfilter = '';
571
572// Filter on categories
573/*
574 if (isModEnabled("categorie")) {
575 require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
576 $moreforfilter.='<div class="divsearchfield">';
577 $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
578 $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
579 $moreforfilter.='</div>';
580 }*/
581
582// If the user can view user other than himself
583$includeonly = 'hierarchyme';
584if (!$user->hasRight('user', 'user', 'lire')) {
585 $includeonly = array($user->id);
586}
587$selecteduser = $search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id;
588$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, '', '0', 0, 0, '', 0, '', 'maxwidth200');
589if ($form->num > 1 || empty($conf->dol_optimize_smallscreen)) {
590 $moreforfilter .= '<div class="divsearchfield">';
591 $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>';
592 $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright pictofixedwidth"');
593 $moreforfilter .= $moreforfiltertmp;
594 $moreforfilter .= '</div>';
595} else {
596 $moreforfilter .= '<input type="hidden" name="search_usertoprocessid" value="'.$selecteduser.'">';
597}
598
599if (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
600 $moreforfilter .= '<div class="divsearchfield">';
601 $moreforfilter .= '<div class="inline-block"></div>';
602 $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">';
603 $moreforfilter .= '</div>';
604
605 $moreforfilter .= '<div class="divsearchfield">';
606 $moreforfilter .= '<div class="inline-block"></div>';
607 $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">';
608 $moreforfilter .= '</div>';
609}
610
611if (!empty($moreforfilter)) {
612 print '<div class="liste_titre liste_titre_bydiv centpercent">';
613 print $moreforfilter;
614 $parameters = array();
615 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
616 print $hookmanager->resPrint;
617 print '</div>';
618}
619
620
621$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
622
623$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
624
625// This must be after the $selectedfields
626$addcolspan = 0;
627if (!empty($arrayfields['t.planned_workload']['checked'])) {
628 $addcolspan++;
629}
630if (!empty($arrayfields['t.progress']['checked'])) {
631 $addcolspan++;
632}
633foreach ($arrayfields as $key => $val) {
634 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
635 $addcolspan++;
636 }
637}
638
639print '<div class="div-table-responsive">';
640print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
641
642print '<tr class="liste_titre_filter">';
643if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
644 print '<td class="liste_titre"><input type="text" class="width75" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
645}
646if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
647 print '<td class="liste_titre"><input type="text" class="width75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>';
648}
649print '<td class="liste_titre"><input type="text" class="width75" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
650// TASK fields
651$search_options_pattern = 'search_task_options_';
652$extrafieldsobjectkey = 'projet_task';
653$extrafieldsobjectprefix = 'efpt.';
654include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
655if (!empty($arrayfields['t.planned_workload']['checked'])) {
656 print '<td class="liste_titre"></td>';
657}
658if (!empty($arrayfields['t.progress']['checked'])) {
659 print '<td class="liste_titre right"><input type="text" class="width50" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
660}
661if (!empty($arrayfields['timeconsumed']['checked'])) {
662 print '<td class="liste_titre"></td>';
663 print '<td class="liste_titre"></td>';
664}
665for ($idw = 0; $idw < 7; $idw++) {
666 print '<td class="liste_titre"></td>';
667}
668// Action column
669print '<td class="liste_titre nowrap right">';
670$searchpicto = $form->showFilterAndCheckAddButtons(0);
671print $searchpicto;
672print '</td>';
673print "</tr>\n";
674
675print '<tr class="liste_titre">';
676if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
677 print '<th>'.$langs->trans("Project").'</th>';
678}
679if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
680 print '<th>'.$langs->trans("ThirdParty").'</th>';
681}
682print '<th>'.$langs->trans("Task").'</th>';
683// TASK fields
684$extrafieldsobjectkey = 'projet_task';
685$extrafieldsobjectprefix = 'efpt.';
686include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
687if (!empty($arrayfields['t.planned_workload']['checked'])) {
688 print '<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans("PlannedWorkload")).'">'.$form->textwithpicto($langs->trans("PlannedWorkloadShort"), $langs->trans("PlannedWorkload")).'</th>';
689}
690if (!empty($arrayfields['t.progress']['checked'])) {
691 print '<th class="right minwidth75 maxwidth100" title="'.dol_escape_htmltag($langs->trans("ProgressDeclared")).'">'.$langs->trans("ProgressDeclared").'</th>';
692}
693if (!empty($arrayfields['timeconsumed']['checked'])) {
694 print '<th class="right maxwidth100">'.$langs->trans("TimeSpentSmall").'<br>';
695 print '<span class="nowraponall">';
696 print '<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphotosmall" src="'.DOL_URL_ROOT.'/theme/common/everybody.png"></span>';
697 print '<span class="opacitymedium paddingleft">'.$langs->trans("EverybodySmall").'</span>';
698 print '</span>';
699 print '</th>';
700 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>';
701}
702for ($idw = 0; $idw < 7; $idw++) {
703 $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
704
705 $cssweekend = '';
706 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
707 $cssweekend = 'weekend';
708 }
709
710 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
711
712 $cssonholiday = '';
713 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
714 $cssonholiday .= 'onholidayallday ';
715 } elseif (!$isavailable[$tmpday]['morning']) {
716 $cssonholiday .= 'onholidaymorning ';
717 } elseif (!$isavailable[$tmpday]['afternoon']) {
718 $cssonholiday .= 'onholidayafternoon ';
719 }
720
721 $year = (int) dol_print_date($dayinloopfromfirstdaytoshow, '%Y');
722 $month = (int) dol_print_date($dayinloopfromfirstdaytoshow, '%m');
723 $day = (int) dol_print_date($dayinloopfromfirstdaytoshow, '%d');
724
725 print '<th width="6%" class="center bold hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
726 print '<a href="'.DOL_URL_ROOT.'/projet/activity/perday.php?year='.$year.'&month='.$month.'&day='.$day.'">';
727 print dol_print_date($dayinloopfromfirstdaytoshow, '%a');
728 print '<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</a></th>';
729}
730
731//print '<td></td>';
732print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
733
734print "</tr>\n";
735
736$colspan = 1 + (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : 2);
737
738// Show lines with total
739if ($conf->use_javascript_ajax && count($tasksarray) >= getDolGlobalInt('NBLINES_TO_DUPLICATE_TOTAL_TIMESPENT_ON_TOP', 10)) {
740 print '<tr class="liste_total hideonsmartphone">';
741 print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
742 print $langs->trans("Total");
743 $htmltooltip = $langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0);
744 print '<span class="opacitymediumbycolor"> <div class="totalDayAll inline-block bold">&nbsp;</div> '.($usertoprocess->weeklyhours ? ' / '.$form->textwithpicto(price($usertoprocess->weeklyhours, 1, $langs, 0, 0), $htmltooltip) : '').'</strong></span>';
745 print '</td>';
746 if (!empty($arrayfields['timeconsumed']['checked'])) {
747 print '<td class="liste_total"></td>';
748 print '<td class="liste_total"></td>';
749 }
750 for ($idw = 0; $idw < 7; $idw++) {
751 $cssweekend = '';
752 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
753 $cssweekend = 'weekend';
754 }
755
756 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
757
758 $cssonholiday = '';
759 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
760 $cssonholiday .= 'onholidayallday ';
761 } elseif (!$isavailable[$tmpday]['morning']) {
762 $cssonholiday .= 'onholidaymorning ';
763 } elseif (!$isavailable[$tmpday]['afternoon']) {
764 $cssonholiday .= 'onholidayafternoon ';
765 }
766 print '<td class="liste_total center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
767 }
768 print '<td class="liste_total center"></td>';
769 print '</tr>';
770}
771
772
773
774// By default, we can edit only tasks we are assigned to
775$restrictviewformytask = getDolGlobalInt('PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED', 2);
776
777if (count($tasksarray) > 0) {
778 //var_dump($tasksarray); // contains only selected tasks
779 //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter)
780 //var_dump($tasksrole);
781
782 $j = 0;
783 $level = 0;
784 $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
785 //var_dump($totalforvisibletasks);
786
787 // Show total for all other tasks
788
789 // Calculate total for all tasks
790 $listofdistinctprojectid = array(); // List of all distinct projects
791 if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
792 foreach ($tasksarraywithoutfilter as $tmptask) {
793 $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
794 }
795 }
796 //var_dump($listofdistinctprojectid);
797 $totalforeachday = array();
798 foreach ($listofdistinctprojectid as $tmpprojectid) {
799 $projectstatic->id = $tmpprojectid;
800 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
801 for ($idw = 0; $idw < 7; $idw++) {
802 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
803 if (empty($totalforeachday[$tmpday])) {
804 $totalforeachday[$tmpday] = empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday];
805 } else {
806 $totalforeachday[$tmpday] += empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday];
807 }
808 }
809 }
810
811 //var_dump($totalforeachday);
812 //var_dump($totalforvisibletasks);
813
814 // Is there a diff between selected/filtered tasks and all tasks ?
815 $isdiff = 0;
816 if (count($totalforeachday)) {
817 for ($idw = 0; $idw < 7; $idw++) {
818 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
819 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
820 if ($timeonothertasks) {
821 $isdiff = 1;
822 break;
823 }
824 }
825 }
826
827 // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user
828 if ($isdiff) {
829 print '<tr class="oddeven othertaskwithtime">';
830 print '<td colspan="'.($colspan + $addcolspan).'" class="opacitymedium">';
831 print $langs->trans("OtherFilteredTasks");
832 print '</td>';
833 if (!empty($arrayfields['timeconsumed']['checked'])) {
834 print '<td class="liste_total"></td>';
835 print '<td class="liste_total"></td>';
836 }
837 $j = 0;
838 for ($idw = 0; $idw < 7; $idw++) {
839 $j++;
840 $cssweekend = '';
841 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
842 $cssweekend = 'weekend';
843 }
844
845 print '<td class="center hide'.$idw.' '.($cssweekend ? ' '.$cssweekend : '').($j <= 1 ? ' borderleft' : '').'">';
846 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
847 $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
848 if ($timeonothertasks) {
849 print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd width50" disabled="" id="timespent[-1]['.$idw.']" name="task[-1]['.$idw.']" value="';
850 print convertSecondToTime($timeonothertasks, 'allhourmin');
851 print '"></span>';
852 }
853 print '</td>';
854 }
855 print ' <td class="liste_total"></td>';
856 print '</tr>';
857 }
858
859 if ($conf->use_javascript_ajax) {
860 print '<tr class="liste_total">';
861 print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
862 print $langs->trans("Total");
863 $htmltooltip = $langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0);
864 print '<span class="opacitymediumbycolor"> <div class="totalDayAll inline-block bold">&nbsp;</div> '.($usertoprocess->weeklyhours ? ' / '.$form->textwithpicto(price($usertoprocess->weeklyhours, 1, $langs, 0, 0), $htmltooltip) : '').'</strong></span>';
865 print '</td>';
866 if (!empty($arrayfields['timeconsumed']['checked'])) {
867 print '<td class="liste_total"></td>';
868 print '<td class="liste_total"></td>';
869 }
870
871 $j = 0;
872 for ($idw = 0; $idw < 7; $idw++) {
873 $j++;
874 $cssweekend = '';
875 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
876 $cssweekend = 'weekend';
877 }
878
879 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
880
881 $cssonholiday = '';
882 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
883 $cssonholiday .= 'onholidayallday ';
884 } elseif (!$isavailable[$tmpday]['morning']) {
885 $cssonholiday .= 'onholidaymorning ';
886 } elseif (!$isavailable[$tmpday]['afternoon']) {
887 $cssonholiday .= 'onholidayafternoon ';
888 }
889
890 print '<td class="liste_total center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').($j <= 1 ? ' borderleft' : '').'"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
891 }
892 print '<td class="liste_total center"></td>';
893 print '</tr>';
894 }
895} else {
896 print '<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans("NoAssignedTasks").'</span></td></tr>';
897}
898print "</table>";
899print '</div>';
900
901print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
902
903print $form->buttonsSaveCancel("Save", '');
904
905print '</form>'."\n\n";
906
907$modeinput = 'hours';
908
909if ($conf->use_javascript_ajax) {
910 print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
911 print '<script type="text/javascript">'."\n";
912 print "jQuery(document).ready(function () {\n";
913 print ' jQuery(".timesheetalreadyrecorded").tooltip({
914 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
915 hide: { effect:\'toggle\', delay: 50 },
916 tooltipClass: "mytooltip",
917 content: function () {
918 return \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).'\';
919 }
920 });'."\n";
921
922 $idw = 0;
923 while ($idw < 7) {
924 print " updateTotal(".((int) $idw).", '".dol_escape_js($modeinput)."');";
925 $idw++;
926 }
927 print "\n});\n";
928 print '</script>';
929}
930
931// End of page
932llxFooter();
933$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage building of HTML components.
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 tasks.
Class to manage Dolibarr users.
global $mysoc
dol_get_next_week($day, $week, $month, $year)
Return next week.
Definition date.lib.php:598
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
Definition date.lib.php:695
num_public_holiday($timestampStart, $timestampEnd, $countryCodeOrId='', $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 ...
Definition date.lib.php:787
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:263
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
Definition date.lib.php:129
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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)
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
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.
projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $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
Definition receipt.php:492
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.