28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40 global $db, $langs, $conf, $user;
45 $head[$h][0] = DOL_URL_ROOT.
'/projet/card.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
46 $head[$h][1] = $langs->trans(
"Project");
47 $head[$h][2] =
'project';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
52 $cachekey =
'count_contacts_project_'.$project->id;
55 if (!is_null($dataretrieved)) {
56 $nbContacts = $dataretrieved;
58 $nbContacts = count($project->liste_contact(-1,
'internal')) + count($project->liste_contact(-1,
'external'));
61 $head[$h][0] = DOL_URL_ROOT.
'/projet/contact.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
62 $head[$h][1] = $langs->trans(
"ProjectContact");
63 if ($nbContacts > 0) {
64 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContacts.
'</span>';
66 $head[$h][2] =
'contact';
69 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
73 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
74 $cachekey =
'count_tasks_project_'.$project->id;
77 if (!is_null($dataretrieved)) {
78 $nbTasks = $dataretrieved;
80 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
81 $taskstatic =
new Task($db);
82 $nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0));
85 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
86 $head[$h][1] = $langs->trans(
"Tasks");
88 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTasks).
'</span>';
90 $head[$h][2] =
'tasks';
95 $cachekey =
'count_timespent_project_'.$project->id;
97 if (!is_null($dataretrieved)) {
98 $nbTimeSpent = $dataretrieved;
100 $sql =
"SELECT t.rowid";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t, ".MAIN_DB_PREFIX.
"projet_task as pt";
104 $sql .=
" WHERE t.fk_task = pt.rowid";
105 $sql .=
" AND pt.fk_projet =".((int) $project->id);
106 $resql = $db->query(
$sql);
108 $obj = $db->fetch_object($resql);
118 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&projectid='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
119 $head[$h][1] = $langs->trans(
"TimeSpent");
120 if ($nbTimeSpent > 0) {
121 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
123 $head[$h][2] =
'timespent';
133 $cachekey =
'count_elements_project_'.$project->id;
135 if (!is_null($dataretrieved)) {
136 $nbElements = $dataretrieved;
139 $nbElements += $project->getElementCount(
'stock',
'entrepot',
'fk_project');
142 $nbElements += $project->getElementCount(
'propal',
'propal');
145 $nbElements += $project->getElementCount(
'order',
'commande');
148 $nbElements += $project->getElementCount(
'invoice',
'facture');
151 $nbElements += $project->getElementCount(
'invoice_predefined',
'facture_rec');
154 $nbElements += $project->getElementCount(
'proposal_supplier',
'supplier_proposal');
157 $nbElements += $project->getElementCount(
'order_supplier',
'commande_fournisseur');
160 $nbElements += $project->getElementCount(
'invoice_supplier',
'facture_fourn');
163 $nbElements += $project->getElementCount(
'contract',
'contrat');
166 $nbElements += $project->getElementCount(
'intervention',
'fichinter');
169 $nbElements += $project->getElementCount(
'shipping',
'expedition');
172 $nbElements += $project->getElementCount(
'mrp',
'mrp_mo',
'fk_project');
175 $nbElements += $project->getElementCount(
'trip',
'deplacement');
178 $nbElements += $project->getElementCount(
'expensereport',
'expensereport');
181 $nbElements += $project->getElementCount(
'donation',
'don');
183 if (!empty($conf->loan->enabled)) {
184 $nbElements += $project->getElementCount(
'loan',
'loan');
187 $nbElements += $project->getElementCount(
'chargesociales',
'chargesociales');
190 $nbElements += $project->getElementCount(
'project_task',
'projet_task');
193 $nbElements += $project->getElementCount(
'stock_mouvement',
'stock');
195 if (!empty($conf->salaries->enabled)) {
196 $nbElements += $project->getElementCount(
'salaries',
'payment_salary');
199 $nbElements += $project->getElementCount(
'variouspayment',
'payment_various');
203 $head[$h][0] = DOL_URL_ROOT.
'/projet/element.php?id='.$project->id;
204 $head[$h][1] = $langs->trans(
"ProjectOverview");
205 if ($nbElements > 0) {
206 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbElements.
'</span>';
208 $head[$h][2] =
'element';
212 if (
isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
213 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
214 $Tickettatic =
new Ticket($db);
215 $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id,
'*',
'fk_project',
'ticket'));
216 $head[$h][0] = DOL_URL_ROOT.
'/ticket/list.php?projectid='.((int) $project->id);
217 $head[$h][1] = $langs->trans(
"Ticket");
219 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTicket).
'</span>';
221 $head[$h][2] =
'ticket';
225 if (
isModEnabled(
'eventorganization') && !empty($project->usage_organize_event)) {
226 $langs->load(
'eventorganization');
227 $head[$h][0] = DOL_URL_ROOT .
'/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
228 $head[$h][1] = $langs->trans(
"EventOrganization");
232 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
233 $cachekey =
'count_conferenceorbooth_'.$project->id;
235 if (!is_null($dataretrieved)) {
236 $nbConfOrBooth = $dataretrieved;
238 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
240 $result = $conforbooth->fetchAll(
'',
'', 0, 0, array(
't.fk_project'=>$project->id));
242 if (!is_array($result) && $result<0) {
245 $nbConfOrBooth = count($result);
249 if ($nbConfOrBooth > 0) {
250 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbConfOrBooth .
'</span>';
252 $head[$h][2] =
'eventorganisation';
263 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
265 if (!empty($project->note_private)) {
268 if (!empty($project->note_public)) {
271 $head[$h][0] = DOL_URL_ROOT.
'/projet/note.php?id='.$project->id;
272 $head[$h][1] = $langs->trans(
'Notes');
274 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
276 $head[$h][2] =
'notes';
283 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
284 $cachekey =
'count_attached_project_'.$project->id;
286 if (!is_null($dataretrieved)) {
287 $totalAttached = $dataretrieved;
289 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
290 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
292 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
293 $nbLinks =
Link::count($db, $project->element, $project->id);
294 $totalAttached = $nbFiles + $nbLinks;
297 $head[$h][0] = DOL_URL_ROOT.
'/projet/document.php?id='.$project->id;
298 $head[$h][1] = $langs->trans(
'Documents');
299 if (($totalAttached) > 0) {
300 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
302 $head[$h][2] =
'document';
306 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) {
309 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
310 $cachekey =
'count_attached_project_'.$project->id;
312 if (!is_null($dataretrieved)) {
313 $nbComments = $dataretrieved;
315 $nbComments = $project->getNbComments();
318 $head[$h][0] = DOL_URL_ROOT.
'/projet/comment.php?id='.$project->id;
319 $head[$h][1] = $langs->trans(
"CommentLink");
320 if ($nbComments > 0) {
321 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
323 $head[$h][2] =
'project_comment';
327 $head[$h][0] = DOL_URL_ROOT.
'/projet/messaging.php?id='.$project->id;
328 $head[$h][1] = $langs->trans(
"Events");
329 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
331 $head[$h][1] .= $langs->trans(
"Agenda");
333 $head[$h][2] =
'agenda';
352 global $db, $langs, $conf, $user;
356 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/task.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
357 $head[$h][1] = $langs->trans(
"Task");
358 $head[$h][2] =
'task_task';
361 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
362 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/contact.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
363 $head[$h][1] = $langs->trans(
"TaskRessourceLinks");
364 if ($nbContact > 0) {
365 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
367 $head[$h][2] =
'task_contact';
372 $sql =
"SELECT t.rowid";
375 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
376 $sql .=
" WHERE t.fk_task = ".((int) $object->id);
377 $resql = $db->query(
$sql);
379 $obj = $db->fetch_object($resql);
387 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
388 $head[$h][1] = $langs->trans(
"TimeSpent");
389 if ($nbTimeSpent > 0) {
390 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
392 $head[$h][2] =
'task_time';
401 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
403 if (!empty($object->note_private)) {
406 if (!empty($object->note_public)) {
409 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/note.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
410 $head[$h][1] = $langs->trans(
'Notes');
412 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
414 $head[$h][2] =
'task_notes';
418 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/document.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
420 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
421 include_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
422 $nbFiles = count(
dol_dir_list($filesdir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
423 $nbLinks =
Link::count($db, $object->element, $object->id);
424 $head[$h][1] = $langs->trans(
'Documents');
425 if (($nbFiles + $nbLinks) > 0) {
426 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
428 $head[$h][2] =
'task_document';
432 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) {
433 $nbComments = $object->getNbComments();
434 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/comment.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
435 $head[$h][1] = $langs->trans(
"CommentLink");
436 if ($nbComments > 0) {
437 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
439 $head[$h][2] =
'task_comment';
459 global $langs, $conf, $user;
466 $param .= ($mode ?
'&mode='.$mode :
'');
467 if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
468 $param .=
'&search_usertoprocessid='.$fuser->id;
471 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) {
472 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/permonth.php".($param ?
'?'.$param :
'');
473 $head[$h][1] = $langs->trans(
"InputPerMonth");
474 $head[$h][2] =
'inputpermonth';
478 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) {
479 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perweek.php".($param ?
'?'.$param :
'');
480 $head[$h][1] = $langs->trans(
"InputPerWeek");
481 $head[$h][2] =
'inputperweek';
485 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) {
486 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perday.php".($param ?
'?'.$param :
'');
487 $head[$h][1] = $langs->trans(
"InputPerDay");
488 $head[$h][2] =
'inputperday';
507 global $langs, $conf, $user, $db;
510 $extrafields->fetch_name_optionals_label(
'projet');
511 $extrafields->fetch_name_optionals_label(
'projet_task');
516 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project.php";
517 $head[$h][1] = $langs->trans(
"Projects");
518 $head[$h][2] =
'project';
523 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project_extrafields.php";
524 $head[$h][1] = $langs->trans(
"ExtraFieldsProject");
525 $nbExtrafields = $extrafields->attributes[
'projet'][
'count'];
526 if ($nbExtrafields > 0) {
527 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
529 $head[$h][2] =
'attributes';
532 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/project_task_extrafields.php';
533 $head[$h][1] = $langs->trans(
"ExtraFieldsProjectTask");
534 $nbExtrafields = $extrafields->attributes[
'projet_task'][
'count'];
535 if ($nbExtrafields > 0) {
536 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
538 $head[$h][2] =
'attributes_task';
541 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
542 $langs->load(
"members");
544 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/website.php';
545 $head[$h][1] = $langs->trans(
"BlankSubscriptionForm");
546 $head[$h][2] =
'website';
575 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc =
'', $showbilltime = 0, $arrayfields = array(), $arrayofselected = array())
577 global $user, $langs, $conf, $db, $hookmanager;
578 global $projectstatic, $taskstatic, $extrafields;
582 $projectsArrayId = explode(
',', $projectsListId);
583 if ($filterprogresscalc !==
'') {
584 foreach ($lines as $key => $line) {
585 if (!empty($line->planned_workload) && !empty($line->duration)) {
586 $filterprogresscalc = str_replace(
' = ',
' == ', $filterprogresscalc);
587 if (!eval($filterprogresscalc)) {
592 $lines = array_values($lines);
594 $numlines = count($lines);
597 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;
600 $total_projectlinesa_spent = 0;
601 $total_projectlinesa_planned = 0;
602 $total_projectlinesa_spent_if_planned = 0;
603 $total_projectlinesa_declared_if_planned = 0;
604 $total_projectlinesa_tobill = 0;
605 $total_projectlinesa_billed = 0;
606 $total_budget_amount = 0;
609 for ($i = 0; $i < $numlines; $i++) {
610 if ($parent == 0 && $level >= 0) {
617 if ($lines[$i]->fk_parent == $parent || $level < 0) {
623 if (is_array($taskrole)) {
625 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_parent) {
627 $foundtaskforuserdeeper = 0;
630 if ($foundtaskforuserdeeper > 0) {
639 if (empty($user->rights->projet->all->lire)) {
641 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
652 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
654 $lastprojectid = $lines[$i]->fk_project;
657 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
659 $projectstatic->id = $lines[$i]->fk_project;
660 $projectstatic->ref = $lines[$i]->projectref;
661 $projectstatic->public = $lines[$i]->public;
662 $projectstatic->title = $lines[$i]->projectlabel;
663 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
664 $projectstatic->status = $lines[$i]->projectstatus;
666 $taskstatic->id = $lines[$i]->id;
667 $taskstatic->ref = $lines[$i]->ref;
668 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
669 $taskstatic->projectstatus = $lines[$i]->projectstatus;
670 $taskstatic->progress = $lines[$i]->progress;
671 $taskstatic->fk_statut = $lines[$i]->status;
672 $taskstatic->date_start = $lines[$i]->date_start;
673 $taskstatic->date_end = $lines[$i]->date_end;
674 $taskstatic->datee = $lines[$i]->date_end;
675 $taskstatic->planned_workload = $lines[$i]->planned_workload;
676 $taskstatic->duration_effective = $lines[$i]->duration;
677 $taskstatic->budget_amount = $lines[$i]->budget_amount;
682 print
'<td class="nowraponall">';
684 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
685 print $projectstatic->getNomUrl(1);
687 print $projectstatic->getNomUrl(1,
'nolink');
694 $projectstatic->statut = $lines[$i]->projectstatus;
695 print $projectstatic->getLibStatut(2);
700 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
701 print
'<td class="nowraponall">';
702 if ($showlineingray) {
703 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
705 print $taskstatic->getNomUrl(1,
'withproject');
711 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
713 if ($showlineingray) {
714 $labeltoshow .=
'<i>';
717 for ($k = 0; $k < $level; $k++) {
718 $labeltoshow .=
'<div class="marginleftonly">';
721 for ($k = 0; $k < $level; $k++) {
722 $labeltoshow .=
'</div>';
724 if ($showlineingray) {
725 $labeltoshow .=
'</i>';
727 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
732 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
733 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
734 print $lines[$i]->description;
739 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
740 print
'<td class="center nowraponall">';
746 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
747 print
'<td class="center nowraponall">';
749 if ($taskstatic->hasDelay()) {
755 $plannedworkloadoutputformat =
'allhourmin';
756 $timespentoutputformat =
'allhourmin';
757 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
758 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
760 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
761 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
765 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
766 print
'<td class="right">';
767 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
769 if ($lines[$i]->planned_workload !=
'') {
779 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
780 print
'<td class="right">';
781 if ($showlineingray) {
784 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
786 if ($lines[$i]->duration) {
791 if ($showlineingray) {
800 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
801 print
'<td class="right">';
802 if ($lines[$i]->planned_workload || $lines[$i]->duration) {
803 if ($lines[$i]->planned_workload) {
804 print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).
' %';
806 print
'<span class="opacitymedium">'.$langs->trans(
'WorkloadNotDefined').
'</span>';
813 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
814 print
'<td class="right">';
815 if ($lines[$i]->progress !=
'') {
822 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
823 print
'<td class="right">';
824 if ($lines[$i]->progress !=
'' && $lines[$i]->duration) {
832 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
833 print
'<td class="right">';
834 if ($lines[$i]->usage_bill_time) {
836 $total_projectlinesa_tobill += $lines[$i]->tobill;
838 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
844 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
845 print
'<td class="right">';
846 if ($lines[$i]->usage_bill_time) {
848 $total_projectlinesa_billed += $lines[$i]->billed;
850 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
857 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
858 print
'<td class="center">';
859 if ($lines[$i]->budget_amount) {
860 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
861 $total_budget_amount += $lines[$i]->budget_amount;
867 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
868 print
'<td class="center">';
870 foreach (array(
'internal',
'external') as $source) {
871 $tab = $lines[$i]->liste_contact(-1, $source);
872 $numcontact = count($tab);
873 if (!empty($numcontact)) {
874 foreach ($tab as $contacttask) {
876 if ($source ==
'internal') {
881 $c->fetch($contacttask[
'id']);
882 if (!empty($c->photo)) {
883 if (get_class($c) ==
'User') {
884 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
886 print $c->getNomUrl(-2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
889 if (get_class($c) ==
'User') {
890 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
892 print $c->getNomUrl(2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
903 $extrafieldsobjectkey = $taskstatic->table_element;
905 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
907 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$lines[$i]);
908 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
909 print $hookmanager->resPrint;
912 print
'<td class="tdlineupdown center"></td>';
915 print
'<td class="nowrap" align="center">';
917 if (in_array($lines[$i]->
id, $arrayofselected)) {
920 print
'<input id="cb' . $lines[$i]->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
926 if (!$showlineingray) {
932 if ($lines[$i]->
id) {
933 projectLinesa($inc, $lines[$i]->
id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
938 $total_projectlinesa_spent += $lines[$i]->duration;
939 $total_projectlinesa_planned += $lines[$i]->planned_workload;
940 if ($lines[$i]->planned_workload) {
941 $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
943 if ($lines[$i]->planned_workload) {
944 $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
952 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
954 print
'<tr class="liste_total nodrag nodrop">';
955 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
957 print
'<td></td><td></td>';
959 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
962 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
965 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
968 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
969 print
'<td class="nowrap liste_total right">';
973 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
974 print
'<td class="nowrap liste_total right">';
975 if ($projectidfortotallink > 0) {
976 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
979 if ($projectidfortotallink > 0) {
985 if ($total_projectlinesa_planned) {
986 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
987 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
990 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
993 $progressBarClass =
'progress-bar-info';
994 $badgeClass =
'badge ';
996 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
997 $progressBarClass =
'progress-bar-danger';
998 $badgeClass .=
'badge-danger';
999 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
1000 $progressBarClass =
'progress-bar-warning';
1001 $badgeClass .=
'badge-warning';
1003 $progressBarClass =
'progress-bar-success';
1004 $badgeClass .=
'badge-success';
1009 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
1010 print
'<td class="nowrap liste_total right">';
1011 if ($total_projectlinesa_planned) {
1012 print $totalCalculatedProgress.
' %';
1018 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
1019 print
'<td class="nowrap liste_total right">';
1020 if ($total_projectlinesa_planned) {
1021 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
1028 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
1029 print
'<td class="right">';
1030 if ($total_projectlinesa_planned) {
1032 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
1033 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1040 if ($showbilltime) {
1041 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1042 print
'<td class="nowrap liste_total right">';
1046 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1047 print
'<td class="nowrap liste_total right">';
1054 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1055 print
'<td class="nowrap liste_total center">';
1056 if (strcmp($total_budget_amount,
'')) {
1057 print
price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1063 if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
1067 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1070 print
'<td class=""></td>';
1095 function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1097 global $conf, $db, $user, $langs;
1098 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1101 $totalforeachline = array();
1102 $workloadforid = array();
1103 $lineswithoutlevel0 = array();
1105 $numlines = count($lines);
1109 for ($i = 0; $i < $numlines; $i++) {
1110 if ($lines[$i]->fk_task_parent) {
1111 $lineswithoutlevel0[] = $lines[$i];
1116 if (empty($oldprojectforbreak)) {
1117 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1121 for ($i = 0; $i < $numlines; $i++) {
1129 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1133 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1134 $lastprojectid = $lines[$i]->fk_project;
1135 if ($preselectedday) {
1136 $projectstatic->id = $lines[$i]->fk_project;
1140 if (empty($workloadforid[$projectstatic->id])) {
1141 if ($preselectedday) {
1142 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1143 $workloadforid[$projectstatic->id] = 1;
1147 $projectstatic->id = $lines[$i]->fk_project;
1148 $projectstatic->ref = $lines[$i]->project_ref;
1149 $projectstatic->title = $lines[$i]->project_label;
1150 $projectstatic->public = $lines[$i]->public;
1151 $projectstatic->status = $lines[$i]->project->status;
1153 $taskstatic->id = $lines[$i]->fk_statut;
1154 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1155 $taskstatic->label = $lines[$i]->task_label;
1156 $taskstatic->date_start = $lines[$i]->date_start;
1157 $taskstatic->date_end = $lines[$i]->date_end;
1159 $thirdpartystatic->id = $lines[$i]->socid;
1160 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1161 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1163 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1164 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1165 print
'<td colspan="11">';
1166 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1167 if ($projectstatic->title) {
1169 print $projectstatic->title;
1175 if ($oldprojectforbreak != -1) {
1176 $oldprojectforbreak = $projectstatic->id;
1179 print
'<tr class="oddeven">'.
"\n";
1190 if ($oldprojectforbreak == -1) {
1191 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1192 print
'<br>'.$projectstatic->title;
1197 print
'<td class="tdoverflowmax100">';
1198 if ($thirdpartystatic->id > 0) {
1199 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1205 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1206 for ($k = 0; $k < $level; $k++) {
1207 print
" ";
1209 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1212 for ($k = 0; $k < $level; $k++) {
1213 print
" ";
1215 print $taskstatic->label;
1222 print
'<td class="center">';
1226 $disabledproject = 1;
1232 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1233 $disabledproject = 0;
1237 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1242 print
'<td class="nowrap center">';
1247 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1248 $cssonholiday .=
'onholidayallday ';
1249 } elseif (!$isavailable[$preselectedday][
'morning']) {
1250 $cssonholiday .=
'onholidaymorning ';
1251 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1252 $cssonholiday .=
'onholidayafternoon ';
1256 print
'<td class="duration'.($cssonholiday ?
' '.$cssonholiday :
'').
' center">';
1258 $dayWorkLoad = $lines[$i]->timespent_duration;
1259 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1262 if ($dayWorkLoad > 0) {
1271 print
'<td class="center">';
1272 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1273 print $lines[$i]->timespent_note;
1274 print
'</textarea>';
1278 print
'<td class="right">';
1298 return $totalforeachline;
1321 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1323 global $conf, $db, $user, $langs;
1324 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1327 $totalforeachday = array();
1328 $workloadforid = array();
1329 $lineswithoutlevel0 = array();
1331 $numlines = count($lines);
1335 for ($i = 0; $i < $numlines; $i++) {
1336 if ($lines[$i]->fk_task_parent) {
1337 $lineswithoutlevel0[] = $lines[$i];
1342 if (empty($oldprojectforbreak)) {
1343 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1346 $restrictBefore =
null;
1348 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1349 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1354 for ($i = 0; $i < $numlines; $i++) {
1359 if ($lines[$i]->fk_task_parent == $parent) {
1363 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1366 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1371 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1372 $lastprojectid = $lines[$i]->fk_project;
1373 if ($preselectedday) {
1374 $projectstatic->id = $lines[$i]->fk_project;
1378 if (empty($workloadforid[$projectstatic->id])) {
1379 if ($preselectedday) {
1380 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1381 $workloadforid[$projectstatic->id] = 1;
1385 $projectstatic->id = $lines[$i]->fk_project;
1386 $projectstatic->ref = $lines[$i]->projectref;
1387 $projectstatic->title = $lines[$i]->projectlabel;
1388 $projectstatic->public = $lines[$i]->public;
1389 $projectstatic->status = $lines[$i]->projectstatus;
1391 $taskstatic->id = $lines[$i]->id;
1392 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1393 $taskstatic->label = $lines[$i]->label;
1394 $taskstatic->date_start = $lines[$i]->date_start;
1395 $taskstatic->date_end = $lines[$i]->date_end;
1397 $thirdpartystatic->id = $lines[$i]->socid;
1398 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1399 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1401 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1403 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1406 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1409 foreach ($arrayfields as $key => $val) {
1410 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1415 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1416 print
'<td colspan="'.(7 + $addcolspan).
'">';
1417 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1418 if ($thirdpartystatic->id > 0) {
1419 print
' - '.$thirdpartystatic->getNomUrl(1);
1421 if ($projectstatic->title) {
1423 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1490 if ($oldprojectforbreak != -1) {
1491 $oldprojectforbreak = $projectstatic->id;
1494 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1504 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1506 if ($oldprojectforbreak == -1) {
1507 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1513 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1514 print
'<td class="tdoverflowmax100">';
1515 if ($thirdpartystatic->id > 0) {
1516 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1523 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1524 for ($k = 0; $k < $level; $k++) {
1525 print
'<div class="marginleftonly">';
1527 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1530 print
'<span class="opacitymedium">'.$taskstatic->label.
'</a>';
1531 for ($k = 0; $k < $level; $k++) {
1537 $extrafieldsobjectkey =
'projet_task';
1538 $extrafieldsobjectprefix =
'efpt.';
1539 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1542 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1543 print
'<td class="leftborder plannedworkload right">';
1544 if ($lines[$i]->planned_workload) {
1553 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1554 print
'<td class="right">';
1555 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1559 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1561 print
'<td class="right">';
1563 if ($lines[$i]->duration) {
1564 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1573 print
'<td class="right">';
1574 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1575 if ($tmptimespent[
'total_duration']) {
1583 $disabledproject = 1;
1589 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1590 $disabledproject = 0;
1594 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1598 if ($restrictBefore && $preselectedday < $restrictBefore) {
1603 print
'<td class="nowraponall leftborder center minwidth150imp">';
1604 $tableCell =
$form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1609 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1610 $cssonholiday .=
'onholidayallday ';
1611 } elseif (!$isavailable[$preselectedday][
'morning']) {
1612 $cssonholiday .=
'onholidaymorning ';
1613 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1614 $cssonholiday .=
'onholidayafternoon ';
1620 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1621 global $numstartworkingday, $numendworkingday;
1623 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1624 $cssweekend =
'weekend';
1628 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1629 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1630 if (!isset($totalforeachday[$preselectedday])) {
1631 $totalforeachday[$preselectedday] = 0;
1633 $totalforeachday[$preselectedday] += $dayWorkLoad;
1636 if ($dayWorkLoad > 0) {
1643 $tableCell .=
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="'.$alreadyspent.
'"></span>';
1644 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1646 $tableCell .=
$form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1653 print
'<td class="center">';
1654 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1655 print
'</textarea>';
1659 print
'<td class="right">';
1660 if ((!$lines[$i]->
public) && $disabledproject) {
1661 print
$form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1662 } elseif ($disabledtask) {
1663 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1664 if ($fuser->id != $user->id) {
1665 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1668 print
$form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1677 if ($lines[$i]->
id > 0) {
1680 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1683 foreach ($ret as $key => $val) {
1684 $totalforeachday[$key] += $val;
1695 return $totalforeachday;
1718 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1720 global $conf, $db, $user, $langs;
1721 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1723 $numlines = count($lines);
1726 $workloadforid = array();
1727 $totalforeachday = array();
1728 $lineswithoutlevel0 = array();
1732 for ($i = 0; $i < $numlines; $i++) {
1733 if ($lines[$i]->fk_task_parent) {
1734 $lineswithoutlevel0[] = $lines[$i];
1741 if (empty($oldprojectforbreak)) {
1742 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1745 $restrictBefore =
null;
1747 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1748 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1752 for ($i = 0; $i < $numlines; $i++) {
1757 if ($lines[$i]->fk_task_parent == $parent) {
1761 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1764 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1769 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1770 $lastprojectid = $lines[$i]->fk_project;
1771 $projectstatic->id = $lines[$i]->fk_project;
1776 if (empty($workloadforid[$projectstatic->id])) {
1777 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1778 $workloadforid[$projectstatic->id] = 1;
1783 $projectstatic->id = $lines[$i]->fk_project;
1784 $projectstatic->ref = $lines[$i]->projectref;
1785 $projectstatic->title = $lines[$i]->projectlabel;
1786 $projectstatic->public = $lines[$i]->public;
1787 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1788 $projectstatic->status = $lines[$i]->projectstatus;
1790 $taskstatic->id = $lines[$i]->id;
1791 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1792 $taskstatic->label = $lines[$i]->label;
1793 $taskstatic->date_start = $lines[$i]->date_start;
1794 $taskstatic->date_end = $lines[$i]->date_end;
1796 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1797 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1798 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1800 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1802 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1805 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1808 foreach ($arrayfields as $key => $val) {
1809 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1814 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1815 print
'<td colspan="'.(11 + $addcolspan).
'">';
1816 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1817 if ($thirdpartystatic->id > 0) {
1818 print
' - '.$thirdpartystatic->getNomUrl(1);
1820 if ($projectstatic->title) {
1822 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1889 if ($oldprojectforbreak != -1) {
1890 $oldprojectforbreak = $projectstatic->id;
1893 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1903 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1904 print
'<td class="nowrap">';
1905 if ($oldprojectforbreak == -1) {
1906 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1912 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1913 print
'<td class="tdoverflowmax100">';
1914 if ($thirdpartystatic->id > 0) {
1915 print $thirdpartystatic->getNomUrl(1,
'project');
1921 print
'<td class="nowrap">';
1922 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1923 for ($k = 0; $k < $level; $k++) {
1924 print
'<div class="marginleftonly">';
1926 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1929 print
'<span class="opacitymedium">'.$taskstatic->label.
'</span>';
1930 for ($k = 0; $k < $level; $k++) {
1936 $extrafieldsobjectkey =
'projet_task';
1937 $extrafieldsobjectprefix =
'efpt.';
1938 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1941 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1942 print
'<td class="leftborder plannedworkload right">';
1943 if ($lines[$i]->planned_workload) {
1951 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1953 print
'<td class="right">';
1954 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1958 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1960 print
'<td class="right">';
1962 if ($lines[$i]->duration) {
1963 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1972 print
'<td class="right">';
1973 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1974 if ($tmptimespent[
'total_duration']) {
1982 $disabledproject = 1;
1988 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1989 $disabledproject = 0;
1993 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
2001 $modeinput =
'hours';
2002 for ($idw = 0; $idw < 7; $idw++) {
2004 if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
2006 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
2007 $cssonholiday .=
'onholidayallday ';
2008 } elseif (!$isavailable[$tmpday][
'morning']) {
2009 $cssonholiday .=
'onholidaymorning ';
2010 } elseif (!$isavailable[$tmpday][
'afternoon']) {
2011 $cssonholiday .=
'onholidayafternoon ';
2015 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2016 $totalforeachday[$tmpday] += $dayWorkLoad;
2019 if ($dayWorkLoad > 0) {
2022 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", !empty($tmparray[
'day']) ? $tmparray[
'day'] : 0, $tmparray[
'mon']);
2024 global $numstartworkingday, $numendworkingday;
2026 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
2027 $cssweekend =
'weekend';
2030 $disabledtaskday = $disabledtask;
2032 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2033 $disabledtaskday = 1;
2036 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
2039 if ($alreadyspent) {
2040 $tableCell .=
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="'.$alreadyspent.
'"></span>';
2044 $tableCell .=
'<input type="text" alt="'.($disabledtaskday ?
'' : $alttitle).
'" title="'.($disabledtaskday ?
'' : $alttitle).
'" '.($disabledtaskday ?
'disabled' : $placeholder).
' class="center smallpadd" size="2" id="timeadded['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="" cols="2" maxlength="5"';
2045 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2046 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
2047 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
2048 $tableCell .= '</td>';
2053 print '<td class="right
">';
2054 if ((!$lines[$i]->public) && $disabledproject) {
2055 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2056 } elseif ($disabledtask) {
2057 $titleassigntask = $langs->trans("AssignTaskToMe
");
2058 if ($fuser->id != $user->id) {
2059 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2062 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2069 // Call to show task with a lower level (task under the current task)
2072 if ($lines[$i]->id > 0) {
2073 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2074 //var_dump($totalforeachday);
2075 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2076 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2078 foreach ($ret as $key => $val) {
2079 $totalforeachday[$key] += $val;
2081 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2082 //var_dump($totalforeachday);
2090 return $totalforeachday;
2111 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
2113 global $conf, $db, $user, $langs;
2114 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2116 $numlines = count($lines);
2119 $workloadforid = array();
2120 $totalforeachweek = array();
2121 $lineswithoutlevel0 = array();
2123 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2124 if ($parent == 0) { // Always and only if at first level
2125 for ($i = 0; $i < $numlines; $i++) {
2126 if ($lines[$i]->fk_task_parent) {
2127 $lineswithoutlevel0[] = $lines[$i];
2132 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
2134 if (empty($oldprojectforbreak)) {
2135 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
2138 $restrictBefore = null;
2140 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
2141 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2142 $restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
2145 for ($i = 0; $i < $numlines; $i++) {
2150 if ($lines[$i]->fk_task_parent == $parent) {
2151 // If we want all or we have a role on task, we show it
2152 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2153 //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);
2155 // Break on a new project
2156 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2157 $lastprojectid = $lines[$i]->fk_project;
2158 $projectstatic->id = $lines[$i]->fk_project;
2161 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2162 //var_dump($projectstatic->weekWorkLoadPerTask);
2163 if (empty($workloadforid[$projectstatic->id])) {
2164 $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
2165 $workloadforid[$projectstatic->id] = 1;
2167 //var_dump($projectstatic->weekWorkLoadPerTask);
2168 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2170 $projectstatic->id = $lines[$i]->fk_project;
2171 $projectstatic->ref = $lines[$i]->projectref;
2172 $projectstatic->title = $lines[$i]->projectlabel;
2173 $projectstatic->public = $lines[$i]->public;
2174 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2175 $projectstatic->status = $lines[$i]->projectstatus;
2177 $taskstatic->id = $lines[$i]->id;
2178 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2179 $taskstatic->label = $lines[$i]->label;
2180 $taskstatic->date_start = $lines[$i]->date_start;
2181 $taskstatic->date_end = $lines[$i]->date_end;
2183 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2184 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2185 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2187 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2188 print '<tr class="oddeven trforbreak nobold
">'."\n
";
2189 print '<td colspan="'.(6 + count($TWeek)).'">';
2190 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2191 if ($thirdpartystatic->id > 0) {
2192 print ' - '.$thirdpartystatic->getNomUrl(1);
2194 if ($projectstatic->title) {
2196 print '<span class="secondary
">'.$projectstatic->title.'</span>';
2202 if ($oldprojectforbreak != -1) {
2203 $oldprojectforbreak = $projectstatic->id;
2205 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
2209 print '<td class="nowrap
">';
2210 print $fuser->getNomUrl(1, 'withproject', 'time');
2215 /*print '<td class="nowrap
">';
2216 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
2220 /*print '<td class="tdoverflowmax100
">';
2221 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2225 print '<td class="nowrap
">';
2226 print '<!-- Task id = '.$lines[$i]->id.' -->';
2227 for ($k = 0; $k < $level; $k++) {
2228 print '<div class="marginleftonly
">';
2230 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2233 print '<span class="opacitymedium
">'.$taskstatic->label.'</span>';
2234 for ($k = 0; $k < $level; $k++) {
2240 print '<td class="leftborder plannedworkload right
">';
2241 if ($lines[$i]->planned_workload) {
2242 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2248 // Progress declared %
2249 print '<td class="right
">';
2250 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2253 // Time spent by everybody
2254 print '<td class="right
">';
2255 // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2256 if ($lines[$i]->duration) {
2257 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2258 print convertSecondToTime($lines[$i]->duration, 'allhourmin');
2265 // Time spent by user
2266 print '<td class="right
">';
2267 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2268 if ($tmptimespent['total_duration']) {
2269 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2275 $disabledproject = 1;
2277 //print "x
".$lines[$i]->fk_project;
2278 //var_dump($lines[$i]);
2279 //var_dump($projectsrole[$lines[$i]->fk_project]);
2280 // If at least one role for project
2281 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2282 $disabledproject = 0;
2285 // If $restricteditformytask is on and I have no role on task, i disable edit
2286 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2290 //var_dump($projectstatic->weekWorkLoadPerTask);
2292 // Fields to show current time
2294 $modeinput = 'hours';
2295 $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
2296 $TFirstDay[reset($TWeek)] = 1;
2298 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2299 $year = $firstdaytoshowarray['year'];
2300 $month = $firstdaytoshowarray['mon'];
2301 foreach ($TWeek as $weekIndex => $weekNb) {
2302 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2303 if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
2304 $totalforeachweek[$weekNb] += $weekWorkLoad;
2307 if ($weekWorkLoad > 0) {
2308 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2310 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2312 $disabledtaskweek = $disabledtask;
2313 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2315 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2316 $disabledtaskweek = 1;
2319 $tableCell = '<td class="center hide weekend
">';
2321 if ($alreadyspent) {
2322 $tableCell .= '<span class="timesheetalreadyrecorded
" title="texttoreplace
"><input type="text
" class="center smallpadd
" size="2
" disabled id="timespent[
'.$inc.'][
'.((int) $weekNb).']
" name="task[
'.$lines[$i]->id.'][
'.$weekNb.']
" value="'.$alreadyspent.'"></span>';
2323 //$placeholder=' placeholder="00:00
"';
2327 $tableCell .= '<input type="text
" alt="'.($disabledtaskweek ? '' : $alttitle).'" title="'.($disabledtaskweek ? '' : $alttitle).'" '.($disabledtaskweek ? 'disabled' : $placeholder).' class="center smallpadd
" size="2
" id="timeadded[
'.$inc.'][
'.((int) $weekNb).']
" name="task[
'.$lines[$i]->id.'][
'.($TFirstDay[$weekNb] - 1).']
" value="" cols="2
" maxlength="5
"';
2328 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2329 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2330 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2331 $tableCell .= '</td>';
2336 print '<td class="right
">';
2337 if ((!$lines[$i]->public) && $disabledproject) {
2338 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2339 } elseif ($disabledtask) {
2340 $titleassigntask = $langs->trans("AssignTaskToMe
");
2341 if ($fuser->id != $user->id) {
2342 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2345 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2352 // Call to show task with a lower level (task under the current task)
2355 if ($lines[$i]->id > 0) {
2356 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2357 //var_dump($totalforeachday);
2358 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2359 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2361 foreach ($ret as $key => $val) {
2362 $totalforeachweek[$key] += $val;
2364 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2365 //var_dump($totalforeachday);
2373 return $totalforeachweek;
2386 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2388 //print 'Search in line with parent id = '.$parent.'<br>';
2389 $numlines = count($lines);
2390 for ($i = 0; $i < $numlines; $i++) {
2391 // Process line $lines[$i]
2392 if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) {
2393 // If task is legitimate to show, no more need to search deeper
2394 if (isset($taskrole[$lines[$i]->id])) {
2395 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2400 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2401 //print 'Found inc='.$inc.'<br>';
2426 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2428 global $langs, $conf, $user;
2429 global $theme_datacolor;
2431 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2433 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2435 $listofstatus = array_keys($listofoppstatus);
2437 if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2438 // Define $themeColorId and array $statusOppList for each $listofstatus
2440 $statusOppList = array();
2441 foreach ($listofstatus as $oppStatus) {
2442 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2443 if ($oppStatusCode) {
2444 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2445 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2451 $projectstatic = new Project($db);
2452 $thirdpartystatic = new Societe($db);
2456 $project_year_filter = 0;
2458 $title = $langs->trans("Projects");
2459 if (strcmp($status, '') && $status >= 0) {
2460 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2463 print '<!-- print_projecttasks_array -->';
2464 print '<div class="div-table-responsive-no-min
">';
2465 print '<table class="noborder centpercent
">';
2467 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2469 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2470 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2471 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2473 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2475 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2476 $sql .= " AND p.rowid IN (
".$db->sanitize($projectsListId).")
";
2478 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2481 $sql .= " AND p.rowid = t.fk_projet
";
2482 $sql .= " AND ec.element_id = t.rowid
";
2483 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2484 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2485 $sql .= " AND ctc.element =
'project_task'";
2488 $sql .= " AND p.fk_statut =
".(int) $status;
2490 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2491 $project_year_filter = GETPOST("project_year_filter
");
2492 //Check if empty or invalid year. Wildcard ignores the sql check
2493 if ($project_year_filter != "*
") {
2494 if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
2495 $project_year_filter = date("Y
");
2497 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")
";
2498 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")
";
2502 // Get id of project we must show tasks
2503 $arrayidofprojects = array();
2504 $sql1 = "SELECT p.rowid as projectid
";
2506 $resql = $db->query($sql1);
2509 $num = $db->num_rows($resql);
2511 $objp = $db->fetch_object($resql);
2512 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2516 dol_print_error($db);
2518 if (empty($arrayidofprojects)) {
2519 $arrayidofprojects[0] = -1;
2522 // Get list of project with calculation on tasks
2523 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2524 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2525 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2526 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2527 $sql2 .= " s.logo, s.email, s.entity,
";
2528 $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,
";
2529 $sql2 .= " p.dateo, p.datee,
";
2530 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2531 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2532 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.
rowid = p.fk_soc";
2533 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.
rowid = t.fk_projet";
2534 $sql2 .= " WHERE p.
rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")";
2535 $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,";
2536 $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";
2537 $sql2 .= " ORDER BY p.title, p.
ref";
2539 $resql = $db->query($sql2);
2543 $total_opp_amount = 0;
2544 $ponderated_opp_amount = 0;
2545 $total_plannedworkload = 0;
2546 $total_declaredprogressworkload = 0;
2548 $num = $db->num_rows($resql);
2549 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2552 print
'<tr class="liste_titre">';
2553 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);
2555 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2556 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2557 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2559 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 ');
2562 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2564 if (!in_array(
'plannedworkload', $hiddenfields)) {
2565 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2567 if (!in_array(
'declaredprogress', $hiddenfields)) {
2568 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2571 if (!in_array(
'projectstatus', $hiddenfields)) {
2576 while ($i < $nbofloop) {
2577 $objp = $db->fetch_object($resql);
2579 if ($max && $i >= $max) {
2582 $total_task += $objp->nb;
2583 $total_opp_amount += $objp->opp_amount;
2584 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2585 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2586 $plannedworkload = $objp->planned_workload;
2587 $total_plannedworkload += $plannedworkload;
2588 $declaredprogressworkload = $objp->declared_progess_workload;
2589 $total_declaredprogressworkload += $declaredprogressworkload;
2593 $projectstatic->id = $objp->projectid;
2594 $projectstatic->user_author_id = $objp->fk_user_creat;
2595 $projectstatic->public = $objp->public;
2598 $userAccess = $projectstatic->restrictedProjectArea($user);
2599 if ($userAccess >= 0) {
2600 $projectstatic->ref = $objp->ref;
2601 $projectstatic->status = $objp->status;
2602 $projectstatic->title = $objp->title;
2603 $projectstatic->date_end = $db->jdate($objp->datee);
2604 $projectstatic->date_start = $db->jdate($objp->dateo);
2606 print
'<tr class="oddeven">';
2608 print
'<td class="tdoverflowmax150">';
2609 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2610 if (!in_array(
'projectlabel', $hiddenfields)) {
2611 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).
'</span>';
2615 print
'<td class="nowraponall tdoverflowmax100">';
2616 if ($objp->fk_soc > 0) {
2617 $thirdpartystatic->id = $objp->socid;
2618 $thirdpartystatic->name = $objp->socname;
2621 $thirdpartystatic->code_compta = $objp->code_compta;
2622 $thirdpartystatic->client = $objp->client;
2624 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2625 $thirdpartystatic->fournisseur = $objp->fournisseur;
2626 $thirdpartystatic->logo = $objp->logo;
2627 $thirdpartystatic->email = $objp->email;
2628 $thirdpartystatic->entity = $objp->entity;
2629 print $thirdpartystatic->getNomUrl(1);
2633 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2634 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2635 print
'<td class="center tdoverflowmax75">';
2637 if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2638 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2639 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2640 print $langs->trans(
"OppStatus".$oppStatusCode);
2643 if (isset($statusOppList[$objp->opp_status])) {
2644 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2645 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2647 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2648 $oppStatusColor =
'';
2650 if ($oppStatusCode) {
2651 if (!empty($oppStatusColor)) {
2652 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>';
2654 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2661 print
'<td class="right">';
2662 if ($objp->opp_percent && $objp->opp_amount) {
2663 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2664 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0, $conf->currency);
2665 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2667 if ($objp->opp_amount) {
2668 print
'<span class="amount" title="'.$alttext.
'">'.
$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2673 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2674 print
'<td class="right">'.$objp->nb.
'</td>';
2676 $plannedworkload = $objp->planned_workload;
2677 $total_plannedworkload += $plannedworkload;
2678 if (!in_array(
'plannedworkload', $hiddenfields)) {
2679 print
'<td class="right nowraponall">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2681 if (!in_array(
'declaredprogress', $hiddenfields)) {
2682 $declaredprogressworkload = $objp->declared_progess_workload;
2683 $total_declaredprogressworkload += $declaredprogressworkload;
2684 print
'<td class="right nowraponall">';
2686 print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2691 if (!in_array(
'projectstatus', $hiddenfields)) {
2692 print
'<td class="right">';
2693 print $projectstatic->getLibStatut(3);
2699 $total_task += $objp->nb;
2700 $total_opp_amount += $objp->opp_amount;
2707 print
'<tr class="oddeven">';
2708 print
'<td class="nowrap" colspan="5">';
2709 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
2714 print
'<tr class="liste_total">';
2715 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2716 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2717 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2718 print
'<td class="liste_total"></td>';
2720 print
'<td class="liste_total right">';
2722 print
$form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0, $conf->currency));
2725 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2726 print
'<td class="liste_total right">'.$total_task.
'</td>';
2727 if (!in_array(
'plannedworkload', $hiddenfields)) {
2728 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2730 if (!in_array(
'declaredprogress', $hiddenfields)) {
2731 print
'<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2734 if (!in_array(
'projectstatus', $hiddenfields)) {
2735 print
'<td class="liste_total"></td>';
2747 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2749 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2750 print
'<table width="100%">';
2752 print
'<td>'.$langs->trans(
"Year").
'</td>';
2753 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.
'"/>';
2755 print
'</table></form>';
2768 function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2770 global $langs, $conf;
2774 $plannedworkloadoutputformat =
'allhourmin';
2775 $timespentoutputformat =
'allhourmin';
2776 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
2777 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2779 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
2780 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2783 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2787 $spaced = !empty($spaced) ?
'spaced' :
'';
2792 $progressBarClass =
'progress-bar-info';
2793 $progressCalculated = 0;
2794 if ($task->planned_workload) {
2795 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2798 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2800 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.($task->progress ?
'%' :
'');
2801 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.($progressCalculated ?
'%' :
'');
2804 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2805 $progressBarClass =
'progress-bar-danger';
2806 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2807 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2808 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2809 $progressBarClass =
'progress-bar-warning';
2810 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2811 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2813 $progressBarClass =
'progress-bar-success';
2814 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2815 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2819 $out .=
'<div class="progress-group">';
2821 if ($label !==
false) {
2822 $out .=
' <span class="progress-text">';
2824 if ($label !==
true) {
2833 if ($progressNumber !==
false) {
2834 $out .=
' <span class="progress-number">';
2835 if ($progressNumber !==
true) {
2836 $out .= $progressNumber;
2838 if ($task->hasDelay()) {
2842 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2844 $out .= !empty($diff) ? $diff.
' ' :
'';
2845 $out .=
'<a href="'.$url.
'" >';
2846 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2847 if ($task->duration_effective) {
2857 $out .=
'<a href="'.$url.
'" >';
2858 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2859 if ($task->planned_workload) {
2871 $out .=
' <div class="progress sm '.$spaced.
'">';
2872 $diffval = floatval($task->progress) - floatval($progressCalculated);
2873 if ($diffval >= 0) {
2875 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.floatval($task->progress).
'%" title="'.floatval($task->progress).
'%">';
2876 if (!empty($task->progress)) {
2877 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated / (floatval($task->progress) == 0 ? 1 : $task->progress) * 100).
'%" title="'.floatval($progressCalculated).
'%"></div>';
2882 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).
'%" title="'.floatval($progressCalculated).
'%">';
2883 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.($task->progress ? floatval($task->progress / (floatval($progressCalculated) == 0 ? 1 : $progressCalculated) * 100).
'%' :
'1px').
'" title="'.floatval($task->progress).
'%"></div>';
2902 global $conf, $langs;
2906 if ($task->progress !=
'') {
2910 $badgeClass =
'badge ';
2911 if ($task->planned_workload) {
2912 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2915 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2917 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2918 $badgeClass .=
'badge-danger';
2919 if (empty($tooltip)) {
2920 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2922 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2923 $badgeClass .=
'badge-warning';
2924 if (empty($tooltip)) {
2925 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2928 $badgeClass .=
'badge-success';
2929 if (empty($tooltip)) {
2930 $tooltip = $task->progress.
'% >= '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2937 if (!empty($tooltip)) {
2938 $badgeClass .=
' classfortooltip';
2939 $title =
'title="'.dol_htmlentities($tooltip).
'"';
2942 if (empty($label)) {
2943 $label = $task->progress.
' %';
2946 if (!empty($label)) {
2947 $out =
'<span class="'.$badgeClass.
'" '.$title.
' >'.$label.
'</span>';