dolibarr  x.y.z
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 $error = 0;
156 
157 
158 /*
159  * Actions
160  */
161 
162 $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid);
163 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
164 if ($reshook < 0) {
165  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
166 }
167 // Purge criteria
168 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
169  $action = '';
170  //$search_categ = '';
171  $search_usertoprocessid = $user->id;
172  $search_task_ref = '';
173  $search_task_label = '';
174  $search_project_ref = '';
175  $search_thirdparty = '';
176  $search_declared_progress = '';
177 
178  $search_array_options_project = array();
179  $search_array_options_task = array();
180 
181  // We redefine $usertoprocess
182  $usertoprocess = $user;
183 }
184 if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) {
185  $action = '';
186 }
187 
188 if (GETPOST('submitdateselect')) {
189  if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) {
190  $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
191  }
192 
193  $action = '';
194 }
195 
196 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
197 
198 if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
199  $action = 'assigntask';
200 
201  if ($taskid > 0) {
202  $result = $object->fetch($taskid, $ref);
203  if ($result < 0) {
204  $error++;
205  }
206  } else {
207  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors');
208  $error++;
209  }
210  if (!GETPOST('type')) {
211  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
212  $error++;
213  }
214 
215  if (!$error) {
216  $idfortaskuser = $usertoprocess->id;
217  $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
218 
219  if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task
220  // 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)
221  $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';
222  $sql .= ' AND ec.fk_socpeople = '.((int) $idfortaskuser)." AND ec.element_id = ".((int) $object->fk_project)." AND tc.element = 'project' AND source = 'internal'";
223  $resql = $db->query($sql);
224  if ($resql) {
225  $obj = $db->fetch_object($resql);
226  if (!$obj) { // User is not already linked to project, so we will create link to first type
227  $project = new Project($db);
228  $project->fetch($object->fk_project);
229  // Get type
230  $listofprojcontact = $project->liste_type_contact('internal');
231 
232  if (count($listofprojcontact)) {
233  $tmparray = array_keys($listofprojcontact);
234  $typeforprojectcontact = reset($tmparray);
235  $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
236  }
237  }
238  } else {
239  dol_print_error($db);
240  }
241  }
242  }
243 
244  if ($result < 0) {
245  $error++;
246  if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
247  $langs->load("errors");
248  setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings');
249  } else {
250  setEventMessages($object->error, $object->errors, 'errors');
251  }
252  }
253 
254  if (!$error) {
255  setEventMessages("TaskAssignedToEnterTime", null);
256  $taskid = 0;
257  }
258 
259  $action = '';
260 }
261 
262 if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
263  $timetoadd = GETPOST('task');
264  if (empty($timetoadd)) {
265  setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
266  } else {
267  foreach ($timetoadd as $tmptaskid => $tmpvalue) { // Loop on each task
268  $updateoftaskdone = 0;
269  foreach ($tmpvalue as $key => $val) { // Loop on each day
270  $amountoadd = $timetoadd[$tmptaskid][$key];
271  if (!empty($amountoadd)) {
272  $tmpduration = explode(':', $amountoadd);
273  $newduration = 0;
274  if (!empty($tmpduration[0])) {
275  $newduration += ($tmpduration[0] * 3600);
276  }
277  if (!empty($tmpduration[1])) {
278  $newduration += ($tmpduration[1] * 60);
279  }
280  if (!empty($tmpduration[2])) {
281  $newduration += ($tmpduration[2]);
282  }
283 
284  if ($newduration > 0) {
285  $object->fetch($tmptaskid);
286 
287  if (GETPOSTISSET($tmptaskid.'progress')) {
288  $object->progress = GETPOST($tmptaskid.'progress', 'int');
289  } else {
290  unset($object->progress);
291  }
292 
293  $object->timespent_duration = $newduration;
294  $object->timespent_fk_user = $usertoprocess->id;
295  $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
296  $object->timespent_datehour = $object->timespent_date;
297  $object->timespent_note = $object->description;
298 
299  $result = $object->addTimeSpent($user);
300  if ($result < 0) {
301  setEventMessages($object->error, $object->errors, 'errors');
302  $error++;
303  break;
304  }
305 
306  $updateoftaskdone++;
307  }
308  }
309  }
310 
311  if (!$updateoftaskdone) { // Check to update progress if no update were done on task.
312  $object->fetch($tmptaskid);
313  //var_dump($object->progress);
314  //var_dump(GETPOST($tmptaskid . 'progress', 'int')); exit;
315  if ($object->progress != GETPOST($tmptaskid.'progress', 'int')) {
316  $object->progress = GETPOST($tmptaskid.'progress', 'int');
317  $result = $object->update($user);
318  if ($result < 0) {
319  setEventMessages($object->error, $object->errors, 'errors');
320  $error++;
321  break;
322  }
323  }
324  }
325  }
326 
327  if (!$error) {
328  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
329 
330  $param = '';
331  $param .= ($mode ? '&mode='.urlencode($mode) : '');
332  $param .= ($projectid ? 'id='.urlencode($projectid) : '');
333  $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
334  $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : '');
335  $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
336  $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
337  $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
338  $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : '');
339  $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
340  $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
341 
342  /*$search_array_options=$search_array_options_project;
343  $search_options_pattern='search_options_';
344  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
345  */
346 
347  $search_array_options = $search_array_options_task;
348  $search_options_pattern = 'search_task_options_';
349  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
350 
351  // Redirect to avoid submit twice on back
352  header('Location: '.$_SERVER["PHP_SELF"].'?'.$param);
353  exit;
354  }
355  }
356 }
357 
358 
359 /*
360  * View
361  */
362 
363 $form = new Form($db);
364 $formother = new FormOther($db);
365 $formcompany = new FormCompany($db);
366 $formproject = new FormProjets($db);
367 $projectstatic = new Project($db);
368 $project = new Project($db);
369 $taskstatic = new Task($db);
370 $thirdpartystatic = new Societe($db);
371 $holiday = new Holiday($db);
372 
373 $title = $langs->trans("TimeSpent");
374 
375 $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
376 //var_dump($projectsListId);
377 if ($id) {
378  $project->fetch($id);
379  $project->fetch_thirdparty();
380 }
381 
382 $onlyopenedproject = 1; // or -1
383 $morewherefilter = '';
384 
385 if ($search_project_ref) {
386  $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref);
387 }
388 if ($search_task_ref) {
389  $morewherefilter .= natural_search("t.ref", $search_task_ref);
390 }
391 if ($search_task_label) {
392  $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label);
393 }
394 if ($search_thirdparty) {
395  $morewherefilter .= natural_search("s.nom", $search_thirdparty);
396 }
397 if ($search_declared_progress) {
398  $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1);
399 }
400 
401 $sql = &$morewherefilter;
402 
403 /*$search_array_options = $search_array_options_project;
404  $extrafieldsobjectprefix='efp.';
405  $search_options_pattern='search_options_';
406  $extrafieldsobjectkey='projet';
407  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
408  */
409 $search_array_options = $search_array_options_task;
410 $extrafieldsobjectprefix = 'efpt.';
411 $search_options_pattern = 'search_task_options_';
412 $extrafieldsobjectkey = 'projet_task';
413 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
414 
415 $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.
416 if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks
417  $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.
418 }
419 $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
420 $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
421 //var_dump($tasksarray);
422 //var_dump($projectsrole);
423 //var_dump($taskrole);
424 
425 
426 llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js'));
427 
428 //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project');
429 
430 $param = '';
431 $param .= ($mode ? '&mode='.urlencode($mode) : '');
432 $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
433 $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
434 $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
435 $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
436 $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
437 
438 $search_array_options = $search_array_options_project;
439 $search_options_pattern = 'search_options_';
440 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
441 
442 $search_array_options = $search_array_options_task;
443 $search_options_pattern = 'search_task_options_';
444 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
445 
446 // Show navigation bar
447 $nav = '<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
448 $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";
449 $nav .= '<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
450 $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' ';
451 $nav .= ' <button type="submit" name="submitdateselect" value="x" class="nobordertransp button_search_x"><span class="fa fa-search"></span></button>';
452 
453 $picto = 'clock';
454 
455 print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
456 print '<input type="hidden" name="token" value="'.newToken().'">';
457 print '<input type="hidden" name="action" value="addtime">';
458 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
459 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
460 print '<input type="hidden" name="mode" value="'.$mode.'">';
461 print '<input type="hidden" name="day" value="'.$day.'">';
462 print '<input type="hidden" name="month" value="'.$month.'">';
463 print '<input type="hidden" name="year" value="'.$year.'">';
464 
465 $head = project_timesheet_prepare_head($mode, $usertoprocess);
466 print dol_get_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, $picto);
467 
468 // Show description of content
469 print '<div class="hideonsmartphone opacitymedium">';
470 if ($mine || ($usertoprocess->id == $user->id)) {
471  print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
472 } else {
473  if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
474  if ($user->rights->projet->all->lire && !$socid) {
475  print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
476  } else {
477  print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
478  }
479  }
480 }
481 if ($mine || ($usertoprocess->id == $user->id)) {
482  print $langs->trans("OnlyYourTaskAreVisible").'<br>';
483 } else {
484  print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>';
485 }
486 print '</div>';
487 
488 print dol_get_fiche_end();
489 
490 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.
491 
492 print '<div class="colorbacktimesheet float valignmiddle">';
493 $titleassigntask = $langs->transnoentities("AssignTaskToMe");
494 if ($usertoprocess->id != $user->id) {
495  $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
496 }
497 print '<div class="taskiddiv inline-block">';
498 print img_picto('', 'projecttask', 'class="pictofixedwidth"');
499 $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess);
500 print '</div>';
501 print ' ';
502 print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
503 print '<input type="submit" class="button valignmiddle smallonsmartphone small" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
504 print '</div>';
505 
506 print '<div class="clearboth" style="padding-bottom: 20px;"></div>';
507 
508 
509 $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
510 
511 $numendworkingday = 0;
512 $numstartworkingday = 0;
513 // Get if user is available or not for each day
514 $isavailable = array();
515 
516 // Assume from Monday to Friday if conf empty or badly formed
517 $numstartworkingday = 1;
518 $numendworkingday = 5;
519 
520 if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
521  $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
522  if (count($tmparray) >= 2) {
523  $numstartworkingday = $tmparray[0];
524  $numendworkingday = $tmparray[1];
525  }
526 }
527 
528 for ($idw = 0; $idw < 7; $idw++) {
529  $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
530  $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
531 
532  $statusofholidaytocheck = Holiday::STATUS_APPROVED;
533 
534  $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck);
535  $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day
536 
537  $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code);
538  if ($test) {
539  $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday');
540  }
541 }
542 
543 
544 
545 $moreforfilter = '';
546 
547 // Filter on categories
548 /*
549  if (!empty($conf->categorie->enabled))
550  {
551  require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
552  $moreforfilter.='<div class="divsearchfield">';
553  $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
554  $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
555  $moreforfilter.='</div>';
556  }*/
557 
558 // If the user can view user other than himself
559 $moreforfilter .= '<div class="divsearchfield">';
560 $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>';
561 $includeonly = 'hierarchyme';
562 if (empty($user->rights->user->user->lire)) {
563  $includeonly = array($user->id);
564 }
565 $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');
566 $moreforfilter .= '</div>';
567 
568 if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
569  $moreforfilter .= '<div class="divsearchfield">';
570  $moreforfilter .= '<div class="inline-block"></div>';
571  $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).'">';
572  $moreforfilter .= '</div>';
573 
574  $moreforfilter .= '<div class="divsearchfield">';
575  $moreforfilter .= '<div class="inline-block"></div>';
576  $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).'">';
577  $moreforfilter .= '</div>';
578 }
579 
580 if (!empty($moreforfilter)) {
581  print '<div class="liste_titre liste_titre_bydiv centpercent">';
582  print $moreforfilter;
583  $parameters = array();
584  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
585  print $hookmanager->resPrint;
586  print '</div>';
587 }
588 
589 
590 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
591 
592 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
593 
594 // This must be after the $selectedfields
595 $addcolspan = 0;
596 if (!empty($arrayfields['t.planned_workload']['checked'])) {
597  $addcolspan++;
598 }
599 if (!empty($arrayfields['t.progress']['checked'])) {
600  $addcolspan++;
601 }
602 foreach ($arrayfields as $key => $val) {
603  if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
604  $addcolspan++;
605  }
606 }
607 
608 print '<div class="div-table-responsive">';
609 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
610 
611 print '<tr class="liste_titre_filter">';
612 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
613  print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
614 }
615 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
616  print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>';
617 }
618 print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
619 // TASK fields
620 $search_options_pattern = 'search_task_options_';
621 $extrafieldsobjectkey = 'projet_task';
622 $extrafieldsobjectprefix = 'efpt.';
623 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
624 if (!empty($arrayfields['t.planned_workload']['checked'])) {
625  print '<td class="liste_titre"></td>';
626 }
627 if (!empty($arrayfields['t.progress']['checked'])) {
628  print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
629 }
630 if (!empty($arrayfields['timeconsumed']['checked'])) {
631  print '<td class="liste_titre"></td>';
632  print '<td class="liste_titre"></td>';
633 }
634 for ($idw = 0; $idw < 7; $idw++) {
635  print '<td class="liste_titre"></td>';
636 }
637 // Action column
638 print '<td class="liste_titre nowrap right">';
639 $searchpicto = $form->showFilterAndCheckAddButtons(0);
640 print $searchpicto;
641 print '</td>';
642 print "</tr>\n";
643 
644 print '<tr class="liste_titre">';
645 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
646  print '<th>'.$langs->trans("Project").'</th>';
647 }
648 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
649  print '<th>'.$langs->trans("ThirdParty").'</th>';
650 }
651 print '<th>'.$langs->trans("Task").'</th>';
652 // TASK fields
653 $extrafieldsobjectkey = 'projet_task';
654 $extrafieldsobjectprefix = 'efpt.';
655 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
656 if (!empty($arrayfields['t.planned_workload']['checked'])) {
657  print '<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans("PlannedWorkload")).'">'.$langs->trans("PlannedWorkload").'</th>';
658 }
659 if (!empty($arrayfields['t.progress']['checked'])) {
660  print '<th class="right minwidth75 maxwidth100" title="'.dol_escape_htmltag($langs->trans("ProgressDeclared")).'">'.$langs->trans("ProgressDeclared").'</th>';
661 }
662 if (!empty($arrayfields['timeconsumed']['checked'])) {
663  print '<th class="right maxwidth100">'.$langs->trans("TimeSpent").'<br>';
664  print '<span class="nowraponall">';
665  print '<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.'/theme/common/everybody.png"></span>';
666  print '<span class="opacitymedium paddingleft">'.$langs->trans("Everybody").'</span>';
667  print '</span>';
668  print '</th>';
669  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>';
670 }
671 for ($idw = 0; $idw < 7; $idw++) {
672  $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
673 
674  $cssweekend = '';
675  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.
676  $cssweekend = 'weekend';
677  }
678 
679  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
680 
681  $cssonholiday = '';
682  if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
683  $cssonholiday .= 'onholidayallday ';
684  } elseif (!$isavailable[$tmpday]['morning']) {
685  $cssonholiday .= 'onholidaymorning ';
686  } elseif (!$isavailable[$tmpday]['afternoon']) {
687  $cssonholiday .= 'onholidayafternoon ';
688  }
689 
690  print '<th width="6%" class="center bold hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
691  print dol_print_date($dayinloopfromfirstdaytoshow, '%a');
692  print '<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</th>';
693 }
694 //print '<td></td>';
695 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
696 
697 
698 print "</tr>\n";
699 
700 $colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
701 
702 if ($conf->use_javascript_ajax) {
703  print '<tr class="liste_total">';
704  print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
705  print $langs->trans("Total");
706  print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
707  print '</td>';
708  if (!empty($arrayfields['timeconsumed']['checked'])) {
709  print '<td class="liste_total"></td>';
710  print '<td class="liste_total"></td>';
711  }
712  for ($idw = 0; $idw < 7; $idw++) {
713  $cssweekend = '';
714  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.
715  $cssweekend = 'weekend';
716  }
717 
718  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
719 
720  $cssonholiday = '';
721  if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
722  $cssonholiday .= 'onholidayallday ';
723  } elseif (!$isavailable[$tmpday]['morning']) {
724  $cssonholiday .= 'onholidaymorning ';
725  } elseif (!$isavailable[$tmpday]['afternoon']) {
726  $cssonholiday .= 'onholidayafternoon ';
727  }
728  print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
729  }
730  print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
731  print '</tr>';
732 }
733 
734 
735 
736 // By default, we can edit only tasks we are assigned to
737 $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
738 if (count($tasksarray) > 0) {
739  //var_dump($tasksarray); // contains only selected tasks
740  //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter)
741  //var_dump($tasksrole);
742 
743  $j = 0;
744  $level = 0;
745  $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
746  //var_dump($totalforvisibletasks);
747 
748  // Show total for all other tasks
749 
750  // Calculate total for all tasks
751  $listofdistinctprojectid = array(); // List of all distinct projects
752  if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
753  foreach ($tasksarraywithoutfilter as $tmptask) {
754  $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
755  }
756  }
757  //var_dump($listofdistinctprojectid);
758  $totalforeachday = array();
759  foreach ($listofdistinctprojectid as $tmpprojectid) {
760  $projectstatic->id = $tmpprojectid;
761  $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
762  for ($idw = 0; $idw < 7; $idw++) {
763  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
764  $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
765  }
766  }
767 
768  //var_dump($totalforeachday);
769  //var_dump($totalforvisibletasks);
770 
771  // Is there a diff between selected/filtered tasks and all tasks ?
772  $isdiff = 0;
773  if (count($totalforeachday)) {
774  for ($idw = 0; $idw < 7; $idw++) {
775  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
776  $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
777  if ($timeonothertasks) {
778  $isdiff = 1;
779  break;
780  }
781  }
782  }
783 
784  // 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
785  if ($isdiff) {
786  print '<tr class="oddeven othertaskwithtime">';
787  print '<td colspan="'.($colspan + $addcolspan).'" class="opacitymedium">';
788  print $langs->trans("OtherFilteredTasks");
789  print '</td>';
790  if (!empty($arrayfields['timeconsumed']['checked'])) {
791  print '<td class="liste_total"></td>';
792  print '<td class="liste_total"></td>';
793  }
794  for ($idw = 0; $idw < 7; $idw++) {
795  $cssweekend = '';
796  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.
797  $cssweekend = 'weekend';
798  }
799 
800  print '<td class="center hide'.$idw.' '.($cssweekend ? ' '.$cssweekend : '').'">';
801  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
802  $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
803  if ($timeonothertasks) {
804  print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.']" name="task[-1]['.$idw.']" value="';
805  print convertSecondToTime($timeonothertasks, 'allhourmin');
806  print '"></span>';
807  }
808  print '</td>';
809  }
810  print ' <td class="liste_total"></td>';
811  print '</tr>';
812  }
813 
814  if ($conf->use_javascript_ajax) {
815  print '<tr class="liste_total">';
816  print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
817  print $langs->trans("Total");
818  print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
819  print '</td>';
820  if (!empty($arrayfields['timeconsumed']['checked'])) {
821  print '<td class="liste_total"></td>';
822  print '<td class="liste_total"></td>';
823  }
824 
825  for ($idw = 0; $idw < 7; $idw++) {
826  $cssweekend = '';
827  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.
828  $cssweekend = 'weekend';
829  }
830 
831  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
832 
833  $cssonholiday = '';
834  if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
835  $cssonholiday .= 'onholidayallday ';
836  } elseif (!$isavailable[$tmpday]['morning']) {
837  $cssonholiday .= 'onholidaymorning ';
838  } elseif (!$isavailable[$tmpday]['afternoon']) {
839  $cssonholiday .= 'onholidayafternoon ';
840  }
841 
842  print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
843  }
844  print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
845  print '</tr>';
846  }
847 } else {
848  print '<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans("NoAssignedTasks").'</span></td></tr>';
849 }
850 print "</table>";
851 print '</div>';
852 
853 print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
854 
855 print $form->buttonsSaveCancel("Save", '');
856 
857 print '</form>'."\n\n";
858 
859 $modeinput = 'hours';
860 
861 if ($conf->use_javascript_ajax) {
862  print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
863  print '<script type="text/javascript">'."\n";
864  print "jQuery(document).ready(function () {\n";
865  print ' jQuery(".timesheetalreadyrecorded").tooltip({
866  show: { collision: "flipfit", effect:\'toggle\', delay:50 },
867  hide: { effect:\'toggle\', delay: 50 },
868  tooltipClass: "mytooltip",
869  content: function () {
870  return \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).'\';
871  }
872  });'."\n";
873 
874  $idw = 0;
875  while ($idw < 7) {
876  print ' updateTotal('.$idw.',\''.$modeinput.'\');';
877  $idw++;
878  }
879  print "\n});\n";
880  print '</script>';
881 }
882 
883 // End of page
884 llxFooter();
885 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
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.
Classe permettant la generation de composants html autre 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.
Definition: task.class.php:38
Class to manage Dolibarr users.
Definition: user.class.php:45
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_get_next_week($day, $week, $month, $year)
Return next week.
Definition: date.lib.php:553
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
Definition: date.lib.php:650
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
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:238
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:744
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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 intput mode.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.