dolibarr 21.0.0-beta
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 //var_dump($contacttask);
919 if ($source == 'internal') {
920 $c = new User($db);
921 } else {
922 $c = new Contact($db);
923 }
924 $c->fetch($contacttask['id']);
925 if (!empty($c->photo)) {
926 if (get_class($c) == 'User') {
927 print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
928 } else {
929 print $c->getNomUrl(-2, '', 0, 0, -1, 0, ($ifisrt ? '' : 'notfirst'));
930 }
931 } else {
932 if (get_class($c) == 'User') {
933 print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
934 } else {
935 print $c->getNomUrl(2, '', 0, 0, -1, 0, ($ifisrt ? '' : 'notfirst'));
936 }
937 }
938 $ifisrt = 0;
939 }
940 }
941 }
942 print '</td>';
943 }
944
945 // Billable
946 if (count($arrayfields) > 0 && !empty($arrayfields['t.billable']['checked'])) {
947 print '<td class="center">';
948 if ($lines[$i]->billable) {
949 print '<span>'.$langs->trans('Yes').'</span>';
950 } else {
951 print '<span>'.$langs->trans('No').'</span>';
952 }
953 print '</td>';
954 }
955
956 // Extra fields
957 $extrafieldsobjectkey = $taskstatic->table_element;
958 $extrafieldsobjectprefix = 'efpt.';
959 $obj = $lines[$i];
960 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
961 // Fields from hook
962 $parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]);
963 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
964 print $hookmanager->resPrint;
965
966 // Tick to drag and drop
967 print '<td class="tdlineupdown center"></td>';
968
969 // Action column
970 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
971 print '<td class="nowrap center">';
972 $selected = 0;
973 if (in_array($lines[$i]->id, $arrayofselected)) {
974 $selected = 1;
975 }
976 print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
977
978 print '</td>';
979 }
980
981 print "</tr>\n";
982
983 if (!$showlineingray) {
984 $inc++;
985 }
986
987 if ($level >= 0) { // Call sublevels
988 $level++;
989 if ($lines[$i]->id) {
990 projectLinesa($inc, $lines[$i]->id, $lines, $level, '', $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, '', $showbilltime, $arrayfields);
991 }
992 $level--;
993 }
994
995 $total_projectlinesa_spent += $lines[$i]->duration_effective;
996 $total_projectlinesa_planned += $lines[$i]->planned_workload;
997 if ($lines[$i]->planned_workload) {
998 $total_projectlinesa_spent_if_planned += $lines[$i]->duration_effective;
999 }
1000 if ($lines[$i]->planned_workload) {
1001 $total_projectlinesa_declared_if_planned += (float) $lines[$i]->planned_workload * $lines[$i]->progress / 100;
1002 }
1003 }
1004 } else {
1005 //$level--;
1006 }
1007 }
1008
1009 // Total line
1010 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
1011 && $level <= 0) {
1012 print '<tr class="liste_total nodrag nodrop">';
1013
1014 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1015 print '<td class="liste_total"></td>';
1016 }
1017
1018 print '<td class="liste_total">'.$langs->trans("Total").'</td>';
1019 if ($showproject) {
1020 print '<td></td><td></td>';
1021 }
1022 if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
1023 print '<td></td>';
1024 }
1025 if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
1026 print '<td></td>';
1027 }
1028 if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
1029 print '<td></td>';
1030 }
1031 if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
1032 print '<td></td>';
1033 }
1034 if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
1035 print '<td class="nowrap liste_total right">';
1036 print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
1037 print '</td>';
1038 }
1039 if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
1040 print '<td class="nowrap liste_total right">';
1041 if ($projectidfortotallink > 0) {
1042 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
1043 }
1044 print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
1045 if ($projectidfortotallink > 0) {
1046 print '</a>';
1047 }
1048 print '</td>';
1049 }
1050
1051 $totalCalculatedProgress = 0;
1052 $totalAverageDeclaredProgress = 0;
1053 $badgeClass = '';
1054 $progressBarClass = '';
1055 if ($total_projectlinesa_planned) {
1056 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
1057 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
1058
1059 // this conf is actually hidden, by default we use 10% for "be careful or warning"
1060 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
1061
1062 // define progress color according to time spend vs workload
1063 $progressBarClass = 'progress-bar-info';
1064 $badgeClass = 'badge ';
1065
1066 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
1067 $progressBarClass = 'progress-bar-danger';
1068 $badgeClass .= 'badge-danger';
1069 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1%
1070 $progressBarClass = 'progress-bar-warning';
1071 $badgeClass .= 'badge-warning';
1072 } else {
1073 $progressBarClass = 'progress-bar-success';
1074 $badgeClass .= 'badge-success';
1075 }
1076 }
1077
1078 // Computed progress
1079 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
1080 print '<td class="nowrap liste_total right">';
1081 if ($total_projectlinesa_planned) {
1082 print $totalCalculatedProgress.' %';
1083 }
1084 print '</td>';
1085 }
1086
1087 // Declared progress
1088 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
1089 print '<td class="nowrap liste_total right">';
1090 if ($total_projectlinesa_planned) {
1091 print '<span class="'.$badgeClass.'" >'.$totalAverageDeclaredProgress.' %</span>';
1092 }
1093 print '</td>';
1094 }
1095
1096
1097 // Progress
1098 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
1099 print '<td class="right">';
1100 if ($total_projectlinesa_planned) {
1101 print '</span>';
1102 print ' <div class="progress sm" title="'.$totalAverageDeclaredProgress.'%" >';
1103 print ' <div class="progress-bar '.$progressBarClass.'" style="width: '.$totalAverageDeclaredProgress.'%"></div>';
1104 print ' </div>';
1105 print '</div>';
1106 }
1107 print '</td>';
1108 }
1109
1110 if ($showbilltime) {
1111 if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
1112 print '<td class="nowrap liste_total right">';
1113 print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin');
1114 print '</td>';
1115 }
1116 if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
1117 print '<td class="nowrap liste_total right">';
1118 print convertSecondToTime($total_projectlinesa_billed, 'allhourmin');
1119 print '</td>';
1120 }
1121 }
1122
1123 // Budget task
1124 if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) {
1125 print '<td class="nowrap liste_total center">';
1126 if (strcmp((string) $total_budget_amount, '')) {
1127 print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1128 }
1129 print '</td>';
1130 }
1131
1132 // Contacts of task for backward compatibility,
1133 if (getDolGlobalString('PROJECT_SHOW_CONTACTS_IN_LIST')) {
1134 print '<td></td>';
1135 }
1136 // Contacts of task
1137 if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
1138 print '<td></td>';
1139 }
1140
1141 // Check if Extrafields is totalizable
1142 if (!empty($extrafields->attributes['projet_task']['totalizable'])) {
1143 foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) {
1144 if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) {
1145 print '<td class="right">';
1146 if ($value == 1) {
1147 print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total'];
1148 }
1149 print '</td>';
1150 }
1151 }
1152 }
1153
1154 // Column for the drag and drop
1155 print '<td class="liste_total"></td>';
1156
1157 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1158 print '<td class="liste_total"></td>';
1159 }
1160
1161 print '</tr>';
1162 }
1163
1164 return $inc;
1165}
1166
1167
1185function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1186{
1187 global $conf, $db, $user, $langs;
1188 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1189 '
1190 @phan-var-force FormOther $formother
1191 @phan-var-force Project $projectstatic
1192 @phan-var-force Task $taskstatic
1193 @phan-var-force Societe $thirdpartystatic
1194 ';
1195
1196 $lastprojectid = 0;
1197 $totalforeachline = array();
1198 $workloadforid = array();
1199 $lineswithoutlevel0 = array();
1200
1201 $numlines = count($lines);
1202
1203 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1204 if ($parent == 0) { // Always and only if at first level
1205 for ($i = 0; $i < $numlines; $i++) {
1206 if ($lines[$i]->fk_task_parent) {
1207 $lineswithoutlevel0[] = $lines[$i];
1208 }
1209 }
1210 }
1211
1212 if (empty($oldprojectforbreak)) {
1213 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1214 }
1215
1216 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1217 for ($i = 0; $i < $numlines; $i++) {
1218 if ($parent == 0) {
1219 $level = 0;
1220 }
1221
1222 //if ($lines[$i]->fk_task_parent == $parent)
1223 //{
1224 // If we want all or we have a role on task, we show it
1225 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1226 //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);
1227
1228 // Break on a new project
1229 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1230 $lastprojectid = $lines[$i]->fk_project;
1231 if ($preselectedday) {
1232 $projectstatic->id = $lines[$i]->fk_project;
1233 }
1234 }
1235
1236 if (empty($workloadforid[$projectstatic->id])) {
1237 if ($preselectedday) {
1238 $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
1239 $workloadforid[$projectstatic->id] = 1;
1240 }
1241 }
1242
1243 $projectstatic->id = $lines[$i]->fk_project;
1244 $projectstatic->ref = $lines[$i]->project_ref;
1245 $projectstatic->title = $lines[$i]->project_label;
1246 $projectstatic->public = $lines[$i]->public;
1247 $projectstatic->status = $lines[$i]->project->status;
1248
1249 $taskstatic->id = $lines[$i]->fk_statut;
1250 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1251 $taskstatic->label = $lines[$i]->task_label;
1252 $taskstatic->date_start = $lines[$i]->date_start;
1253 $taskstatic->date_end = $lines[$i]->date_end;
1254
1255 $thirdpartystatic->id = $lines[$i]->socid;
1256 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1257 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1258
1259 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1260 print '<tr class="oddeven trforbreak nobold">'."\n";
1261 print '<td colspan="11">';
1262 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1263 if ($projectstatic->title) {
1264 print ' - ';
1265 print $projectstatic->title;
1266 }
1267 print '</td>';
1268 print '</tr>';
1269 }
1270
1271 if ($oldprojectforbreak != -1) {
1272 $oldprojectforbreak = $projectstatic->id;
1273 }
1274
1275 print '<tr class="oddeven">'."\n";
1276
1277 // User
1278 /*
1279 print '<td class="nowrap">';
1280 print $fuser->getNomUrl(1, 'withproject', 'time');
1281 print '</td>';
1282 */
1283
1284 // Project
1285 print "<td>";
1286 if ($oldprojectforbreak == -1) {
1287 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1288 print '<br>'.$projectstatic->title;
1289 }
1290 print "</td>";
1291
1292 // Thirdparty
1293 print '<td class="tdoverflowmax100">';
1294 if ($thirdpartystatic->id > 0) {
1295 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1296 }
1297 print '</td>';
1298
1299 // Ref
1300 print '<td>';
1301 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperaction) -->';
1302 for ($k = 0; $k < $level; $k++) {
1303 print '<div class="marginleftonly">';
1304 }
1305 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1306 // Label task
1307 print '<br>';
1308 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1309 for ($k = 0; $k < $level; $k++) {
1310 print "</div>";
1311 }
1312 print "</td>\n";
1313
1314 // Date
1315 print '<td class="center">';
1316 print dol_print_date($lines[$i]->timespent_datehour, 'day');
1317 print '</td>';
1318
1319 $disabledproject = 1;
1320 $disabledtask = 1;
1321 //print "x".$lines[$i]->fk_project;
1322 //var_dump($lines[$i]);
1323 //var_dump($projectsrole[$lines[$i]->fk_project]);
1324 // If at least one role for project
1325 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1326 $disabledproject = 0;
1327 $disabledtask = 0;
1328 }
1329 // If $restricteditformytask is on and I have no role on task, i disable edit
1330 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1331 $disabledtask = 1;
1332 }
1333
1334 // Hour
1335 print '<td class="nowrap center">';
1336 print dol_print_date($lines[$i]->timespent_datehour, 'hour');
1337 print '</td>';
1338
1339 $cssonholiday = '';
1340 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1341 $cssonholiday .= 'onholidayallday ';
1342 } elseif (!$isavailable[$preselectedday]['morning']) {
1343 $cssonholiday .= 'onholidaymorning ';
1344 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1345 $cssonholiday .= 'onholidayafternoon ';
1346 }
1347
1348 // Duration
1349 print '<td class="duration'.($cssonholiday ? ' '.$cssonholiday : '').' center">';
1350
1351 $dayWorkLoad = $lines[$i]->timespent_duration;
1352 if (!array_key_exists($preselectedday, $totalforeachline)) {
1353 $totalforeachline[$preselectedday] = 0;
1354 }
1355 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1356
1357 $alreadyspent = '';
1358 if ($dayWorkLoad > 0) {
1359 $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1360 }
1361
1362 print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1363
1364 print '</td>';
1365
1366 // Note
1367 print '<td class="center">';
1368 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1369 print $lines[$i]->timespent_note;
1370 print '</textarea>';
1371 print '</td>';
1372
1373 // Warning
1374 print '<td class="right">';
1375 /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1376 elseif ($disabledtask)
1377 {
1378 $titleassigntask = $langs->trans("AssignTaskToMe");
1379 if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1380
1381 print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1382 }*/
1383 print '</td>';
1384
1385 print "</tr>\n";
1386 }
1387 //}
1388 //else
1389 //{
1390 //$level--;
1391 //}
1392 }
1393
1394 return $totalforeachline;
1395}
1396
1397
1417function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1418{
1419 global $conf, $db, $user, $langs;
1420 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1421 '
1422 @phan-var-force FormOther $formother
1423 @phan-var-force Project $projectstatic
1424 @phan-var-force Task $taskstatic
1425 @phan-var-force Societe $thirdpartystatic
1426 ';
1427
1428 $lastprojectid = 0;
1429 $totalforeachday = array();
1430 $workloadforid = array();
1431 $lineswithoutlevel0 = array();
1432
1433 $numlines = count($lines);
1434
1435 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1436 if ($parent == 0) { // Always and only if at first level
1437 for ($i = 0; $i < $numlines; $i++) {
1438 if ($lines[$i]->fk_task_parent) {
1439 $lineswithoutlevel0[] = $lines[$i];
1440 }
1441 }
1442 }
1443
1444 if (empty($oldprojectforbreak)) {
1445 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1446 }
1447
1448 $restrictBefore = null;
1449
1450 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1451 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1452 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1453 }
1454
1455 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1456 for ($i = 0; $i < $numlines; $i++) {
1457 if ($parent == 0) {
1458 $level = 0;
1459 }
1460
1461 if ($lines[$i]->fk_task_parent == $parent) {
1462 $obj = &$lines[$i]; // To display extrafields
1463
1464 // If we want all or we have a role on task, we show it
1465 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1466 //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);
1467
1468 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1469 continue;
1470 }
1471
1472 // Break on a new project
1473 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1474 $lastprojectid = $lines[$i]->fk_project;
1475 if ($preselectedday) {
1476 $projectstatic->id = $lines[$i]->fk_project;
1477 }
1478 }
1479
1480 if (empty($workloadforid[$projectstatic->id])) {
1481 if ($preselectedday) {
1482 $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
1483 $workloadforid[$projectstatic->id] = 1;
1484 }
1485 }
1486
1487 $projectstatic->id = $lines[$i]->fk_project;
1488 $projectstatic->ref = $lines[$i]->projectref;
1489 $projectstatic->title = $lines[$i]->projectlabel;
1490 $projectstatic->public = $lines[$i]->public;
1491 $projectstatic->status = $lines[$i]->projectstatus;
1492
1493 $taskstatic->id = $lines[$i]->id;
1494 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1495 $taskstatic->label = $lines[$i]->label;
1496 $taskstatic->date_start = $lines[$i]->date_start;
1497 $taskstatic->date_end = $lines[$i]->date_end;
1498
1499 $thirdpartystatic->id = $lines[$i]->socid;
1500 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1501 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1502
1503 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1504 $addcolspan = 0;
1505 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1506 $addcolspan++;
1507 }
1508 if (!empty($arrayfields['t.progress']['checked'])) {
1509 $addcolspan++;
1510 }
1511 foreach ($arrayfields as $key => $val) {
1512 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1513 $addcolspan++;
1514 }
1515 }
1516
1517 print '<tr class="oddeven trforbreak nobold">'."\n";
1518 print '<td colspan="'.(7 + $addcolspan).'">';
1519 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1520 if ($thirdpartystatic->id > 0) {
1521 print ' - '.$thirdpartystatic->getNomUrl(1);
1522 }
1523 if ($projectstatic->title) {
1524 print ' - ';
1525 print '<span class="secondary">'.$projectstatic->title.'</span>';
1526 }
1527 /*
1528 $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1529 print '<table class="">';
1530
1531 print '<tr class="liste_titre">';
1532
1533 // PROJECT fields
1534 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 ');
1535 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 ');
1536 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 ');
1537 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 ');
1538 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 ');
1539
1540 $extrafieldsobjectkey='projet';
1541 $extrafieldsobjectprefix='efp.';
1542 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1543
1544 print '</tr>';
1545 print '<tr>';
1546
1547 // PROJECT fields
1548 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1549 {
1550 print '<td class="nowrap">';
1551 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1552 if ($code) print $langs->trans("OppStatus".$code);
1553 print "</td>\n";
1554 }
1555 if (!empty($arrayfields['p.opp_amount']['checked']))
1556 {
1557 print '<td class="nowrap">';
1558 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1559 print "</td>\n";
1560 }
1561 if (!empty($arrayfields['p.opp_percent']['checked']))
1562 {
1563 print '<td class="nowrap">';
1564 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1565 print "</td>\n";
1566 }
1567 if (!empty($arrayfields['p.budget_amount']['checked']))
1568 {
1569 print '<td class="nowrap">';
1570 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1571 print "</td>\n";
1572 }
1573 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1574 {
1575 print '<td class="nowrap">';
1576 print yn($lines[$i]->usage_bill_time);
1577 print "</td>\n";
1578 }
1579
1580 $extrafieldsobjectkey='projet';
1581 $extrafieldsobjectprefix='efp.';
1582 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1583
1584 print '</tr>';
1585 print '</table>';
1586
1587 */
1588 print '</td>';
1589 print '</tr>';
1590 }
1591
1592 if ($oldprojectforbreak != -1) {
1593 $oldprojectforbreak = $projectstatic->id;
1594 }
1595
1596 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1597
1598 // User
1599 /*
1600 print '<td class="nowrap">';
1601 print $fuser->getNomUrl(1, 'withproject', 'time');
1602 print '</td>';
1603 */
1604
1605 // Project
1606 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1607 print "<td>";
1608 if ($oldprojectforbreak == -1) {
1609 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1610 }
1611 print "</td>";
1612 }
1613
1614 // Thirdparty
1615 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1616 print '<td class="tdoverflowmax100">';
1617 if ($thirdpartystatic->id > 0) {
1618 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1619 }
1620 print '</td>';
1621 }
1622
1623 // Ref
1624 print '<td>';
1625 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperday) -->';
1626 for ($k = 0; $k < $level; $k++) {
1627 print '<div class="marginleftonly">';
1628 }
1629 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1630 // Label task
1631 print '<br>';
1632 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1633 for ($k = 0; $k < $level; $k++) {
1634 print "</div>";
1635 }
1636 print "</td>\n";
1637
1638 // TASK extrafields
1639 $extrafieldsobjectkey = 'projet_task';
1640 $extrafieldsobjectprefix = 'efpt.';
1641 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1642
1643 // Planned Workload
1644 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1645 print '<td class="leftborder plannedworkload right">';
1646 if ($lines[$i]->planned_workload) {
1647 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1648 } else {
1649 print '--:--';
1650 }
1651 print '</td>';
1652 }
1653
1654 // Progress declared %
1655 if (!empty($arrayfields['t.progress']['checked'])) {
1656 print '<td class="right">';
1657 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1658 print '</td>';
1659 }
1660
1661 if (!empty($arrayfields['timeconsumed']['checked'])) {
1662 // Time spent by everybody
1663 print '<td class="right">';
1664 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
1665 if ($lines[$i]->duration_effective) {
1666 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1667 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
1668 print '</a>';
1669 } else {
1670 print '--:--';
1671 }
1672 print "</td>\n";
1673
1674 // Time spent by user
1675 print '<td class="right">';
1676 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1677 if ($tmptimespent['total_duration']) {
1678 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1679 } else {
1680 print '--:--';
1681 }
1682 print "</td>\n";
1683 }
1684
1685 $disabledproject = 1;
1686 $disabledtask = 1;
1687 //print "x".$lines[$i]->fk_project;
1688 //var_dump($lines[$i]);
1689 //var_dump($projectsrole[$lines[$i]->fk_project]);
1690 // If at least one role for project
1691 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1692 $disabledproject = 0;
1693 $disabledtask = 0;
1694 }
1695 // If $restricteditformytask is on and I have no role on task, i disable edit
1696 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1697 $disabledtask = 1;
1698 }
1699
1700 if ($restrictBefore && $preselectedday < $restrictBefore) {
1701 $disabledtask = 1;
1702 }
1703
1704 // Select hour
1705 print '<td class="nowraponall leftborder center minwidth150imp borderleft">';
1706 $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
1707 print $tableCell;
1708 print '</td>';
1709
1710 $cssonholiday = '';
1711 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1712 $cssonholiday .= 'onholidayallday ';
1713 } elseif (!$isavailable[$preselectedday]['morning']) {
1714 $cssonholiday .= 'onholidaymorning ';
1715 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1716 $cssonholiday .= 'onholidayafternoon ';
1717 }
1718
1719 global $daytoparse;
1720 $tmparray = dol_getdate($daytoparse, true); // detail of current day
1721
1722 $idw = ($tmparray['wday'] - (!getDolGlobalString('MAIN_START_WEEK') ? 0 : 1));
1723 global $numstartworkingday, $numendworkingday;
1724 $cssweekend = '';
1725 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.
1726 $cssweekend = 'weekend';
1727 }
1728
1729 // Duration
1730 print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
1731 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1732 if (!isset($totalforeachday[$preselectedday])) {
1733 $totalforeachday[$preselectedday] = 0;
1734 }
1735 $totalforeachday[$preselectedday] += $dayWorkLoad;
1736
1737 $alreadyspent = '';
1738 if ($dayWorkLoad > 0) {
1739 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
1740 }
1741
1742 $idw = 0;
1743
1744 $tableCell = '';
1745 $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>';
1746 $tableCell .= '<span class="hideonsmartphone"> + </span>';
1747 //$tableCell.='&nbsp;&nbsp;&nbsp;';
1748 $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
1749 //$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
1750 print $tableCell;
1751
1752 print '</td>';
1753
1754 // Note
1755 print '<td class="center">';
1756 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1757 print '</textarea>';
1758 print '</td>';
1759
1760 // Warning
1761 print '<td class="right">';
1762 if ((!$lines[$i]->public) && $disabledproject) {
1763 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1764 } elseif ($disabledtask) {
1765 $titleassigntask = $langs->trans("AssignTaskToMe");
1766 if ($fuser->id != $user->id) {
1767 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1768 }
1769
1770 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1771 }
1772 print '</td>';
1773
1774 print "</tr>\n";
1775 }
1776
1777 $inc++;
1778 $level++;
1779 if ($lines[$i]->id > 0) {
1780 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1781 //var_dump($totalforeachday);
1782 $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1783 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1784 //var_dump($ret);
1785 foreach ($ret as $key => $val) {
1786 $totalforeachday[$key] += $val;
1787 }
1788 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1789 //var_dump($totalforeachday);
1790 }
1791 $level--;
1792 } else {
1793 //$level--;
1794 }
1795 }
1796
1797 return $totalforeachday;
1798}
1799
1800
1820function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1821{
1822 global $conf, $db, $user, $langs;
1823 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1824 '
1825 @phan-var-force FormOther $formother
1826 @phan-var-force Project $projectstatic
1827 @phan-var-force Task $taskstatic
1828 @phan-var-force Societe $thirdpartystatic
1829 ';
1830
1831 $numlines = count($lines);
1832
1833 $lastprojectid = 0;
1834 $workloadforid = array();
1835 $totalforeachday = array();
1836 $lineswithoutlevel0 = array();
1837
1838 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1839 if ($parent == 0) { // Always and only if at first level
1840 for ($i = 0; $i < $numlines; $i++) {
1841 if ($lines[$i]->fk_task_parent) {
1842 $lineswithoutlevel0[] = $lines[$i];
1843 }
1844 }
1845 }
1846
1847 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1848
1849 if (empty($oldprojectforbreak)) {
1850 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
1851 }
1852
1853 $restrictBefore = null;
1854
1855 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1856 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1857 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1858 }
1859
1860 for ($i = 0; $i < $numlines; $i++) {
1861 if ($parent == 0) {
1862 $level = 0;
1863 }
1864
1865 if ($lines[$i]->fk_task_parent == $parent) {
1866 $obj = &$lines[$i]; // To display extrafields
1867
1868 // If we want all or we have a role on task, we show it
1869 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1870 //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);
1871
1872 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1873 continue;
1874 }
1875
1876 // Break on a new project
1877 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1878 $lastprojectid = $lines[$i]->fk_project;
1879 $projectstatic->id = $lines[$i]->fk_project;
1880 }
1881
1882 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1883 //var_dump($projectstatic->weekWorkLoadPerTask);
1884 if (empty($workloadforid[$projectstatic->id])) {
1885 $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
1886 $workloadforid[$projectstatic->id] = 1;
1887 }
1888 //var_dump($projectstatic->weekWorkLoadPerTask);
1889 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1890
1891 $projectstatic->id = $lines[$i]->fk_project;
1892 $projectstatic->ref = $lines[$i]->projectref;
1893 $projectstatic->title = $lines[$i]->projectlabel;
1894 $projectstatic->public = $lines[$i]->public;
1895 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1896 $projectstatic->status = $lines[$i]->projectstatus;
1897
1898 $taskstatic->id = $lines[$i]->id;
1899 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1900 $taskstatic->label = $lines[$i]->label;
1901 $taskstatic->date_start = $lines[$i]->date_start;
1902 $taskstatic->date_end = $lines[$i]->date_end;
1903
1904 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1905 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1906 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1907
1908 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1909 $addcolspan = 0;
1910 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1911 $addcolspan++;
1912 }
1913 if (!empty($arrayfields['t.progress']['checked'])) {
1914 $addcolspan++;
1915 }
1916 foreach ($arrayfields as $key => $val) {
1917 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1918 $addcolspan++;
1919 }
1920 }
1921
1922 print '<tr class="oddeven trforbreak nobold">'."\n";
1923 print '<td colspan="'.(11 + $addcolspan).'">';
1924 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1925 if ($thirdpartystatic->id > 0) {
1926 print ' - '.$thirdpartystatic->getNomUrl(1);
1927 }
1928 if ($projectstatic->title) {
1929 print ' - ';
1930 print '<span class="secondary">'.$projectstatic->title.'</span>';
1931 }
1932
1933 /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1934 print '<table class="">';
1935
1936 print '<tr class="liste_titre">';
1937
1938 // PROJECT fields
1939 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 ');
1940 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 ');
1941 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 ');
1942 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 ');
1943 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 ');
1944
1945 $extrafieldsobjectkey='projet';
1946 $extrafieldsobjectprefix='efp.';
1947 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1948
1949 print '</tr>';
1950 print '<tr>';
1951
1952 // PROJECT fields
1953 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1954 {
1955 print '<td class="nowrap">';
1956 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1957 if ($code) print $langs->trans("OppStatus".$code);
1958 print "</td>\n";
1959 }
1960 if (!empty($arrayfields['p.opp_amount']['checked']))
1961 {
1962 print '<td class="nowrap">';
1963 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1964 print "</td>\n";
1965 }
1966 if (!empty($arrayfields['p.opp_percent']['checked']))
1967 {
1968 print '<td class="nowrap">';
1969 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1970 print "</td>\n";
1971 }
1972 if (!empty($arrayfields['p.budget_amount']['checked']))
1973 {
1974 print '<td class="nowrap">';
1975 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1976 print "</td>\n";
1977 }
1978 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1979 {
1980 print '<td class="nowrap">';
1981 print yn($lines[$i]->usage_bill_time);
1982 print "</td>\n";
1983 }
1984
1985 $extrafieldsobjectkey='projet';
1986 $extrafieldsobjectprefix='efp.';
1987 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1988
1989 print '</tr>';
1990 print '</table>';
1991 */
1992
1993 print '</td>';
1994 print '</tr>';
1995 }
1996
1997 if ($oldprojectforbreak != -1) {
1998 $oldprojectforbreak = $projectstatic->id;
1999 }
2000
2001 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2002
2003 // User
2004 /*
2005 print '<td class="nowrap">';
2006 print $fuser->getNomUrl(1, 'withproject', 'time');
2007 print '</td>';
2008 */
2009
2010 // Project
2011 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2012 print '<td class="nowrap">';
2013 if ($oldprojectforbreak == -1) {
2014 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2015 }
2016 print "</td>";
2017 }
2018
2019 // Thirdparty
2020 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2021 print '<td class="tdoverflowmax100">';
2022 if ($thirdpartystatic->id > 0) {
2023 print $thirdpartystatic->getNomUrl(1, 'project');
2024 }
2025 print '</td>';
2026 }
2027
2028 // Ref
2029 print '<td class="tdoverflowmax300">';
2030 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperweek) -->';
2031 for ($k = 0; $k < $level; $k++) {
2032 print '<div class="marginleftonly">';
2033 }
2034 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2035 // Label task
2036 print '<br>';
2037 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2038 for ($k = 0; $k < $level; $k++) {
2039 print "</div>";
2040 }
2041 print "</td>\n";
2042
2043 // TASK extrafields
2044 $extrafieldsobjectkey = 'projet_task';
2045 $extrafieldsobjectprefix = 'efpt.';
2046 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2047
2048 // Planned Workload
2049 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2050 print '<td class="leftborder plannedworkload right">';
2051 if ($lines[$i]->planned_workload) {
2052 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2053 } else {
2054 print '--:--';
2055 }
2056 print '</td>';
2057 }
2058
2059 if (!empty($arrayfields['t.progress']['checked'])) {
2060 // Progress declared %
2061 print '<td class="right">';
2062 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2063 print '</td>';
2064 }
2065
2066 if (!empty($arrayfields['timeconsumed']['checked'])) {
2067 // Time spent by everybody
2068 print '<td class="right">';
2069 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2070 if ($lines[$i]->duration_effective) {
2071 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'">';
2072 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2073 print '</a>';
2074 } else {
2075 print '--:--';
2076 }
2077 print "</td>\n";
2078
2079 // Time spent by user
2080 print '<td class="right">';
2081 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2082 if ($tmptimespent['total_duration']) {
2083 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'&search_user='.((int) $fuser->id).'">';
2084 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2085 print '</a>';
2086 } else {
2087 print '--:--';
2088 }
2089 print "</td>\n";
2090 }
2091
2092 $disabledproject = 1;
2093 $disabledtask = 1;
2094 //print "x".$lines[$i]->fk_project;
2095 //var_dump($lines[$i]);
2096 //var_dump($projectsrole[$lines[$i]->fk_project]);
2097 // If at least one role for project
2098 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2099 $disabledproject = 0;
2100 $disabledtask = 0;
2101 }
2102 // If $restricteditformytask is on and I have no role on task, i disable edit
2103 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2104 $disabledtask = 1;
2105 }
2106
2107 //var_dump($projectstatic->weekWorkLoadPerTask);
2108
2109 // Fields to show current time
2110 $tableCell = '';
2111 $modeinput = 'hours';
2112 $j = 0;
2113 for ($idw = 0; $idw < 7; $idw++) {
2114 $j++;
2115 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
2116 if (!isset($totalforeachday[$tmpday])) {
2117 $totalforeachday[$tmpday] = 0;
2118 }
2119 $cssonholiday = '';
2120 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
2121 $cssonholiday .= 'onholidayallday ';
2122 } elseif (!$isavailable[$tmpday]['morning']) {
2123 $cssonholiday .= 'onholidaymorning ';
2124 } elseif (!$isavailable[$tmpday]['afternoon']) {
2125 $cssonholiday .= 'onholidayafternoon ';
2126 }
2127
2128 $tmparray = dol_getdate($tmpday);
2129 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2130 $totalforeachday[$tmpday] += $dayWorkLoad;
2131
2132 $alreadyspent = '';
2133 if ($dayWorkLoad > 0) {
2134 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
2135 }
2136 $alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']);
2137
2138 global $numstartworkingday, $numendworkingday;
2139 $cssweekend = '';
2140 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.
2141 $cssweekend = 'weekend';
2142 }
2143
2144 $disabledtaskday = $disabledtask;
2145
2146 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2147 $disabledtaskday = 1;
2148 }
2149
2150 $tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').($j <= 1 ? ' borderleft' : '').'">';
2151 //$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
2152 $placeholder = '';
2153 if ($alreadyspent) {
2154 $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>';
2155 //$placeholder=' placeholder="00:00"';
2156 //$tableCell.='+';
2157 }
2158 $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"';
2159 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2160 $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
2161 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
2162 $tableCell .= '</td>';
2163 print $tableCell;
2164 }
2165
2166 // Warning
2167 print '<td class="right">';
2168 if ((!$lines[$i]->public) && $disabledproject) {
2169 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2170 } elseif ($disabledtask) {
2171 $titleassigntask = $langs->trans("AssignTaskToMe");
2172 if ($fuser->id != $user->id) {
2173 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2174 }
2175
2176 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2177 }
2178 print '</td>';
2179
2180 print "</tr>\n";
2181 }
2182
2183 // Call to show task with a lower level (task under the current task)
2184 $inc++;
2185 $level++;
2186 if ($lines[$i]->id > 0) {
2187 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2188 //var_dump($totalforeachday);
2189 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2190 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2191 //var_dump($ret);
2192 foreach ($ret as $key => $val) {
2193 $totalforeachday[$key] += $val;
2194 }
2195 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2196 //var_dump($totalforeachday);
2197 }
2198 $level--;
2199 } else {
2200 //$level--;
2201 }
2202 }
2203
2204 return $totalforeachday;
2205}
2206
2227function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array(), $arrayfields = array(), $extrafields = null)
2228{
2229 global $conf, $db, $user, $langs;
2230 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2231 '
2232 @phan-var-force FormOther $formother
2233 @phan-var-force Project $projectstatic
2234 @phan-var-force Task $taskstatic
2235 @phan-var-force Societe $thirdpartystatic
2236 ';
2237
2238 $numlines = count($lines);
2239
2240 $lastprojectid = 0;
2241 $workloadforid = array();
2242 $totalforeachweek = array();
2243 $lineswithoutlevel0 = array();
2244
2245 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2246 if ($parent == 0) { // Always and only if at first level
2247 for ($i = 0; $i < $numlines; $i++) {
2248 if ($lines[$i]->fk_task_parent) {
2249 $lineswithoutlevel0[] = $lines[$i];
2250 }
2251 }
2252 }
2253
2254 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
2255
2256 if (empty($oldprojectforbreak)) {
2257 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
2258 }
2259
2260 $restrictBefore = null;
2261
2262 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
2263 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2264 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
2265 }
2266
2267 for ($i = 0; $i < $numlines; $i++) {
2268 if ($parent == 0) {
2269 $level = 0;
2270 }
2271
2272 if ($lines[$i]->fk_task_parent == $parent) {
2273 // If we want all or we have a role on task, we show it
2274 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2275 //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);
2276
2277 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
2278 continue;
2279 }
2280
2281 // Break on a new project
2282 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2283 $lastprojectid = $lines[$i]->fk_project;
2284 $projectstatic->id = $lines[$i]->fk_project;
2285 }
2286
2287 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2288 //var_dump($projectstatic->weekWorkLoadPerTask);
2289 if (empty($workloadforid[$projectstatic->id])) {
2290 $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
2291 $workloadforid[$projectstatic->id] = 1;
2292 }
2293 //var_dump($projectstatic->weekWorkLoadPerTask);
2294 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2295
2296 $projectstatic->id = $lines[$i]->fk_project;
2297 $projectstatic->ref = $lines[$i]->projectref;
2298 $projectstatic->title = $lines[$i]->projectlabel;
2299 $projectstatic->public = $lines[$i]->public;
2300 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2301 $projectstatic->status = $lines[$i]->projectstatus;
2302
2303 $taskstatic->id = $lines[$i]->id;
2304 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2305 $taskstatic->label = $lines[$i]->label;
2306 $taskstatic->date_start = $lines[$i]->date_start;
2307 $taskstatic->date_end = $lines[$i]->date_end;
2308
2309 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2310 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2311 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2312
2313 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2314 print '<tr class="oddeven trforbreak nobold">'."\n";
2315 print '<td colspan="'.(6 + count($TWeek)).'">';
2316 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2317 if ($thirdpartystatic->id > 0) {
2318 print ' - '.$thirdpartystatic->getNomUrl(1);
2319 }
2320 if ($projectstatic->title) {
2321 print ' - ';
2322 print '<span class="secondary">'.$projectstatic->title.'</span>';
2323 }
2324 print '</td>';
2325 print '</tr>';
2326 }
2327
2328 if ($oldprojectforbreak != -1) {
2329 $oldprojectforbreak = $projectstatic->id;
2330 }
2331 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2332
2333 // User
2334 /*
2335 print '<td class="nowrap">';
2336 print $fuser->getNomUrl(1, 'withproject', 'time');
2337 print '</td>';
2338 */
2339
2340 // Project
2341 /*print '<td class="nowrap">';
2342 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2343 print "</td>";*/
2344
2345 // Thirdparty
2346 /*print '<td class="tdoverflowmax100">';
2347 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2348 print '</td>';*/
2349
2350 // Ref
2351 print '<td class="nowrap">';
2352 print '<!-- Task id = '.$lines[$i]->id.' (projectlinespermonth) -->';
2353 for ($k = 0; $k < $level; $k++) {
2354 print '<div class="marginleftonly">';
2355 }
2356 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2357 // Label task
2358 print '<br>';
2359 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2360 for ($k = 0; $k < $level; $k++) {
2361 print "</div>";
2362 }
2363 print "</td>\n";
2364
2365 // Planned Workload
2366 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2367 print '<td class="leftborder plannedworkload right">';
2368 if ($lines[$i]->planned_workload) {
2369 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2370 } else {
2371 print '--:--';
2372 }
2373 print '</td>';
2374 }
2375
2376 // Progress declared %
2377 if (!empty($arrayfields['t.progress']['checked'])) {
2378 print '<td class="right">';
2379 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2380 print '</td>';
2381 }
2382
2383 // Time spent by everybody
2384 if (!empty($arrayfields['timeconsumed']['checked'])) {
2385 print '<td class="right">';
2386 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2387 if ($lines[$i]->duration_effective) {
2388 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
2389 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2390 print '</a>';
2391 } else {
2392 print '--:--';
2393 }
2394 print "</td>\n";
2395
2396 // Time spent by user
2397 print '<td class="right">';
2398 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2399 if ($tmptimespent['total_duration']) {
2400 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2401 } else {
2402 print '--:--';
2403 }
2404 print "</td>\n";
2405 }
2406
2407 $disabledproject = 1;
2408 $disabledtask = 1;
2409 //print "x".$lines[$i]->fk_project;
2410 //var_dump($lines[$i]);
2411 //var_dump($projectsrole[$lines[$i]->fk_project]);
2412 // If at least one role for project
2413 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2414 $disabledproject = 0;
2415 $disabledtask = 0;
2416 }
2417 // If $restricteditformytask is on and I have no role on task, i disable edit
2418 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2419 $disabledtask = 1;
2420 }
2421
2422 //var_dump($projectstatic->weekWorkLoadPerTask);
2423 //TODO
2424 // Fields to show current time
2425 $tableCell = '';
2426 $modeinput = 'hours';
2427 $TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow));
2428 $TFirstDay[reset($TWeek)] = 1;
2429
2430 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2431 $year = $firstdaytoshowarray['year'];
2432 $month = $firstdaytoshowarray['mon'];
2433 $j = 0;
2434 foreach ($TWeek as $weekIndex => $weekNb) {
2435 $j++;
2436 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2437 if (!isset($totalforeachweek[$weekNb])) {
2438 $totalforeachweek[$weekNb] = 0;
2439 }
2440 $totalforeachweek[$weekNb] += $weekWorkLoad;
2441
2442 $alreadyspent = '';
2443 if ($weekWorkLoad > 0) {
2444 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2445 }
2446 $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
2447
2448 $disabledtaskweek = $disabledtask;
2449 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2450
2451 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2452 $disabledtaskweek = 1;
2453 }
2454
2455 $tableCell = '<td class="center hide'.($j <= 1 ? ' borderleft' : '').'">';
2456 $placeholder = '';
2457 if ($alreadyspent) {
2458 $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>';
2459 //$placeholder=' placeholder="00:00"';
2460 //$tableCell.='+';
2461 }
2462
2463 $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"';
2464 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2465 $tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
2466 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
2467 $tableCell .= '</td>';
2468 print $tableCell;
2469 }
2470
2471 // Warning
2472 print '<td class="right">';
2473 if ((!$lines[$i]->public) && $disabledproject) {
2474 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2475 } elseif ($disabledtask) {
2476 $titleassigntask = $langs->trans("AssignTaskToMe");
2477 if ($fuser->id != $user->id) {
2478 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2479 }
2480
2481 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2482 }
2483 print '</td>';
2484
2485 print "</tr>\n";
2486 }
2487
2488 // Call to show task with a lower level (task under the current task)
2489 $inc++;
2490 $level++;
2491 if ($lines[$i]->id > 0) {
2492 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2493 //var_dump($totalforeachday);
2494 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2495 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2496 //var_dump($ret);
2497 foreach ($ret as $key => $val) {
2498 $totalforeachweek[$key] += $val;
2499 }
2500 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2501 //var_dump($totalforeachday);
2502 }
2503 $level--;
2504 } else {
2505 //$level--;
2506 }
2507 }
2508
2509 return $totalforeachweek;
2510}
2511
2512
2522function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2523{
2524 //print 'Search in line with parent id = '.$parent.'<br>';
2525 $numlines = count($lines);
2526 for ($i = 0; $i < $numlines; $i++) {
2527 // Process line $lines[$i]
2528 if ($lines[$i]->fk_task_parent == $parent && $lines[$i]->id != $lines[$i]->fk_task_parent) {
2529 // If task is legitimate to show, no more need to search deeper
2530 if (isset($taskrole[$lines[$i]->id])) {
2531 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2532 $inc++;
2533 return $inc;
2534 }
2535
2536 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2537 //print 'Found inc='.$inc.'<br>';
2538
2539 if ($inc > 0) {
2540 return $inc;
2541 }
2542 }
2543 }
2544
2545 return $inc;
2546}
2547
2562function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2563{
2564 global $langs, $conf, $user;
2565 global $theme_datacolor;
2566
2567 $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2568
2569 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2570
2571 $listofstatus = array_keys($listofoppstatus);
2572
2573 if (is_array($listofstatus) && getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2574 // Define $themeColorId and array $statusOppList for each $listofstatus
2575 $themeColorId = 0;
2576 $statusOppList = array();
2577 foreach ($listofstatus as $oppStatus) {
2578 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2579 if ($oppStatusCode) {
2580 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2581 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2582 }
2583 $themeColorId++;
2584 }
2585 }
2586
2587 $projectstatic = new Project($db);
2588 $thirdpartystatic = new Societe($db);
2589
2590 $sortfield = '';
2591 $sortorder = '';
2592 $project_year_filter = 0;
2593
2594 $title = $langs->trans("Projects");
2595 if (strcmp((string) $status, '') && $status >= 0) {
2596 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->labelStatus[$status]);
2597 }
2598
2599 print '<!-- print_projecttasks_array -->';
2600 print '<div class="div-table-responsive-no-min">';
2601 print '<table class="noborder centpercent">';
2602
2603 $sql = " FROM ".MAIN_DB_PREFIX."projet as p";
2604 if ($mytasks) {
2605 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
2606 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
2607 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
2608 } else {
2609 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2610 }
2611 $sql .= " WHERE p.entity IN (".getEntity('project').")";
2612 $sql .= " AND p.rowid IN (".$db->sanitize((string) $projectsListId).")";
2613 if ($socid) {
2614 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
2615 }
2616 if ($mytasks) {
2617 $sql .= " AND p.rowid = t.fk_projet";
2618 $sql .= " AND ec.element_id = t.rowid";
2619 $sql .= " AND ec.fk_socpeople = ".((int) $user->id);
2620 $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2621 $sql .= " AND ctc.element = 'project_task'";
2622 }
2623 if ($status >= 0) {
2624 $sql .= " AND p.fk_statut = ".(int) $status;
2625 }
2626 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2627 $project_year_filter = GETPOST("project_year_filter", 'alpha'); // '*' seems allowed
2628 //Check if empty or invalid year. Wildcard ignores the sql check
2629 if ($project_year_filter != "*") {
2630 if (empty($project_year_filter) || !is_numeric($project_year_filter)) {
2631 $project_year_filter = date("Y");
2632 }
2633 $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day((int) $project_year_filter, 12, false)).")";
2634 $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day((int) $project_year_filter, 1, false)).")";
2635 }
2636 }
2637
2638 // Get id of project we must show tasks
2639 $arrayidofprojects = array();
2640 $alttext = '';
2641 $sql1 = "SELECT p.rowid as projectid";
2642 $sql1 .= $sql;
2643 $resql = $db->query($sql1);
2644 if ($resql) {
2645 $i = 0;
2646 $num = $db->num_rows($resql);
2647 while ($i < $num) {
2648 $objp = $db->fetch_object($resql);
2649 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2650 $i++;
2651 }
2652 } else {
2653 dol_print_error($db);
2654 }
2655 if (empty($arrayidofprojects)) {
2656 $arrayidofprojects[0] = -1;
2657 }
2658
2659 // Get list of project with calculation on tasks
2660 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,";
2661 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,";
2662 $sql2 .= " s.code_client, s.code_compta, s.client,";
2663 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
2664 $sql2 .= " s.logo, s.email, s.entity,";
2665 $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,";
2666 $sql2 .= " p.dateo, p.datee,";
2667 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2668 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2669 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
2670 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2671 $sql2 .= " WHERE p.rowid IN (".$db->sanitize(implode(',', $arrayidofprojects)).")";
2672 $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,";
2673 $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";
2674 $sql2 .= " ORDER BY p.title, p.ref";
2675
2676 $resql = $db->query($sql2);
2677 if ($resql) {
2678 $othernb = 0;
2679 $total_task = 0;
2680 $total_opp_amount = 0;
2681 $ponderated_opp_amount = 0;
2682 $total_plannedworkload = 0;
2683 $total_declaredprogressworkload = 0;
2684
2685 $num = $db->num_rows($resql);
2686 $nbofloop = min($num, (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2687 $i = 0;
2688
2689 print '<tr class="liste_titre">';
2690 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);
2691 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2692 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2693 if (!in_array('prospectionstatus', $hiddenfields)) {
2694 print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'center ');
2695 }
2696 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 ');
2697 //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
2698 }
2699 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2700 print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
2701 if (!in_array('plannedworkload', $hiddenfields)) {
2702 print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
2703 }
2704 if (!in_array('declaredprogress', $hiddenfields)) {
2705 print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared"));
2706 }
2707 }
2708 if (!in_array('projectstatus', $hiddenfields)) {
2709 print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2710 }
2711 print "</tr>\n";
2712
2713 while ($i < $nbofloop) {
2714 $objp = $db->fetch_object($resql);
2715
2716 if ($max && $i >= $max) {
2717 $othernb++;
2718 $i++;
2719 $total_task += $objp->nb;
2720 $total_opp_amount += $objp->opp_amount;
2721 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2722 $ponderated_opp_amount += price2num($opp_weighted_amount);
2723 $plannedworkload = $objp->planned_workload;
2724 $total_plannedworkload += $plannedworkload;
2725 $declaredprogressworkload = $objp->declared_progess_workload;
2726 $total_declaredprogressworkload += $declaredprogressworkload;
2727 continue;
2728 }
2729
2730 $projectstatic->id = $objp->projectid;
2731 $projectstatic->user_author_id = $objp->fk_user_creat;
2732 $projectstatic->public = $objp->public;
2733
2734 // Check is user has read permission on project
2735 $userAccess = $projectstatic->restrictedProjectArea($user);
2736 if ($userAccess >= 0) {
2737 $projectstatic->ref = $objp->ref;
2738 $projectstatic->status = $objp->status;
2739 $projectstatic->title = $objp->title;
2740 $projectstatic->date_end = $db->jdate($objp->datee);
2741 $projectstatic->date_start = $db->jdate($objp->dateo);
2742
2743 print '<tr class="oddeven">';
2744
2745 print '<td class="tdoverflowmax150">';
2746 print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall');
2747 if (!in_array('projectlabel', $hiddenfields)) {
2748 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).'</span>';
2749 }
2750 print '</td>';
2751
2752 print '<td class="nowraponall tdoverflowmax100">';
2753 if ($objp->fk_soc > 0) {
2754 $thirdpartystatic->id = $objp->socid;
2755 $thirdpartystatic->name = $objp->socname;
2756 //$thirdpartystatic->name_alias = $objp->name_alias;
2757 //$thirdpartystatic->code_client = $objp->code_client;
2758 $thirdpartystatic->code_compta = $objp->code_compta;
2759 $thirdpartystatic->code_compta_client = $objp->code_compta;
2760 $thirdpartystatic->client = $objp->client;
2761 //$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
2762 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2763 $thirdpartystatic->fournisseur = $objp->fournisseur;
2764 $thirdpartystatic->logo = $objp->logo;
2765 $thirdpartystatic->email = $objp->email;
2766 $thirdpartystatic->entity = $objp->entity;
2767 print $thirdpartystatic->getNomUrl(1);
2768 }
2769 print '</td>';
2770
2771 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2772 if (!in_array('prospectionstatus', $hiddenfields)) {
2773 print '<td class="center tdoverflowmax75">';
2774 // Because color of prospection status has no meaning yet, it is used if hidden constant is set
2775 if (!getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2776 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2777 if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) {
2778 print $langs->trans("OppStatus".$oppStatusCode);
2779 }
2780 } else {
2781 if (isset($statusOppList[$objp->opp_status])) {
2782 $oppStatusCode = $statusOppList[$objp->opp_status]['code'];
2783 $oppStatusColor = $statusOppList[$objp->opp_status]['color'];
2784 } else {
2785 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2786 $oppStatusColor = '';
2787 }
2788 if ($oppStatusCode) {
2789 if (!empty($oppStatusColor)) {
2790 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>';
2791 } else {
2792 print '<a href="'.dol_buildpath('/projet/list.php?search_opp_status='.$objp->opp_status, 1).'" title="'.$langs->trans("OppStatus".$oppStatusCode).'">'.$oppStatusCode.'</a>';
2793 }
2794 }
2795 }
2796 print '</td>';
2797 }
2798
2799 print '<td class="right">';
2800 if ($objp->opp_percent && $objp->opp_amount) {
2801 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2802 $alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency);
2803 $ponderated_opp_amount += price2num($opp_weighted_amount);
2804 }
2805 if ($objp->opp_amount) {
2806 print '<span class="amount" title="'.$alttext.'">'.$form->textwithpicto(price($objp->opp_amount, 0, '', 1, -1, 0), $alttext).'</span>';
2807 }
2808 print '</td>';
2809 }
2810
2811 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2812 print '<td class="right">'.$objp->nb.'</td>';
2813
2814 $plannedworkload = $objp->planned_workload;
2815 $total_plannedworkload += $plannedworkload;
2816 if (!in_array('plannedworkload', $hiddenfields)) {
2817 print '<td class="right nowraponall">'.($plannedworkload ? convertSecondToTime($plannedworkload) : '').'</td>';
2818 }
2819 if (!in_array('declaredprogress', $hiddenfields)) {
2820 $declaredprogressworkload = $objp->declared_progess_workload;
2821 $total_declaredprogressworkload += $declaredprogressworkload;
2822 print '<td class="right nowraponall">';
2823 //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
2824 print($plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
2825 print '</td>';
2826 }
2827 }
2828
2829 if (!in_array('projectstatus', $hiddenfields)) {
2830 print '<td class="right">';
2831 print $projectstatic->getLibStatut(3);
2832 print '</td>';
2833 }
2834
2835 print "</tr>\n";
2836
2837 $total_task += $objp->nb;
2838 $total_opp_amount += $objp->opp_amount;
2839 }
2840
2841 $i++;
2842 }
2843
2844 if ($othernb) {
2845 print '<tr class="oddeven">';
2846 print '<td class="nowrap" colspan="5">';
2847 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
2848 print '</td>';
2849 print "</tr>\n";
2850 }
2851
2852 print '<tr class="liste_total">';
2853 print '<td>'.$langs->trans("Total")."</td><td></td>";
2854 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2855 if (!in_array('prospectionstatus', $hiddenfields)) {
2856 print '<td class="liste_total"></td>';
2857 }
2858 print '<td class="liste_total right">';
2859 //$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1);
2860 print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency));
2861 print '</td>';
2862 }
2863 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2864 print '<td class="liste_total right">'.$total_task.'</td>';
2865 if (!in_array('plannedworkload', $hiddenfields)) {
2866 print '<td class="liste_total right">'.($total_plannedworkload ? convertSecondToTime($total_plannedworkload) : '').'</td>';
2867 }
2868 if (!in_array('declaredprogress', $hiddenfields)) {
2869 print '<td class="liste_total right">'.($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
2870 }
2871 }
2872 if (!in_array('projectstatus', $hiddenfields)) {
2873 print '<td class="liste_total"></td>';
2874 }
2875 print '</tr>';
2876
2877 $db->free($resql);
2878 } else {
2879 dol_print_error($db);
2880 }
2881
2882 print "</table>";
2883 print '</div>';
2884
2885 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2886 //Add the year filter input
2887 print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
2888 print '<table width="100%">';
2889 print '<tr>';
2890 print '<td>'.$langs->trans("Year").'</td>';
2891 print '<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.((int) $project_year_filter).'"/>';
2892 print "</tr>\n";
2893 print '</table></form>';
2894 }
2895}
2896
2906function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $spaced = false)
2907{
2908 global $langs, $conf;
2909
2910 $out = '';
2911
2912 $plannedworkloadoutputformat = 'allhourmin';
2913 $timespentoutputformat = 'allhourmin';
2914 if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
2915 $plannedworkloadoutputformat = getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT');
2916 }
2917 if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
2918 $timespentoutputformat = getDolGlobalString('PROJECT_TIME_SPENT_FORMAT');
2919 }
2920
2921 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2922 return '';
2923 }
2924
2925 $spaced = !empty($spaced) ? 'spaced' : '';
2926
2927 $diff = '';
2928
2929 // define progress color according to time spend vs workload
2930 $progressBarClass = 'progress-bar-info';
2931 $progressCalculated = 0;
2932 if ($task->planned_workload) {
2933 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
2934
2935 // this conf is actually hidden, by default we use 10% for "be careful or warning"
2936 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2937
2938 $diffTitle = '<br>'.$langs->trans('ProgressDeclared').' : '.$task->progress.(isset($task->progress) ? '%' : '');
2939 $diffTitle .= '<br>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.(isset($progressCalculated) ? '%' : '');
2940
2941 //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.floatval($task->progress * $warningRatio));
2942 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
2943 $progressBarClass = 'progress-bar-danger';
2944 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2945 $diff = '<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).'%</span>';
2946 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
2947 $progressBarClass = 'progress-bar-warning';
2948 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2949 $diff = '<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).'%</span>';
2950 } else {
2951 $progressBarClass = 'progress-bar-success';
2952 $title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).' '.$langs->trans("point"));
2953 $diff = '<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).'%</span>';
2954 }
2955 }
2956
2957 $out .= '<div class="progress-group">';
2958
2959 if ($label !== false) {
2960 $out .= ' <span class="progress-text">';
2961
2962 if ($label !== true) {
2963 $out .= $label; // replace label by param
2964 } else {
2965 $out .= $task->getNomUrl(1).' '.dol_htmlentities($task->label);
2966 }
2967 $out .= ' </span>';
2968 }
2969
2970
2971 if ($progressNumber !== false) {
2972 $out .= ' <span class="progress-number">';
2973 if ($progressNumber !== true) {
2974 $out .= $progressNumber; // replace label by param
2975 } else {
2976 if ($task->hasDelay()) {
2977 $out .= img_warning($langs->trans("Late")).' ';
2978 }
2979
2980 $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id;
2981
2982 $out .= !empty($diff) ? $diff.' ' : '';
2983 $out .= '<a href="'.$url.'" >';
2984 $out .= '<b title="'.$langs->trans('TimeSpent').'" >';
2985 if ($task->duration_effective) {
2986 $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat);
2987 } else {
2988 $out .= '--:--';
2989 }
2990 $out .= '</b>';
2991 $out .= '</a>';
2992
2993 $out .= ' / ';
2994
2995 $out .= '<a href="'.$url.'" >';
2996 $out .= '<span title="'.$langs->trans('PlannedWorkload').'" >';
2997 if ($task->planned_workload) {
2998 $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat);
2999 } else {
3000 $out .= '--:--';
3001 }
3002 $out .= '</a>';
3003 }
3004 $out .= ' </span>';
3005 }
3006
3007
3008 $out .= '</span>';
3009 $out .= ' <div class="progress sm'.($spaced ? $spaced : '').'">';
3010 $diffval = (float) $task->progress - (float) $progressCalculated;
3011 if ($diffval >= 0) {
3012 // good
3013 $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.(float) $task->progress.'%" title="'.(float) $task->progress.'%">';
3014 if (!empty($task->progress)) {
3015 $out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.(float) ($progressCalculated / ((float) $task->progress == 0 ? 1 : $task->progress) * 100).'%" title="'.(float) $progressCalculated.'%"></div>';
3016 }
3017 $out .= ' </div>';
3018 } else {
3019 // bad
3020 $out .= ' <div class="progress-bar progress-bar-consumed-late" style="width: '.(float) $progressCalculated.'%" title="'.(float) $progressCalculated.'%">';
3021 $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>';
3022 $out .= ' </div>';
3023 }
3024 $out .= ' </div>';
3025 $out .= '</div>';
3026
3027
3028
3029 return $out;
3030}
3038function getTaskProgressBadge($task, $label = '', $tooltip = '')
3039{
3040 global $conf, $langs;
3041
3042 $out = '';
3043 $badgeClass = '';
3044 if ($task->progress != '') {
3045 // TODO : manage 100%
3046
3047 // define color according to time spend vs workload
3048 $badgeClass = 'badge ';
3049 if ($task->planned_workload) {
3050 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
3051
3052 // this conf is actually hidden, by default we use 10% for "be careful or warning"
3053 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
3054
3055 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
3056 $badgeClass .= 'badge-danger';
3057 if (empty($tooltip)) {
3058 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3059 }
3060 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
3061 $badgeClass .= 'badge-warning';
3062 if (empty($tooltip)) {
3063 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3064 }
3065 } else {
3066 $badgeClass .= 'badge-success';
3067 if (empty($tooltip)) {
3068 $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3069 }
3070 }
3071 }
3072 }
3073
3074 $title = '';
3075 if (!empty($tooltip)) {
3076 $badgeClass .= ' classfortooltip';
3077 $title = 'title="'.dol_htmlentities($tooltip).'"';
3078 }
3079
3080 if (empty($label)) {
3081 $label = $task->progress.' %';
3082 }
3083
3084 if (!empty($label)) {
3085 $out = '<span class="'.$badgeClass.'" '.$title.' >'.$label.'</span>';
3086 }
3087
3088 return $out;
3089}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
$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
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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).
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)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
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.
projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0, $dummy='', $showbilltime=0, $arrayfields=array(), $arrayofselected=array())
Show task lines with a particular parent.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.