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