dolibarr  13.0.2
project.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  * or see https://www.gnu.org/
20  */
21 
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 
29 
36 function project_prepare_head(Project $project)
37 {
38  global $db, $langs, $conf, $user;
39 
40  $h = 0;
41  $head = array();
42 
43  $head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.$project->id;
44  $head[$h][1] = $langs->trans("Project");
45  $head[$h][2] = 'project';
46  $h++;
47 
48  $nbContact = count($project->liste_contact(-1, 'internal')) + count($project->liste_contact(-1, 'external'));
49  $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$project->id;
50  $head[$h][1] = $langs->trans("ProjectContact");
51  if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
52  $head[$h][2] = 'contact';
53  $h++;
54 
55  if (empty($conf->global->PROJECT_HIDE_TASKS))
56  {
57  // Then tab for sub level of projet, i mean tasks
58  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id;
59  $head[$h][1] = $langs->trans("Tasks");
60 
61  require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
62  $taskstatic = new Task($db);
63  $nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0));
64  if ($nbTasks > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbTasks).'</span>';
65  $head[$h][2] = 'tasks';
66  $h++;
67 
68  $nbTimeSpent = 0;
69  $sql = "SELECT t.rowid";
70  //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
71  //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
72  $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt";
73  $sql .= " WHERE t.fk_task = pt.rowid";
74  $sql .= " AND pt.fk_projet =".$project->id;
75  $resql = $db->query($sql);
76  if ($resql)
77  {
78  $obj = $db->fetch_object($resql);
79  if ($obj) $nbTimeSpent = 1;
80  } else dol_print_error($db);
81 
82  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$project->id;
83  $head[$h][1] = $langs->trans("TimeSpent");
84  if ($nbTimeSpent > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
85  $head[$h][2] = 'timespent';
86  $h++;
87  }
88 
89  if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
90  || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
91  || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
92  || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled))
93  {
94  $count = 0;
95 
96  if (!empty($conf->propal->enabled)) $count += $project->getElementCount('propal', 'propal');
97  if (!empty($conf->commande->enabled)) $count += $project->getElementCount('order', 'commande');
98  if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice', 'facture');
99  if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice_predefined', 'facture_rec');
100  if (!empty($conf->supplier_proposal->enabled)) $count += $project->getElementCount('proposal_supplier', 'supplier_proposal');
101  if (!empty($conf->supplier_order->enabled)) $count += $project->getElementCount('order_supplier', 'commande_fournisseur');
102  if (!empty($conf->supplier_invoice->enabled)) $count += $project->getElementCount('invoice_supplier', 'facture_fourn');
103  if (!empty($conf->contrat->enabled)) $count += $project->getElementCount('contract', 'contrat');
104  if (!empty($conf->ficheinter->enabled)) $count += $project->getElementCount('intervention', 'fichinter');
105  if (!empty($conf->expedition->enabled)) $count += $project->getElementCount('shipping', 'expedition');
106  if (!empty($conf->mrp->enabled)) $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project');
107  if (!empty($conf->deplacement->enabled)) $count += $project->getElementCount('trip', 'deplacement');
108  if (!empty($conf->expensereport->enabled)) $count += $project->getElementCount('expensereport', 'expensereport');
109  if (!empty($conf->don->enabled)) $count += $project->getElementCount('donation', 'don');
110  if (!empty($conf->loan->enabled)) $count += $project->getElementCount('loan', 'loan');
111  if (!empty($conf->tax->enabled)) $count += $project->getElementCount('chargesociales', 'chargesociales');
112  if (!empty($conf->projet->enabled)) $count += $project->getElementCount('project_task', 'projet_task');
113  if (!empty($conf->stock->enabled)) $count += $project->getElementCount('stock_mouvement', 'stock');
114  if (!empty($conf->salaries->enabled)) $count += $project->getElementCount('salaries', 'payment_salary');
115  if (!empty($conf->banque->enabled)) $count += $project->getElementCount('variouspayment', 'payment_various');
116 
117  $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$project->id;
118  $head[$h][1] = $langs->trans("ProjectOverview");
119  if ($count > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$count.'</span>';
120  $head[$h][2] = 'element';
121  $h++;
122  }
123 
124  // Show more tabs from modules
125  // Entries must be declared in modules descriptor with line
126  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
127  // $this->tabs = array('entity:-tabname); to remove a tab
128  complete_head_from_modules($conf, $langs, $project, $head, $h, 'project');
129 
130 
131  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
132  {
133  $nbNote = 0;
134  if (!empty($project->note_private)) $nbNote++;
135  if (!empty($project->note_public)) $nbNote++;
136  $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$project->id;
137  $head[$h][1] = $langs->trans('Notes');
138  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
139  $head[$h][2] = 'notes';
140  $h++;
141  }
142 
143  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
144  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
145  $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($project->ref);
146  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
147  $nbLinks = Link::count($db, $project->element, $project->id);
148  $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$project->id;
149  $head[$h][1] = $langs->trans('Documents');
150  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
151  $head[$h][2] = 'document';
152  $h++;
153 
154  // Manage discussion
155  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
156  {
157  $nbComments = $project->getNbComments();
158  $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$project->id;
159  $head[$h][1] = $langs->trans("CommentLink");
160  if ($nbComments > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>';
161  $head[$h][2] = 'project_comment';
162  $h++;
163  }
164 
165  $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$project->id;
166  $head[$h][1] .= $langs->trans("Events");
167  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
168  {
169  $head[$h][1] .= '/';
170  $head[$h][1] .= $langs->trans("Agenda");
171  }
172  $head[$h][2] = 'agenda';
173  $h++;
174 
175  complete_head_from_modules($conf, $langs, $project, $head, $h, 'project', 'remove');
176 
177  return $head;
178 }
179 
180 
187 function task_prepare_head($object)
188 {
189  global $db, $langs, $conf, $user;
190  $h = 0;
191  $head = array();
192 
193  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
194  $head[$h][1] = $langs->trans("Task");
195  $head[$h][2] = 'task_task';
196  $h++;
197 
198  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
199  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
200  $head[$h][1] = $langs->trans("TaskRessourceLinks");
201  if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
202  $head[$h][2] = 'task_contact';
203  $h++;
204 
205  // Is there timespent ?
206  $nbTimeSpent = 0;
207  $sql = "SELECT t.rowid";
208  //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
209  //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
210  $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
211  $sql .= " WHERE t.fk_task =".$object->id;
212  $resql = $db->query($sql);
213  if ($resql)
214  {
215  $obj = $db->fetch_object($resql);
216  if ($obj) $nbTimeSpent = 1;
217  } else dol_print_error($db);
218 
219  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
220  $head[$h][1] = $langs->trans("TimeSpent");
221  if ($nbTimeSpent > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
222  $head[$h][2] = 'task_time';
223  $h++;
224 
225  // Show more tabs from modules
226  // Entries must be declared in modules descriptor with line
227  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
228  // $this->tabs = array('entity:-tabname); to remove a tab
229  complete_head_from_modules($conf, $langs, $object, $head, $h, 'task');
230 
231  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
232  {
233  $nbNote = 0;
234  if (!empty($object->note_private)) $nbNote++;
235  if (!empty($object->note_public)) $nbNote++;
236  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
237  $head[$h][1] = $langs->trans('Notes');
238  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
239  $head[$h][2] = 'task_notes';
240  $h++;
241  }
242 
243  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
244  $filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref);
245  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
246  include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
247  $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
248  $nbLinks = Link::count($db, $object->element, $object->id);
249  $head[$h][1] = $langs->trans('Documents');
250  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
251  $head[$h][2] = 'task_document';
252  $h++;
253 
254  // Manage discussion
255  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
256  {
257  $nbComments = $object->getNbComments();
258  $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
259  $head[$h][1] = $langs->trans("CommentLink");
260  if ($nbComments > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>';
261  $head[$h][2] = 'task_comment';
262  $h++;
263  }
264 
265  complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove');
266 
267  return $head;
268 }
269 
277 function project_timesheet_prepare_head($mode, $fuser = null)
278 {
279  global $langs, $conf, $user;
280  $h = 0;
281  $head = array();
282 
283  $h = 0;
284 
285  $param = '';
286  $param .= ($mode ? '&mode='.$mode : '');
287  if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id;
288 
289  if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH))
290  {
291  $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : '');
292  $head[$h][1] = $langs->trans("InputPerMonth");
293  $head[$h][2] = 'inputpermonth';
294  $h++;
295  }
296 
297  if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
298  {
299  $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
300  $head[$h][1] = $langs->trans("InputPerWeek");
301  $head[$h][2] = 'inputperweek';
302  $h++;
303  }
304 
305  if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
306  {
307  $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : '');
308  $head[$h][1] = $langs->trans("InputPerDay");
309  $head[$h][2] = 'inputperday';
310  $h++;
311  }
312 
313  /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
314  {
315  $head[$h][0] = DOL_URL_ROOT."/projet/activity/perline.php".($param?'?'.$param:'');
316  $head[$h][1] = $langs->trans("InputDetail");
317  $head[$h][2] = 'inputperline';
318  $h++;
319  }*/
320 
321  complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet');
322 
323  complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove');
324 
325  return $head;
326 }
327 
328 
335 {
336  global $langs, $conf, $user;
337  $h = 0;
338  $head = array();
339 
340  $h = 0;
341 
342  $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php";
343  $head[$h][1] = $langs->trans("Projects");
344  $head[$h][2] = 'project';
345  $h++;
346 
347  complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin');
348 
349  $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
350  $head[$h][1] = $langs->trans("ExtraFieldsProject");
351  $head[$h][2] = 'attributes';
352  $h++;
353 
354  $head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php';
355  $head[$h][1] = $langs->trans("ExtraFieldsProjectTask");
356  $head[$h][2] = 'attributes_task';
357  $h++;
358 
359  complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
360 
361  return $head;
362 }
363 
364 
383 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '', $showbilltime = 0, $arrayfields = array())
384 {
385  global $user, $langs, $conf, $db, $hookmanager;
386  global $projectstatic, $taskstatic, $extrafields;
387 
388  $lastprojectid = 0;
389 
390  $projectsArrayId = explode(',', $projectsListId);
391  if ($filterprogresscalc !== '') {
392  foreach ($lines as $key=>$line) {
393  if (!empty($line->planned_workload) && !empty($line->duration)) {
394  $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc);
395  if (!eval($filterprogresscalc)) {
396  unset($lines[$key]);
397  }
398  }
399  }
400  $lines = array_values($lines);
401  }
402  $numlines = count($lines);
403 
404  // We declare counter as global because we want to edit them into recursive call
405  global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed;
406 
407  if ($level == 0)
408  {
409  $total_projectlinesa_spent = 0;
410  $total_projectlinesa_planned = 0;
411  $total_projectlinesa_spent_if_planned = 0;
412  $total_projectlinesa_declared_if_planned = 0;
413  $total_projectlinesa_tobill = 0;
414  $total_projectlinesa_billed = 0;
415  }
416 
417  for ($i = 0; $i < $numlines; $i++)
418  {
419  if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines
420 
421  // Process line
422  // print "i:".$i."-".$lines[$i]->fk_project.'<br>';
423 
424  if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines
425  {
426  // Show task line.
427  $showline = 1;
428  $showlineingray = 0;
429 
430  // If there is filters to use
431  if (is_array($taskrole))
432  {
433  // If task not legitimate to show, search if a legitimate task exists later in tree
434  if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
435  {
436  // So search if task has a subtask legitimate to show
437  $foundtaskforuserdeeper = 0;
438  searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
439  //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
440  if ($foundtaskforuserdeeper > 0)
441  {
442  $showlineingray = 1; // We will show line but in gray
443  } else {
444  $showline = 0; // No reason to show line
445  }
446  }
447  } else {
448  // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project
449  // or into all other projects if user has permission to).
450  if (empty($user->rights->projet->all->lire))
451  {
452  // User is not allowed on this project and project is not public, so we hide line
453  if (!in_array($lines[$i]->fk_project, $projectsArrayId))
454  {
455  // Note that having a user assigned to a task into a project user has no permission on, should not be possible
456  // because assignement on task can be done only on contact of project.
457  // If assignement was done and after, was removed from contact of project, then we can hide the line.
458  $showline = 0;
459  }
460  }
461  }
462 
463  if ($showline)
464  {
465  // Break on a new project
466  if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
467  {
468  $var = !$var;
469  $lastprojectid = $lines[$i]->fk_project;
470  }
471 
472  print '<tr class="oddeven" id="row-'.$lines[$i]->id.'">'."\n";
473 
474  $projectstatic->id = $lines[$i]->fk_project;
475  $projectstatic->ref = $lines[$i]->projectref;
476  $projectstatic->public = $lines[$i]->public;
477  $projectstatic->title = $lines[$i]->projectlabel;
478  $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
479  $projectstatic->status = $lines[$i]->projectstatus;
480 
481  $taskstatic->id = $lines[$i]->id;
482  $taskstatic->ref = $lines[$i]->ref;
483  $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : '');
484  $taskstatic->projectstatus = $lines[$i]->projectstatus;
485  $taskstatic->progress = $lines[$i]->progress;
486  $taskstatic->fk_statut = $lines[$i]->status;
487  $taskstatic->date_start = $lines[$i]->date_start;
488  $taskstatic->date_end = $lines[$i]->date_end;
489  $taskstatic->datee = $lines[$i]->date_end; // deprecated
490  $taskstatic->planned_workload = $lines[$i]->planned_workload;
491  $taskstatic->duration_effective = $lines[$i]->duration;
492 
493 
494  if ($showproject)
495  {
496  // Project ref
497  print "<td>";
498  //if ($showlineingray) print '<i>';
499  if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
500  else print $projectstatic->getNomUrl(1, 'nolink');
501  //if ($showlineingray) print '</i>';
502  print "</td>";
503 
504  // Project status
505  print '<td>';
506  $projectstatic->statut = $lines[$i]->projectstatus;
507  print $projectstatic->getLibStatut(2);
508  print "</td>";
509  }
510 
511  // Ref of task
512  if (count($arrayfields) > 0 && !empty($arrayfields['t.ref']['checked'])) {
513  print '<td class="nowraponall">';
514  if ($showlineingray) {
515  print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>';
516  } else {
517  print $taskstatic->getNomUrl(1, 'withproject');
518  }
519  print '</td>';
520  }
521 
522  // Title of task
523  if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
524  print "<td>";
525  if ($showlineingray)
526  print '<i>';
527  //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
528  for ($k = 0; $k < $level; $k++) {
529  print '<div class="marginleftonly">';
530  }
531  print $lines[$i]->label;
532  for ($k = 0; $k < $level; $k++) {
533  print '</div>';
534  }
535  if ($showlineingray)
536  print '</i>';
537  //else print '</a>';
538  print "</td>\n";
539  }
540 
541  if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
542  print "<td>";
543  print $lines[$i]->description;
544  print "</td>\n";
545  }
546 
547  // Date start
548  if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
549  print '<td class="center">';
550  print dol_print_date($lines[$i]->date_start, 'dayhour');
551  print '</td>';
552  }
553 
554  // Date end
555  if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
556  print '<td class="center">';
557  print dol_print_date($lines[$i]->date_end, 'dayhour');
558  if ($taskstatic->hasDelay())
559  print img_warning($langs->trans("Late"));
560  print '</td>';
561  }
562 
563  $plannedworkloadoutputformat = 'allhourmin';
564  $timespentoutputformat = 'allhourmin';
565  if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
566  if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
567 
568  // Planned Workload (in working hours)
569  if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
570  print '<td class="right">';
571  $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
572  $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
573  if ($lines[$i]->planned_workload != '') {
574  print $fullhour;
575  // TODO Add delay taking account of working hours per day and working day per week
576  //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
577  }
578  //else print '--:--';
579  print '</td>';
580  }
581 
582  // Time spent
583  if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
584  print '<td class="right">';
585  if ($showlineingray)
586  print '<i>';
587  else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">';
588  if ($lines[$i]->duration)
589  print convertSecondToTime($lines[$i]->duration, $timespentoutputformat);
590  else print '--:--';
591  if ($showlineingray)
592  print '</i>';
593  else print '</a>';
594  print '</td>';
595  }
596 
597  // Progress calculated (Note: ->duration is time spent)
598  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
599  print '<td class="right">';
600  if ($lines[$i]->planned_workload || $lines[$i]->duration) {
601  if ($lines[$i]->planned_workload)
602  print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %';
603  else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
604  }
605  print '</td>';
606  }
607 
608  // Progress declared
609  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
610  print '<td class="right">';
611  if ($lines[$i]->progress != '') {
612  print getTaskProgressBadge($taskstatic);
613  }
614  print '</td>';
615  }
616 
617  // resume
618  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
619  print '<td class="right">';
620  if ($lines[$i]->progress != '' && $lines[$i]->duration) {
621  print getTaskProgressView($taskstatic, false, false);
622  }
623  print '</td>';
624  }
625 
626  if ($showbilltime)
627  {
628  // Time not billed
629  if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
630  print '<td class="right">';
631  if ($lines[$i]->usage_bill_time) {
632  print convertSecondToTime($lines[$i]->tobill, 'allhourmin');
633  $total_projectlinesa_tobill += $lines[$i]->tobill;
634  } else {
635  print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
636  }
637  print '</td>';
638  }
639 
640  // Time billed
641  if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
642  print '<td class="right">';
643  if ($lines[$i]->usage_bill_time) {
644  print convertSecondToTime($lines[$i]->billed, 'allhourmin');
645  $total_projectlinesa_billed += $lines[$i]->billed;
646  } else {
647  print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
648  }
649  print '</td>';
650  }
651  }
652 
653  // Contacts of task
654  if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST))
655  {
656  print '<td>';
657  foreach (array('internal', 'external') as $source)
658  {
659  $tab = $lines[$i]->liste_contact(-1, $source);
660  $num = count($tab);
661  if (!empty($num)) {
662  foreach ($tab as $contacttask) {
663  //var_dump($contacttask);
664  if ($source == 'internal') $c = new User($db);
665  else $c = new Contact($db);
666  $c->fetch($contacttask['id']);
667  print $c->getNomUrl(1).' ('.$contacttask['libelle'].')<br>';
668  }
669  }
670  }
671  print '</td>';
672  }
673 
674  // Extra fields
675  $extrafieldsobjectkey = $taskstatic->table_element;
676  $obj = $lines[$i];
677  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
678  // Fields from hook
679  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]);
680  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
681  print $hookmanager->resPrint;
682 
683  // Tick to drag and drop
684  print '<td class="tdlineupdown center"></td>';
685 
686  print "</tr>\n";
687 
688  if (!$showlineingray) $inc++;
689 
690  if ($level >= 0) // Call sublevels
691  {
692  $level++;
693  if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
694  $level--;
695  }
696 
697  $total_projectlinesa_spent += $lines[$i]->duration;
698  $total_projectlinesa_planned += $lines[$i]->planned_workload;
699  if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
700  if ($lines[$i]->planned_workload) $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
701  }
702  } else {
703  //$level--;
704  }
705  }
706 
707  if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0)
708  && $level <= 0)
709  {
710  print '<tr class="liste_total nodrag nodrop">';
711  print '<td class="liste_total">'.$langs->trans("Total").'</td>';
712  if ($showproject) print '<td></td><td></td>';
713  if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) print '<td></td>';
714  if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) print '<td></td>';
715  if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) print '<td></td>';
716  if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
717  print '<td class="nowrap liste_total right">';
718  print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
719  print '</td>';
720  }
721  if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
722  print '<td class="nowrap liste_total right">';
723  if ($projectidfortotallink > 0)
724  print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
725  print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
726  if ($projectidfortotallink > 0)
727  print '</a>';
728  print '</td>';
729  }
730 
731  if ($total_projectlinesa_planned) {
732  $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
733  $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
734 
735  // this conf is actually hidden, by default we use 10% for "be carefull or warning"
736  $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
737 
738  // define progress color according to time spend vs workload
739  $progressBarClass = 'progress-bar-info';
740  $badgeClass = 'badge ';
741 
742  if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
743  $progressBarClass = 'progress-bar-danger';
744  $badgeClass .= 'badge-danger';
745  } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1%
746  $progressBarClass = 'progress-bar-warning';
747  $badgeClass .= 'badge-warning';
748  } else {
749  $progressBarClass = 'progress-bar-success';
750  $badgeClass .= 'badge-success';
751  }
752  }
753 
754  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
755  print '<td class="nowrap liste_total right">';
756  if ($total_projectlinesa_planned)
757  print $totalCalculatedProgress.' %';
758  print '</td>';
759  }
760  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
761  print '<td class="nowrap liste_total right">';
762  if ($total_projectlinesa_planned)
763  print '<span class="'.$badgeClass.'" >'.$totalAverageDeclaredProgress.' %</span>';
764  print '</td>';
765  }
766 
767 
768  // resume
769  if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
770  print '<td class="right">';
771  if ($total_projectlinesa_planned) {
772  print '</span>';
773  print ' <div class="progress sm" title="'.$totalAverageDeclaredProgress.'%" >';
774  print ' <div class="progress-bar '.$progressBarClass.'" style="width: '.$totalAverageDeclaredProgress.'%"></div>';
775  print ' </div>';
776  print '</div>';
777  }
778  print '</td>';
779  }
780 
781  if ($showbilltime)
782  {
783  if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
784  print '<td class="nowrap liste_total right">';
785  print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin');
786  print '</td>';
787  }
788  if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
789  print '<td class="nowrap liste_total right">';
790  print convertSecondToTime($total_projectlinesa_billed, 'allhourmin');
791  print '</td>';
792  }
793  }
794  // Contacts of task
795  if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST))
796  {
797  print '<td></td>';
798  }
799  print '<td class=""></td>';
800  print '</tr>';
801  }
802 
803  return $inc;
804 }
805 
806 
824 function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
825 {
826  global $conf, $db, $user, $langs;
827  global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
828 
829  $lastprojectid = 0;
830  $totalforeachline = array();
831  $workloadforid = array();
832  $lineswithoutlevel0 = array();
833 
834  $numlines = count($lines);
835 
836  // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
837  if ($parent == 0) // Always and only if at first level
838  {
839  for ($i = 0; $i < $numlines; $i++)
840  {
841  if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
842  }
843  }
844 
845  if (empty($oldprojectforbreak))
846  {
847  $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
848  }
849 
850  //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
851  for ($i = 0; $i < $numlines; $i++)
852  {
853  if ($parent == 0) $level = 0;
854 
855  //if ($lines[$i]->fk_task_parent == $parent)
856  //{
857  // If we want all or we have a role on task, we show it
858  if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
859  {
860  //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
861 
862  // Break on a new project
863  if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
864  {
865  $lastprojectid = $lines[$i]->fk_project;
866  if ($preselectedday)
867  {
868  $projectstatic->id = $lines[$i]->fk_project;
869  }
870  }
871 
872  if (empty($workloadforid[$projectstatic->id]))
873  {
874  if ($preselectedday)
875  {
876  $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877  $workloadforid[$projectstatic->id] = 1;
878  }
879  }
880 
881  $projectstatic->id = $lines[$i]->fk_project;
882  $projectstatic->ref = $lines[$i]->project_ref;
883  $projectstatic->title = $lines[$i]->project_label;
884  $projectstatic->public = $lines[$i]->public;
885  $projectstatic->status = $lines[$i]->project_status;
886 
887  $taskstatic->id = $lines[$i]->task_id;
888  $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
889  $taskstatic->label = $lines[$i]->task_label;
890  $taskstatic->date_start = $lines[$i]->date_start;
891  $taskstatic->date_end = $lines[$i]->date_end;
892 
893  $thirdpartystatic->id = $lines[$i]->socid;
894  $thirdpartystatic->name = $lines[$i]->thirdparty_name;
895  $thirdpartystatic->email = $lines[$i]->thirdparty_email;
896 
897  if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
898  {
899  print '<tr class="oddeven trforbreak nobold">'."\n";
900  print '<td colspan="11">';
901  print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
902  if ($projectstatic->title)
903  {
904  print ' - ';
905  print $projectstatic->title;
906  }
907  print '</td>';
908  print '</tr>';
909  }
910 
911  if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
912 
913  print '<tr class="oddeven">'."\n";
914 
915  // User
916  /*
917  print '<td class="nowrap">';
918  print $fuser->getNomUrl(1, 'withproject', 'time');
919  print '</td>';
920  */
921 
922  // Project
923  print "<td>";
924  if ($oldprojectforbreak == -1)
925  {
926  print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
927  print '<br>'.$projectstatic->title;
928  }
929  print "</td>";
930 
931  // Thirdparty
932  print '<td class="tdoverflowmax100">';
933  if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10);
934  print '</td>';
935 
936  // Ref
937  print '<td>';
938  print '<!-- Task id = '.$lines[$i]->id.' -->';
939  for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
940  print $taskstatic->getNomUrl(1, 'withproject', 'time');
941  // Label task
942  print '<br>';
943  for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
944  print $taskstatic->label;
945  //print "<br>";
946  //for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
947  //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
948  print "</td>\n";
949 
950  // Date
951  print '<td class="center">';
952  print dol_print_date($lines[$i]->timespent_datehour, 'day');
953  print '</td>';
954 
955  $disabledproject = 1; $disabledtask = 1;
956  //print "x".$lines[$i]->fk_project;
957  //var_dump($lines[$i]);
958  //var_dump($projectsrole[$lines[$i]->fk_project]);
959  // If at least one role for project
960  if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
961  {
962  $disabledproject = 0;
963  $disabledtask = 0;
964  }
965  // If $restricteditformytask is on and I have no role on task, i disable edit
966  if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
967  {
968  $disabledtask = 1;
969  }
970 
971  // Hour
972  print '<td class="nowrap center">';
973  print dol_print_date($lines[$i]->timespent_datehour, 'hour');
974  print '</td>';
975 
976  $cssonholiday = '';
977  if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday ';
978  elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning ';
979  elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
980 
981  // Duration
982  print '<td class="duration'.($cssonholiday ? ' '.$cssonholiday : '').' center">';
983 
984  $dayWorkLoad = $lines[$i]->timespent_duration;
985  $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
986 
987  $alreadyspent = '';
988  if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
989 
990  print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
991 
992  $modeinput = 'hours';
993 
994  print '<script type="text/javascript">';
995  print "jQuery(document).ready(function () {\n";
996  print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });";
997  print "})\n";
998  print '</script>';
999 
1000  print '</td>';
1001 
1002  // Note
1003  print '<td class="center">';
1004  print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1005  print $lines[$i]->timespent_note;
1006  print '</textarea>';
1007  print '</td>';
1008 
1009  // Warning
1010  print '<td class="right">';
1011  /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1012  elseif ($disabledtask)
1013  {
1014  $titleassigntask = $langs->trans("AssignTaskToMe");
1015  if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1016 
1017  print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1018  }*/
1019  print '</td>';
1020 
1021  print "</tr>\n";
1022  }
1023  //}
1024  //else
1025  //{
1026  //$level--;
1027  //}
1028  }
1029 
1030  return $totalforeachline;
1031 }
1032 
1033 
1053 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1054 {
1055  global $conf, $db, $user, $langs;
1056  global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1057 
1058  $lastprojectid = 0;
1059  $totalforeachday = array();
1060  $workloadforid = array();
1061  $lineswithoutlevel0 = array();
1062 
1063  $numlines = count($lines);
1064 
1065  // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1066  if ($parent == 0) // Always and only if at first level
1067  {
1068  for ($i = 0; $i < $numlines; $i++)
1069  {
1070  if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
1071  }
1072  }
1073 
1074  if (empty($oldprojectforbreak))
1075  {
1076  $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
1077  }
1078 
1079  //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1080  for ($i = 0; $i < $numlines; $i++)
1081  {
1082  if ($parent == 0) $level = 0;
1083 
1084  if ($lines[$i]->fk_task_parent == $parent)
1085  {
1086  $obj = &$lines[$i]; // To display extrafields
1087 
1088  // If we want all or we have a role on task, we show it
1089  if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
1090  {
1091  //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
1092 
1093  if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases
1094  {
1095  continue;
1096  }
1097 
1098  // Break on a new project
1099  if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
1100  {
1101  $lastprojectid = $lines[$i]->fk_project;
1102  if ($preselectedday)
1103  {
1104  $projectstatic->id = $lines[$i]->fk_project;
1105  }
1106  }
1107 
1108  if (empty($workloadforid[$projectstatic->id]))
1109  {
1110  if ($preselectedday)
1111  {
1112  $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1113  $workloadforid[$projectstatic->id] = 1;
1114  }
1115  }
1116 
1117  $projectstatic->id = $lines[$i]->fk_project;
1118  $projectstatic->ref = $lines[$i]->projectref;
1119  $projectstatic->title = $lines[$i]->projectlabel;
1120  $projectstatic->public = $lines[$i]->public;
1121 
1122  $taskstatic->id = $lines[$i]->id;
1123  $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1124  $taskstatic->label = $lines[$i]->label;
1125  $taskstatic->date_start = $lines[$i]->date_start;
1126  $taskstatic->date_end = $lines[$i]->date_end;
1127 
1128  $thirdpartystatic->id = $lines[$i]->socid;
1129  $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1130  $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1131 
1132  if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
1133  {
1134  $addcolspan = 0;
1135  if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++;
1136  if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++;
1137  foreach ($arrayfields as $key => $val)
1138  {
1139  if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++;
1140  }
1141 
1142  print '<tr class="oddeven trforbreak nobold">'."\n";
1143  print '<td colspan="'.(7 + $addcolspan).'">';
1144  print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1145  if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
1146  if ($projectstatic->title)
1147  {
1148  print ' - ';
1149  print '<span class="secondary">'.$projectstatic->title.'</span>';
1150  }
1151  /*
1152  $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1153  print '<table class="">';
1154 
1155  print '<tr class="liste_titre">';
1156 
1157  // PROJECT fields
1158  if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
1159  if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1160  if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
1161  if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1162  if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
1163 
1164  $extrafieldsobjectkey='projet';
1165  $extrafieldsobjectprefix='efp.';
1166  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1167 
1168  print '</tr>';
1169  print '<tr>';
1170 
1171  // PROJECT fields
1172  if (! empty($arrayfields['p.fk_opp_status']['checked']))
1173  {
1174  print '<td class="nowrap">';
1175  $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1176  if ($code) print $langs->trans("OppStatus".$code);
1177  print "</td>\n";
1178  }
1179  if (! empty($arrayfields['p.opp_amount']['checked']))
1180  {
1181  print '<td class="nowrap">';
1182  print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1183  print "</td>\n";
1184  }
1185  if (! empty($arrayfields['p.opp_percent']['checked']))
1186  {
1187  print '<td class="nowrap">';
1188  print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1189  print "</td>\n";
1190  }
1191  if (! empty($arrayfields['p.budget_amount']['checked']))
1192  {
1193  print '<td class="nowrap">';
1194  print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1195  print "</td>\n";
1196  }
1197  if (! empty($arrayfields['p.usage_bill_time']['checked']))
1198  {
1199  print '<td class="nowrap">';
1200  print yn($lines[$i]->usage_bill_time);
1201  print "</td>\n";
1202  }
1203 
1204  $extrafieldsobjectkey='projet';
1205  $extrafieldsobjectprefix='efp.';
1206  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1207 
1208  print '</tr>';
1209  print '</table>';
1210 
1211  */
1212  print '</td>';
1213  print '</tr>';
1214  }
1215 
1216  if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
1217 
1218  print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1219 
1220  // User
1221  /*
1222  print '<td class="nowrap">';
1223  print $fuser->getNomUrl(1, 'withproject', 'time');
1224  print '</td>';
1225  */
1226 
1227  // Project
1228  if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
1229  {
1230  print "<td>";
1231  if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1232  print "</td>";
1233  }
1234 
1235  // Thirdparty
1236  if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
1237  {
1238  print '<td class="tdoverflowmax100">';
1239  if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10);
1240  print '</td>';
1241  }
1242 
1243  // Ref
1244  print '<td>';
1245  print '<!-- Task id = '.$lines[$i]->id.' -->';
1246  for ($k = 0; $k < $level; $k++) print '<div class="marginleftonly">';
1247  print $taskstatic->getNomUrl(1, 'withproject', 'time');
1248  // Label task
1249  print '<br>';
1250  print '<span class="opacitymedium">'.$taskstatic->label.'</a>';
1251  for ($k = 0; $k < $level; $k++) print "</div>";
1252  print "</td>\n";
1253 
1254  // TASK extrafields
1255  $extrafieldsobjectkey = 'projet_task';
1256  $extrafieldsobjectprefix = 'efpt.';
1257  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1258 
1259  // Planned Workload
1260  if (!empty($arrayfields['t.planned_workload']['checked']))
1261  {
1262  print '<td class="leftborder plannedworkload right">';
1263  if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1264  else print '--:--';
1265  print '</td>';
1266  }
1267 
1268  // Progress declared %
1269  if (!empty($arrayfields['t.progress']['checked']))
1270  {
1271  print '<td class="right">';
1272  print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1273  print '</td>';
1274  }
1275 
1276  // Time spent by everybody
1277  print '<td class="right">';
1278  // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
1279  if ($lines[$i]->duration)
1280  {
1281  print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1282  print convertSecondToTime($lines[$i]->duration, 'allhourmin');
1283  print '</a>';
1284  } else print '--:--';
1285  print "</td>\n";
1286 
1287  // Time spent by user
1288  print '<td class="right">';
1289  $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1290  if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1291  else print '--:--';
1292  print "</td>\n";
1293 
1294  $disabledproject = 1; $disabledtask = 1;
1295  //print "x".$lines[$i]->fk_project;
1296  //var_dump($lines[$i]);
1297  //var_dump($projectsrole[$lines[$i]->fk_project]);
1298  // If at least one role for project
1299  if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
1300  {
1301  $disabledproject = 0;
1302  $disabledtask = 0;
1303  }
1304  // If $restricteditformytask is on and I have no role on task, i disable edit
1305  if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
1306  {
1307  $disabledtask = 1;
1308  }
1309 
1310  // Form to add new time
1311  print '<td class="nowrap leftborder center">';
1312  $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
1313  print $tableCell;
1314  print '</td>';
1315 
1316  $cssonholiday = '';
1317  if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday ';
1318  elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning ';
1319  elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
1320 
1321  global $daytoparse;
1322  $tmparray = dol_getdate($daytoparse, true); // detail of current day
1323 
1324  $idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1325  global $numstartworkingday, $numendworkingday;
1326  $cssweekend = '';
1327  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.
1328  {
1329  $cssweekend = 'weekend';
1330  }
1331 
1332  // Duration
1333  print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
1334  $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1335  $totalforeachday[$preselectedday] += $dayWorkLoad;
1336 
1337  $alreadyspent = '';
1338  if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
1339 
1340  $idw = 0;
1341 
1342  $tableCell = '';
1343  $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1344  $tableCell .= '<span class="hideonsmartphone"> + </span>';
1345  //$tableCell.='&nbsp;&nbsp;&nbsp;';
1346  $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
1347  //$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
1348  print $tableCell;
1349 
1350  $modeinput = 'hours';
1351 
1352  print '<script type="text/javascript">';
1353  print "jQuery(document).ready(function () {\n";
1354  print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });";
1355  print "})\n";
1356  print '</script>';
1357 
1358  print '</td>';
1359 
1360  // Note
1361  print '<td class="center">';
1362  print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1363  print '</textarea>';
1364  print '</td>';
1365 
1366  // Warning
1367  print '<td class="right">';
1368  if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1369  elseif ($disabledtask)
1370  {
1371  $titleassigntask = $langs->trans("AssignTaskToMe");
1372  if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1373 
1374  print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1375  }
1376  print '</td>';
1377 
1378  print "</tr>\n";
1379  }
1380 
1381  $inc++;
1382  $level++;
1383  if ($lines[$i]->id > 0)
1384  {
1385  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1386  //var_dump($totalforeachday);
1387  $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1388  //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1389  //var_dump($ret);
1390  foreach ($ret as $key => $val)
1391  {
1392  $totalforeachday[$key] += $val;
1393  }
1394  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1395  //var_dump($totalforeachday);
1396  }
1397  $level--;
1398  } else {
1399  //$level--;
1400  }
1401  }
1402 
1403  return $totalforeachday;
1404 }
1405 
1406 
1426 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1427 {
1428  global $conf, $db, $user, $langs;
1429  global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1430 
1431  $numlines = count($lines);
1432 
1433  $lastprojectid = 0;
1434  $workloadforid = array();
1435  $totalforeachday = array();
1436  $lineswithoutlevel0 = array();
1437 
1438  // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1439  if ($parent == 0) // Always and only if at first level
1440  {
1441  for ($i = 0; $i < $numlines; $i++)
1442  {
1443  if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
1444  }
1445  }
1446 
1447  //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1448 
1449  if (empty($oldprojectforbreak))
1450  {
1451  $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
1452  }
1453 
1454  for ($i = 0; $i < $numlines; $i++)
1455  {
1456  if ($parent == 0) $level = 0;
1457 
1458  if ($lines[$i]->fk_task_parent == $parent)
1459  {
1460  $obj = &$lines[$i]; // To display extrafields
1461 
1462  // If we want all or we have a role on task, we show it
1463  if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
1464  {
1465  //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
1466 
1467  if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases
1468  {
1469  continue;
1470  }
1471 
1472  // Break on a new project
1473  if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
1474  {
1475  $lastprojectid = $lines[$i]->fk_project;
1476  $projectstatic->id = $lines[$i]->fk_project;
1477  }
1478 
1479  //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1480  //var_dump($projectstatic->weekWorkLoadPerTask);
1481  if (empty($workloadforid[$projectstatic->id]))
1482  {
1483  $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1484  $workloadforid[$projectstatic->id] = 1;
1485  }
1486  //var_dump($projectstatic->weekWorkLoadPerTask);
1487  //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1488 
1489  $projectstatic->id = $lines[$i]->fk_project;
1490  $projectstatic->ref = $lines[$i]->projectref;
1491  $projectstatic->title = $lines[$i]->projectlabel;
1492  $projectstatic->public = $lines[$i]->public;
1493  $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1494 
1495  $taskstatic->id = $lines[$i]->id;
1496  $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1497  $taskstatic->label = $lines[$i]->label;
1498  $taskstatic->date_start = $lines[$i]->date_start;
1499  $taskstatic->date_end = $lines[$i]->date_end;
1500 
1501  $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1502  $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1503  $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1504 
1505  if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
1506  {
1507  $addcolspan = 0;
1508  if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++;
1509  if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++;
1510  foreach ($arrayfields as $key => $val)
1511  {
1512  if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++;
1513  }
1514 
1515  print '<tr class="oddeven trforbreak nobold">'."\n";
1516  print '<td colspan="'.(11 + $addcolspan).'">';
1517  print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1518  if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
1519  if ($projectstatic->title)
1520  {
1521  print ' - ';
1522  print '<span class="secondary">'.$projectstatic->title.'</span>';
1523  }
1524 
1525  /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1526  print '<table class="">';
1527 
1528  print '<tr class="liste_titre">';
1529 
1530  // PROJECT fields
1531  if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
1532  if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1533  if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
1534  if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1535  if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
1536 
1537  $extrafieldsobjectkey='projet';
1538  $extrafieldsobjectprefix='efp.';
1539  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1540 
1541  print '</tr>';
1542  print '<tr>';
1543 
1544  // PROJECT fields
1545  if (! empty($arrayfields['p.fk_opp_status']['checked']))
1546  {
1547  print '<td class="nowrap">';
1548  $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1549  if ($code) print $langs->trans("OppStatus".$code);
1550  print "</td>\n";
1551  }
1552  if (! empty($arrayfields['p.opp_amount']['checked']))
1553  {
1554  print '<td class="nowrap">';
1555  print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1556  print "</td>\n";
1557  }
1558  if (! empty($arrayfields['p.opp_percent']['checked']))
1559  {
1560  print '<td class="nowrap">';
1561  print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1562  print "</td>\n";
1563  }
1564  if (! empty($arrayfields['p.budget_amount']['checked']))
1565  {
1566  print '<td class="nowrap">';
1567  print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1568  print "</td>\n";
1569  }
1570  if (! empty($arrayfields['p.usage_bill_time']['checked']))
1571  {
1572  print '<td class="nowrap">';
1573  print yn($lines[$i]->usage_bill_time);
1574  print "</td>\n";
1575  }
1576 
1577  $extrafieldsobjectkey='projet';
1578  $extrafieldsobjectprefix='efp.';
1579  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1580 
1581  print '</tr>';
1582  print '</table>';
1583  */
1584 
1585  print '</td>';
1586  print '</tr>';
1587  }
1588 
1589  if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
1590 
1591  print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1592 
1593  // User
1594  /*
1595  print '<td class="nowrap">';
1596  print $fuser->getNomUrl(1, 'withproject', 'time');
1597  print '</td>';
1598  */
1599 
1600  // Project
1601  if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
1602  {
1603  print '<td class="nowrap">';
1604  if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1605  print "</td>";
1606  }
1607 
1608  // Thirdparty
1609  if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
1610  {
1611  print '<td class="tdoverflowmax100">';
1612  if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
1613  print '</td>';
1614  }
1615 
1616  // Ref
1617  print '<td class="nowrap">';
1618  print '<!-- Task id = '.$lines[$i]->id.' -->';
1619  for ($k = 0; $k < $level; $k++) print '<div class="marginleftonly">';
1620  print $taskstatic->getNomUrl(1, 'withproject', 'time');
1621  // Label task
1622  print '<br>';
1623  print '<span class="opacitymedium">'.$taskstatic->label.'</span>';
1624  for ($k = 0; $k < $level; $k++) print "</div>";
1625  print "</td>\n";
1626 
1627  // TASK extrafields
1628  $extrafieldsobjectkey = 'projet_task';
1629  $extrafieldsobjectprefix = 'efpt.';
1630  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1631 
1632  // Planned Workload
1633  if (!empty($arrayfields['t.planned_workload']['checked']))
1634  {
1635  print '<td class="leftborder plannedworkload right">';
1636  if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1637  else print '--:--';
1638  print '</td>';
1639  }
1640 
1641  if (!empty($arrayfields['t.progress']['checked']))
1642  {
1643  // Progress declared %
1644  print '<td class="right">';
1645  print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1646  print '</td>';
1647  }
1648 
1649  // Time spent by everybody
1650  print '<td class="right">';
1651  // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
1652  if ($lines[$i]->duration)
1653  {
1654  print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1655  print convertSecondToTime($lines[$i]->duration, 'allhourmin');
1656  print '</a>';
1657  } else print '--:--';
1658  print "</td>\n";
1659 
1660  // Time spent by user
1661  print '<td class="right">';
1662  $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1663  if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1664  else print '--:--';
1665  print "</td>\n";
1666 
1667  $disabledproject = 1; $disabledtask = 1;
1668  //print "x".$lines[$i]->fk_project;
1669  //var_dump($lines[$i]);
1670  //var_dump($projectsrole[$lines[$i]->fk_project]);
1671  // If at least one role for project
1672  if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
1673  {
1674  $disabledproject = 0;
1675  $disabledtask = 0;
1676  }
1677  // If $restricteditformytask is on and I have no role on task, i disable edit
1678  if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
1679  {
1680  $disabledtask = 1;
1681  }
1682 
1683  //var_dump($projectstatic->weekWorkLoadPerTask);
1684 
1685  // Fields to show current time
1686  $tableCell = ''; $modeinput = 'hours';
1687  for ($idw = 0; $idw < 7; $idw++)
1688  {
1689  $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
1690 
1691  $cssonholiday = '';
1692  if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday ';
1693  elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning ';
1694  elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
1695 
1696  $tmparray = dol_getdate($tmpday);
1697  $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
1698  $totalforeachday[$tmpday] += $dayWorkLoad;
1699 
1700  $alreadyspent = '';
1701  if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
1702  $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']);
1703 
1704  global $numstartworkingday, $numendworkingday;
1705  $cssweekend = '';
1706  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.
1707  {
1708  $cssweekend = 'weekend';
1709  }
1710 
1711  $tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
1712  //$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
1713  $placeholder = '';
1714  if ($alreadyspent)
1715  {
1716  $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1717  //$placeholder=' placeholder="00:00"';
1718  //$tableCell.='+';
1719  }
1720  $tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
1721  $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1722  $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1723  $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1724  $tableCell .= '</td>';
1725  print $tableCell;
1726  }
1727 
1728  // Warning
1729  print '<td class="right">';
1730  if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1731  elseif ($disabledtask)
1732  {
1733  $titleassigntask = $langs->trans("AssignTaskToMe");
1734  if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1735 
1736  print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1737  }
1738  print '</td>';
1739 
1740  print "</tr>\n";
1741  }
1742 
1743  // Call to show task with a lower level (task under the current task)
1744  $inc++;
1745  $level++;
1746  if ($lines[$i]->id > 0)
1747  {
1748  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1749  //var_dump($totalforeachday);
1750  $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1751  //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1752  //var_dump($ret);
1753  foreach ($ret as $key => $val)
1754  {
1755  $totalforeachday[$key] += $val;
1756  }
1757  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1758  //var_dump($totalforeachday);
1759  }
1760  $level--;
1761  } else {
1762  //$level--;
1763  }
1764  }
1765 
1766  return $totalforeachday;
1767 }
1768 
1787 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
1788 {
1789  global $conf, $db, $user, $langs;
1790  global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1791 
1792  $numlines = count($lines);
1793 
1794  $lastprojectid = 0;
1795  $workloadforid = array();
1796  $totalforeachweek = array();
1797  $lineswithoutlevel0 = array();
1798 
1799  // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1800  if ($parent == 0) // Always and only if at first level
1801  {
1802  for ($i = 0; $i < $numlines; $i++)
1803  {
1804  if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
1805  }
1806  }
1807 
1808  //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1809 
1810  if (empty($oldprojectforbreak))
1811  {
1812  $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
1813  }
1814 
1815  for ($i = 0; $i < $numlines; $i++)
1816  {
1817  if ($parent == 0) $level = 0;
1818 
1819  if ($lines[$i]->fk_task_parent == $parent)
1820  {
1821  // If we want all or we have a role on task, we show it
1822  if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
1823  {
1824  //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
1825 
1826  // Break on a new project
1827  if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
1828  {
1829  $lastprojectid = $lines[$i]->fk_project;
1830  $projectstatic->id = $lines[$i]->fk_project;
1831  }
1832 
1833  //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1834  //var_dump($projectstatic->weekWorkLoadPerTask);
1835  if (empty($workloadforid[$projectstatic->id]))
1836  {
1837  $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1838  $workloadforid[$projectstatic->id] = 1;
1839  }
1840  //var_dump($projectstatic->weekWorkLoadPerTask);
1841  //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1842 
1843  $projectstatic->id = $lines[$i]->fk_project;
1844  $projectstatic->ref = $lines[$i]->projectref;
1845  $projectstatic->title = $lines[$i]->projectlabel;
1846  $projectstatic->public = $lines[$i]->public;
1847  $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1848  $projectstatic->status = $lines[$i]->projectstatus;
1849 
1850  $taskstatic->id = $lines[$i]->id;
1851  $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1852  $taskstatic->label = $lines[$i]->label;
1853  $taskstatic->date_start = $lines[$i]->date_start;
1854  $taskstatic->date_end = $lines[$i]->date_end;
1855 
1856  $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1857  $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1858  $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1859 
1860  if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
1861  {
1862  print '<tr class="oddeven trforbreak nobold">'."\n";
1863  print '<td colspan="'.(6 + count($TWeek)).'">';
1864  print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1865  if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
1866  if ($projectstatic->title)
1867  {
1868  print ' - ';
1869  print '<span class="secondary">'.$projectstatic->title.'</span>';
1870  }
1871  print '</td>';
1872  print '</tr>';
1873  }
1874 
1875  if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
1876  print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1877 
1878  // User
1879  /*
1880  print '<td class="nowrap">';
1881  print $fuser->getNomUrl(1, 'withproject', 'time');
1882  print '</td>';
1883  */
1884 
1885  // Project
1886  /*print '<td class="nowrap">';
1887  if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1888  print "</td>";*/
1889 
1890  // Thirdparty
1891  /*print '<td class="tdoverflowmax100">';
1892  if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
1893  print '</td>';*/
1894 
1895  // Ref
1896  print '<td class="nowrap">';
1897  print '<!-- Task id = '.$lines[$i]->id.' -->';
1898  for ($k = 0; $k < $level; $k++) print '<div class="marginleftonly">';
1899  print $taskstatic->getNomUrl(1, 'withproject', 'time');
1900  // Label task
1901  print '<br>';
1902  print '<span class="opacitymedium">'.$taskstatic->label.'</span>';
1903  for ($k = 0; $k < $level; $k++) print "</div>";
1904  print "</td>\n";
1905 
1906  // Planned Workload
1907  print '<td class="leftborder plannedworkload right">';
1908  if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1909  else print '--:--';
1910  print '</td>';
1911 
1912  // Progress declared %
1913  print '<td class="right">';
1914  print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1915  print '</td>';
1916 
1917  // Time spent by everybody
1918  print '<td class="right">';
1919  // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
1920  if ($lines[$i]->duration)
1921  {
1922  print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1923  print convertSecondToTime($lines[$i]->duration, 'allhourmin');
1924  print '</a>';
1925  } else print '--:--';
1926  print "</td>\n";
1927 
1928  // Time spent by user
1929  print '<td class="right">';
1930  $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1931  if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1932  else print '--:--';
1933  print "</td>\n";
1934 
1935  $disabledproject = 1; $disabledtask = 1;
1936  //print "x".$lines[$i]->fk_project;
1937  //var_dump($lines[$i]);
1938  //var_dump($projectsrole[$lines[$i]->fk_project]);
1939  // If at least one role for project
1940  if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
1941  {
1942  $disabledproject = 0;
1943  $disabledtask = 0;
1944  }
1945  // If $restricteditformytask is on and I have no role on task, i disable edit
1946  if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
1947  {
1948  $disabledtask = 1;
1949  }
1950 
1951  //var_dump($projectstatic->weekWorkLoadPerTask);
1952  //TODO
1953  // Fields to show current time
1954  $tableCell = ''; $modeinput = 'hours';
1955  $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
1956  $TFirstDay[reset($TWeek)] = 1;
1957  foreach ($TFirstDay as &$fday) {
1958  $fday--;
1959  }
1960  foreach ($TWeek as $weekNb)
1961  {
1962  $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
1963  $totalforeachweek[$weekNb] += $weekWorkLoad;
1964 
1965  $alreadyspent = '';
1966  if ($weekWorkLoad > 0) $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
1967  $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
1968 
1969 
1970  $tableCell = '<td class="center hide weekend">';
1971  $placeholder = '';
1972  if ($alreadyspent)
1973  {
1974  $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.$weekNb.']" value="'.$alreadyspent.'"></span>';
1975  //$placeholder=' placeholder="00:00"';
1976  //$tableCell.='+';
1977  }
1978 
1979  $tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.$TFirstDay[$weekNb].']" value="" cols="2" maxlength="5"';
1980  $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1981  $tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
1982  $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
1983  $tableCell .= '</td>';
1984  print $tableCell;
1985  }
1986 
1987  // Warning
1988  print '<td class="right">';
1989  if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1990  elseif ($disabledtask)
1991  {
1992  $titleassigntask = $langs->trans("AssignTaskToMe");
1993  if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1994 
1995  print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1996  }
1997  print '</td>';
1998 
1999  print "</tr>\n";
2000  }
2001 
2002  // Call to show task with a lower level (task under the current task)
2003  $inc++;
2004  $level++;
2005  if ($lines[$i]->id > 0)
2006  {
2007  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2008  //var_dump($totalforeachday);
2009  $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2010  //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2011  //var_dump($ret);
2012  foreach ($ret as $key => $val)
2013  {
2014  $totalforeachweek[$key] += $val;
2015  }
2016  //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2017  //var_dump($totalforeachday);
2018  }
2019  $level--;
2020  } else {
2021  //$level--;
2022  }
2023  }
2024 
2025  return $totalforeachweek;
2026 }
2027 
2028 
2038 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2039 {
2040  //print 'Search in line with parent id = '.$parent.'<br>';
2041  $numlines = count($lines);
2042  for ($i = 0; $i < $numlines; $i++)
2043  {
2044  // Process line $lines[$i]
2045  if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)
2046  {
2047  // If task is legitimate to show, no more need to search deeper
2048  if (isset($taskrole[$lines[$i]->id]))
2049  {
2050  //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2051  $inc++;
2052  return $inc;
2053  }
2054 
2055  searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2056  //print 'Found inc='.$inc.'<br>';
2057 
2058  if ($inc > 0) return $inc;
2059  }
2060  }
2061 
2062  return $inc;
2063 }
2064 
2078 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array())
2079 {
2080  global $langs, $conf, $user;
2081  global $theme_datacolor;
2082 
2083  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2084 
2085  $listofstatus = array_keys($listofoppstatus);
2086 
2087  if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2088  // Define $themeColorId and array $statusOppList for each $listofstatus
2089  $themeColorId = 0;
2090  $statusOppList = array();
2091  foreach ($listofstatus as $oppStatus) {
2092  $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2093  if ($oppStatusCode) {
2094  $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2095  $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2096  }
2097  $themeColorId++;
2098  }
2099  }
2100 
2101  $projectstatic = new Project($db);
2102  $thirdpartystatic = new Societe($db);
2103 
2104  $sortfield = '';
2105  $sortorder = '';
2106  $project_year_filter = 0;
2107 
2108  $title = $langs->trans("Projects");
2109  if (strcmp($status, '') && $status >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2110 
2111  $arrayidtypeofcontact = array();
2112 
2113  print '<div class="div-table-responsive-no-min">';
2114  print '<table class="noborder centpercent">';
2115 
2116  $sql = " FROM ".MAIN_DB_PREFIX."projet as p";
2117  if ($mytasks)
2118  {
2119  $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
2120  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
2121  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
2122  } else {
2123  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2124  }
2125  $sql .= " WHERE p.entity IN (".getEntity('project').")";
2126  $sql .= " AND p.rowid IN (".$projectsListId.")";
2127  if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
2128  if ($mytasks)
2129  {
2130  $sql .= " AND p.rowid = t.fk_projet";
2131  $sql .= " AND ec.element_id = t.rowid";
2132  $sql .= " AND ec.fk_socpeople = ".$user->id;
2133  $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2134  $sql .= " AND ctc.element = 'project_task'";
2135  }
2136  if ($status >= 0)
2137  {
2138  $sql .= " AND p.fk_statut = ".(int) $status;
2139  }
2140  if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
2141  {
2142  $project_year_filter = GETPOST("project_year_filter");
2143  //Check if empty or invalid year. Wildcard ignores the sql check
2144  if ($project_year_filter != "*")
2145  {
2146  if (empty($project_year_filter) || !ctype_digit($project_year_filter))
2147  {
2148  $project_year_filter = date("Y");
2149  }
2150  $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")";
2151  $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")";
2152  }
2153  }
2154 
2155  // Get id of project we must show tasks
2156  $arrayidofprojects = array();
2157  $sql1 = "SELECT p.rowid as projectid";
2158  $sql1 .= $sql;
2159  $resql = $db->query($sql1);
2160  if ($resql)
2161  {
2162  $i = 0;
2163  $num = $db->num_rows($resql);
2164  while ($i < $num)
2165  {
2166  $objp = $db->fetch_object($resql);
2167  $arrayidofprojects[$objp->projectid] = $objp->projectid;
2168  $i++;
2169  }
2170  } else dol_print_error($db);
2171  if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
2172 
2173  // Get list of project with calculation on tasks
2174  $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,";
2175  $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,";
2176  $sql2 .= " s.code_client, s.code_compta, s.client,";
2177  $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
2178  $sql2 .= " s.logo, s.email, s.entity,";
2179  $sql2 .= " p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_percent, p.opp_amount,";
2180  $sql2 .= " p.dateo, p.datee,";
2181  $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2182  $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2183  $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
2184  $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2185  $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
2186  $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
2187  $sql2 .= " s.logo, s.email, s.entity, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee";
2188  $sql2 .= " ORDER BY p.title, p.ref";
2189 
2190  $resql = $db->query($sql2);
2191  if ($resql)
2192  {
2193  $total_task = 0;
2194  $total_opp_amount = 0;
2195  $ponderated_opp_amount = 0;
2196 
2197  $num = $db->num_rows($resql);
2198  $i = 0;
2199 
2200  print '<tr class="liste_titre">';
2201  print_liste_field_titre($title.'<span class="badge marginleftonlyshort">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2202  print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2203  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
2204  {
2205  if (!in_array('prospectionstatus', $hiddenfields)) print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2206  print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
2207  //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
2208  }
2209  if (empty($conf->global->PROJECT_HIDE_TASKS))
2210  {
2211  print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
2212  if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2213  if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2214  }
2215  if (!in_array('projectstatus', $hiddenfields)) print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2216  print "</tr>\n";
2217 
2218  $total_plannedworkload = 0;
2219  $total_declaredprogressworkload = 0;
2220  while ($i < $num)
2221  {
2222  $objp = $db->fetch_object($resql);
2223 
2224  $projectstatic->id = $objp->projectid;
2225  $projectstatic->user_author_id = $objp->fk_user_creat;
2226  $projectstatic->public = $objp->public;
2227 
2228  // Check is user has read permission on project
2229  $userAccess = $projectstatic->restrictedProjectArea($user);
2230  if ($userAccess >= 0)
2231  {
2232  $projectstatic->ref = $objp->ref;
2233  $projectstatic->status = $objp->status;
2234  $projectstatic->title = $objp->title;
2235  $projectstatic->datee = $db->jdate($objp->datee);
2236  $projectstatic->dateo = $db->jdate($objp->dateo);
2237 
2238  print '<tr class="oddeven">';
2239 
2240  print '<td class="tdoverflowmax150">';
2241  print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall');
2242  if (!in_array('projectlabel', $hiddenfields)) print '<br><span class="opacitymedium">'.dol_trunc($objp->title, 24).'</span>';
2243  print '</td>';
2244 
2245  print '<td class="nowraponall tdoverflowmax100">';
2246  if ($objp->fk_soc > 0)
2247  {
2248  $thirdpartystatic->id = $objp->socid;
2249  $thirdpartystatic->name = $objp->socname;
2250  //$thirdpartystatic->name_alias = $objp->name_alias;
2251  //$thirdpartystatic->code_client = $objp->code_client;
2252  $thirdpartystatic->code_compta = $objp->code_compta;
2253  $thirdpartystatic->client = $objp->client;
2254  //$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
2255  $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2256  $thirdpartystatic->fournisseur = $objp->fournisseur;
2257  $thirdpartystatic->logo = $objp->logo;
2258  $thirdpartystatic->email = $objp->email;
2259  $thirdpartystatic->entity = $objp->entity;
2260  print $thirdpartystatic->getNomUrl(1);
2261  }
2262  print '</td>';
2263 
2264  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
2265  {
2266  if (!in_array('prospectionstatus', $hiddenfields)) {
2267  print '<td class="center tdoverflowmax75">';
2268  // Because color of prospection status has no meaning yet, it is used if hidden constant is set
2269  if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2270  $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2271  if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) {
2272  print $langs->trans("OppStatus".$oppStatusCode);
2273  }
2274  } else {
2275  if (isset($statusOppList[$objp->opp_status])) {
2276  $oppStatusCode = $statusOppList[$objp->opp_status]['code'];
2277  $oppStatusColor = $statusOppList[$objp->opp_status]['color'];
2278  } else {
2279  $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2280  $oppStatusColor = '';
2281  }
2282  if ($oppStatusCode) {
2283  if (!empty($oppStatusColor)) {
2284  print '<a href="'.dol_buildpath('/projet/list.php?search_opp_status='.$objp->opp_status, 1).'" style="display: inline-block; width: 4px; border: 5px solid rgb('.$oppStatusColor.'); border-radius: 2px;" title="'.$langs->trans("OppStatus".$oppStatusCode).'"></a>';
2285  } else {
2286  print '<a href="'.dol_buildpath('/projet/list.php?search_opp_status='.$objp->opp_status, 1).'" title="'.$langs->trans("OppStatus".$oppStatusCode).'">'.$oppStatusCode.'</a>';
2287  }
2288  }
2289  }
2290  print '</td>';
2291  }
2292 
2293  print '<td class="right">';
2294  if ($objp->opp_percent && $objp->opp_amount) {
2295  $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2296  $alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency);
2297  $ponderated_opp_amount += price2num($opp_weighted_amount);
2298  }
2299  if ($objp->opp_amount) print '<span title="'.$alttext.'">'.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).'</span>';
2300  print '</td>';
2301  }
2302 
2303  if (empty($conf->global->PROJECT_HIDE_TASKS))
2304  {
2305  print '<td class="right">'.$objp->nb.'</td>';
2306 
2307  $plannedworkload = $objp->planned_workload;
2308  $total_plannedworkload += $plannedworkload;
2309  if (!in_array('plannedworkload', $hiddenfields))
2310  {
2311  print '<td class="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>';
2312  }
2313  if (!in_array('declaredprogress', $hiddenfields))
2314  {
2315  $declaredprogressworkload = $objp->declared_progess_workload;
2316  $total_declaredprogressworkload += $declaredprogressworkload;
2317  print '<td class="right">';
2318  //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
2319  print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
2320  print '</td>';
2321  }
2322  }
2323 
2324  if (!in_array('projectstatus', $hiddenfields)) {
2325  print '<td class="right">';
2326  print $projectstatic->getLibStatut(3);
2327  print '</td>';
2328  }
2329 
2330  print "</tr>\n";
2331 
2332  $total_task = $total_task + $objp->nb;
2333  $total_opp_amount = $total_opp_amount + $objp->opp_amount;
2334  }
2335 
2336  $i++;
2337  }
2338 
2339  print '<tr class="liste_total">';
2340  print '<td>'.$langs->trans("Total")."</td><td></td>";
2341  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
2342  {
2343  if (!in_array('prospectionstatus', $hiddenfields)) {
2344  print '<td class="liste_total"></td>';
2345  }
2346  print '<td class="liste_total right">';
2347  //$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1);
2348  print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency));
2349  print '</td>';
2350  }
2351  if (empty($conf->global->PROJECT_HIDE_TASKS))
2352  {
2353  print '<td class="liste_total right">'.$total_task.'</td>';
2354  if (!in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>';
2355  if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
2356  }
2357  if (!in_array('projectstatus', $hiddenfields)) {
2358  print '<td class="liste_total"></td>';
2359  }
2360  print '</tr>';
2361 
2362  $db->free($resql);
2363  } else {
2364  dol_print_error($db);
2365  }
2366 
2367  print "</table>";
2368  print '</div>';
2369 
2370  if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
2371  {
2372  //Add the year filter input
2373  print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
2374  print '<table width="100%">';
2375  print '<tr>';
2376  print '<td>'.$langs->trans("Year").'</td>';
2377  print '<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.'"/>';
2378  print "</tr>\n";
2379  print '</table></form>';
2380  }
2381 }
2382 
2392 function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $spaced = false)
2393 {
2394  global $langs, $conf;
2395 
2396  $out = '';
2397 
2398  $plannedworkloadoutputformat = 'allhourmin';
2399  $timespentoutputformat = 'allhourmin';
2400  if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2401  if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2402 
2403  if (empty($task->progress) && !empty($hideOnProgressNull)) {
2404  return '';
2405  }
2406 
2407  $spaced = !empty($spaced) ? 'spaced' : '';
2408 
2409  $diff = '';
2410 
2411  // define progress color according to time spend vs workload
2412  $progressBarClass = 'progress-bar-info';
2413  if ($task->planned_workload) {
2414  $progressCalculated = round(100 * doubleval($task->duration_effective) / doubleval($task->planned_workload), 2);
2415 
2416  // this conf is actually hidden, by default we use 10% for "be carefull or warning"
2417  $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2418 
2419  $diffTitle = '<br>'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : '');
2420  $diffTitle .= '<br>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : '');
2421 
2422  //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.doubleval($task->progress * $warningRatio));
2423  if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) {
2424  $progressBarClass = 'progress-bar-danger';
2425  $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2426  $diff = '<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).'%</span>';
2427  } elseif (doubleval($progressCalculated) > doubleval($task->progress)) { // warning if close at 10%
2428  $progressBarClass = 'progress-bar-warning';
2429  $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2430  $diff = '<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).'%</span>';
2431  } else {
2432  $progressBarClass = 'progress-bar-success';
2433  $title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).' '.$langs->trans("point"));
2434  $diff = '<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).'%</span>';
2435  }
2436  }
2437 
2438  $out .= '<div class="progress-group">';
2439 
2440  if ($label !== false)
2441  {
2442  $out .= ' <span class="progress-text">';
2443 
2444  if ($label !== true) {
2445  $out .= $label; // replace label by param
2446  } else {
2447  $out .= $task->getNomUrl(1).' '.dol_htmlentities($task->label);
2448  }
2449  $out .= ' </span>';
2450  }
2451 
2452 
2453  if ($progressNumber !== false)
2454  {
2455  $out .= ' <span class="progress-number">';
2456  if ($progressNumber !== true) {
2457  $out .= $progressNumber; // replace label by param
2458  } else {
2459  if ($task->hasDelay()) $out .= img_warning($langs->trans("Late")).' ';
2460 
2461  $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id;
2462 
2463  $out .= !empty($diff) ? $diff.' ' : '';
2464  $out .= '<a href="'.$url.'" >';
2465  $out .= '<b title="'.$langs->trans('TimeSpent').'" >';
2466  if ($task->duration_effective) $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat);
2467  else $out .= '--:--';
2468  $out .= '</b>';
2469  $out .= '</a>';
2470 
2471  $out .= ' / ';
2472 
2473  $out .= '<a href="'.$url.'" >';
2474  $out .= '<span title="'.$langs->trans('PlannedWorkload').'" >';
2475  if ($task->planned_workload) $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat);
2476  else $out .= '--:--';
2477  $out .= '</a>';
2478  }
2479  $out .= ' </span>';
2480  }
2481 
2482 
2483  $out .= '</span>';
2484  $out .= ' <div class="progress sm '.$spaced.'">';
2485  $diffval = doubleval($task->progress) - doubleval($progressCalculated);
2486  if ($diffval >= 0) {
2487  // good
2488  $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.doubleval($task->progress).'%" title="'.doubleval($task->progress).'%">';
2489  if (!empty($task->progress)) {
2490  $out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.doubleval($progressCalculated / $task->progress * 100).'%" title="'.doubleval($progressCalculated).'%"></div>';
2491  }
2492  $out .= ' </div>';
2493  } else {
2494  // bad
2495  $out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.doubleval($progressCalculated).'%" title="'.doubleval($progressCalculated).'%">';
2496  $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.($task->progress ? doubleval($task->progress / $progressCalculated * 100).'%' : '1px').'" title="'.doubleval($task->progress).'%"></div>';
2497  $out .= ' </div>';
2498  }
2499  $out .= ' </div>';
2500  $out .= '</div>';
2501 
2502 
2503 
2504  return $out;
2505 }
2513 function getTaskProgressBadge($task, $label = '', $tooltip = '')
2514 {
2515  global $conf, $langs;
2516 
2517  $out = '';
2518  $badgeClass = '';
2519  if ($task->progress != '')
2520  {
2521  // TODO : manage 100%
2522 
2523  // define color according to time spend vs workload
2524  $badgeClass = 'badge ';
2525  if ($task->planned_workload) {
2526  $progressCalculated = round(100 * doubleval($task->duration_effective) / doubleval($task->planned_workload), 2);
2527 
2528  // this conf is actually hidden, by default we use 10% for "be carefull or warning"
2529  $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2530 
2531  if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) {
2532  $badgeClass .= 'badge-danger';
2533  if (empty($tooltip)) {
2534  $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
2535  }
2536  } elseif (doubleval($progressCalculated) > doubleval($task->progress)) { // warning if close at 10%
2537  $badgeClass .= 'badge-warning';
2538  if (empty($tooltip)) $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
2539  } else {
2540  $badgeClass .= 'badge-success';
2541  if (empty($tooltip)) $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
2542  }
2543  }
2544  }
2545 
2546  $title = '';
2547  if (!empty($tooltip)) {
2548  $badgeClass .= ' classfortooltip';
2549  $title = 'title="'.dol_htmlentities($tooltip).'"';
2550  }
2551 
2552  if (empty($label)) {
2553  $label = $task->progress.' %';
2554  }
2555 
2556  if (!empty($label)) {
2557  $out = '<span class="'.$badgeClass.'" '.$title.' >'.$label.'</span>';
2558  }
2559 
2560  return $out;
2561 }
Class to manage contact/addresses.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
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.
projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a pertime intput mode.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId= '', $addordertick=0, $projectidfortotallink=0, $filterprogresscalc= '', $showbilltime=0, $arrayfields=array())
Show task lines with a particular parent.
getElementCount($type, $tablename, $projectkey= 'fk_projet')
Return the count of a type of linked elements of this project.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
Search in task lines with a particular parent if there is a task for a particular user (in taskrole) ...
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
if(!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:560
projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0)
Output a task line into a pertime intput mode.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)
liste_contact($status=-1, $source= 'external', $list=0, $code= '')
Get array of all contacts for an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
getTaskProgressBadge($task, $label= '', $tooltip= '')
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
project_prepare_head(Project $project)
Prepare array with list of tabs.
Definition: project.lib.php:36
print
Draft customers invoices.
Definition: index.php:89
Class to manage tasks.
Definition: task.class.php:35
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
getNbComments()
Return nb comments already posted.
project_admin_prepare_head()
Prepare array with list of tabs.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:114
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
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:180
task_prepare_head($object)
Prepare array with list of tabs.