dolibarr 21.0.4
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 global $objectoffield;
605
606 '
607 @phan-var-force Project $projectstatic
608 @phan-var-force Task $taskstatic
609 @phan-var-force ExtraFields $extrafields
610 ';
611
612 $lastprojectid = 0;
613
614 $projectsArrayId = array();
615 if ($projectsListId) {
616 $projectsArrayId = explode(',', $projectsListId);
617 }
618
619 $numlines = count($lines);
620
621 // We declare counter as global because we want to edit them into recursive call
622 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;
623 global $totalarray;
624
625 if ($level == 0) {
626 $total_projectlinesa_spent = 0;
627 $total_projectlinesa_planned = 0;
628 $total_projectlinesa_spent_if_planned = 0;
629 $total_projectlinesa_declared_if_planned = 0;
630 $total_projectlinesa_tobill = 0;
631 $total_projectlinesa_billed = 0;
632 $total_budget_amount = 0;
633 $totalarray = array();
634 }
635
636 for ($i = 0; $i < $numlines; $i++) {
637 if ($parent == 0 && $level >= 0) {
638 $level = 0; // if $level = -1, we don't use sublevel recursion, we show all lines
639 }
640
641 // Process line
642 // print "i:".$i."-".$lines[$i]->fk_project.'<br>';
643 if ($lines[$i]->fk_task_parent == $parent || $level < 0) { // if $level = -1, we don't use sublevel recursion, we show all lines
644 // Show task line.
645 $showline = 1;
646 $showlineingray = 0;
647
648 // If there is filters to use
649 if (is_array($taskrole)) {
650 // If task not legitimate to show, search if a legitimate task exists later in tree
651 if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_task_parent) {
652 // So search if task has a subtask legitimate to show
653 $foundtaskforuserdeeper = 0;
654 searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
655 //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
656 if ($foundtaskforuserdeeper > 0) {
657 $showlineingray = 1; // We will show line but in gray
658 } else {
659 $showline = 0; // No reason to show line
660 }
661 }
662 } else {
663 // 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
664 // or into all other projects if user has permission to).
665 if (!$user->hasRight('projet', 'all', 'lire')) {
666 // User is not allowed on this project and project is not public, so we hide line
667 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
668 // Note that having a user assigned to a task into a project user has no permission on, should not be possible
669 // because assignment on task can be done only on contact of project.
670 // If assignment was done and after, was removed from contact of project, then we can hide the line.
671 $showline = 0;
672 }
673 }
674 }
675
676 if ($showline) {
677 // Break on a new project
678 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
679 $lastprojectid = $lines[$i]->fk_project;
680 }
681
682 print '<tr class="oddeven" id="row-'.$lines[$i]->id.'">'."\n";
683
684 $projectstatic->id = $lines[$i]->fk_project;
685 $projectstatic->ref = $lines[$i]->projectref;
686 $projectstatic->public = $lines[$i]->public;
687 $projectstatic->title = $lines[$i]->projectlabel;
688 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
689 $projectstatic->status = $lines[$i]->projectstatus;
690
691 $taskstatic->id = $lines[$i]->id;
692 $taskstatic->ref = $lines[$i]->ref;
693 $taskstatic->label = (!empty($taskrole[$lines[$i]->id]) ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : '');
694 $taskstatic->projectstatus = $lines[$i]->projectstatus;
695 $taskstatic->progress = $lines[$i]->progress;
696 $taskstatic->fk_statut = $lines[$i]->status; // deprecated
697 $taskstatic->status = $lines[$i]->status;
698 $taskstatic->date_start = $lines[$i]->date_start;
699 $taskstatic->date_end = $lines[$i]->date_end;
700 $taskstatic->datee = $lines[$i]->date_end; // deprecated
701 $taskstatic->planned_workload = $lines[$i]->planned_workload;
702 $taskstatic->duration_effective = $lines[$i]->duration_effective;
703 $taskstatic->budget_amount = $lines[$i]->budget_amount;
704 $taskstatic->billable = $lines[$i]->billable;
705
706 // Action column
707 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
708 print '<td class="nowrap center">';
709 $selected = 0;
710 if (in_array($lines[$i]->id, $arrayofselected)) {
711 $selected = 1;
712 }
713 print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
714 print '</td>';
715 }
716
717 if ($showproject) {
718 // Project ref
719 print '<td class="nowraponall">';
720 //if ($showlineingray) print '<i>';
721 if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || $user->hasRight('projet', 'all', 'lire')) {
722 print $projectstatic->getNomUrl(1);
723 } else {
724 print $projectstatic->getNomUrl(1, 'nolink');
725 }
726 //if ($showlineingray) print '</i>';
727 print "</td>";
728
729 // Project status
730 print '<td>';
731 $projectstatic->statut = $lines[$i]->projectstatus;
732 print $projectstatic->getLibStatut(2);
733 print "</td>";
734 }
735
736 // Ref of task
737 if (count($arrayfields) > 0 && !empty($arrayfields['t.ref']['checked'])) {
738 print '<td class="nowraponall">';
739 if ($showlineingray) {
740 print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>';
741 } else {
742 print $taskstatic->getNomUrl(1, 'withproject');
743 }
744 print '</td>';
745 }
746
747 // Title of task
748 if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
749 $labeltoshow = '';
750 if ($showlineingray) {
751 $labeltoshow .= '<i>';
752 }
753 //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
754 for ($k = 0; $k < $level; $k++) {
755 $labeltoshow .= '<div class="marginleftonly">';
756 }
757 $labeltoshow .= dol_escape_htmltag($lines[$i]->label);
758 for ($k = 0; $k < $level; $k++) {
759 $labeltoshow .= '</div>';
760 }
761 if ($showlineingray) {
762 $labeltoshow .= '</i>';
763 }
764 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).'">';
765 print $labeltoshow;
766 print "</td>\n";
767 }
768
769 if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
770 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->description).'">';
771 print $lines[$i]->description;
772 print "</td>\n";
773 }
774
775 // Date start
776 if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
777 print '<td class="center nowraponall">';
778 print dol_print_date($lines[$i]->date_start, 'dayhour');
779 print '</td>';
780 }
781
782 // Date end
783 if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
784 print '<td class="center nowraponall">';
785 print dol_print_date($lines[$i]->date_end, 'dayhour');
786 if ($taskstatic->hasDelay()) {
787 print img_warning($langs->trans("Late"));
788 }
789 print '</td>';
790 }
791
792 $plannedworkloadoutputformat = 'allhourmin';
793 $timespentoutputformat = 'allhourmin';
794 if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
795 $plannedworkloadoutputformat = getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT');
796 }
797 if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
798 $timespentoutputformat = getDolGlobalString('PROJECT_TIME_SPENT_FORMAT');
799 }
800
801 // Planned Workload (in working hours)
802 if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
803 print '<td class="right">';
804 $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
805 $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
806 if ($lines[$i]->planned_workload != '') {
807 print $fullhour;
808 // TODO Add delay taking account of working hours per day and working day per week
809 //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
810 }
811 //else print '--:--';
812 print '</td>';
813 }
814
815 // Time spent
816 if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
817 print '<td class="right">';
818 if ($showlineingray) {
819 print '<i>';
820 } else {
821 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">';
822 }
823 if ($lines[$i]->duration_effective) {
824 print convertSecondToTime($lines[$i]->duration_effective, $timespentoutputformat);
825 } else {
826 print '--:--';
827 }
828 if ($showlineingray) {
829 print '</i>';
830 } else {
831 print '</a>';
832 }
833 print '</td>';
834 }
835
836 // Progress calculated (Note: ->duration_effective is time spent)
837 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
838 $s = '';
839 $shtml = '';
840 if ($lines[$i]->planned_workload || $lines[$i]->duration_effective) {
841 if ($lines[$i]->planned_workload) {
842 $s = round(100 * (float) $lines[$i]->duration_effective / (float) $lines[$i]->planned_workload, 2).' %';
843 $shtml = $s;
844 } else {
845 $s = $langs->trans('WorkloadNotDefined');
846 $shtml = '<span class="opacitymedium">'.$s.'</span>';
847 }
848 }
849 print '<td class="right tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
850 print $shtml;
851 print '</td>';
852 }
853
854 // Progress declared
855 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
856 print '<td class="right">';
857 if ($lines[$i]->progress != '') {
858 print getTaskProgressBadge($taskstatic);
859 }
860 print '</td>';
861 }
862
863 // resume
864 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
865 print '<td class="right">';
866 if ($lines[$i]->progress != '' && $lines[$i]->duration_effective) {
867 print getTaskProgressView($taskstatic, false, false);
868 }
869 print '</td>';
870 }
871
872 if ($showbilltime) {
873 // Time not billed
874 if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
875 print '<td class="right">';
876 if ($lines[$i]->usage_bill_time) {
877 print convertSecondToTime($lines[$i]->tobill, 'allhourmin');
878 $total_projectlinesa_tobill += $lines[$i]->tobill;
879 } else {
880 print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
881 }
882 print '</td>';
883 }
884
885 // Time billed
886 if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
887 print '<td class="right">';
888 if ($lines[$i]->usage_bill_time) {
889 print convertSecondToTime($lines[$i]->billed, 'allhourmin');
890 $total_projectlinesa_billed += $lines[$i]->billed;
891 } else {
892 print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
893 }
894 print '</td>';
895 }
896 }
897
898 // Budget task
899 if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) {
900 print '<td class="center">';
901 if ($lines[$i]->budget_amount) {
902 print '<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
903 $total_budget_amount += $lines[$i]->budget_amount;
904 }
905 print '</td>';
906 }
907
908 // Contacts of task
909 if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
910 print '<td class="center">';
911 $ifisrt = 1;
912 foreach (array('internal', 'external') as $source) {
913 //$tab = $lines[$i]->liste_contact(-1, $source);
914 $tab = $lines[$i]->liste_contact(-1, $source, 0, '', 1);
915
916 $numcontact = count($tab);
917 if (!empty($numcontact)) {
918 foreach ($tab as $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') {
928 '@phan-var-force User $c';
929 print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
930 } else {
932 '@phan-var-force Contact $c';
933 print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
934 }
935 } else {
936 if (get_class($c) == 'User') {
938 '@phan-var-force User $c';
939 print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
940 } else {
942 '@phan-var-force Contact $c';
943 print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
944 }
945 }
946 $ifisrt = 0;
947 }
948 }
949 }
950 print '</td>';
951 }
952
953 // Billable
954 if (count($arrayfields) > 0 && !empty($arrayfields['t.billable']['checked'])) {
955 print '<td class="center">';
956 if ($lines[$i]->billable) {
957 print '<span>'.$langs->trans('Yes').'</span>';
958 } else {
959 print '<span>'.$langs->trans('No').'</span>';
960 }
961 print '</td>';
962 }
963
964 // Extra fields
965 $extrafieldsobjectkey = $taskstatic->table_element;
966 $extrafieldsobjectprefix = 'efpt.';
967 $obj = $lines[$i];
968 $object = $lines[$i];
969 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
970 // Fields from hook
971 $parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]);
972 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
973 print $hookmanager->resPrint;
974
975 // Tick to drag and drop
976 print '<td class="tdlineupdown center"></td>';
977
978 // Action column
979 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
980 print '<td class="nowrap center">';
981 $selected = 0;
982 if (in_array($lines[$i]->id, $arrayofselected)) {
983 $selected = 1;
984 }
985 print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
986
987 print '</td>';
988 }
989
990 print "</tr>\n";
991
992 if (!$showlineingray) {
993 $inc++;
994 }
995
996 if ($level >= 0) { // Call sublevels
997 $level++;
998 if ($lines[$i]->id) {
999 projectLinesa($inc, $lines[$i]->id, $lines, $level, '', $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, '', $showbilltime, $arrayfields);
1000 }
1001 $level--;
1002 }
1003
1004 $total_projectlinesa_spent += $lines[$i]->duration_effective;
1005 $total_projectlinesa_planned += $lines[$i]->planned_workload;
1006 if ($lines[$i]->planned_workload) {
1007 $total_projectlinesa_spent_if_planned += $lines[$i]->duration_effective;
1008 }
1009 if ($lines[$i]->planned_workload) {
1010 $total_projectlinesa_declared_if_planned += (float) $lines[$i]->planned_workload * $lines[$i]->progress / 100;
1011 }
1012 }
1013 } else {
1014 //$level--;
1015 }
1016 }
1017
1018 // Total line
1019 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
1020 && $level <= 0) {
1021 print '<tr class="liste_total nodrag nodrop">';
1022
1023 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1024 print '<td class="liste_total"></td>';
1025 }
1026
1027 print '<td class="liste_total">'.$langs->trans("Total").'</td>';
1028 if ($showproject) {
1029 print '<td></td><td></td>';
1030 }
1031 if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
1032 print '<td></td>';
1033 }
1034 if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) {
1035 print '<td></td>';
1036 }
1037 if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
1038 print '<td></td>';
1039 }
1040 if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
1041 print '<td></td>';
1042 }
1043 if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
1044 print '<td class="nowrap liste_total right">';
1045 print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
1046 print '</td>';
1047 }
1048 if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
1049 print '<td class="nowrap liste_total right">';
1050 if ($projectidfortotallink > 0) {
1051 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
1052 }
1053 print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
1054 if ($projectidfortotallink > 0) {
1055 print '</a>';
1056 }
1057 print '</td>';
1058 }
1059
1060 $totalCalculatedProgress = 0;
1061 $totalAverageDeclaredProgress = 0;
1062 $badgeClass = '';
1063 $progressBarClass = '';
1064 if ($total_projectlinesa_planned) {
1065 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
1066 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
1067
1068 // this conf is actually hidden, by default we use 10% for "be careful or warning"
1069 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
1070
1071 // define progress color according to time spend vs workload
1072 $progressBarClass = 'progress-bar-info';
1073 $badgeClass = 'badge ';
1074
1075 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
1076 $progressBarClass = 'progress-bar-danger';
1077 $badgeClass .= 'badge-danger';
1078 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1%
1079 $progressBarClass = 'progress-bar-warning';
1080 $badgeClass .= 'badge-warning';
1081 } else {
1082 $progressBarClass = 'progress-bar-success';
1083 $badgeClass .= 'badge-success';
1084 }
1085 }
1086
1087 // Computed progress
1088 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
1089 print '<td class="nowrap liste_total right">';
1090 if ($total_projectlinesa_planned) {
1091 print $totalCalculatedProgress.' %';
1092 }
1093 print '</td>';
1094 }
1095
1096 // Declared progress
1097 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
1098 print '<td class="nowrap liste_total right">';
1099 if ($total_projectlinesa_planned) {
1100 print '<span class="'.$badgeClass.'" >'.$totalAverageDeclaredProgress.' %</span>';
1101 }
1102 print '</td>';
1103 }
1104
1105
1106 // Progress
1107 if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) {
1108 print '<td class="right">';
1109 if ($total_projectlinesa_planned) {
1110 print '</span>';
1111 print ' <div class="progress sm" title="'.$totalAverageDeclaredProgress.'%" >';
1112 print ' <div class="progress-bar '.$progressBarClass.'" style="width: '.$totalAverageDeclaredProgress.'%"></div>';
1113 print ' </div>';
1114 print '</div>';
1115 }
1116 print '</td>';
1117 }
1118
1119 if ($showbilltime) {
1120 if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
1121 print '<td class="nowrap liste_total right">';
1122 print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin');
1123 print '</td>';
1124 }
1125 if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) {
1126 print '<td class="nowrap liste_total right">';
1127 print convertSecondToTime($total_projectlinesa_billed, 'allhourmin');
1128 print '</td>';
1129 }
1130 }
1131
1132 // Budget task
1133 if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) {
1134 print '<td class="nowrap liste_total center">';
1135 if (strcmp((string) $total_budget_amount, '')) {
1136 print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1137 }
1138 print '</td>';
1139 }
1140
1141 // Contacts of task for backward compatibility,
1142 if (getDolGlobalString('PROJECT_SHOW_CONTACTS_IN_LIST')) {
1143 print '<td></td>';
1144 }
1145 // Contacts of task
1146 if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
1147 print '<td></td>';
1148 }
1149
1150 // Check if Extrafields is totalizable
1151 if (!empty($extrafields->attributes['projet_task']['totalizable'])) {
1152 foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) {
1153 if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) {
1154 print '<td class="right">';
1155 if ($value == 1) {
1156 print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total'];
1157 }
1158 print '</td>';
1159 }
1160 }
1161 }
1162
1163 // Column for the drag and drop
1164 print '<td class="liste_total"></td>';
1165
1166 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1167 print '<td class="liste_total"></td>';
1168 }
1169
1170 print '</tr>';
1171 }
1172
1173 return $inc;
1174}
1175
1176
1194function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1195{
1196 global $conf, $db, $user, $langs;
1197 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1198 '
1199 @phan-var-force FormOther $formother
1200 @phan-var-force Project $projectstatic
1201 @phan-var-force Task $taskstatic
1202 @phan-var-force Societe $thirdpartystatic
1203 ';
1204
1205 $lastprojectid = 0;
1206 $totalforeachline = array();
1207 $workloadforid = array();
1208 $lineswithoutlevel0 = array();
1209
1210 $numlines = count($lines);
1211
1212 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1213 if ($parent == 0) { // Always and only if at first level
1214 for ($i = 0; $i < $numlines; $i++) {
1215 if ($lines[$i]->fk_task_parent) {
1216 $lineswithoutlevel0[] = $lines[$i];
1217 }
1218 }
1219 }
1220
1221 if (empty($oldprojectforbreak)) {
1222 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1223 }
1224
1225 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1226 for ($i = 0; $i < $numlines; $i++) {
1227 if ($parent == 0) {
1228 $level = 0;
1229 }
1230
1231 //if ($lines[$i]->fk_task_parent == $parent)
1232 //{
1233 // If we want all or we have a role on task, we show it
1234 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1235 //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);
1236
1237 // Break on a new project
1238 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1239 $lastprojectid = $lines[$i]->fk_project;
1240 if ($preselectedday) {
1241 $projectstatic->id = $lines[$i]->fk_project;
1242 }
1243 }
1244
1245 if (empty($workloadforid[$projectstatic->id])) {
1246 if ($preselectedday) {
1247 $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
1248 $workloadforid[$projectstatic->id] = 1;
1249 }
1250 }
1251
1252 $projectstatic->id = $lines[$i]->fk_project;
1253 $projectstatic->ref = $lines[$i]->project_ref;
1254 $projectstatic->title = $lines[$i]->project_label;
1255 $projectstatic->public = $lines[$i]->public;
1256 $projectstatic->status = $lines[$i]->project->status;
1257
1258 $taskstatic->id = $lines[$i]->fk_statut;
1259 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1260 $taskstatic->label = $lines[$i]->task_label;
1261 $taskstatic->date_start = $lines[$i]->date_start;
1262 $taskstatic->date_end = $lines[$i]->date_end;
1263
1264 $thirdpartystatic->id = $lines[$i]->socid;
1265 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1266 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1267
1268 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1269 print '<tr class="oddeven trforbreak nobold">'."\n";
1270 print '<td colspan="11">';
1271 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1272 if ($projectstatic->title) {
1273 print ' - ';
1274 print $projectstatic->title;
1275 }
1276 print '</td>';
1277 print '</tr>';
1278 }
1279
1280 if ($oldprojectforbreak != -1) {
1281 $oldprojectforbreak = $projectstatic->id;
1282 }
1283
1284 print '<tr class="oddeven">'."\n";
1285
1286 // User
1287 /*
1288 print '<td class="nowrap">';
1289 print $fuser->getNomUrl(1, 'withproject', 'time');
1290 print '</td>';
1291 */
1292
1293 // Project
1294 print "<td>";
1295 if ($oldprojectforbreak == -1) {
1296 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1297 print '<br>'.$projectstatic->title;
1298 }
1299 print "</td>";
1300
1301 // Thirdparty
1302 print '<td class="tdoverflowmax100">';
1303 if ($thirdpartystatic->id > 0) {
1304 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1305 }
1306 print '</td>';
1307
1308 // Ref
1309 print '<td>';
1310 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperaction) -->';
1311 for ($k = 0; $k < $level; $k++) {
1312 print '<div class="marginleftonly">';
1313 }
1314 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1315 // Label task
1316 print '<br>';
1317 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1318 for ($k = 0; $k < $level; $k++) {
1319 print "</div>";
1320 }
1321 print "</td>\n";
1322
1323 // Date
1324 print '<td class="center">';
1325 print dol_print_date($lines[$i]->timespent_datehour, 'day');
1326 print '</td>';
1327
1328 $disabledproject = 1;
1329 $disabledtask = 1;
1330 //print "x".$lines[$i]->fk_project;
1331 //var_dump($lines[$i]);
1332 //var_dump($projectsrole[$lines[$i]->fk_project]);
1333 // If at least one role for project
1334 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1335 $disabledproject = 0;
1336 $disabledtask = 0;
1337 }
1338 // If $restricteditformytask is on and I have no role on task, i disable edit
1339 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1340 $disabledtask = 1;
1341 }
1342
1343 // Hour
1344 print '<td class="nowrap center">';
1345 print dol_print_date($lines[$i]->timespent_datehour, 'hour');
1346 print '</td>';
1347
1348 $cssonholiday = '';
1349 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1350 $cssonholiday .= 'onholidayallday ';
1351 } elseif (!$isavailable[$preselectedday]['morning']) {
1352 $cssonholiday .= 'onholidaymorning ';
1353 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1354 $cssonholiday .= 'onholidayafternoon ';
1355 }
1356
1357 // Duration
1358 print '<td class="duration'.($cssonholiday ? ' '.$cssonholiday : '').' center">';
1359
1360 $dayWorkLoad = $lines[$i]->timespent_duration;
1361 if (!array_key_exists($preselectedday, $totalforeachline)) {
1362 $totalforeachline[$preselectedday] = 0;
1363 }
1364 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1365
1366 $alreadyspent = '';
1367 if ($dayWorkLoad > 0) {
1368 $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1369 }
1370
1371 print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
1372
1373 print '</td>';
1374
1375 // Note
1376 print '<td class="center">';
1377 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1378 print $lines[$i]->timespent_note;
1379 print '</textarea>';
1380 print '</td>';
1381
1382 // Warning
1383 print '<td class="right">';
1384 /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1385 elseif ($disabledtask)
1386 {
1387 $titleassigntask = $langs->trans("AssignTaskToMe");
1388 if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1389
1390 print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1391 }*/
1392 print '</td>';
1393
1394 print "</tr>\n";
1395 }
1396 //}
1397 //else
1398 //{
1399 //$level--;
1400 //}
1401 }
1402
1403 return $totalforeachline;
1404}
1405
1406
1426function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1427{
1428 global $conf, $db, $user, $langs;
1429 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1430 '
1431 @phan-var-force FormOther $formother
1432 @phan-var-force Project $projectstatic
1433 @phan-var-force Task $taskstatic
1434 @phan-var-force Societe $thirdpartystatic
1435 ';
1436
1437 $lastprojectid = 0;
1438 $totalforeachday = array();
1439 $workloadforid = array();
1440 $lineswithoutlevel0 = array();
1441
1442 $numlines = count($lines);
1443
1444 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1445 if ($parent == 0) { // Always and only if at first level
1446 for ($i = 0; $i < $numlines; $i++) {
1447 if ($lines[$i]->fk_task_parent) {
1448 $lineswithoutlevel0[] = $lines[$i];
1449 }
1450 }
1451 }
1452
1453 if (empty($oldprojectforbreak)) {
1454 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 to start break , -1 no break
1455 }
1456
1457 $restrictBefore = null;
1458
1459 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1460 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1461 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1462 }
1463
1464 //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1465 for ($i = 0; $i < $numlines; $i++) {
1466 if ($parent == 0) {
1467 $level = 0;
1468 }
1469
1470 if ($lines[$i]->fk_task_parent == $parent) {
1471 $obj = &$lines[$i]; // To display extrafields
1472
1473 // If we want all or we have a role on task, we show it
1474 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1475 //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);
1476
1477 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1478 continue;
1479 }
1480
1481 // Break on a new project
1482 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1483 $lastprojectid = $lines[$i]->fk_project;
1484 if ($preselectedday) {
1485 $projectstatic->id = $lines[$i]->fk_project;
1486 }
1487 }
1488
1489 if (empty($workloadforid[$projectstatic->id])) {
1490 if ($preselectedday) {
1491 $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
1492 $workloadforid[$projectstatic->id] = 1;
1493 }
1494 }
1495
1496 $projectstatic->id = $lines[$i]->fk_project;
1497 $projectstatic->ref = $lines[$i]->projectref;
1498 $projectstatic->title = $lines[$i]->projectlabel;
1499 $projectstatic->public = $lines[$i]->public;
1500 $projectstatic->status = $lines[$i]->projectstatus;
1501
1502 $taskstatic->id = $lines[$i]->id;
1503 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1504 $taskstatic->label = $lines[$i]->label;
1505 $taskstatic->date_start = $lines[$i]->date_start;
1506 $taskstatic->date_end = $lines[$i]->date_end;
1507
1508 $thirdpartystatic->id = $lines[$i]->socid;
1509 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1510 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1511
1512 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1513 $addcolspan = 0;
1514 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1515 $addcolspan++;
1516 }
1517 if (!empty($arrayfields['t.progress']['checked'])) {
1518 $addcolspan++;
1519 }
1520 foreach ($arrayfields as $key => $val) {
1521 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1522 $addcolspan++;
1523 }
1524 }
1525
1526 print '<tr class="oddeven trforbreak nobold">'."\n";
1527 print '<td colspan="'.(7 + $addcolspan).'">';
1528 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1529 if ($thirdpartystatic->id > 0) {
1530 print ' - '.$thirdpartystatic->getNomUrl(1);
1531 }
1532 if ($projectstatic->title) {
1533 print ' - ';
1534 print '<span class="secondary">'.$projectstatic->title.'</span>';
1535 }
1536 /*
1537 $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1538 print '<table class="">';
1539
1540 print '<tr class="liste_titre">';
1541
1542 // PROJECT fields
1543 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 ');
1544 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 ');
1545 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 ');
1546 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 ');
1547 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 ');
1548
1549 $extrafieldsobjectkey='projet';
1550 $extrafieldsobjectprefix='efp.';
1551 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1552
1553 print '</tr>';
1554 print '<tr>';
1555
1556 // PROJECT fields
1557 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1558 {
1559 print '<td class="nowrap">';
1560 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1561 if ($code) print $langs->trans("OppStatus".$code);
1562 print "</td>\n";
1563 }
1564 if (!empty($arrayfields['p.opp_amount']['checked']))
1565 {
1566 print '<td class="nowrap">';
1567 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1568 print "</td>\n";
1569 }
1570 if (!empty($arrayfields['p.opp_percent']['checked']))
1571 {
1572 print '<td class="nowrap">';
1573 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1574 print "</td>\n";
1575 }
1576 if (!empty($arrayfields['p.budget_amount']['checked']))
1577 {
1578 print '<td class="nowrap">';
1579 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1580 print "</td>\n";
1581 }
1582 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1583 {
1584 print '<td class="nowrap">';
1585 print yn($lines[$i]->usage_bill_time);
1586 print "</td>\n";
1587 }
1588
1589 $extrafieldsobjectkey='projet';
1590 $extrafieldsobjectprefix='efp.';
1591 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1592
1593 print '</tr>';
1594 print '</table>';
1595
1596 */
1597 print '</td>';
1598 print '</tr>';
1599 }
1600
1601 if ($oldprojectforbreak != -1) {
1602 $oldprojectforbreak = $projectstatic->id;
1603 }
1604
1605 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
1606
1607 // User
1608 /*
1609 print '<td class="nowrap">';
1610 print $fuser->getNomUrl(1, 'withproject', 'time');
1611 print '</td>';
1612 */
1613
1614 // Project
1615 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1616 print "<td>";
1617 if ($oldprojectforbreak == -1) {
1618 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
1619 }
1620 print "</td>";
1621 }
1622
1623 // Thirdparty
1624 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
1625 print '<td class="tdoverflowmax100">';
1626 if ($thirdpartystatic->id > 0) {
1627 print $thirdpartystatic->getNomUrl(1, 'project', 10);
1628 }
1629 print '</td>';
1630 }
1631
1632 // Ref
1633 print '<td>';
1634 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperday) -->';
1635 for ($k = 0; $k < $level; $k++) {
1636 print '<div class="marginleftonly">';
1637 }
1638 print $taskstatic->getNomUrl(1, 'withproject', 'time');
1639 // Label task
1640 print '<br>';
1641 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
1642 for ($k = 0; $k < $level; $k++) {
1643 print "</div>";
1644 }
1645 print "</td>\n";
1646
1647 // TASK extrafields
1648 $extrafieldsobjectkey = 'projet_task';
1649 $extrafieldsobjectprefix = 'efpt.';
1650 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1651
1652 // Planned Workload
1653 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1654 print '<td class="leftborder plannedworkload right">';
1655 if ($lines[$i]->planned_workload) {
1656 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
1657 } else {
1658 print '--:--';
1659 }
1660 print '</td>';
1661 }
1662
1663 // Progress declared %
1664 if (!empty($arrayfields['t.progress']['checked'])) {
1665 print '<td class="right">';
1666 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
1667 print '</td>';
1668 }
1669
1670 if (!empty($arrayfields['timeconsumed']['checked'])) {
1671 // Time spent by everybody
1672 print '<td class="right">';
1673 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
1674 if ($lines[$i]->duration_effective) {
1675 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1676 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
1677 print '</a>';
1678 } else {
1679 print '--:--';
1680 }
1681 print "</td>\n";
1682
1683 // Time spent by user
1684 print '<td class="right">';
1685 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1686 if ($tmptimespent['total_duration']) {
1687 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
1688 } else {
1689 print '--:--';
1690 }
1691 print "</td>\n";
1692 }
1693
1694 $disabledproject = 1;
1695 $disabledtask = 1;
1696 //print "x".$lines[$i]->fk_project;
1697 //var_dump($lines[$i]);
1698 //var_dump($projectsrole[$lines[$i]->fk_project]);
1699 // If at least one role for project
1700 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
1701 $disabledproject = 0;
1702 $disabledtask = 0;
1703 }
1704 // If $restricteditformytask is on and I have no role on task, i disable edit
1705 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
1706 $disabledtask = 1;
1707 }
1708
1709 if ($restrictBefore && $preselectedday < $restrictBefore) {
1710 $disabledtask = 1;
1711 }
1712
1713 // Select hour
1714 print '<td class="nowraponall leftborder center minwidth150imp borderleft">';
1715 $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
1716 print $tableCell;
1717 print '</td>';
1718
1719 $cssonholiday = '';
1720 if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
1721 $cssonholiday .= 'onholidayallday ';
1722 } elseif (!$isavailable[$preselectedday]['morning']) {
1723 $cssonholiday .= 'onholidaymorning ';
1724 } elseif (!$isavailable[$preselectedday]['afternoon']) {
1725 $cssonholiday .= 'onholidayafternoon ';
1726 }
1727
1728 global $daytoparse;
1729 $tmparray = dol_getdate($daytoparse, true); // detail of current day
1730
1731 $idw = ($tmparray['wday'] - (!getDolGlobalString('MAIN_START_WEEK') ? 0 : 1));
1732 global $numstartworkingday, $numendworkingday;
1733 $cssweekend = '';
1734 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.
1735 $cssweekend = 'weekend';
1736 }
1737
1738 // Duration
1739 print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
1740 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1741 if (!isset($totalforeachday[$preselectedday])) {
1742 $totalforeachday[$preselectedday] = 0;
1743 }
1744 $totalforeachday[$preselectedday] += $dayWorkLoad;
1745
1746 $alreadyspent = '';
1747 if ($dayWorkLoad > 0) {
1748 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
1749 }
1750
1751 $idw = 0;
1752
1753 $tableCell = '';
1754 $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>';
1755 $tableCell .= '<span class="hideonsmartphone"> + </span>';
1756 //$tableCell.='&nbsp;&nbsp;&nbsp;';
1757 $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
1758 //$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
1759 print $tableCell;
1760
1761 print '</td>';
1762
1763 // Note
1764 print '<td class="center">';
1765 print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
1766 print '</textarea>';
1767 print '</td>';
1768
1769 // Warning
1770 print '<td class="right">';
1771 if ((!$lines[$i]->public) && $disabledproject) {
1772 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1773 } elseif ($disabledtask) {
1774 $titleassigntask = $langs->trans("AssignTaskToMe");
1775 if ($fuser->id != $user->id) {
1776 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1777 }
1778
1779 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1780 }
1781 print '</td>';
1782
1783 print "</tr>\n";
1784 }
1785
1786 $inc++;
1787 $level++;
1788 if ($lines[$i]->id > 0) {
1789 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1790 //var_dump($totalforeachday);
1791 $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1792 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1793 //var_dump($ret);
1794 foreach ($ret as $key => $val) {
1795 $totalforeachday[$key] += $val;
1796 }
1797 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1798 //var_dump($totalforeachday);
1799 }
1800 $level--;
1801 } else {
1802 //$level--;
1803 }
1804 }
1805
1806 return $totalforeachday;
1807}
1808
1809
1829function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1830{
1831 global $conf, $db, $user, $langs;
1832 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1833 '
1834 @phan-var-force FormOther $formother
1835 @phan-var-force Project $projectstatic
1836 @phan-var-force Task $taskstatic
1837 @phan-var-force Societe $thirdpartystatic
1838 ';
1839
1840 $numlines = count($lines);
1841
1842 $lastprojectid = 0;
1843 $workloadforid = array();
1844 $totalforeachday = array();
1845 $lineswithoutlevel0 = array();
1846
1847 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1848 if ($parent == 0) { // Always and only if at first level
1849 for ($i = 0; $i < $numlines; $i++) {
1850 if ($lines[$i]->fk_task_parent) {
1851 $lineswithoutlevel0[] = $lines[$i];
1852 }
1853 }
1854 }
1855
1856 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
1857
1858 if (empty($oldprojectforbreak)) {
1859 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
1860 }
1861
1862 $restrictBefore = null;
1863
1864 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
1865 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1866 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
1867 }
1868
1869 for ($i = 0; $i < $numlines; $i++) {
1870 if ($parent == 0) {
1871 $level = 0;
1872 }
1873
1874 if ($lines[$i]->fk_task_parent == $parent) {
1875 $obj = &$lines[$i]; // To display extrafields
1876
1877 // If we want all or we have a role on task, we show it
1878 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1879 //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);
1880
1881 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
1882 continue;
1883 }
1884
1885 // Break on a new project
1886 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1887 $lastprojectid = $lines[$i]->fk_project;
1888 $projectstatic->id = $lines[$i]->fk_project;
1889 }
1890
1891 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1892 //var_dump($projectstatic->weekWorkLoadPerTask);
1893 if (empty($workloadforid[$projectstatic->id])) {
1894 $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
1895 $workloadforid[$projectstatic->id] = 1;
1896 }
1897 //var_dump($projectstatic->weekWorkLoadPerTask);
1898 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1899
1900 $projectstatic->id = $lines[$i]->fk_project;
1901 $projectstatic->ref = $lines[$i]->projectref;
1902 $projectstatic->title = $lines[$i]->projectlabel;
1903 $projectstatic->public = $lines[$i]->public;
1904 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1905 $projectstatic->status = $lines[$i]->projectstatus;
1906
1907 $taskstatic->id = $lines[$i]->id;
1908 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1909 $taskstatic->label = $lines[$i]->label;
1910 $taskstatic->date_start = $lines[$i]->date_start;
1911 $taskstatic->date_end = $lines[$i]->date_end;
1912
1913 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1914 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1915 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1916
1917 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1918 $addcolspan = 0;
1919 if (!empty($arrayfields['t.planned_workload']['checked'])) {
1920 $addcolspan++;
1921 }
1922 if (!empty($arrayfields['t.progress']['checked'])) {
1923 $addcolspan++;
1924 }
1925 foreach ($arrayfields as $key => $val) {
1926 if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
1927 $addcolspan++;
1928 }
1929 }
1930
1931 print '<tr class="oddeven trforbreak nobold">'."\n";
1932 print '<td colspan="'.(11 + $addcolspan).'">';
1933 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1934 if ($thirdpartystatic->id > 0) {
1935 print ' - '.$thirdpartystatic->getNomUrl(1);
1936 }
1937 if ($projectstatic->title) {
1938 print ' - ';
1939 print '<span class="secondary">'.$projectstatic->title.'</span>';
1940 }
1941
1942 /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
1943 print '<table class="">';
1944
1945 print '<tr class="liste_titre">';
1946
1947 // PROJECT fields
1948 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 ');
1949 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 ');
1950 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 ');
1951 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 ');
1952 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 ');
1953
1954 $extrafieldsobjectkey='projet';
1955 $extrafieldsobjectprefix='efp.';
1956 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1957
1958 print '</tr>';
1959 print '<tr>';
1960
1961 // PROJECT fields
1962 if (!empty($arrayfields['p.fk_opp_status']['checked']))
1963 {
1964 print '<td class="nowrap">';
1965 $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
1966 if ($code) print $langs->trans("OppStatus".$code);
1967 print "</td>\n";
1968 }
1969 if (!empty($arrayfields['p.opp_amount']['checked']))
1970 {
1971 print '<td class="nowrap">';
1972 print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
1973 print "</td>\n";
1974 }
1975 if (!empty($arrayfields['p.opp_percent']['checked']))
1976 {
1977 print '<td class="nowrap">';
1978 print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
1979 print "</td>\n";
1980 }
1981 if (!empty($arrayfields['p.budget_amount']['checked']))
1982 {
1983 print '<td class="nowrap">';
1984 print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1985 print "</td>\n";
1986 }
1987 if (!empty($arrayfields['p.usage_bill_time']['checked']))
1988 {
1989 print '<td class="nowrap">';
1990 print yn($lines[$i]->usage_bill_time);
1991 print "</td>\n";
1992 }
1993
1994 $extrafieldsobjectkey='projet';
1995 $extrafieldsobjectprefix='efp.';
1996 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1997
1998 print '</tr>';
1999 print '</table>';
2000 */
2001
2002 print '</td>';
2003 print '</tr>';
2004 }
2005
2006 if ($oldprojectforbreak != -1) {
2007 $oldprojectforbreak = $projectstatic->id;
2008 }
2009
2010 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2011
2012 // User
2013 /*
2014 print '<td class="nowrap">';
2015 print $fuser->getNomUrl(1, 'withproject', 'time');
2016 print '</td>';
2017 */
2018
2019 // Project
2020 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2021 print '<td class="nowrap">';
2022 if ($oldprojectforbreak == -1) {
2023 print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2024 }
2025 print "</td>";
2026 }
2027
2028 // Thirdparty
2029 if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
2030 print '<td class="tdoverflowmax100">';
2031 if ($thirdpartystatic->id > 0) {
2032 print $thirdpartystatic->getNomUrl(1, 'project');
2033 }
2034 print '</td>';
2035 }
2036
2037 // Ref
2038 print '<td class="tdoverflowmax300">';
2039 print '<!-- Task id = '.$lines[$i]->id.' (projectlinesperweek) -->';
2040 for ($k = 0; $k < $level; $k++) {
2041 print '<div class="marginleftonly">';
2042 }
2043 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2044 // Label task
2045 print '<br>';
2046 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2047 for ($k = 0; $k < $level; $k++) {
2048 print "</div>";
2049 }
2050 print "</td>\n";
2051
2052 // TASK extrafields
2053 $extrafieldsobjectkey = 'projet_task';
2054 $extrafieldsobjectprefix = 'efpt.';
2055 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2056
2057 // Planned Workload
2058 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2059 print '<td class="leftborder plannedworkload right">';
2060 if ($lines[$i]->planned_workload) {
2061 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2062 } else {
2063 print '--:--';
2064 }
2065 print '</td>';
2066 }
2067
2068 if (!empty($arrayfields['t.progress']['checked'])) {
2069 // Progress declared %
2070 print '<td class="right">';
2071 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2072 print '</td>';
2073 }
2074
2075 if (!empty($arrayfields['timeconsumed']['checked'])) {
2076 // Time spent by everybody
2077 print '<td class="right">';
2078 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2079 if ($lines[$i]->duration_effective) {
2080 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'">';
2081 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2082 print '</a>';
2083 } else {
2084 print '--:--';
2085 }
2086 print "</td>\n";
2087
2088 // Time spent by user
2089 print '<td class="right">';
2090 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2091 if ($tmptimespent['total_duration']) {
2092 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.((int) $lines[$i]->id).'&search_user='.((int) $fuser->id).'">';
2093 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2094 print '</a>';
2095 } else {
2096 print '--:--';
2097 }
2098 print "</td>\n";
2099 }
2100
2101 $disabledproject = 1;
2102 $disabledtask = 1;
2103 //print "x".$lines[$i]->fk_project;
2104 //var_dump($lines[$i]);
2105 //var_dump($projectsrole[$lines[$i]->fk_project]);
2106 // If at least one role for project
2107 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2108 $disabledproject = 0;
2109 $disabledtask = 0;
2110 }
2111 // If $restricteditformytask is on and I have no role on task, i disable edit
2112 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2113 $disabledtask = 1;
2114 }
2115
2116 //var_dump($projectstatic->weekWorkLoadPerTask);
2117
2118 // Fields to show current time
2119 $tableCell = '';
2120 $modeinput = 'hours';
2121 $j = 0;
2122 for ($idw = 0; $idw < 7; $idw++) {
2123 $j++;
2124 $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
2125 if (!isset($totalforeachday[$tmpday])) {
2126 $totalforeachday[$tmpday] = 0;
2127 }
2128 $cssonholiday = '';
2129 if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
2130 $cssonholiday .= 'onholidayallday ';
2131 } elseif (!$isavailable[$tmpday]['morning']) {
2132 $cssonholiday .= 'onholidaymorning ';
2133 } elseif (!$isavailable[$tmpday]['afternoon']) {
2134 $cssonholiday .= 'onholidayafternoon ';
2135 }
2136
2137 $tmparray = dol_getdate($tmpday);
2138 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2139 $totalforeachday[$tmpday] += $dayWorkLoad;
2140
2141 $alreadyspent = '';
2142 if ($dayWorkLoad > 0) {
2143 $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
2144 }
2145 $alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']);
2146
2147 global $numstartworkingday, $numendworkingday;
2148 $cssweekend = '';
2149 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.
2150 $cssweekend = 'weekend';
2151 }
2152
2153 $disabledtaskday = $disabledtask;
2154
2155 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2156 $disabledtaskday = 1;
2157 }
2158
2159 $tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').($j <= 1 ? ' borderleft' : '').'">';
2160 //$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
2161 $placeholder = '';
2162 if ($alreadyspent) {
2163 $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>';
2164 //$placeholder=' placeholder="00:00"';
2165 //$tableCell.='+';
2166 }
2167 $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"';
2168 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2169 $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
2170 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
2171 $tableCell .= '</td>';
2172 print $tableCell;
2173 }
2174
2175 // Warning
2176 print '<td class="right">';
2177 if ((!$lines[$i]->public) && $disabledproject) {
2178 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2179 } elseif ($disabledtask) {
2180 $titleassigntask = $langs->trans("AssignTaskToMe");
2181 if ($fuser->id != $user->id) {
2182 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2183 }
2184
2185 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2186 }
2187 print '</td>';
2188
2189 print "</tr>\n";
2190 }
2191
2192 // Call to show task with a lower level (task under the current task)
2193 $inc++;
2194 $level++;
2195 if ($lines[$i]->id > 0) {
2196 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2197 //var_dump($totalforeachday);
2198 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2199 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2200 //var_dump($ret);
2201 foreach ($ret as $key => $val) {
2202 $totalforeachday[$key] += $val;
2203 }
2204 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2205 //var_dump($totalforeachday);
2206 }
2207 $level--;
2208 } else {
2209 //$level--;
2210 }
2211 }
2212
2213 return $totalforeachday;
2214}
2215
2236function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array(), $arrayfields = array(), $extrafields = null)
2237{
2238 global $conf, $db, $user, $langs;
2239 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2240 '
2241 @phan-var-force FormOther $formother
2242 @phan-var-force Project $projectstatic
2243 @phan-var-force Task $taskstatic
2244 @phan-var-force Societe $thirdpartystatic
2245 ';
2246
2247 $numlines = count($lines);
2248
2249 $lastprojectid = 0;
2250 $workloadforid = array();
2251 $totalforeachweek = array();
2252 $lineswithoutlevel0 = array();
2253
2254 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2255 if ($parent == 0) { // Always and only if at first level
2256 for ($i = 0; $i < $numlines; $i++) {
2257 if ($lines[$i]->fk_task_parent) {
2258 $lineswithoutlevel0[] = $lines[$i];
2259 }
2260 }
2261 }
2262
2263 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
2264
2265 if (empty($oldprojectforbreak)) {
2266 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
2267 }
2268
2269 $restrictBefore = null;
2270
2271 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
2272 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2273 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
2274 }
2275
2276 for ($i = 0; $i < $numlines; $i++) {
2277 if ($parent == 0) {
2278 $level = 0;
2279 }
2280
2281 if ($lines[$i]->fk_task_parent == $parent) {
2282 // If we want all or we have a role on task, we show it
2283 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2284 //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);
2285
2286 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
2287 continue;
2288 }
2289
2290 // Break on a new project
2291 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2292 $lastprojectid = $lines[$i]->fk_project;
2293 $projectstatic->id = $lines[$i]->fk_project;
2294 }
2295
2296 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2297 //var_dump($projectstatic->weekWorkLoadPerTask);
2298 if (empty($workloadforid[$projectstatic->id])) {
2299 $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
2300 $workloadforid[$projectstatic->id] = 1;
2301 }
2302 //var_dump($projectstatic->weekWorkLoadPerTask);
2303 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2304
2305 $projectstatic->id = $lines[$i]->fk_project;
2306 $projectstatic->ref = $lines[$i]->projectref;
2307 $projectstatic->title = $lines[$i]->projectlabel;
2308 $projectstatic->public = $lines[$i]->public;
2309 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2310 $projectstatic->status = $lines[$i]->projectstatus;
2311
2312 $taskstatic->id = $lines[$i]->id;
2313 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2314 $taskstatic->label = $lines[$i]->label;
2315 $taskstatic->date_start = $lines[$i]->date_start;
2316 $taskstatic->date_end = $lines[$i]->date_end;
2317
2318 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2319 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2320 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2321
2322 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2323 print '<tr class="oddeven trforbreak nobold">'."\n";
2324 print '<td colspan="'.(6 + count($TWeek)).'">';
2325 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2326 if ($thirdpartystatic->id > 0) {
2327 print ' - '.$thirdpartystatic->getNomUrl(1);
2328 }
2329 if ($projectstatic->title) {
2330 print ' - ';
2331 print '<span class="secondary">'.$projectstatic->title.'</span>';
2332 }
2333 print '</td>';
2334 print '</tr>';
2335 }
2336
2337 if ($oldprojectforbreak != -1) {
2338 $oldprojectforbreak = $projectstatic->id;
2339 }
2340 print '<tr class="oddeven" data-taskid="'.$lines[$i]->id.'">'."\n";
2341
2342 // User
2343 /*
2344 print '<td class="nowrap">';
2345 print $fuser->getNomUrl(1, 'withproject', 'time');
2346 print '</td>';
2347 */
2348
2349 // Project
2350 /*print '<td class="nowrap">';
2351 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
2352 print "</td>";*/
2353
2354 // Thirdparty
2355 /*print '<td class="tdoverflowmax100">';
2356 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2357 print '</td>';*/
2358
2359 // Ref
2360 print '<td class="nowrap">';
2361 print '<!-- Task id = '.$lines[$i]->id.' (projectlinespermonth) -->';
2362 for ($k = 0; $k < $level; $k++) {
2363 print '<div class="marginleftonly">';
2364 }
2365 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2366 // Label task
2367 print '<br>';
2368 print '<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2369 for ($k = 0; $k < $level; $k++) {
2370 print "</div>";
2371 }
2372 print "</td>\n";
2373
2374 // Planned Workload
2375 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2376 print '<td class="leftborder plannedworkload right">';
2377 if ($lines[$i]->planned_workload) {
2378 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2379 } else {
2380 print '--:--';
2381 }
2382 print '</td>';
2383 }
2384
2385 // Progress declared %
2386 if (!empty($arrayfields['t.progress']['checked'])) {
2387 print '<td class="right">';
2388 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2389 print '</td>';
2390 }
2391
2392 // Time spent by everybody
2393 if (!empty($arrayfields['timeconsumed']['checked'])) {
2394 print '<td class="right">';
2395 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2396 if ($lines[$i]->duration_effective) {
2397 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
2398 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2399 print '</a>';
2400 } else {
2401 print '--:--';
2402 }
2403 print "</td>\n";
2404
2405 // Time spent by user
2406 print '<td class="right">';
2407 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2408 if ($tmptimespent['total_duration']) {
2409 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2410 } else {
2411 print '--:--';
2412 }
2413 print "</td>\n";
2414 }
2415
2416 $disabledproject = 1;
2417 $disabledtask = 1;
2418 //print "x".$lines[$i]->fk_project;
2419 //var_dump($lines[$i]);
2420 //var_dump($projectsrole[$lines[$i]->fk_project]);
2421 // If at least one role for project
2422 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2423 $disabledproject = 0;
2424 $disabledtask = 0;
2425 }
2426 // If $restricteditformytask is on and I have no role on task, i disable edit
2427 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2428 $disabledtask = 1;
2429 }
2430
2431 //var_dump($projectstatic->weekWorkLoadPerTask);
2432 //TODO
2433 // Fields to show current time
2434 $tableCell = '';
2435 $modeinput = 'hours';
2436 $TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow));
2437 $TFirstDay[reset($TWeek)] = 1;
2438
2439 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2440 $year = $firstdaytoshowarray['year'];
2441 $month = $firstdaytoshowarray['mon'];
2442 $j = 0;
2443 foreach ($TWeek as $weekIndex => $weekNb) {
2444 $j++;
2445 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2446 if (!isset($totalforeachweek[$weekNb])) {
2447 $totalforeachweek[$weekNb] = 0;
2448 }
2449 $totalforeachweek[$weekNb] += $weekWorkLoad;
2450
2451 $alreadyspent = '';
2452 if ($weekWorkLoad > 0) {
2453 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2454 }
2455 $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
2456
2457 $disabledtaskweek = $disabledtask;
2458 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2459
2460 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2461 $disabledtaskweek = 1;
2462 }
2463
2464 $tableCell = '<td class="center hide'.($j <= 1 ? ' borderleft' : '').'">';
2465 $placeholder = '';
2466 if ($alreadyspent) {
2467 $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>';
2468 //$placeholder=' placeholder="00:00"';
2469 //$tableCell.='+';
2470 }
2471
2472 $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"';
2473 $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2474 $tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
2475 $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
2476 $tableCell .= '</td>';
2477 print $tableCell;
2478 }
2479
2480 // Warning
2481 print '<td class="right">';
2482 if ((!$lines[$i]->public) && $disabledproject) {
2483 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
2484 } elseif ($disabledtask) {
2485 $titleassigntask = $langs->trans("AssignTaskToMe");
2486 if ($fuser->id != $user->id) {
2487 $titleassigntask = $langs->trans("AssignTaskToUser", '...');
2488 }
2489
2490 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
2491 }
2492 print '</td>';
2493
2494 print "</tr>\n";
2495 }
2496
2497 // Call to show task with a lower level (task under the current task)
2498 $inc++;
2499 $level++;
2500 if ($lines[$i]->id > 0) {
2501 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2502 //var_dump($totalforeachday);
2503 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2504 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2505 //var_dump($ret);
2506 foreach ($ret as $key => $val) {
2507 $totalforeachweek[$key] += $val;
2508 }
2509 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2510 //var_dump($totalforeachday);
2511 }
2512 $level--;
2513 } else {
2514 //$level--;
2515 }
2516 }
2517
2518 return $totalforeachweek;
2519}
2520
2521
2531function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2532{
2533 //print 'Search in line with parent id = '.$parent.'<br>';
2534 $numlines = count($lines);
2535 for ($i = 0; $i < $numlines; $i++) {
2536 // Process line $lines[$i]
2537 if ($lines[$i]->fk_task_parent == $parent && $lines[$i]->id != $lines[$i]->fk_task_parent) {
2538 // If task is legitimate to show, no more need to search deeper
2539 if (isset($taskrole[$lines[$i]->id])) {
2540 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2541 $inc++;
2542 return $inc;
2543 }
2544
2545 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2546 //print 'Found inc='.$inc.'<br>';
2547
2548 if ($inc > 0) {
2549 return $inc;
2550 }
2551 }
2552 }
2553
2554 return $inc;
2555}
2556
2571function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2572{
2573 global $langs, $conf, $user;
2574 global $theme_datacolor;
2575
2576 $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2577
2578 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2579
2580 $listofstatus = array_keys($listofoppstatus);
2581
2582 if (is_array($listofstatus) && getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2583 // Define $themeColorId and array $statusOppList for each $listofstatus
2584 $themeColorId = 0;
2585 $statusOppList = array();
2586 foreach ($listofstatus as $oppStatus) {
2587 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2588 if ($oppStatusCode) {
2589 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2590 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2591 }
2592 $themeColorId++;
2593 }
2594 }
2595
2596 $projectstatic = new Project($db);
2597 $thirdpartystatic = new Societe($db);
2598
2599 $sortfield = '';
2600 $sortorder = '';
2601 $project_year_filter = 0;
2602
2603 $title = $langs->trans("Projects");
2604 if (strcmp((string) $status, '') && $status >= 0) {
2605 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->labelStatus[$status]);
2606 }
2607
2608 print '<!-- print_projecttasks_array -->';
2609 print '<div class="div-table-responsive-no-min">';
2610 print '<table class="noborder centpercent">';
2611
2612 $sql = " FROM ".MAIN_DB_PREFIX."projet as p";
2613 if ($mytasks) {
2614 $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
2615 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
2616 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
2617 } else {
2618 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2619 }
2620 $sql .= " WHERE p.entity IN (".getEntity('project').")";
2621 $sql .= " AND p.rowid IN (".$db->sanitize((string) $projectsListId).")";
2622 if ($socid) {
2623 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
2624 }
2625 if ($mytasks) {
2626 $sql .= " AND p.rowid = t.fk_projet";
2627 $sql .= " AND ec.element_id = t.rowid";
2628 $sql .= " AND ec.fk_socpeople = ".((int) $user->id);
2629 $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2630 $sql .= " AND ctc.element = 'project_task'";
2631 }
2632 if ($status >= 0) {
2633 $sql .= " AND p.fk_statut = ".(int) $status;
2634 }
2635 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2636 $project_year_filter = GETPOST("project_year_filter", 'alpha'); // '*' seems allowed
2637 //Check if empty or invalid year. Wildcard ignores the sql check
2638 if ($project_year_filter != "*") {
2639 if (empty($project_year_filter) || !is_numeric($project_year_filter)) {
2640 $project_year_filter = date("Y");
2641 }
2642 $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day((int) $project_year_filter, 12, false)).")";
2643 $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day((int) $project_year_filter, 1, false)).")";
2644 }
2645 }
2646
2647 // Get id of project we must show tasks
2648 $arrayidofprojects = array();
2649 $alttext = '';
2650 $sql1 = "SELECT p.rowid as projectid";
2651 $sql1 .= $sql;
2652 $resql = $db->query($sql1);
2653 if ($resql) {
2654 $i = 0;
2655 $num = $db->num_rows($resql);
2656 while ($i < $num) {
2657 $objp = $db->fetch_object($resql);
2658 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2659 $i++;
2660 }
2661 } else {
2662 dol_print_error($db);
2663 }
2664 if (empty($arrayidofprojects)) {
2665 $arrayidofprojects[0] = -1;
2666 }
2667
2668 // Get list of project with calculation on tasks
2669 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,";
2670 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,";
2671 $sql2 .= " s.code_client, s.code_compta, s.client,";
2672 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
2673 $sql2 .= " s.logo, s.email, s.entity,";
2674 $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,";
2675 $sql2 .= " p.dateo, p.datee,";
2676 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2677 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2678 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
2679 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2680 $sql2 .= " WHERE p.rowid IN (".$db->sanitize(implode(',', $arrayidofprojects)).")";
2681 $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,";
2682 $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";
2683 $sql2 .= " ORDER BY p.title, p.ref";
2684
2685 $resql = $db->query($sql2);
2686 if ($resql) {
2687 $othernb = 0;
2688 $total_task = 0;
2689 $total_opp_amount = 0;
2690 $ponderated_opp_amount = 0;
2691 $total_plannedworkload = 0;
2692 $total_declaredprogressworkload = 0;
2693
2694 $num = $db->num_rows($resql);
2695 $nbofloop = min($num, (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2696 $i = 0;
2697
2698 print '<tr class="liste_titre">';
2699 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);
2700 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
2701 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2702 if (!in_array('prospectionstatus', $hiddenfields)) {
2703 print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'center ');
2704 }
2705 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 ');
2706 //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
2707 }
2708 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2709 print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
2710 if (!in_array('plannedworkload', $hiddenfields)) {
2711 print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
2712 }
2713 if (!in_array('declaredprogress', $hiddenfields)) {
2714 print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared"));
2715 }
2716 }
2717 if (!in_array('projectstatus', $hiddenfields)) {
2718 print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
2719 }
2720 print "</tr>\n";
2721
2722 while ($i < $nbofloop) {
2723 $objp = $db->fetch_object($resql);
2724
2725 if ($max && $i >= $max) {
2726 $othernb++;
2727 $i++;
2728 $total_task += $objp->nb;
2729 $total_opp_amount += $objp->opp_amount;
2730 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2731 $ponderated_opp_amount += price2num($opp_weighted_amount);
2732 $plannedworkload = $objp->planned_workload;
2733 $total_plannedworkload += $plannedworkload;
2734 $declaredprogressworkload = $objp->declared_progess_workload;
2735 $total_declaredprogressworkload += $declaredprogressworkload;
2736 continue;
2737 }
2738
2739 $projectstatic->id = $objp->projectid;
2740 $projectstatic->user_author_id = $objp->fk_user_creat;
2741 $projectstatic->public = $objp->public;
2742
2743 // Check is user has read permission on project
2744 $userAccess = $projectstatic->restrictedProjectArea($user);
2745 if ($userAccess >= 0) {
2746 $projectstatic->ref = $objp->ref;
2747 $projectstatic->status = $objp->status;
2748 $projectstatic->title = $objp->title;
2749 $projectstatic->date_end = $db->jdate($objp->datee);
2750 $projectstatic->date_start = $db->jdate($objp->dateo);
2751
2752 print '<tr class="oddeven">';
2753
2754 print '<td class="tdoverflowmax150">';
2755 print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall');
2756 if (!in_array('projectlabel', $hiddenfields)) {
2757 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).'</span>';
2758 }
2759 print '</td>';
2760
2761 print '<td class="nowraponall tdoverflowmax100">';
2762 if ($objp->fk_soc > 0) {
2763 $thirdpartystatic->id = $objp->socid;
2764 $thirdpartystatic->name = $objp->socname;
2765 //$thirdpartystatic->name_alias = $objp->name_alias;
2766 //$thirdpartystatic->code_client = $objp->code_client;
2767 $thirdpartystatic->code_compta = $objp->code_compta;
2768 $thirdpartystatic->code_compta_client = $objp->code_compta;
2769 $thirdpartystatic->client = $objp->client;
2770 //$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
2771 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2772 $thirdpartystatic->fournisseur = $objp->fournisseur;
2773 $thirdpartystatic->logo = $objp->logo;
2774 $thirdpartystatic->email = $objp->email;
2775 $thirdpartystatic->entity = $objp->entity;
2776 print $thirdpartystatic->getNomUrl(1);
2777 }
2778 print '</td>';
2779
2780 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2781 if (!in_array('prospectionstatus', $hiddenfields)) {
2782 print '<td class="center tdoverflowmax75">';
2783 // Because color of prospection status has no meaning yet, it is used if hidden constant is set
2784 if (!getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2785 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2786 if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) {
2787 print $langs->trans("OppStatus".$oppStatusCode);
2788 }
2789 } else {
2790 if (isset($statusOppList[$objp->opp_status])) {
2791 $oppStatusCode = $statusOppList[$objp->opp_status]['code'];
2792 $oppStatusColor = $statusOppList[$objp->opp_status]['color'];
2793 } else {
2794 $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
2795 $oppStatusColor = '';
2796 }
2797 if ($oppStatusCode) {
2798 if (!empty($oppStatusColor)) {
2799 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>';
2800 } else {
2801 print '<a href="'.dol_buildpath('/projet/list.php?search_opp_status='.$objp->opp_status, 1).'" title="'.$langs->trans("OppStatus".$oppStatusCode).'">'.$oppStatusCode.'</a>';
2802 }
2803 }
2804 }
2805 print '</td>';
2806 }
2807
2808 print '<td class="right">';
2809 $alttext = '';
2810 if ($objp->opp_percent && $objp->opp_amount) {
2811 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2812 $alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency);
2813 $ponderated_opp_amount += price2num($opp_weighted_amount);
2814 }
2815 if ($objp->opp_amount) {
2816 print '<span class="amount" title="'.$alttext.'">'.$form->textwithpicto(price($objp->opp_amount, 0, '', 1, -1, 0), $alttext).'</span>';
2817 }
2818 print '</td>';
2819 }
2820
2821 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2822 print '<td class="right">'.$objp->nb.'</td>';
2823
2824 $plannedworkload = $objp->planned_workload;
2825 $total_plannedworkload += $plannedworkload;
2826 if (!in_array('plannedworkload', $hiddenfields)) {
2827 print '<td class="right nowraponall">'.($plannedworkload ? convertSecondToTime($plannedworkload) : '').'</td>';
2828 }
2829 if (!in_array('declaredprogress', $hiddenfields)) {
2830 $declaredprogressworkload = $objp->declared_progess_workload;
2831 $total_declaredprogressworkload += $declaredprogressworkload;
2832 print '<td class="right nowraponall">';
2833 //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
2834 print($plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
2835 print '</td>';
2836 }
2837 }
2838
2839 if (!in_array('projectstatus', $hiddenfields)) {
2840 print '<td class="right">';
2841 print $projectstatic->getLibStatut(3);
2842 print '</td>';
2843 }
2844
2845 print "</tr>\n";
2846
2847 $total_task += $objp->nb;
2848 $total_opp_amount += $objp->opp_amount;
2849 }
2850
2851 $i++;
2852 }
2853
2854 if ($othernb) {
2855 print '<tr class="oddeven">';
2856 print '<td class="nowrap" colspan="5">';
2857 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
2858 print '</td>';
2859 print "</tr>\n";
2860 }
2861
2862 print '<tr class="liste_total">';
2863 print '<td>'.$langs->trans("Total")."</td><td></td>";
2864 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2865 if (!in_array('prospectionstatus', $hiddenfields)) {
2866 print '<td class="liste_total"></td>';
2867 }
2868 print '<td class="liste_total right">';
2869 //$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1);
2870 print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency));
2871 print '</td>';
2872 }
2873 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2874 print '<td class="liste_total right">'.$total_task.'</td>';
2875 if (!in_array('plannedworkload', $hiddenfields)) {
2876 print '<td class="liste_total right">'.($total_plannedworkload ? convertSecondToTime($total_plannedworkload) : '').'</td>';
2877 }
2878 if (!in_array('declaredprogress', $hiddenfields)) {
2879 print '<td class="liste_total right">'.($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
2880 }
2881 }
2882 if (!in_array('projectstatus', $hiddenfields)) {
2883 print '<td class="liste_total"></td>';
2884 }
2885 print '</tr>';
2886
2887 $db->free($resql);
2888 } else {
2889 dol_print_error($db);
2890 }
2891
2892 print "</table>";
2893 print '</div>';
2894
2895 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2896 //Add the year filter input
2897 print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
2898 print '<table width="100%">';
2899 print '<tr>';
2900 print '<td>'.$langs->trans("Year").'</td>';
2901 print '<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.((int) $project_year_filter).'"/>';
2902 print "</tr>\n";
2903 print '</table></form>';
2904 }
2905}
2906
2916function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $spaced = false)
2917{
2918 global $langs, $conf;
2919
2920 $out = '';
2921
2922 $plannedworkloadoutputformat = 'allhourmin';
2923 $timespentoutputformat = 'allhourmin';
2924 if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
2925 $plannedworkloadoutputformat = getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT');
2926 }
2927 if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
2928 $timespentoutputformat = getDolGlobalString('PROJECT_TIME_SPENT_FORMAT');
2929 }
2930
2931 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2932 return '';
2933 }
2934
2935 $spaced = !empty($spaced) ? 'spaced' : '';
2936
2937 $diff = '';
2938
2939 // define progress color according to time spend vs workload
2940 $progressBarClass = 'progress-bar-info';
2941 $progressCalculated = 0;
2942 if ($task->planned_workload) {
2943 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
2944
2945 // this conf is actually hidden, by default we use 10% for "be careful or warning"
2946 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2947
2948 $diffTitle = '<br>'.$langs->trans('ProgressDeclared').' : '.$task->progress.(isset($task->progress) ? '%' : '');
2949 $diffTitle .= '<br>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.(isset($progressCalculated) ? '%' : '');
2950
2951 //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.floatval($task->progress * $warningRatio));
2952 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
2953 $progressBarClass = 'progress-bar-danger';
2954 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2955 $diff = '<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).'%</span>';
2956 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
2957 $progressBarClass = 'progress-bar-warning';
2958 $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point"));
2959 $diff = '<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).'%</span>';
2960 } else {
2961 $progressBarClass = 'progress-bar-success';
2962 $title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).' '.$langs->trans("point"));
2963 $diff = '<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).'%</span>';
2964 }
2965 }
2966
2967 $out .= '<div class="progress-group">';
2968
2969 if ($label !== false) {
2970 $out .= ' <span class="progress-text">';
2971
2972 if ($label !== true) {
2973 $out .= $label; // replace label by param
2974 } else {
2975 $out .= $task->getNomUrl(1).' '.dol_htmlentities($task->label);
2976 }
2977 $out .= ' </span>';
2978 }
2979
2980
2981 if ($progressNumber !== false) {
2982 $out .= ' <span class="progress-number">';
2983 if ($progressNumber !== true) {
2984 $out .= $progressNumber; // replace label by param
2985 } else {
2986 if ($task->hasDelay()) {
2987 $out .= img_warning($langs->trans("Late")).' ';
2988 }
2989
2990 $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id;
2991
2992 $out .= !empty($diff) ? $diff.' ' : '';
2993 $out .= '<a href="'.$url.'" >';
2994 $out .= '<b title="'.$langs->trans('TimeSpent').'" >';
2995 if ($task->duration_effective) {
2996 $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat);
2997 } else {
2998 $out .= '--:--';
2999 }
3000 $out .= '</b>';
3001 $out .= '</a>';
3002
3003 $out .= ' / ';
3004
3005 $out .= '<a href="'.$url.'" >';
3006 $out .= '<span title="'.$langs->trans('PlannedWorkload').'" >';
3007 if ($task->planned_workload) {
3008 $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat);
3009 } else {
3010 $out .= '--:--';
3011 }
3012 $out .= '</a>';
3013 }
3014 $out .= ' </span>';
3015 }
3016
3017
3018 $out .= '</span>';
3019 $out .= ' <div class="progress sm'.($spaced ? $spaced : '').'">';
3020 $diffval = (float) $task->progress - (float) $progressCalculated;
3021 if ($diffval >= 0) {
3022 // good
3023 $out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.(float) $task->progress.'%" title="'.(float) $task->progress.'%">';
3024 if (!empty($task->progress)) {
3025 $out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.(float) ($progressCalculated / ((float) $task->progress == 0 ? 1 : $task->progress) * 100).'%" title="'.(float) $progressCalculated.'%"></div>';
3026 }
3027 $out .= ' </div>';
3028 } else {
3029 // bad
3030 $out .= ' <div class="progress-bar progress-bar-consumed-late" style="width: '.(float) $progressCalculated.'%" title="'.(float) $progressCalculated.'%">';
3031 $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>';
3032 $out .= ' </div>';
3033 }
3034 $out .= ' </div>';
3035 $out .= '</div>';
3036
3037
3038
3039 return $out;
3040}
3048function getTaskProgressBadge($task, $label = '', $tooltip = '')
3049{
3050 global $conf, $langs;
3051
3052 $out = '';
3053 $badgeClass = '';
3054 if ($task->progress != '') {
3055 // TODO : manage 100%
3056
3057 // define color according to time spend vs workload
3058 $badgeClass = 'badge ';
3059 if ($task->planned_workload) {
3060 $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2);
3061
3062 // this conf is actually hidden, by default we use 10% for "be careful or warning"
3063 $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
3064
3065 if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
3066 $badgeClass .= 'badge-danger';
3067 if (empty($tooltip)) {
3068 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3069 }
3070 } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10%
3071 $badgeClass .= 'badge-warning';
3072 if (empty($tooltip)) {
3073 $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3074 }
3075 } else {
3076 $badgeClass .= 'badge-success';
3077 if (empty($tooltip)) {
3078 $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%';
3079 }
3080 }
3081 }
3082 }
3083
3084 $title = '';
3085 if (!empty($tooltip)) {
3086 $badgeClass .= ' classfortooltip';
3087 $title = 'title="'.dol_htmlentities($tooltip).'"';
3088 }
3089
3090 if (empty($label)) {
3091 $label = $task->progress.' %';
3092 }
3093
3094 if (!empty($label)) {
3095 $out = '<span class="'.$badgeClass.'" '.$title.' >'.$label.'</span>';
3096 }
3097
3098 return $out;
3099}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
$c
Definition line.php:327
$object ref
Definition info.php:89
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage projects.
Class to manage tasks.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:244
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
treeview li table
No Email.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dol_setcache($memoryid, $data, $expire=0, $filecache=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
Class to generate the form for creating a new ticket.
projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a pertime input mode.
task_prepare_head($object)
Prepare array with list of tabs.
searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)
projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0)
Output a task line into a pertime input mode.
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
project_admin_prepare_head()
Prepare array with list of tabs.
getTaskProgressBadge($task, $label='', $tooltip='')
projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a perday input mode.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.