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