dolibarr 21.0.3
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-2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
7 * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Vincent de Grandpré <vincent@de-grandpre.quebec>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
31require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
32
33
41function project_prepare_head(Project $project, $moreparam = '')
42{
43 global $db, $langs, $conf, $user;
44
45 $h = 0;
46 $head = array();
47
48 $head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.((int) $project->id).($moreparam ? '&'.$moreparam : '');
49 $head[$h][1] = $langs->trans("Project");
50 $head[$h][2] = 'project';
51 $h++;
52 $nbContacts = 0;
53 // Enable caching of project count Contacts
54 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
55 $cachekey = 'count_contacts_project_'.$project->id;
56 $dataretrieved = dol_getcache($cachekey);
57
58 if (!is_null($dataretrieved)) {
59 $nbContacts = $dataretrieved;
60 } else {
61 $nbContacts = count($project->liste_contact(-1, 'internal')) + count($project->liste_contact(-1, 'external'));
62 dol_setcache($cachekey, $nbContacts, 120); // If setting cache fails, this is not a problem, so we do not test result.
63 }
64 $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.((int) $project->id).($moreparam ? '&'.$moreparam : '');
65 $head[$h][1] = $langs->trans("ProjectContact");
66 if ($nbContacts > 0) {
67 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContacts.'</span>';
68 }
69 $head[$h][2] = 'contact';
70 $h++;
71
72 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
73 // Then tab for sub level of projet, i mean tasks
74 $nbTasks = 0;
75 // Enable caching of project count Tasks
76 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
77 $cachekey = 'count_tasks_project_'.$project->id;
78 $dataretrieved = dol_getcache($cachekey);
79
80 if (!is_null($dataretrieved)) {
81 $nbTasks = $dataretrieved;
82 } else {
83 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
84 $taskstatic = new Task($db);
85 $nbTasks = count($taskstatic->getTasksArray(null, null, $project->id, 0, 0));
86 dol_setcache($cachekey, $nbTasks, 120); // If setting cache fails, this is not a problem, so we do not test result.
87 }
88 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.((int) $project->id).($moreparam ? '&'.$moreparam : '');
89 $head[$h][1] = $langs->trans("Tasks");
90 if ($nbTasks > 0) {
91 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbTasks).'</span>';
92 }
93 $head[$h][2] = 'tasks';
94 $h++;
95
96 $nbTimeSpent = 0;
97 // Enable caching of project count Timespent
98 $cachekey = 'count_timespent_project_'.$project->id;
99 $dataretrieved = dol_getcache($cachekey);
100 if (!is_null($dataretrieved)) {
101 $nbTimeSpent = $dataretrieved;
102 } else {
103 $sql = "SELECT t.rowid";
104 //$sql .= " FROM ".MAIN_DB_PREFIX."element_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
105 //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
106 $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t, ".MAIN_DB_PREFIX."projet_task as pt";
107 $sql .= " WHERE t.fk_element = pt.rowid";
108 $sql .= " AND t.elementtype = 'task'";
109 $sql .= " AND pt.fk_projet =".((int) $project->id);
110 $resql = $db->query($sql);
111 if ($resql) {
112 $obj = $db->fetch_object($resql);
113 if ($obj) {
114 $nbTimeSpent = 1;
115 dol_setcache($cachekey, $nbTimeSpent, 120); // If setting cache fails, this is not a problem, so we do not test result.
116 }
117 } else {
118 dol_print_error($db);
119 }
120 }
121
122 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.((int) $project->id).($moreparam ? '&'.$moreparam : '');
123 $head[$h][1] = $langs->trans("TimeSpent");
124 if ($nbTimeSpent > 0) {
125 $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
126 }
127 $head[$h][2] = 'timespent';
128 $h++;
129 }
130
131 if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")
132 || isModEnabled("propal") || isModEnabled('order')
133 || isModEnabled('invoice') || isModEnabled('contract')
134 || isModEnabled('intervention') || isModEnabled('agenda') || isModEnabled('deplacement') || isModEnabled('stock')) {
135 $nbElements = 0;
136 // Enable caching of thirdrparty count Contacts
137 $cachekey = 'count_elements_project_'.$project->id;
138 $dataretrieved = dol_getcache($cachekey);
139 if (!is_null($dataretrieved)) {
140 $nbElements = $dataretrieved;
141 } else {
142 if (isModEnabled('stock')) {
143 $nbElements += $project->getElementCount('stock', 'entrepot', 'fk_project');
144 }
145 if (isModEnabled("propal")) {
146 $nbElements += $project->getElementCount('propal', 'propal');
147 }
148 if (isModEnabled('order')) {
149 $nbElements += $project->getElementCount('order', 'commande');
150 }
151 if (isModEnabled('invoice')) {
152 $nbElements += $project->getElementCount('invoice', 'facture');
153 }
154 if (isModEnabled('invoice')) {
155 $nbElements += $project->getElementCount('invoice_predefined', 'facture_rec');
156 }
157 if (isModEnabled('supplier_proposal')) {
158 $nbElements += $project->getElementCount('proposal_supplier', 'supplier_proposal');
159 }
160 if (isModEnabled("supplier_order")) {
161 $nbElements += $project->getElementCount('order_supplier', 'commande_fournisseur');
162 }
163 if (isModEnabled("supplier_invoice")) {
164 $nbElements += $project->getElementCount('invoice_supplier', 'facture_fourn');
165 }
166 if (isModEnabled('contract')) {
167 $nbElements += $project->getElementCount('contract', 'contrat');
168 }
169 if (isModEnabled('intervention')) {
170 $nbElements += $project->getElementCount('intervention', 'fichinter');
171 }
172 if (isModEnabled("shipping")) {
173 $nbElements += $project->getElementCount('shipping', 'expedition');
174 }
175 if (isModEnabled('mrp')) {
176 $nbElements += $project->getElementCount('mrp', 'mrp_mo', 'fk_project');
177 }
178 if (isModEnabled('deplacement')) {
179 $nbElements += $project->getElementCount('trip', 'deplacement');
180 }
181 if (isModEnabled('expensereport')) {
182 $nbElements += $project->getElementCount('expensereport', 'expensereport');
183 }
184 if (isModEnabled('don')) {
185 $nbElements += $project->getElementCount('donation', 'don');
186 }
187 if (isModEnabled('loan')) {
188 $nbElements += $project->getElementCount('loan', 'loan');
189 }
190 if (isModEnabled('tax')) {
191 $nbElements += $project->getElementCount('chargesociales', 'chargesociales');
192 }
193 if (isModEnabled('project')) {
194 $nbElements += $project->getElementCount('project_task', 'projet_task');
195 }
196 if (isModEnabled('stock')) {
197 $nbElements += $project->getElementCount('stock_mouvement', 'stock');
198 }
199 if (isModEnabled('salaries')) {
200 $nbElements += $project->getElementCount('salaries', 'payment_salary');
201 }
202 if (isModEnabled("bank")) {
203 $nbElements += $project->getElementCount('variouspayment', 'payment_various');
204 }
205 dol_setcache($cachekey, $nbElements, 120); // If setting cache fails, this is not a problem, so we do not test result.
206 }
207 $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$project->id;
208 $head[$h][1] = $langs->trans("ProjectOverview");
209 if ($nbElements > 0) {
210 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbElements.'</span>';
211 }
212 $head[$h][2] = 'element';
213 $h++;
214 }
215
216 if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) {
217 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
218 $Tickettatic = new Ticket($db);
219 $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket');
220 $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id);
221 $head[$h][1] = $langs->trans("Ticket");
222 if ($nbTicket > 0) {
223 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbTicket).'</span>';
224 }
225 $head[$h][2] = 'ticket';
226 $h++;
227 }
228
229 if (isModEnabled('eventorganization') && !empty($project->usage_organize_event)) {
230 $langs->load('eventorganization');
231 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
232 $head[$h][1] = $langs->trans("EventOrganization");
233
234 // Enable caching of conf or booth count
235 $nbConfOrBooth = 0;
236 $nbAttendees = 0;
237 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
238 $cachekey = 'count_conferenceorbooth_'.$project->id;
239 $dataretrieved = dol_getcache($cachekey);
240 if (!is_null($dataretrieved)) {
241 $nbConfOrBooth = $dataretrieved;
242 } else {
243 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
244 $conforbooth = new ConferenceOrBooth($db);
245 $result = $conforbooth->fetchAll('', '', 0, 0, '(t.fk_project:=:'.((int) $project->id).")");
246 //,
247 if (!is_array($result) && $result < 0) {
248 setEventMessages($conforbooth->error, $conforbooth->errors, 'errors');
249 } else {
250 $nbConfOrBooth = count($result);
251 }
252 dol_setcache($cachekey, $nbConfOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result.
253 }
254 $cachekey = 'count_attendees_'.$project->id;
255 $dataretrieved = dol_getcache($cachekey);
256 if (!is_null($dataretrieved)) {
257 $nbAttendees = $dataretrieved;
258 } else {
259 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
260 $conforboothattendee = new ConferenceOrBoothAttendee($db);
261 $result = $conforboothattendee->fetchAll('', '', 0, 0, '(t.fk_project:=:'.((int) $project->id).')');
262
263 if (!is_array($result) && $result < 0) {
264 setEventMessages($conforboothattendee->error, $conforboothattendee->errors, 'errors');
265 } else {
266 $nbAttendees = count($result);
267 }
268 dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
269 }
270 if ($nbConfOrBooth > 0 || $nbAttendees > 0) {
271 $head[$h][1] .= '<span class="badge marginleftonlyshort">';
272 $head[$h][1] .= '<span title="'.dol_escape_htmltag($langs->trans("ConferenceOrBooth")).'">'.$nbConfOrBooth.'</span>';
273 $head[$h][1] .= ' + ';
274 $head[$h][1] .= '<span title="'.dol_escape_htmltag($langs->trans("Attendees")).'">'.$nbAttendees.'</span>';
275 $head[$h][1] .= '</span>';
276 }
277 $head[$h][2] = 'eventorganisation';
278 $h++;
279 }
280
281 // Show more tabs from modules
282 // Entries must be declared in modules descriptor with line
283 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
284 // $this->tabs = array('entity:-tabname); to remove a tab
285 complete_head_from_modules($conf, $langs, $project, $head, $h, 'project', 'add', 'core');
286
287
288 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
289 $nbNote = 0;
290 if (!empty($project->note_private)) {
291 $nbNote++;
292 }
293 if (!empty($project->note_public)) {
294 $nbNote++;
295 }
296 $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$project->id;
297 $head[$h][1] = $langs->trans('Notes');
298 if ($nbNote > 0) {
299 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
300 }
301 $head[$h][2] = 'notes';
302 $h++;
303 }
304
305 // Attached files and Links
306 $totalAttached = 0;
307 // Enable caching of thirdrparty count attached files and links
308 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
309 $cachekey = 'count_attached_project_'.$project->id;
310 $dataretrieved = dol_getcache($cachekey);
311 if (!is_null($dataretrieved)) {
312 $totalAttached = $dataretrieved;
313 } else {
314 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
315 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
316 $upload_dir = $conf->project->multidir_output[empty($project->entity) ? 1 : $project->entity]."/".dol_sanitizeFileName($project->ref);
317 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
318 $nbLinks = Link::count($db, $project->element, $project->id);
319 $totalAttached = $nbFiles + $nbLinks;
320 dol_setcache($cachekey, $totalAttached, 120); // If setting cache fails, this is not a problem, so we do not test result.
321 }
322 $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$project->id;
323 $head[$h][1] = $langs->trans('Documents');
324 if (($totalAttached) > 0) {
325 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($totalAttached).'</span>';
326 }
327 $head[$h][2] = 'document';
328 $h++;
329
330 // Manage discussion
331 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT')) {
332 $nbComments = 0;
333 // Enable caching of thirdrparty count attached files and links
334 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
335 $cachekey = 'count_attached_project_'.$project->id;
336 $dataretrieved = dol_getcache($cachekey);
337 if (!is_null($dataretrieved)) {
338 $nbComments = $dataretrieved;
339 } else {
340 $nbComments = $project->getNbComments();
341 dol_setcache($cachekey, $nbComments, 120); // If setting cache fails, this is not a problem, so we do not test result.
342 }
343 $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$project->id;
344 $head[$h][1] = $langs->trans("CommentLink");
345 if ($nbComments > 0) {
346 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>';
347 }
348 $head[$h][2] = 'project_comment';
349 $h++;
350 }
351
352 $head[$h][0] = DOL_URL_ROOT.'/projet/messaging.php?id='.$project->id;
353 $head[$h][1] = $langs->trans("Events");
354 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
355 $head[$h][1] .= '/';
356 $head[$h][1] .= $langs->trans("Agenda");
357 }
358 $head[$h][2] = 'agenda';
359 $h++;
360
361 complete_head_from_modules($conf, $langs, $project, $head, $h, 'project', 'add', 'external');
362
363 complete_head_from_modules($conf, $langs, $project, $head, $h, 'project', 'remove');
364
365 return $head;
366}
367
368
376{
377 global $db, $langs, $conf, $user;
378 $h = 0;
379 $head = array();
380
381 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
382 $head[$h][1] = $langs->trans("Task");
383 $head[$h][2] = 'task_task';
384 $h++;
385
386 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
387 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
388 $head[$h][1] = $langs->trans("TaskRessourceLinks");
389 if ($nbContact > 0) {
390 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
391 }
392 $head[$h][2] = 'task_contact';
393 $h++;
394
395 // Is there timespent ?
396 $nbTimeSpent = 0;
397 $sql = "SELECT t.rowid";
398 //$sql .= " FROM ".MAIN_DB_PREFIX."element_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
399 //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
400 $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t";
401 $sql .= " WHERE t.elementtype='task' AND t.fk_element = ".((int) $object->id);
402 $resql = $db->query($sql);
403 if ($resql) {
404 $obj = $db->fetch_object($resql);
405 if ($obj) {
406 $nbTimeSpent = 1;
407 }
408 } else {
409 dol_print_error($db);
410 }
411
412 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.urlencode((string) $object->id).(GETPOST('withproject') ? '&withproject=1' : '');
413 $head[$h][1] = $langs->trans("TimeSpent");
414 if ($nbTimeSpent > 0) {
415 $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
416 }
417 $head[$h][2] = 'task_time';
418 $h++;
419
420 // Show more tabs from modules
421 // Entries must be declared in modules descriptor with line
422 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
423 // $this->tabs = array('entity:-tabname); to remove a tab
424 complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'add', 'core');
425
426 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
427 $nbNote = 0;
428 if (!empty($object->note_private)) {
429 $nbNote++;
430 }
431 if (!empty($object->note_public)) {
432 $nbNote++;
433 }
434 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.urlencode((string) $object->id).(GETPOST('withproject') ? '&withproject=1' : '');
435 $head[$h][1] = $langs->trans('Notes');
436 if ($nbNote > 0) {
437 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
438 }
439 $head[$h][2] = 'task_notes';
440 $h++;
441 }
442
443 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
444 $filesdir = $conf->project->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref);
445 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
446 include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
447 $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
448 $nbLinks = Link::count($db, $object->element, $object->id);
449 $head[$h][1] = $langs->trans('Documents');
450 if (($nbFiles + $nbLinks) > 0) {
451 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
452 }
453 $head[$h][2] = 'task_document';
454 $h++;
455
456 // Manage discussion
457 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK')) {
458 $nbComments = $object->getNbComments();
459 $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
460 $head[$h][1] = $langs->trans("CommentLink");
461 if ($nbComments > 0) {
462 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>';
463 }
464 $head[$h][2] = 'task_comment';
465 $h++;
466 }
467
468 complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'add', 'external');
469
470 complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove');
471
472 return $head;
473}
474
482function project_timesheet_prepare_head($mode, $fuser = null)
483{
484 global $langs, $conf, $user;
485 $h = 0;
486 $head = array();
487
488 $param = '';
489 $param .= ($mode ? '&mode='.$mode : '');
490 if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
491 $param .= '&search_usertoprocessid='.$fuser->id;
492 }
493
494 if (!getDolGlobalString('PROJECT_DISABLE_TIMESHEET_PERMONTH')) {
495 $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : '');
496 $head[$h][1] = $langs->trans("InputPerMonth");
497 $head[$h][2] = 'inputpermonth';
498 $h++;
499 }
500
501 if (!getDolGlobalString('PROJECT_DISABLE_TIMESHEET_PERWEEK')) {
502 $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
503 $head[$h][1] = $langs->trans("InputPerWeek");
504 $head[$h][2] = 'inputperweek';
505 $h++;
506 }
507
508 if (!getDolGlobalString('PROJECT_DISABLE_TIMESHEET_PERTIME')) {
509 $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : '');
510 $head[$h][1] = $langs->trans("InputPerDay");
511 $head[$h][2] = 'inputperday';
512 $h++;
513 }
514
515 complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet');
516
517 complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove');
518
519 return $head;
520}
521
522
529{
530 global $langs, $conf, $user, $db;
531
532 $extrafields = new ExtraFields($db);
533 $extrafields->fetch_name_optionals_label('projet');
534 $extrafields->fetch_name_optionals_label('projet_task');
535
536 $h = 0;
537 $head = array();
538
539 $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php";
540 $head[$h][1] = $langs->trans("Projects");
541 $head[$h][2] = 'project';
542 $h++;
543
544 complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin');
545
546 $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
547 $head[$h][1] = $langs->trans("ExtraFieldsProject");
548 $nbExtrafields = $extrafields->attributes['projet']['count'];
549 if ($nbExtrafields > 0) {
550 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
551 }
552 $head[$h][2] = 'attributes';
553 $h++;
554
555 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
556 $head[$h][0] = DOL_URL_ROOT . '/projet/admin/project_task_extrafields.php';
557 $head[$h][1] = $langs->trans("ExtraFieldsProjectTask");
558 $nbExtrafields = $extrafields->attributes['projet_task']['count'];
559 if ($nbExtrafields > 0) {
560 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
561 }
562 $head[$h][2] = 'attributes_task';
563 $h++;
564 }
565
566 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
567 $langs->load("members");
568
569 $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
570 $head[$h][1] = $langs->trans("BlankSubscriptionForm");
571 $head[$h][2] = 'website';
572 $h++;
573 }
574
575 complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
576
577 return $head;
578}
579
580
600function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $dummy = '', $showbilltime = 0, $arrayfields = array(), $arrayofselected = array())
601{
602 global $user, $langs, $conf, $db, $hookmanager;
603 global $projectstatic, $taskstatic, $extrafields;
604
605 '
606 @phan-var-force Project $projectstatic
607 @phan-var-force Task $taskstatic
608 @phan-var-force ExtraFields $extrafields
609 ';
610
611 $lastprojectid = 0;
612
613 $projectsArrayId = array();
614 if ($projectsListId) {
615 $projectsArrayId = explode(',', $projectsListId);
616 }
617
618 $numlines = count($lines);
619
620 // We declare counter as global because we want to edit them into recursive call
621 global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed, $total_budget_amount;
622 global $totalarray;
623
624 if ($level == 0) {
625 $total_projectlinesa_spent = 0;
626 $total_projectlinesa_planned = 0;
627 $total_projectlinesa_spent_if_planned = 0;
628 $total_projectlinesa_declared_if_planned = 0;
629 $total_projectlinesa_tobill = 0;
630 $total_projectlinesa_billed = 0;
631 $total_budget_amount = 0;
632 $totalarray = array();
633 }
634
635 for ($i = 0; $i < $numlines; $i++) {
636 if ($parent == 0 && $level >= 0) {
637 $level = 0; // if $level = -1, we don't use sublevel recursion, we show all lines
638 }
639
640 // Process line
641 // print "i:".$i."-".$lines[$i]->fk_project.'<br>';
642 if ($lines[$i]->fk_task_parent == $parent || $level < 0) { // if $level = -1, we don't use sublevel recursion, we show all lines
643 // Show task line.
644 $showline = 1;
645 $showlineingray = 0;
646
647 // If there is filters to use
648 if (is_array($taskrole)) {
649 // If task not legitimate to show, search if a legitimate task exists later in tree
650 if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_task_parent) {
651 // So search if task has a subtask legitimate to show
652 $foundtaskforuserdeeper = 0;
653 searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
654 //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
655 if ($foundtaskforuserdeeper > 0) {
656 $showlineingray = 1; // We will show line but in gray
657 } else {
658 $showline = 0; // No reason to show line
659 }
660 }
661 } else {
662 // 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
663 // or into all other projects if user has permission to).
664 if (!$user->hasRight('projet', 'all', 'lire')) {
665 // User is not allowed on this project and project is not public, so we hide line
666 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
667 // Note that having a user assigned to a task into a project user has no permission on, should not be possible
668 // because assignment on task can be done only on contact of project.
669 // If assignment was done and after, was removed from contact of project, then we can hide the line.
670 $showline = 0;
671 }
672 }
673 }
674
675 if ($showline) {
676 // Break on a new project
677 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
678 $lastprojectid = $lines[$i]->fk_project;
679 }
680
681 print '<tr class="oddeven" id="row-'.$lines[$i]->id.'">'."\n";
682
683 $projectstatic->id = $lines[$i]->fk_project;
684 $projectstatic->ref = $lines[$i]->projectref;
685 $projectstatic->public = $lines[$i]->public;
686 $projectstatic->title = $lines[$i]->projectlabel;
687 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
688 $projectstatic->status = $lines[$i]->projectstatus;
689
690 $taskstatic->id = $lines[$i]->id;
691 $taskstatic->ref = $lines[$i]->ref;
692 $taskstatic->label = (!empty($taskrole[$lines[$i]->id]) ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : '');
693 $taskstatic->projectstatus = $lines[$i]->projectstatus;
694 $taskstatic->progress = $lines[$i]->progress;
695 $taskstatic->fk_statut = $lines[$i]->status; // deprecated
696 $taskstatic->status = $lines[$i]->status;
697 $taskstatic->date_start = $lines[$i]->date_start;
698 $taskstatic->date_end = $lines[$i]->date_end;
699 $taskstatic->datee = $lines[$i]->date_end; // deprecated
700 $taskstatic->planned_workload = $lines[$i]->planned_workload;
701 $taskstatic->duration_effective = $lines[$i]->duration_effective;
702 $taskstatic->budget_amount = $lines[$i]->budget_amount;
703 $taskstatic->billable = $lines[$i]->billable;
704
705 // Action column
706 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
707 print '<td class="nowrap center">';
708 $selected = 0;
709 if (in_array($lines[$i]->id, $arrayofselected)) {
710 $selected = 1;
711 }
712 print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
713 print '</td>';
714 }
715
716 if ($showproject) {
717 // Project ref
718 print '<td class="nowraponall">';
719 //if ($showlineingray) print '<i>';
720 if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || $user->hasRight('projet', 'all', 'lire')) {
721 print $projectstatic->getNomUrl(1);
722 } else {
723 print $projectstatic->getNomUrl(1, 'nolink');
724 }
725 //if ($showlineingray) print '</i>';
726 print "</td>";
727
728 // Project status
729 print '<td>';
730 $projectstatic->statut = $lines[$i]->projectstatus;
731 print $projectstatic->getLibStatut(2);
732 print "</td>";
733 }
734
735 // Ref of task
736 if (count($arrayfields) > 0 && !empty($arrayfields['t.ref']['checked'])) {
737 print '<td class="nowraponall">';
738 if ($showlineingray) {
739 print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>';
740 } else {
741 print $taskstatic->getNomUrl(1, 'withproject');
742 }
743 print '</td>';
744 }
745
746 // Title of task
747 if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
748 $labeltoshow = '';
749 if ($showlineingray) {
750 $labeltoshow .= '<i>';
751 }
752 //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
753 for ($k = 0; $k < $level; $k++) {
754 $labeltoshow .= '<div class="marginleftonly">';
755 }
756 $labeltoshow .= dol_escape_htmltag($lines[$i]->label);
757 for ($k = 0; $k < $level; $k++) {
758 $labeltoshow .= '</div>';
759 }
760 if ($showlineingray) {
761 $labeltoshow .= '</i>';
762 }
763 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).'">';
764 print $labeltoshow;
765 print "</td>\n";
766 }
767
768 if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
769 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->description).'">';
770 print $lines[$i]->description;
771 print "</td>\n";
772 }
773
774 // Date start
775 if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
776 print '<td class="center nowraponall">';
777 print dol_print_date($lines[$i]->date_start, 'dayhour');
778 print '</td>';
779 }
780
781 // Date end
782 if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
783 print '<td class="center nowraponall">';
784 print dol_print_date($lines[$i]->date_end, 'dayhour');
785 if ($taskstatic->hasDelay()) {
786 print img_warning($langs->trans("Late"));
787 }
788 print '</td>';
789 }
790
791 $plannedworkloadoutputformat = 'allhourmin';
792 $timespentoutputformat = 'allhourmin';
793 if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
794 $plannedworkloadoutputformat = getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT');
795 }
796 if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
797 $timespentoutputformat = getDolGlobalString('PROJECT_TIME_SPENT_FORMAT');
798 }
799
800 // Planned Workload (in working hours)
801 if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
802 print '<td class="right">';
803 $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
804 $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
805 if ($lines[$i]->planned_workload != '') {
806 print $fullhour;
807 // TODO Add delay taking account of working hours per day and working day per week
808 //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
809 }
810 //else print '--:--';
811 print '</td>';
812 }
813
814 // Time spent
815 if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
816 print '<td class="right">';
817 if ($showlineingray) {
818 print '<i>';
819 } else {
820 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">';
821 }
822 if ($lines[$i]->duration_effective) {
823 print convertSecondToTime($lines[$i]->duration_effective, $timespentoutputformat);
824 } else {
825 print '--:--';
826 }
827 if ($showlineingray) {
828 print '</i>';
829 } else {
830 print '</a>';
831 }
832 print '</td>';
833 }
834
835 // Progress calculated (Note: ->duration_effective is time spent)
836 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
837 $s = '';
838 $shtml = '';
839 if ($lines[$i]->planned_workload || $lines[$i]->duration_effective) {
840 if ($lines[$i]->planned_workload) {
841 $s = round(100 * (float) $lines[$i]->duration_effective / (float) $lines[$i]->planned_workload, 2).' %';
842 $shtml = $s;
843 } else {
844 $s = $langs->trans('WorkloadNotDefined');
845 $shtml = '<span class="opacitymedium">'.$s.'</span>';
846 }
847 }
848 print '<td class="right tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
849 print $shtml;
850 print '</td>';
851 }
852
853 // Progress declared
854 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
855 print '<td class="right">';
856 if ($lines[$i]->progress != '') {
857 print getTaskProgressBadge($taskstatic);
858 }
859 print '</td>';
860 }
861
862 // resume
863 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
864 print '<td class="right">';
865 if ($lines[$i]->progress != '' && $lines[$i]->duration_effective) {
866 print getTaskProgressView($taskstatic, false, false);
867 }
868 print '</td>';
869 }
870
871 if ($showbilltime) {
872 // Time not billed
873 if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
874 print '<td class="right">';
875 if ($lines[$i]->usage_bill_time) {
876 print convertSecondToTime($lines[$i]->tobill, 'allhourmin');
877 $total_projectlinesa_tobill += $lines[$i]->tobill;
878 } else {
879 print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
880 }
881 print '</td>';
882 }
883
884 // Time billed
885 if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
886 print '<td class="right">';
887 if ($lines[$i]->usage_bill_time) {
888 print convertSecondToTime($lines[$i]->billed, 'allhourmin');
889 $total_projectlinesa_billed += $lines[$i]->billed;
890 } else {
891 print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
892 }
893 print '</td>';
894 }
895 }
896
897 // Budget task
898 if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) {
899 print '<td class="center">';
900 if ($lines[$i]->budget_amount) {
901 print '<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
902 $total_budget_amount += $lines[$i]->budget_amount;
903 }
904 print '</td>';
905 }
906
907 // Contacts of task
908 if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
909 print '<td class="center">';
910 $ifisrt = 1;
911 foreach (array('internal', 'external') as $source) {
912 //$tab = $lines[$i]->liste_contact(-1, $source);
913 $tab = $lines[$i]->liste_contact(-1, $source, 0, '', 1);
914
915 $numcontact = count($tab);
916 if (!empty($numcontact)) {
917 foreach ($tab as $contacttask) {
918 if ($source == 'internal') {
919 $c = new User($db);
920 } else {
921 $c = new Contact($db);
922 }
923 $c->fetch($contacttask['id']);
924 if (!empty($c->photo)) {
925 if (get_class($c) == 'User') {
927 '@phan-var-force User $c';
928 print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
929 } else {
931 '@phan-var-force Contact $c';
932 print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
933 }
934 } else {
935 if (get_class($c) == 'User') {
937 '@phan-var-force User $c';
938 print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
939 } else {
941 '@phan-var-force Contact $c';
942 print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
943 }
944 }
945 $ifisrt = 0;
946 }
947 }
948 }
949 print '</td>';
950 }
951
952 // Billable
953 if (count($arrayfields) > 0 && !empty($arrayfields['t.billable']['checked'])) {
954 print '<td class="center">';
955 if ($lines[$i]->billable) {
956 print '<span>'.$langs->trans('Yes').'</span>';
957 } else {
958 print '<span>'.$langs->trans('No').'</span>';
959 }
960 print '</td>';
961 }
962
963 // Extra fields
964 $extrafieldsobjectkey = $taskstatic->table_element;
965 $extrafieldsobjectprefix = 'efpt.';
966 $obj = $lines[$i];
967 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
968 // Fields from hook
969 $parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]);
970 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
971 print $hookmanager->resPrint;
972
973 // Tick to drag and drop
974 print '<td class="tdlineupdown center"></td>';
975
976 // Action column
977 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
978 print '<td class="nowrap center">';
979 $selected = 0;
980 if (in_array($lines[$i]->id, $arrayofselected)) {
981 $selected = 1;
982 }
983 print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
984
985 print '</td>';
986 }
987
988 print "</tr>\n";
989
990 if (!$showlineingray) {
991 $inc++;
992 }
993
994 if ($level >= 0) { // Call sublevels
995 $level++;
996 if ($lines[$i]->id) {
997 projectLinesa($inc, $lines[$i]->id, $lines, $level, '', $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, '', $showbilltime, $arrayfields);
998 }
999 $level--;
1000 }
1001
1002 $total_projectlinesa_spent += $lines[$i]->duration_effective;
1003 $total_projectlinesa_planned += $lines[$i]->planned_workload;
1004 if ($lines[$i]->planned_workload) {
1005 $total_projectlinesa_spent_if_planned += $lines[$i]->duration_effective;
1006 }
1007 if ($lines[$i]->planned_workload) {
1008 $total_projectlinesa_declared_if_planned += (float) $lines[$i]->planned_workload * $lines[$i]->progress / 100;
1009 }
1010 }
1011 } else {
1012 //$level--;
1013 }
1014 }
1015
1016 // Total line
1017 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
1018 && $level <= 0) {
1019 print '<tr class="liste_total nodrag nodrop">';
1020
1021 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1022 print '<td class="liste_total"></td>';
1023 }
1024
1025 print '<td class="liste_total">'.$langs->trans("Total").'</td>';
1026 if ($showproject) {
1027 print '<td></td><td></td>';
1028 }
1029 if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
1030 print '<td></td>';
1031 }
1032 if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
1033 print '<td></td>';
1034 }
1035 if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
1036 print '<td></td>';
1037 }
1038 if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
1039 print '<td></td>';
1040 }
1041 if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
1042 print '<td class="nowrap liste_total right">';
1043 print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
1044 print '</td>';
1045 }
1046 if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
1047 print '<td class="nowrap liste_total right">';
1048 if ($projectidfortotallink > 0) {
1049 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
1050 }
1051 print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
1052 if ($projectidfortotallink > 0) {
1053 print '</a>';
1054 }
1055 print '</td>';
1056 }
1057
1058 $totalCalculatedProgress = 0;
1059 $totalAverageDeclaredProgress = 0;
1060 $badgeClass = '';
1061 $progressBarClass = '';
1062 if ($total_projectlinesa_planned) {
1063 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
1064 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
1065
1066 // this conf is actually hidden, by default we use 10% for "be careful or warning"
1067 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
1068
1069 // define progress color according to time spend vs workload
1070 $progressBarClass = 'progress-bar-info';
1071 $badgeClass = 'badge ';
1072
1073 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
1074 $progressBarClass = 'progress-bar-danger';
1075 $badgeClass .= 'badge-danger';
1076 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1%
1077 $progressBarClass = 'progress-bar-warning';
1078 $badgeClass .= 'badge-warning';
1079 } else {
1080 $progressBarClass = 'progress-bar-success';
1081 $badgeClass .= 'badge-success';
1082 }
1083 }
1084
1085 // Computed progress
1086 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
1087 print '<td class="nowrap liste_total right">';
1088 if ($total_projectlinesa_planned) {
1089 print $totalCalculatedProgress.' %';
1090 }
1091 print '</td>';
1092 }
1093
1094 // Declared progress
1095 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
1096 print '<td class="nowrap liste_total right">';
1097 if ($total_projectlinesa_planned) {
1098 print '<span class="'.$badgeClass.'" >'.$totalAverageDeclaredProgress.' %</span>';
1099 }
1100 print '</td>';
1101 }
1102
1103
1104 // Progress
1105 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
1106 print '<td class="right">';
1107 if ($total_projectlinesa_planned) {
1108 print '</span>';
1109 print ' <div class="progress sm" title="'.$totalAverageDeclaredProgress.'%" >';
1110 print ' <div class="progress-bar '.$progressBarClass.'" style="width: '.$totalAverageDeclaredProgress.'%"></div>';
1111 print ' </div>';
1112 print '</div>';
1113 }
1114 print '</td>';
1115 }
1116
1117 if ($showbilltime) {
1118 if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
1119 print '<td class="nowrap liste_total right">';
1120 print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin');
1121 print '</td>';
1122 }
1123 if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
1124 print '<td class="nowrap liste_total right">';
1125 print convertSecondToTime($total_projectlinesa_billed, 'allhourmin');
1126 print '</td>';
1127 }
1128 }
1129
1130 // Budget task
1131 if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) {
1132 print '<td class="nowrap liste_total center">';
1133 if (strcmp((string) $total_budget_amount, '')) {
1134 print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1135 }
1136 print '</td>';
1137 }
1138
1139 // Contacts of task for backward compatibility,
1140 if (getDolGlobalString('PROJECT_SHOW_CONTACTS_IN_LIST')) {
1141 print '<td></td>';
1142 }
1143 // Contacts of task
1144 if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
1145 print '<td></td>';
1146 }
1147
1148 // Check if Extrafields is totalizable
1149 if (!empty($extrafields->attributes['projet_task']['totalizable'])) {
1150 foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) {
1151 if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) {
1152 print '<td class="right">';
1153 if ($value == 1) {
1154 print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total'];
1155 }
1156 print '</td>';
1157 }
1158 }
1159 }
1160
1161 // Column for the drag and drop
1162 print '<td class="liste_total"></td>';
1163
1164 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1165 print '<td class="liste_total"></td>';
1166 }
1167
1168 print '</tr>';
1169 }
1170
1171 return $inc;
1172}
1173
1174
1192function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1193{
1194 global $conf, $db, $user, $langs;
1195 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1196 '
1197 @phan-var-force FormOther $formother
1198 @phan-var-force Project $projectstatic
1199 @phan-var-force Task $taskstatic
1200 @phan-var-force Societe $thirdpartystatic
1201 ';
1202
1203 $lastprojectid = 0;
1204 $totalforeachline = array();
1205 $workloadforid = array();
1206 $lineswithoutlevel0 = array();
1207
1208 $numlines = count($lines);
1209
1210 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1211 if ($parent == 0) { // Always and only if at first level
1212 for ($i = 0; $i < $numlines; $i++) {
1213 if ($lines[$i]->fk_task_parent) {
1214 $lineswithoutlevel0[] = $lines[$i];
1215 }
1216 }
1217 }
1218
1219 if (empty($oldprojectforbreak)) {
1220 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1221 }
1222
1223 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1224 for ($i = 0; $i < $numlines; $i++) {
1225 if ($parent == 0) {
1226 $level = 0;
1227 }
1228
1229 //if ($lines[$i]->fk_task_parent == $parent)
1230 //{
1231 // If we want all or we have a role on task, we show it
1232 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1233 //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);
1234
1235 // Break on a new project
1236 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1237 $lastprojectid = $lines[$i]->fk_project;
1238 if ($preselectedday) {
1239 $projectstatic->id = $lines[$i]->fk_project;
1240 }
1241 }
1242
1243 if (empty($workloadforid[$projectstatic->id])) {
1244 if ($preselectedday) {
1245 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1246 $workloadforid[$projectstatic->id] = 1;
1247 }
1248 }
1249
1250 $projectstatic->id = $lines[$i]->fk_project;
1251 $projectstatic->ref = $lines[$i]->project_ref;
1252 $projectstatic->title = $lines[$i]->project_label;
1253 $projectstatic->public = $lines[$i]->public;
1254 $projectstatic->status = $lines[$i]->project->status;
1255
1256 $taskstatic->id = $lines[$i]->fk_statut;
1257 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1258 $taskstatic->label = $lines[$i]->task_label;
1259 $taskstatic->date_start = $lines[$i]->date_start;
1260 $taskstatic->date_end = $lines[$i]->date_end;
1261
1262 $thirdpartystatic->id = $lines[$i]->socid;
1263 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1264 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1265
1266 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1267 print '<tr class="oddeven trforbreak nobold">'."\n";
1268 print '<td colspan="11">';
1269 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1270 if ($projectstatic->title) {
1271 print ' - ';
1272 print $projectstatic->title;
1273 }
1274 print '</td>';
1275 print '</tr>';
1276 }
1277
1278 if ($oldprojectforbreak != -1) {
1279 $oldprojectforbreak = $projectstatic->id;
1280 }
1281
1282 print '<tr class="oddeven">'."\n";
1283
1284 // User
1285 /*
1286 print '<td class="nowrap">';
1287 print $fuser->getNomUrl(1, 'withproject', 'time');
1288 print '</td>';
1289 */
1290
1291 // Project
1292 print "<td>";
1293 if ($oldprojectforbreak == -1) {
1294 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1295 print '<br>'.$projectstatic->title;
1296 }
1297 print "</td>";
1298
1299 // Thirdparty
1300 print '<td class="tdoverflowmax100">';
1301 if ($thirdpartystatic->id > 0) {
1302 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1303 }
1304 print '</td>';
1305
1306 // Ref
1307 print '<td>';
1308 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperaction) -->';
1309 for ($k = 0; $k < $level; $k++) {
1310 print '<div class="marginleftonly">';
1311 }
1312 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1313 // Label task
1314 print '<br>';
1315 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1316 for ($k = 0; $k < $level; $k++) {
1317 print "</div>";
1318 }
1319 print "</td>\n";
1320
1321 // Date
1322 print '<td class="center">';
1323 print dol_print_date($lines[$i]->timespent_datehour, 'day');
1324 print '</td>';
1325
1326 $disabledproject = 1;
1327 $disabledtask = 1;
1328 //print "x".$lines[$i]->fk_project;
1329 //var_dump($lines[$i]);
1330 //var_dump($projectsrole[$lines[$i]->fk_project]);
1331 // If at least one role for project
1332 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1333 $disabledproject = 0;
1334 $disabledtask = 0;
1335 }
1336 // If $restricteditformytask is on and I have no role on task, i disable edit
1337 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1338 $disabledtask = 1;
1339 }
1340
1341 // Hour
1342 print '<td class="nowrap center">';
1343 print dol_print_date($lines[$i]->timespent_datehour, 'hour');
1344 print '</td>';
1345
1346 $cssonholiday = '';
1347 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1348 $cssonholiday .= 'onholidayallday ';
1349 } elseif (!$isavailable[$preselectedday]['morning']) {
1350 $cssonholiday .= 'onholidaymorning ';
1351 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1352 $cssonholiday .= 'onholidayafternoon ';
1353 }
1354
1355 // Duration
1356 print '<td class="duration'.($cssonholiday ? ' '.$cssonholiday : '').' center">';
1357
1358 $dayWorkLoad = $lines[$i]->timespent_duration;
1359 if (!array_key_exists($preselectedday, $totalforeachline)) {
1360 $totalforeachline[$preselectedday] = 0;
1361 }
1362 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1363
1364 $alreadyspent = '';
1365 if ($dayWorkLoad > 0) {
1366 $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1367 }
1368
1369 print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1370
1371 print '</td>';
1372
1373 // Note
1374 print '<td class="center">';
1375 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1376 print $lines[$i]->timespent_note;
1377 print '</textarea>';
1378 print '</td>';
1379
1380 // Warning
1381 print '<td class="right">';
1382 /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1383 elseif ($disabledtask)
1384 {
1385 $titleassigntask = $langs->trans("AssignTaskToMe");
1386 if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1387
1388 print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1389 }*/
1390 print '</td>';
1391
1392 print "</tr>\n";
1393 }
1394 //}
1395 //else
1396 //{
1397 //$level--;
1398 //}
1399 }
1400
1401 return $totalforeachline;
1402}
1403
1404
1424function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1425{
1426 global $conf, $db, $user, $langs;
1427 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1428 '
1429 @phan-var-force FormOther $formother
1430 @phan-var-force Project $projectstatic
1431 @phan-var-force Task $taskstatic
1432 @phan-var-force Societe $thirdpartystatic
1433 ';
1434
1435 $lastprojectid = 0;
1436 $totalforeachday = array();
1437 $workloadforid = array();
1438 $lineswithoutlevel0 = array();
1439
1440 $numlines = count($lines);
1441
1442 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1443 if ($parent == 0) { // Always and only if at first level
1444 for ($i = 0; $i < $numlines; $i++) {
1445 if ($lines[$i]->fk_task_parent) {
1446 $lineswithoutlevel0[] = $lines[$i];
1447 }
1448 }
1449 }
1450
1451 if (empty($oldprojectforbreak)) {
1452 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1453 }
1454
1455 $restrictBefore = null;
1456
1457 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1458 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1459 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1460 }
1461
1462 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1463 for ($i = 0; $i < $numlines; $i++) {
1464 if ($parent == 0) {
1465 $level = 0;
1466 }
1467
1468 if ($lines[$i]->fk_task_parent == $parent) {
1469 $obj = &$lines[$i]; // To display extrafields
1470
1471 // If we want all or we have a role on task, we show it
1472 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1473 //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);
1474
1475 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1476 continue;
1477 }
1478
1479 // Break on a new project
1480 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1481 $lastprojectid = $lines[$i]->fk_project;
1482 if ($preselectedday) {
1483 $projectstatic->id = $lines[$i]->fk_project;
1484 }
1485 }
1486
1487 if (empty($workloadforid[$projectstatic->id])) {
1488 if ($preselectedday) {
1489 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1490 $workloadforid[$projectstatic->id] = 1;
1491 }
1492 }
1493
1494 $projectstatic->id = $lines[$i]->fk_project;
1495 $projectstatic->ref = $lines[$i]->projectref;
1496 $projectstatic->title = $lines[$i]->projectlabel;
1497 $projectstatic->public = $lines[$i]->public;
1498 $projectstatic->status = $lines[$i]->projectstatus;
1499
1500 $taskstatic->id = $lines[$i]->id;
1501 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1502 $taskstatic->label = $lines[$i]->label;
1503 $taskstatic->date_start = $lines[$i]->date_start;
1504 $taskstatic->date_end = $lines[$i]->date_end;
1505
1506 $thirdpartystatic->id = $lines[$i]->socid;
1507 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1508 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1509
1510 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1511 $addcolspan = 0;
1512 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1513 $addcolspan++;
1514 }
1515 if (!empty($arrayfields['t.progress']['checked'])) {
1516 $addcolspan++;
1517 }
1518 foreach ($arrayfields as $key => $val) {
1519 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1520 $addcolspan++;
1521 }
1522 }
1523
1524 print '<tr class="oddeven trforbreak nobold">'."\n";
1525 print '<td colspan="'.(7 + $addcolspan).'">';
1526 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1527 if ($thirdpartystatic->id > 0) {
1528 print ' - '.$thirdpartystatic->getNomUrl(1);
1529 }
1530 if ($projectstatic->title) {
1531 print ' - ';
1532 print '<span class="secondary">'.$projectstatic->title.'</span>';
1533 }
1534 /*
1535 $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1536 print '<table class="">';
1537
1538 print '<tr class="liste_titre">';
1539
1540 // PROJECT fields
1541 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 ');
1542 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 ');
1543 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 ');
1544 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 ');
1545 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 ');
1546
1547 $extrafieldsobjectkey='projet';
1548 $extrafieldsobjectprefix='efp.';
1549 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1550
1551 print '</tr>';
1552 print '<tr>';
1553
1554 // PROJECT fields
1555 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1556 {
1557 print '<td class="nowrap">';
1558 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1559 if ($code) print $langs->trans("OppStatus".$code);
1560 print "</td>\n";
1561 }
1562 if (!empty($arrayfields['p.opp_amount']['checked']))
1563 {
1564 print '<td class="nowrap">';
1565 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1566 print "</td>\n";
1567 }
1568 if (!empty($arrayfields['p.opp_percent']['checked']))
1569 {
1570 print '<td class="nowrap">';
1571 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1572 print "</td>\n";
1573 }
1574 if (!empty($arrayfields['p.budget_amount']['checked']))
1575 {
1576 print '<td class="nowrap">';
1577 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1578 print "</td>\n";
1579 }
1580 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1581 {
1582 print '<td class="nowrap">';
1583 print yn($lines[$i]->usage_bill_time);
1584 print "</td>\n";
1585 }
1586
1587 $extrafieldsobjectkey='projet';
1588 $extrafieldsobjectprefix='efp.';
1589 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1590
1591 print '</tr>';
1592 print '</table>';
1593
1594 */
1595 print '</td>';
1596 print '</tr>';
1597 }
1598
1599 if ($oldprojectforbreak != -1) {
1600 $oldprojectforbreak = $projectstatic->id;
1601 }
1602
1603 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1604
1605 // User
1606 /*
1607 print '<td class="nowrap">';
1608 print $fuser->getNomUrl(1, 'withproject', 'time');
1609 print '</td>';
1610 */
1611
1612 // Project
1613 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1614 print "<td>";
1615 if ($oldprojectforbreak == -1) {
1616 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1617 }
1618 print "</td>";
1619 }
1620
1621 // Thirdparty
1622 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1623 print '<td class="tdoverflowmax100">';
1624 if ($thirdpartystatic->id > 0) {
1625 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1626 }
1627 print '</td>';
1628 }
1629
1630 // Ref
1631 print '<td>';
1632 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperday) -->';
1633 for ($k = 0; $k < $level; $k++) {
1634 print '<div class="marginleftonly">';
1635 }
1636 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1637 // Label task
1638 print '<br>';
1639 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1640 for ($k = 0; $k < $level; $k++) {
1641 print "</div>";
1642 }
1643 print "</td>\n";
1644
1645 // TASK extrafields
1646 $extrafieldsobjectkey = 'projet_task';
1647 $extrafieldsobjectprefix = 'efpt.';
1648 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1649
1650 // Planned Workload
1651 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1652 print '<td class="leftborder plannedworkload right">';
1653 if ($lines[$i]->planned_workload) {
1654 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1655 } else {
1656 print '--:--';
1657 }
1658 print '</td>';
1659 }
1660
1661 // Progress declared %
1662 if (!empty($arrayfields['t.progress']['checked'])) {
1663 print '<td class="right">';
1664 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1665 print '</td>';
1666 }
1667
1668 if (!empty($arrayfields['timeconsumed']['checked'])) {
1669 // Time spent by everybody
1670 print '<td class="right">';
1671 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
1672 if ($lines[$i]->duration_effective) {
1673 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1674 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
1675 print '</a>';
1676 } else {
1677 print '--:--';
1678 }
1679 print "</td>\n";
1680
1681 // Time spent by user
1682 print '<td class="right">';
1683 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1684 if ($tmptimespent['total_duration']) {
1685 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1686 } else {
1687 print '--:--';
1688 }
1689 print "</td>\n";
1690 }
1691
1692 $disabledproject = 1;
1693 $disabledtask = 1;
1694 //print "x".$lines[$i]->fk_project;
1695 //var_dump($lines[$i]);
1696 //var_dump($projectsrole[$lines[$i]->fk_project]);
1697 // If at least one role for project
1698 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1699 $disabledproject = 0;
1700 $disabledtask = 0;
1701 }
1702 // If $restricteditformytask is on and I have no role on task, i disable edit
1703 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1704 $disabledtask = 1;
1705 }
1706
1707 if ($restrictBefore && $preselectedday < $restrictBefore) {
1708 $disabledtask = 1;
1709 }
1710
1711 // Select hour
1712 print '<td class="nowraponall leftborder center minwidth150imp borderleft">';
1713 $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
1714 print $tableCell;
1715 print '</td>';
1716
1717 $cssonholiday = '';
1718 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1719 $cssonholiday .= 'onholidayallday ';
1720 } elseif (!$isavailable[$preselectedday]['morning']) {
1721 $cssonholiday .= 'onholidaymorning ';
1722 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1723 $cssonholiday .= 'onholidayafternoon ';
1724 }
1725
1726 global $daytoparse;
1727 $tmparray = dol_getdate($daytoparse, true); // detail of current day
1728
1729 $idw = ($tmparray['wday'] - (!getDolGlobalString('MAIN_START_WEEK') ? 0 : 1));
1730 global $numstartworkingday, $numendworkingday;
1731 $cssweekend = '';
1732 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.
1733 $cssweekend = 'weekend';
1734 }
1735
1736 // Duration
1737 print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
1738 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1739 if (!isset($totalforeachday[$preselectedday])) {
1740 $totalforeachday[$preselectedday] = 0;
1741 }
1742 $totalforeachday[$preselectedday] += $dayWorkLoad;
1743
1744 $alreadyspent = '';
1745 if ($dayWorkLoad > 0) {
1746 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
1747 }
1748
1749 $idw = 0;
1750
1751 $tableCell = '';
1752 $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center width40" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1753 $tableCell .= '<span class="hideonsmartphone"> + </span>';
1754 //$tableCell.='&nbsp;&nbsp;&nbsp;';
1755 $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
1756 //$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
1757 print $tableCell;
1758
1759 print '</td>';
1760
1761 // Note
1762 print '<td class="center">';
1763 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1764 print '</textarea>';
1765 print '</td>';
1766
1767 // Warning
1768 print '<td class="right">';
1769 if ((!$lines[$i]->public) && $disabledproject) {
1770 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1771 } elseif ($disabledtask) {
1772 $titleassigntask = $langs->trans("AssignTaskToMe");
1773 if ($fuser->id != $user->id) {
1774 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1775 }
1776
1777 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1778 }
1779 print '</td>';
1780
1781 print "</tr>\n";
1782 }
1783
1784 $inc++;
1785 $level++;
1786 if ($lines[$i]->id > 0) {
1787 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1788 //var_dump($totalforeachday);
1789 $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1790 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1791 //var_dump($ret);
1792 foreach ($ret as $key => $val) {
1793 $totalforeachday[$key] += $val;
1794 }
1795 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1796 //var_dump($totalforeachday);
1797 }
1798 $level--;
1799 } else {
1800 //$level--;
1801 }
1802 }
1803
1804 return $totalforeachday;
1805}
1806
1807
1827function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1828{
1829 global $conf, $db, $user, $langs;
1830 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1831 '
1832 @phan-var-force FormOther $formother
1833 @phan-var-force Project $projectstatic
1834 @phan-var-force Task $taskstatic
1835 @phan-var-force Societe $thirdpartystatic
1836 ';
1837
1838 $numlines = count($lines);
1839
1840 $lastprojectid = 0;
1841 $workloadforid = array();
1842 $totalforeachday = array();
1843 $lineswithoutlevel0 = array();
1844
1845 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1846 if ($parent == 0) { // Always and only if at first level
1847 for ($i = 0; $i < $numlines; $i++) {
1848 if ($lines[$i]->fk_task_parent) {
1849 $lineswithoutlevel0[] = $lines[$i];
1850 }
1851 }
1852 }
1853
1854 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1855
1856 if (empty($oldprojectforbreak)) {
1857 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
1858 }
1859
1860 $restrictBefore = null;
1861
1862 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1863 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1864 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1865 }
1866
1867 for ($i = 0; $i < $numlines; $i++) {
1868 if ($parent == 0) {
1869 $level = 0;
1870 }
1871
1872 if ($lines[$i]->fk_task_parent == $parent) {
1873 $obj = &$lines[$i]; // To display extrafields
1874
1875 // If we want all or we have a role on task, we show it
1876 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1877 //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);
1878
1879 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1880 continue;
1881 }
1882
1883 // Break on a new project
1884 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1885 $lastprojectid = $lines[$i]->fk_project;
1886 $projectstatic->id = $lines[$i]->fk_project;
1887 }
1888
1889 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1890 //var_dump($projectstatic->weekWorkLoadPerTask);
1891 if (empty($workloadforid[$projectstatic->id])) {
1892 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
1893 $workloadforid[$projectstatic->id] = 1;
1894 }
1895 //var_dump($projectstatic->weekWorkLoadPerTask);
1896 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1897
1898 $projectstatic->id = $lines[$i]->fk_project;
1899 $projectstatic->ref = $lines[$i]->projectref;
1900 $projectstatic->title = $lines[$i]->projectlabel;
1901 $projectstatic->public = $lines[$i]->public;
1902 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1903 $projectstatic->status = $lines[$i]->projectstatus;
1904
1905 $taskstatic->id = $lines[$i]->id;
1906 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1907 $taskstatic->label = $lines[$i]->label;
1908 $taskstatic->date_start = $lines[$i]->date_start;
1909 $taskstatic->date_end = $lines[$i]->date_end;
1910
1911 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1912 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1913 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1914
1915 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1916 $addcolspan = 0;
1917 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1918 $addcolspan++;
1919 }
1920 if (!empty($arrayfields['t.progress']['checked'])) {
1921 $addcolspan++;
1922 }
1923 foreach ($arrayfields as $key => $val) {
1924 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1925 $addcolspan++;
1926 }
1927 }
1928
1929 print '<tr class="oddeven trforbreak nobold">'."\n";
1930 print '<td colspan="'.(11 + $addcolspan).'">';
1931 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1932 if ($thirdpartystatic->id > 0) {
1933 print ' - '.$thirdpartystatic->getNomUrl(1);
1934 }
1935 if ($projectstatic->title) {
1936 print ' - ';
1937 print '<span class="secondary">'.$projectstatic->title.'</span>';
1938 }
1939
1940 /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1941 print '<table class="">';
1942
1943 print '<tr class="liste_titre">';
1944
1945 // PROJECT fields
1946 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 ');
1947 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 ');
1948 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 ');
1949 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 ');
1950 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 ');
1951
1952 $extrafieldsobjectkey='projet';
1953 $extrafieldsobjectprefix='efp.';
1954 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1955
1956 print '</tr>';
1957 print '<tr>';
1958
1959 // PROJECT fields
1960 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1961 {
1962 print '<td class="nowrap">';
1963 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1964 if ($code) print $langs->trans("OppStatus".$code);
1965 print "</td>\n";
1966 }
1967 if (!empty($arrayfields['p.opp_amount']['checked']))
1968 {
1969 print '<td class="nowrap">';
1970 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1971 print "</td>\n";
1972 }
1973 if (!empty($arrayfields['p.opp_percent']['checked']))
1974 {
1975 print '<td class="nowrap">';
1976 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1977 print "</td>\n";
1978 }
1979 if (!empty($arrayfields['p.budget_amount']['checked']))
1980 {
1981 print '<td class="nowrap">';
1982 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1983 print "</td>\n";
1984 }
1985 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1986 {
1987 print '<td class="nowrap">';
1988 print yn($lines[$i]->usage_bill_time);
1989 print "</td>\n";
1990 }
1991
1992 $extrafieldsobjectkey='projet';
1993 $extrafieldsobjectprefix='efp.';
1994 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1995
1996 print '</tr>';
1997 print '</table>';
1998 */
1999
2000 print '</td>';
2001 print '</tr>';
2002 }
2003
2004 if ($oldprojectforbreak != -1) {
2005 $oldprojectforbreak = $projectstatic->id;
2006 }
2007
2008 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2009
2010 // User
2011 /*
2012 print '<td class="nowrap">';
2013 print $fuser->getNomUrl(1, 'withproject', 'time');
2014 print '</td>';
2015 */
2016
2017 // Project
2018 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2019 print '<td class="nowrap">';
2020 if ($oldprojectforbreak == -1) {
2021 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2022 }
2023 print "</td>";
2024 }
2025
2026 // Thirdparty
2027 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2028 print '<td class="tdoverflowmax100">';
2029 if ($thirdpartystatic->id > 0) {
2030 print $thirdpartystatic->getNomUrl(1, 'project');
2031 }
2032 print '</td>';
2033 }
2034
2035 // Ref
2036 print '<td class="tdoverflowmax300">';
2037 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperweek) -->';
2038 for ($k = 0; $k < $level; $k++) {
2039 print '<div class="marginleftonly">';
2040 }
2041 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2042 // Label task
2043 print '<br>';
2044 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2045 for ($k = 0; $k < $level; $k++) {
2046 print "</div>";
2047 }
2048 print "</td>\n";
2049
2050 // TASK extrafields
2051 $extrafieldsobjectkey = 'projet_task';
2052 $extrafieldsobjectprefix = 'efpt.';
2053 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2054
2055 // Planned Workload
2056 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2057 print '<td class="leftborder plannedworkload right">';
2058 if ($lines[$i]->planned_workload) {
2059 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2060 } else {
2061 print '--:--';
2062 }
2063 print '</td>';
2064 }
2065
2066 if (!empty($arrayfields['t.progress']['checked'])) {
2067 // Progress declared %
2068 print '<td class="right">';
2069 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2070 print '</td>';
2071 }
2072
2073 if (!empty($arrayfields['timeconsumed']['checked'])) {
2074 // Time spent by everybody
2075 print '<td class="right">';
2076 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2077 if ($lines[$i]->duration_effective) {
2078 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'">';
2079 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2080 print '</a>';
2081 } else {
2082 print '--:--';
2083 }
2084 print "</td>\n";
2085
2086 // Time spent by user
2087 print '<td class="right">';
2088 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2089 if ($tmptimespent['total_duration']) {
2090 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'&search_user='.((int) $fuser->id).'">';
2091 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2092 print '</a>';
2093 } else {
2094 print '--:--';
2095 }
2096 print "</td>\n";
2097 }
2098
2099 $disabledproject = 1;
2100 $disabledtask = 1;
2101 //print "x".$lines[$i]->fk_project;
2102 //var_dump($lines[$i]);
2103 //var_dump($projectsrole[$lines[$i]->fk_project]);
2104 // If at least one role for project
2105 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2106 $disabledproject = 0;
2107 $disabledtask = 0;
2108 }
2109 // If $restricteditformytask is on and I have no role on task, i disable edit
2110 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2111 $disabledtask = 1;
2112 }
2113
2114 //var_dump($projectstatic->weekWorkLoadPerTask);
2115
2116 // Fields to show current time
2117 $tableCell = '';
2118 $modeinput = 'hours';
2119 $j = 0;
2120 for ($idw = 0; $idw < 7; $idw++) {
2121 $j++;
2122 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
2123 if (!isset($totalforeachday[$tmpday])) {
2124 $totalforeachday[$tmpday] = 0;
2125 }
2126 $cssonholiday = '';
2127 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
2128 $cssonholiday .= 'onholidayallday ';
2129 } elseif (!$isavailable[$tmpday]['morning']) {
2130 $cssonholiday .= 'onholidaymorning ';
2131 } elseif (!$isavailable[$tmpday]['afternoon']) {
2132 $cssonholiday .= 'onholidayafternoon ';
2133 }
2134
2135 $tmparray = dol_getdate($tmpday);
2136 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2137 $totalforeachday[$tmpday] += $dayWorkLoad;
2138
2139 $alreadyspent = '';
2140 if ($dayWorkLoad > 0) {
2141 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
2142 }
2143 $alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']);
2144
2145 global $numstartworkingday, $numendworkingday;
2146 $cssweekend = '';
2147 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.
2148 $cssweekend = 'weekend';
2149 }
2150
2151 $disabledtaskday = $disabledtask;
2152
2153 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2154 $disabledtaskday = 1;
2155 }
2156
2157 $tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').($j <= 1 ? ' borderleft' : '').'">';
2158 //$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
2159 $placeholder = '';
2160 if ($alreadyspent) {
2161 $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd width40" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
2162 //$placeholder=' placeholder="00:00"';
2163 //$tableCell.='+';
2164 }
2165 $tableCell .= '<input type="text" alt="'.($disabledtaskday ? '' : $alttitle).'" title="'.($disabledtaskday ? '' : $alttitle).'" '.($disabledtaskday ? 'disabled' : $placeholder).' class="center smallpadd width40" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
2166 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2167 $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
2168 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
2169 $tableCell .= '</td>';
2170 print $tableCell;
2171 }
2172
2173 // Warning
2174 print '<td class="right">';
2175 if ((!$lines[$i]->public) && $disabledproject) {
2176 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2177 } elseif ($disabledtask) {
2178 $titleassigntask = $langs->trans("AssignTaskToMe");
2179 if ($fuser->id != $user->id) {
2180 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2181 }
2182
2183 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2184 }
2185 print '</td>';
2186
2187 print "</tr>\n";
2188 }
2189
2190 // Call to show task with a lower level (task under the current task)
2191 $inc++;
2192 $level++;
2193 if ($lines[$i]->id > 0) {
2194 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2195 //var_dump($totalforeachday);
2196 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2197 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2198 //var_dump($ret);
2199 foreach ($ret as $key => $val) {
2200 $totalforeachday[$key] += $val;
2201 }
2202 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2203 //var_dump($totalforeachday);
2204 }
2205 $level--;
2206 } else {
2207 //$level--;
2208 }
2209 }
2210
2211 return $totalforeachday;
2212}
2213
2234function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array(), $arrayfields = array(), $extrafields = null)
2235{
2236 global $conf, $db, $user, $langs;
2237 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2238 '
2239 @phan-var-force FormOther $formother
2240 @phan-var-force Project $projectstatic
2241 @phan-var-force Task $taskstatic
2242 @phan-var-force Societe $thirdpartystatic
2243 ';
2244
2245 $numlines = count($lines);
2246
2247 $lastprojectid = 0;
2248 $workloadforid = array();
2249 $totalforeachweek = array();
2250 $lineswithoutlevel0 = array();
2251
2252 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2253 if ($parent == 0) { // Always and only if at first level
2254 for ($i = 0; $i < $numlines; $i++) {
2255 if ($lines[$i]->fk_task_parent) {
2256 $lineswithoutlevel0[] = $lines[$i];
2257 }
2258 }
2259 }
2260
2261 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
2262
2263 if (empty($oldprojectforbreak)) {
2264 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
2265 }
2266
2267 $restrictBefore = null;
2268
2269 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
2270 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2271 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
2272 }
2273
2274 for ($i = 0; $i < $numlines; $i++) {
2275 if ($parent == 0) {
2276 $level = 0;
2277 }
2278
2279 if ($lines[$i]->fk_task_parent == $parent) {
2280 // If we want all or we have a role on task, we show it
2281 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2282 //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);
2283
2284 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
2285 continue;
2286 }
2287
2288 // Break on a new project
2289 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2290 $lastprojectid = $lines[$i]->fk_project;
2291 $projectstatic->id = $lines[$i]->fk_project;
2292 }
2293
2294 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2295 //var_dump($projectstatic->weekWorkLoadPerTask);
2296 if (empty($workloadforid[$projectstatic->id])) {
2297 $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
2298 $workloadforid[$projectstatic->id] = 1;
2299 }
2300 //var_dump($projectstatic->weekWorkLoadPerTask);
2301 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2302
2303 $projectstatic->id = $lines[$i]->fk_project;
2304 $projectstatic->ref = $lines[$i]->projectref;
2305 $projectstatic->title = $lines[$i]->projectlabel;
2306 $projectstatic->public = $lines[$i]->public;
2307 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2308 $projectstatic->status = $lines[$i]->projectstatus;
2309
2310 $taskstatic->id = $lines[$i]->id;
2311 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2312 $taskstatic->label = $lines[$i]->label;
2313 $taskstatic->date_start = $lines[$i]->date_start;
2314 $taskstatic->date_end = $lines[$i]->date_end;
2315
2316 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2317 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2318 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2319
2320 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2321 print '<tr class="oddeven trforbreak nobold">'."\n";
2322 print '<td colspan="'.(6 + count($TWeek)).'">';
2323 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2324 if ($thirdpartystatic->id > 0) {
2325 print ' - '.$thirdpartystatic->getNomUrl(1);
2326 }
2327 if ($projectstatic->title) {
2328 print ' - ';
2329 print '<span class="secondary">'.$projectstatic->title.'</span>';
2330 }
2331 print '</td>';
2332 print '</tr>';
2333 }
2334
2335 if ($oldprojectforbreak != -1) {
2336 $oldprojectforbreak = $projectstatic->id;
2337 }
2338 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2339
2340 // User
2341 /*
2342 print '<td class="nowrap">';
2343 print $fuser->getNomUrl(1, 'withproject', 'time');
2344 print '</td>';
2345 */
2346
2347 // Project
2348 /*print '<td class="nowrap">';
2349 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2350 print "</td>";*/
2351
2352 // Thirdparty
2353 /*print '<td class="tdoverflowmax100">';
2354 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2355 print '</td>';*/
2356
2357 // Ref
2358 print '<td class="nowrap">';
2359 print '<!-- Task id = '.$lines[$i]->id.' (projectlinespermonth) -->';
2360 for ($k = 0; $k < $level; $k++) {
2361 print '<div class="marginleftonly">';
2362 }
2363 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2364 // Label task
2365 print '<br>';
2366 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2367 for ($k = 0; $k < $level; $k++) {
2368 print "</div>";
2369 }
2370 print "</td>\n";
2371
2372 // Planned Workload
2373 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2374 print '<td class="leftborder plannedworkload right">';
2375 if ($lines[$i]->planned_workload) {
2376 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2377 } else {
2378 print '--:--';
2379 }
2380 print '</td>';
2381 }
2382
2383 // Progress declared %
2384 if (!empty($arrayfields['t.progress']['checked'])) {
2385 print '<td class="right">';
2386 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2387 print '</td>';
2388 }
2389
2390 // Time spent by everybody
2391 if (!empty($arrayfields['timeconsumed']['checked'])) {
2392 print '<td class="right">';
2393 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2394 if ($lines[$i]->duration_effective) {
2395 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
2396 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2397 print '</a>';
2398 } else {
2399 print '--:--';
2400 }
2401 print "</td>\n";
2402
2403 // Time spent by user
2404 print '<td class="right">';
2405 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2406 if ($tmptimespent['total_duration']) {
2407 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2408 } else {
2409 print '--:--';
2410 }
2411 print "</td>\n";
2412 }
2413
2414 $disabledproject = 1;
2415 $disabledtask = 1;
2416 //print "x".$lines[$i]->fk_project;
2417 //var_dump($lines[$i]);
2418 //var_dump($projectsrole[$lines[$i]->fk_project]);
2419 // If at least one role for project
2420 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2421 $disabledproject = 0;
2422 $disabledtask = 0;
2423 }
2424 // If $restricteditformytask is on and I have no role on task, i disable edit
2425 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2426 $disabledtask = 1;
2427 }
2428
2429 //var_dump($projectstatic->weekWorkLoadPerTask);
2430 //TODO
2431 // Fields to show current time
2432 $tableCell = '';
2433 $modeinput = 'hours';
2434 $TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow));
2435 $TFirstDay[reset($TWeek)] = 1;
2436
2437 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2438 $year = $firstdaytoshowarray['year'];
2439 $month = $firstdaytoshowarray['mon'];
2440 $j = 0;
2441 foreach ($TWeek as $weekIndex => $weekNb) {
2442 $j++;
2443 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2444 if (!isset($totalforeachweek[$weekNb])) {
2445 $totalforeachweek[$weekNb] = 0;
2446 }
2447 $totalforeachweek[$weekNb] += $weekWorkLoad;
2448
2449 $alreadyspent = '';
2450 if ($weekWorkLoad > 0) {
2451 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2452 }
2453 $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
2454
2455 $disabledtaskweek = $disabledtask;
2456 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2457
2458 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2459 $disabledtaskweek = 1;
2460 }
2461
2462 $tableCell = '<td class="center hide'.($j <= 1 ? ' borderleft' : '').'">';
2463 $placeholder = '';
2464 if ($alreadyspent) {
2465 $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd width40" disabled id="timespent['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.$weekNb.']" value="'.$alreadyspent.'"></span>';
2466 //$placeholder=' placeholder="00:00"';
2467 //$tableCell.='+';
2468 }
2469
2470 $tableCell .= '<input type="text" alt="'.($disabledtaskweek ? '' : $alttitle).'" title="'.($disabledtaskweek ? '' : $alttitle).'" '.($disabledtaskweek ? 'disabled' : $placeholder).' class="center smallpadd width40" id="timeadded['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.($TFirstDay[$weekNb] - 1).']" value="" cols="2" maxlength="5"';
2471 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2472 $tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
2473 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
2474 $tableCell .= '</td>';
2475 print $tableCell;
2476 }
2477
2478 // Warning
2479 print '<td class="right">';
2480 if ((!$lines[$i]->public) && $disabledproject) {
2481 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2482 } elseif ($disabledtask) {
2483 $titleassigntask = $langs->trans("AssignTaskToMe");
2484 if ($fuser->id != $user->id) {
2485 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2486 }
2487
2488 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2489 }
2490 print '</td>';
2491
2492 print "</tr>\n";
2493 }
2494
2495 // Call to show task with a lower level (task under the current task)
2496 $inc++;
2497 $level++;
2498 if ($lines[$i]->id > 0) {
2499 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2500 //var_dump($totalforeachday);
2501 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2502 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2503 //var_dump($ret);
2504 foreach ($ret as $key => $val) {
2505 $totalforeachweek[$key] += $val;
2506 }
2507 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2508 //var_dump($totalforeachday);
2509 }
2510 $level--;
2511 } else {
2512 //$level--;
2513 }
2514 }
2515
2516 return $totalforeachweek;
2517}
2518
2519
2529function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2530{
2531 //print 'Search in line with parent id = '.$parent.'<br>';
2532 $numlines = count($lines);
2533 for ($i = 0; $i < $numlines; $i++) {
2534 // Process line $lines[$i]
2535 if ($lines[$i]->fk_task_parent == $parent && $lines[$i]->id != $lines[$i]->fk_task_parent) {
2536 // If task is legitimate to show, no more need to search deeper
2537 if (isset($taskrole[$lines[$i]->id])) {
2538 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2539 $inc++;
2540 return $inc;
2541 }
2542
2543 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2544 //print 'Found inc='.$inc.'<br>';
2545
2546 if ($inc > 0) {
2547 return $inc;
2548 }
2549 }
2550 }
2551
2552 return $inc;
2553}
2554
2569function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2570{
2571 global $langs, $conf, $user;
2572 global $theme_datacolor;
2573
2574 $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2575
2576 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2577
2578 $listofstatus = array_keys($listofoppstatus);
2579
2580 if (is_array($listofstatus) && getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2581 // Define $themeColorId and array $statusOppList for each $listofstatus
2582 $themeColorId = 0;
2583 $statusOppList = array();
2584 foreach ($listofstatus as $oppStatus) {
2585 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2586 if ($oppStatusCode) {
2587 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2588 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2589 }
2590 $themeColorId++;
2591 }
2592 }
2593
2594 $projectstatic = new Project($db);
2595 $thirdpartystatic = new Societe($db);
2596
2597 $sortfield = '';
2598 $sortorder = '';
2599 $project_year_filter = 0;
2600
2601 $title = $langs->trans("Projects");
2602 if (strcmp((string) $status, '') && $status >= 0) {
2603 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->labelStatus[$status]);
2604 }
2605
2606 print '<!-- print_projecttasks_array -->';
2607 print '<div class="div-table-responsive-no-min">';
2608 print '<table class="noborder centpercent">';
2609
2610 $sql = " FROM ".MAIN_DB_PREFIX."projet as p";
2611 if ($mytasks) {
2612 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
2613 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
2614 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
2615 } else {
2616 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2617 }
2618 $sql .= " WHERE p.entity IN (".getEntity('project').")";
2619 $sql .= " AND p.rowid IN (".$db->sanitize((string) $projectsListId).")";
2620 if ($socid) {
2621 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
2622 }
2623 if ($mytasks) {
2624 $sql .= " AND p.rowid = t.fk_projet";
2625 $sql .= " AND ec.element_id = t.rowid";
2626 $sql .= " AND ec.fk_socpeople = ".((int) $user->id);
2627 $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2628 $sql .= " AND ctc.element = 'project_task'";
2629 }
2630 if ($status >= 0) {
2631 $sql .= " AND p.fk_statut = ".(int) $status;
2632 }
2633 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2634 $project_year_filter = GETPOST("project_year_filter", 'alpha'); // '*' seems allowed
2635 //Check if empty or invalid year. Wildcard ignores the sql check
2636 if ($project_year_filter != "*") {
2637 if (empty($project_year_filter) || !is_numeric($project_year_filter)) {
2638 $project_year_filter = date("Y");
2639 }
2640 $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day((int) $project_year_filter, 12, false)).")";
2641 $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day((int) $project_year_filter, 1, false)).")";
2642 }
2643 }
2644
2645 // Get id of project we must show tasks
2646 $arrayidofprojects = array();
2647 $alttext = '';
2648 $sql1 = "SELECT p.rowid as projectid";
2649 $sql1 .= $sql;
2650 $resql = $db->query($sql1);
2651 if ($resql) {
2652 $i = 0;
2653 $num = $db->num_rows($resql);
2654 while ($i < $num) {
2655 $objp = $db->fetch_object($resql);
2656 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2657 $i++;
2658 }
2659 } else {
2660 dol_print_error($db);
2661 }
2662 if (empty($arrayidofprojects)) {
2663 $arrayidofprojects[0] = -1;
2664 }
2665
2666 // Get list of project with calculation on tasks
2667 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,";
2668 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,";
2669 $sql2 .= " s.code_client, s.code_compta, s.client,";
2670 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
2671 $sql2 .= " s.logo, s.email, s.entity,";
2672 $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,";
2673 $sql2 .= " p.dateo, p.datee,";
2674 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2675 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2676 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
2677 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2678 $sql2 .= " WHERE p.rowid IN (".$db->sanitize(implode(',', $arrayidofprojects)).")";
2679 $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,";
2680 $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";
2681 $sql2 .= " ORDER BY p.title, p.ref";
2682
2683 $resql = $db->query($sql2);
2684 if ($resql) {
2685 $othernb = 0;
2686 $total_task = 0;
2687 $total_opp_amount = 0;
2688 $ponderated_opp_amount = 0;
2689 $total_plannedworkload = 0;
2690 $total_declaredprogressworkload = 0;
2691
2692 $num = $db->num_rows($resql);
2693 $nbofloop = min($num, (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2694 $i = 0;
2695
2696 print '<tr class="liste_titre">';
2697 print_liste_field_titre($title.'<a href="'.DOL_URL_ROOT.'/projet/list.php?search_status='.((int) $status).'"><span class="badge marginleftonlyshort">'.$num.'</span></a>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2698 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2699 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2700 if (!in_array('prospectionstatus', $hiddenfields)) {
2701 print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'center ');
2702 }
2703 print_liste_field_titre($form->textwithpicto($langs->trans("Amount"), $langs->trans("OpportunityAmount").' ('.$langs->trans("Tooltip").' = '.$langs->trans("OpportunityWeightedAmount").')'), "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
2704 //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
2705 }
2706 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2707 print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
2708 if (!in_array('plannedworkload', $hiddenfields)) {
2709 print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
2710 }
2711 if (!in_array('declaredprogress', $hiddenfields)) {
2712 print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared"));
2713 }
2714 }
2715 if (!in_array('projectstatus', $hiddenfields)) {
2716 print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2717 }
2718 print "</tr>\n";
2719
2720 while ($i < $nbofloop) {
2721 $objp = $db->fetch_object($resql);
2722
2723 if ($max && $i >= $max) {
2724 $othernb++;
2725 $i++;
2726 $total_task += $objp->nb;
2727 $total_opp_amount += $objp->opp_amount;
2728 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2729 $ponderated_opp_amount += price2num($opp_weighted_amount);
2730 $plannedworkload = $objp->planned_workload;
2731 $total_plannedworkload += $plannedworkload;
2732 $declaredprogressworkload = $objp->declared_progess_workload;
2733 $total_declaredprogressworkload += $declaredprogressworkload;
2734 continue;
2735 }
2736
2737 $projectstatic->id = $objp->projectid;
2738 $projectstatic->user_author_id = $objp->fk_user_creat;
2739 $projectstatic->public = $objp->public;
2740
2741 // Check is user has read permission on project
2742 $userAccess = $projectstatic->restrictedProjectArea($user);
2743 if ($userAccess >= 0) {
2744 $projectstatic->ref = $objp->ref;
2745 $projectstatic->status = $objp->status;
2746 $projectstatic->title = $objp->title;
2747 $projectstatic->date_end = $db->jdate($objp->datee);
2748 $projectstatic->date_start = $db->jdate($objp->dateo);
2749
2750 print '<tr class="oddeven">';
2751
2752 print '<td class="tdoverflowmax150">';
2753 print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall');
2754 if (!in_array('projectlabel', $hiddenfields)) {
2755 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).'</span>';
2756 }
2757 print '</td>';
2758
2759 print '<td class="nowraponall tdoverflowmax100">';
2760 if ($objp->fk_soc > 0) {
2761 $thirdpartystatic->id = $objp->socid;
2762 $thirdpartystatic->name = $objp->socname;
2763 //$thirdpartystatic->name_alias = $objp->name_alias;
2764 //$thirdpartystatic->code_client = $objp->code_client;
2765 $thirdpartystatic->code_compta = $objp->code_compta;
2766 $thirdpartystatic->code_compta_client = $objp->code_compta;
2767 $thirdpartystatic->client = $objp->client;
2768 //$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
2769 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2770 $thirdpartystatic->fournisseur = $objp->fournisseur;
2771 $thirdpartystatic->logo = $objp->logo;
2772 $thirdpartystatic->email = $objp->email;
2773 $thirdpartystatic->entity = $objp->entity;
2774 print $thirdpartystatic->getNomUrl(1);
2775 }
2776 print '</td>';
2777
2778 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2779 if (!in_array('prospectionstatus', $hiddenfields)) {
2780 print '<td class="center tdoverflowmax75">';
2781 // Because color of prospection status has no meaning yet, it is used if hidden constant is set
2782 if (!getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2783 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2784 if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) {
2785 print $langs->trans("OppStatus".$oppStatusCode);
2786 }
2787 } else {
2788 if (isset($statusOppList[$objp->opp_status])) {
2789 $oppStatusCode = $statusOppList[$objp->opp_status]['code'];
2790 $oppStatusColor = $statusOppList[$objp->opp_status]['color'];
2791 } else {
2792 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2793 $oppStatusColor = '';
2794 }
2795 if ($oppStatusCode) {
2796 if (!empty($oppStatusColor)) {
2797 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>';
2798 } else {
2799 print '<a href="'.dol_buildpath('/projet/list.php?search_opp_status='.$objp->opp_status, 1).'" title="'.$langs->trans("OppStatus".$oppStatusCode).'">'.$oppStatusCode.'</a>';
2800 }
2801 }
2802 }
2803 print '</td>';
2804 }
2805
2806 print '<td class="right">';
2807 $alttext = '';
2808 if ($objp->opp_percent && $objp->opp_amount) {
2809 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2810 $alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency);
2811 $ponderated_opp_amount += price2num($opp_weighted_amount);
2812 }
2813 if ($objp->opp_amount) {
2814 print '<span class="amount" title="'.$alttext.'">'.$form->textwithpicto(price($objp->opp_amount, 0, '', 1, -1, 0), $alttext).'</span>';
2815 }
2816 print '</td>';
2817 }
2818
2819 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2820 print '<td class="right">'.$objp->nb.'</td>';
2821
2822 $plannedworkload = $objp->planned_workload;
2823 $total_plannedworkload += $plannedworkload;
2824 if (!in_array('plannedworkload', $hiddenfields)) {
2825 print '<td class="right nowraponall">'.($plannedworkload ? convertSecondToTime($plannedworkload) : '').'</td>';
2826 }
2827 if (!in_array('declaredprogress', $hiddenfields)) {
2828 $declaredprogressworkload = $objp->declared_progess_workload;
2829 $total_declaredprogressworkload += $declaredprogressworkload;
2830 print '<td class="right nowraponall">';
2831 //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
2832 print($plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
2833 print '</td>';
2834 }
2835 }
2836
2837 if (!in_array('projectstatus', $hiddenfields)) {
2838 print '<td class="right">';
2839 print $projectstatic->getLibStatut(3);
2840 print '</td>';
2841 }
2842
2843 print "</tr>\n";
2844
2845 $total_task += $objp->nb;
2846 $total_opp_amount += $objp->opp_amount;
2847 }
2848
2849 $i++;
2850 }
2851
2852 if ($othernb) {
2853 print '<tr class="oddeven">';
2854 print '<td class="nowrap" colspan="5">';
2855 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
2856 print '</td>';
2857 print "</tr>\n";
2858 }
2859
2860 print '<tr class="liste_total">';
2861 print '<td>'.$langs->trans("Total")."</td><td></td>";
2862 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2863 if (!in_array('prospectionstatus', $hiddenfields)) {
2864 print '<td class="liste_total"></td>';
2865 }
2866 print '<td class="liste_total right">';
2867 //$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1);
2868 print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency));
2869 print '</td>';
2870 }
2871 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2872 print '<td class="liste_total right">'.$total_task.'</td>';
2873 if (!in_array('plannedworkload', $hiddenfields)) {
2874 print '<td class="liste_total right">'.($total_plannedworkload ? convertSecondToTime($total_plannedworkload) : '').'</td>';
2875 }
2876 if (!in_array('declaredprogress', $hiddenfields)) {
2877 print '<td class="liste_total right">'.($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
2878 }
2879 }
2880 if (!in_array('projectstatus', $hiddenfields)) {
2881 print '<td class="liste_total"></td>';
2882 }
2883 print '</tr>';
2884
2885 $db->free($resql);
2886 } else {
2887 dol_print_error($db);
2888 }
2889
2890 print "</table>";
2891 print '</div>';
2892
2893 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2894 //Add the year filter input
2895 print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
2896 print '<table width="100%">';
2897 print '<tr>';
2898 print '<td>'.$langs->trans("Year").'</td>';
2899 print '<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.((int) $project_year_filter).'"/>';
2900 print "</tr>\n";
2901 print '</table></form>';
2902 }
2903}
2904
2914function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $spaced = false)
2915{
2916 global $langs, $conf;
2917
2918 $out = '';
2919
2920 $plannedworkloadoutputformat = 'allhourmin';
2921 $timespentoutputformat = 'allhourmin';
2922 if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
2923 $plannedworkloadoutputformat = getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT');
2924 }
2925 if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
2926 $timespentoutputformat = getDolGlobalString('PROJECT_TIME_SPENT_FORMAT');
2927 }
2928
2929 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2930 return '';
2931 }
2932
2933 $spaced = !empty($spaced) ? 'spaced' : '';
2934
2935 $diff = '';
2936
2937 // define progress color according to time spend vs workload
2938 $progressBarClass = 'progress-bar-info';
2939 $progressCalculated = 0;
2940 if ($task->planned_workload) {
2941 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
2942
2943 // this conf is actually hidden, by default we use 10% for "be careful or warning"
2944 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2945
2946 $diffTitle = '<br>'.$langs->trans('ProgressDeclared').' : '.$task->progress.(isset($task->progress) ? '%' : '');
2947 $diffTitle .= '<br>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.(isset($progressCalculated) ? '%' : '');
2948
2949 //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.floatval($task->progress * $warningRatio));
2950 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
2951 $progressBarClass = 'progress-bar-danger';
2952 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2953 $diff = '<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).'%</span>';
2954 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
2955 $progressBarClass = 'progress-bar-warning';
2956 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2957 $diff = '<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).'%</span>';
2958 } else {
2959 $progressBarClass = 'progress-bar-success';
2960 $title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).' '.$langs->trans("point"));
2961 $diff = '<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).'%</span>';
2962 }
2963 }
2964
2965 $out .= '<div class="progress-group">';
2966
2967 if ($label !== false) {
2968 $out .= ' <span class="progress-text">';
2969
2970 if ($label !== true) {
2971 $out .= $label; // replace label by param
2972 } else {
2973 $out .= $task->getNomUrl(1).' '.dol_htmlentities($task->label);
2974 }
2975 $out .= ' </span>';
2976 }
2977
2978
2979 if ($progressNumber !== false) {
2980 $out .= ' <span class="progress-number">';
2981 if ($progressNumber !== true) {
2982 $out .= $progressNumber; // replace label by param
2983 } else {
2984 if ($task->hasDelay()) {
2985 $out .= img_warning($langs->trans("Late")).' ';
2986 }
2987
2988 $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id;
2989
2990 $out .= !empty($diff) ? $diff.' ' : '';
2991 $out .= '<a href="'.$url.'" >';
2992 $out .= '<b title="'.$langs->trans('TimeSpent').'" >';
2993 if ($task->duration_effective) {
2994 $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat);
2995 } else {
2996 $out .= '--:--';
2997 }
2998 $out .= '</b>';
2999 $out .= '</a>';
3000
3001 $out .= ' / ';
3002
3003 $out .= '<a href="'.$url.'" >';
3004 $out .= '<span title="'.$langs->trans('PlannedWorkload').'" >';
3005 if ($task->planned_workload) {
3006 $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat);
3007 } else {
3008 $out .= '--:--';
3009 }
3010 $out .= '</a>';
3011 }
3012 $out .= ' </span>';
3013 }
3014
3015
3016 $out .= '</span>';
3017 $out .= ' <div class="progress sm'.($spaced ? $spaced : '').'">';
3018 $diffval = (float) $task->progress - (float) $progressCalculated;
3019 if ($diffval >= 0) {
3020 // good
3021 $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.(float) $task->progress.'%" title="'.(float) $task->progress.'%">';
3022 if (!empty($task->progress)) {
3023 $out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.(float) ($progressCalculated / ((float) $task->progress == 0 ? 1 : $task->progress) * 100).'%" title="'.(float) $progressCalculated.'%"></div>';
3024 }
3025 $out .= ' </div>';
3026 } else {
3027 // bad
3028 $out .= ' <div class="progress-bar progress-bar-consumed-late" style="width: '.(float) $progressCalculated.'%" title="'.(float) $progressCalculated.'%">';
3029 $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.($task->progress ? (float) ($task->progress / ((float) $progressCalculated == 0 ? 1 : $progressCalculated) * 100).'%' : '1px').'" title="'.(float) $task->progress.'%"></div>';
3030 $out .= ' </div>';
3031 }
3032 $out .= ' </div>';
3033 $out .= '</div>';
3034
3035
3036
3037 return $out;
3038}
3046function getTaskProgressBadge($task, $label = '', $tooltip = '')
3047{
3048 global $conf, $langs;
3049
3050 $out = '';
3051 $badgeClass = '';
3052 if ($task->progress != '') {
3053 // TODO : manage 100%
3054
3055 // define color according to time spend vs workload
3056 $badgeClass = 'badge ';
3057 if ($task->planned_workload) {
3058 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
3059
3060 // this conf is actually hidden, by default we use 10% for "be careful or warning"
3061 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
3062
3063 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
3064 $badgeClass .= 'badge-danger';
3065 if (empty($tooltip)) {
3066 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3067 }
3068 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
3069 $badgeClass .= 'badge-warning';
3070 if (empty($tooltip)) {
3071 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3072 }
3073 } else {
3074 $badgeClass .= 'badge-success';
3075 if (empty($tooltip)) {
3076 $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3077 }
3078 }
3079 }
3080 }
3081
3082 $title = '';
3083 if (!empty($tooltip)) {
3084 $badgeClass .= ' classfortooltip';
3085 $title = 'title="'.dol_htmlentities($tooltip).'"';
3086 }
3087
3088 if (empty($label)) {
3089 $label = $task->progress.' %';
3090 }
3091
3092 if (!empty($label)) {
3093 $out = '<span class="'.$badgeClass.'" '.$title.' >'.$label.'</span>';
3094 }
3095
3096 return $out;
3097}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
$c
Definition line.php:327
$object ref
Definition info.php:89
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage projects.
Class to manage tasks.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
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:244
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
treeview li table
No Email.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dol_setcache($memoryid, $data, $expire=0, $filecache=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
Class to generate the form for creating a new ticket.
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 input mode.
task_prepare_head($object)
Prepare array with list of tabs.
searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)
projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0)
Output a task line into a pertime input mode.
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
project_admin_prepare_head()
Prepare array with list of tabs.
getTaskProgressBadge($task, $label='', $tooltip='')
projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a perday input mode.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.