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