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;
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';
127 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
128 || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
129 ||
isModEnabled(
'facture') || !empty($conf->contrat->enabled)
130 || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->stock->enabled)) {
133 $cachekey =
'count_elements_project_'.$project->id;
135 if (!is_null($dataretrieved)) {
136 $nbElements = $dataretrieved;
138 if (!empty($conf->stock->enabled)) {
139 $nbElements += $project->
getElementCount(
'stock',
'entrepot',
'fk_project');
141 if (!empty($conf->propal->enabled)) {
144 if (!empty($conf->commande->enabled)) {
151 $nbElements += $project->
getElementCount(
'invoice_predefined',
'facture_rec');
153 if (!empty($conf->supplier_proposal->enabled)) {
154 $nbElements += $project->
getElementCount(
'proposal_supplier',
'supplier_proposal');
156 if (!empty($conf->supplier_order->enabled)) {
157 $nbElements += $project->
getElementCount(
'order_supplier',
'commande_fournisseur');
159 if (!empty($conf->supplier_invoice->enabled)) {
160 $nbElements += $project->
getElementCount(
'invoice_supplier',
'facture_fourn');
162 if (!empty($conf->contrat->enabled)) {
165 if (!empty($conf->ficheinter->enabled)) {
168 if (!empty($conf->expedition->enabled)) {
171 if (!empty($conf->mrp->enabled)) {
172 $nbElements += $project->
getElementCount(
'mrp',
'mrp_mo',
'fk_project');
174 if (!empty($conf->deplacement->enabled)) {
177 if (!empty($conf->expensereport->enabled)) {
178 $nbElements += $project->
getElementCount(
'expensereport',
'expensereport');
180 if (!empty($conf->don->enabled)) {
183 if (!empty($conf->loan->enabled)) {
186 if (!empty($conf->tax->enabled)) {
187 $nbElements += $project->
getElementCount(
'chargesociales',
'chargesociales');
189 if (!empty($conf->project->enabled)) {
190 $nbElements += $project->
getElementCount(
'project_task',
'projet_task');
192 if (!empty($conf->stock->enabled)) {
195 if (!empty($conf->salaries->enabled)) {
196 $nbElements += $project->
getElementCount(
'salaries',
'payment_salary');
198 if (!empty($conf->banque->enabled)) {
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 (!empty($conf->eventorganization->enabled) && !empty($project->usage_organize_event)) {
213 $langs->load(
'eventorganization');
214 $head[$h][0] = DOL_URL_ROOT .
'/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
215 $head[$h][1] = $langs->trans(
"EventOrganization");
219 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
220 $cachekey =
'count_conferenceorbooth_'.$project->id;
222 if (!is_null($dataretrieved)) {
223 $nbConfOrBooth = $dataretrieved;
225 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
227 $result = $conforbooth->fetchAll(
'',
'', 0, 0, array(
't.fk_project'=>$project->id));
229 if (!is_array($result) && $result<0) {
232 $nbConfOrBooth = count($result);
236 if ($nbConfOrBooth > 0) {
237 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbConfOrBooth .
'</span>';
239 $head[$h][2] =
'eventorganisation';
250 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
252 if (!empty($project->note_private)) {
255 if (!empty($project->note_public)) {
258 $head[$h][0] = DOL_URL_ROOT.
'/projet/note.php?id='.$project->id;
259 $head[$h][1] = $langs->trans(
'Notes');
261 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
263 $head[$h][2] =
'notes';
270 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
271 $cachekey =
'count_attached_project_'.$project->id;
273 if (!is_null($dataretrieved)) {
274 $totalAttached = $dataretrieved;
276 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
277 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
279 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
280 $nbLinks =
Link::count($db, $project->element, $project->id);
281 $totalAttached = $nbFiles + $nbLinks;
284 $head[$h][0] = DOL_URL_ROOT.
'/projet/document.php?id='.$project->id;
285 $head[$h][1] = $langs->trans(
'Documents');
286 if (($totalAttached) > 0) {
287 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
289 $head[$h][2] =
'document';
293 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) {
296 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
297 $cachekey =
'count_attached_project_'.$project->id;
299 if (!is_null($dataretrieved)) {
300 $nbComments = $dataretrieved;
305 $head[$h][0] = DOL_URL_ROOT.
'/projet/comment.php?id='.$project->id;
306 $head[$h][1] = $langs->trans(
"CommentLink");
307 if ($nbComments > 0) {
308 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
310 $head[$h][2] =
'project_comment';
314 $head[$h][0] = DOL_URL_ROOT.
'/projet/info.php?id='.$project->id;
315 $head[$h][1] = $langs->trans(
"Events");
316 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
318 $head[$h][1] .= $langs->trans(
"Agenda");
320 $head[$h][2] =
'agenda';
337 global $db, $langs, $conf, $user;
341 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/task.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
342 $head[$h][1] = $langs->trans(
"Task");
343 $head[$h][2] =
'task_task';
346 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
347 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/contact.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
348 $head[$h][1] = $langs->trans(
"TaskRessourceLinks");
349 if ($nbContact > 0) {
350 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
352 $head[$h][2] =
'task_contact';
357 $sql =
"SELECT t.rowid";
360 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
361 $sql .=
" WHERE t.fk_task = ".((int) $object->id);
362 $resql = $db->query($sql);
364 $obj = $db->fetch_object(
$resql);
372 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
373 $head[$h][1] = $langs->trans(
"TimeSpent");
374 if ($nbTimeSpent > 0) {
375 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
377 $head[$h][2] =
'task_time';
386 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
388 if (!empty($object->note_private)) {
391 if (!empty($object->note_public)) {
394 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/note.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
395 $head[$h][1] = $langs->trans(
'Notes');
397 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
399 $head[$h][2] =
'task_notes';
403 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/document.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
405 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
406 include_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
407 $nbFiles = count(
dol_dir_list($filesdir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
408 $nbLinks =
Link::count($db, $object->element, $object->id);
409 $head[$h][1] = $langs->trans(
'Documents');
410 if (($nbFiles + $nbLinks) > 0) {
411 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
413 $head[$h][2] =
'task_document';
417 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) {
418 $nbComments = $object->getNbComments();
419 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/comment.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
420 $head[$h][1] = $langs->trans(
"CommentLink");
421 if ($nbComments > 0) {
422 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
424 $head[$h][2] =
'task_comment';
442 global $langs, $conf, $user;
449 $param .= ($mode ?
'&mode='.$mode :
'');
450 if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
451 $param .=
'&search_usertoprocessid='.$fuser->id;
454 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) {
455 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/permonth.php".($param ?
'?'.$param :
'');
456 $head[$h][1] = $langs->trans(
"InputPerMonth");
457 $head[$h][2] =
'inputpermonth';
461 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) {
462 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perweek.php".($param ?
'?'.$param :
'');
463 $head[$h][1] = $langs->trans(
"InputPerWeek");
464 $head[$h][2] =
'inputperweek';
468 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) {
469 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perday.php".($param ?
'?'.$param :
'');
470 $head[$h][1] = $langs->trans(
"InputPerDay");
471 $head[$h][2] =
'inputperday';
490 global $langs, $conf, $user;
496 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project.php";
497 $head[$h][1] = $langs->trans(
"Projects");
498 $head[$h][2] =
'project';
503 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project_extrafields.php";
504 $head[$h][1] = $langs->trans(
"ExtraFieldsProject");
505 $head[$h][2] =
'attributes';
508 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/project_task_extrafields.php';
509 $head[$h][1] = $langs->trans(
"ExtraFieldsProjectTask");
510 $head[$h][2] =
'attributes_task';
513 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
514 $langs->load(
"members");
516 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/website.php';
517 $head[$h][1] = $langs->trans(
"BlankSubscriptionForm");
518 $head[$h][2] =
'website';
546 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc =
'', $showbilltime = 0, $arrayfields = array())
548 global $user, $langs, $conf, $db, $hookmanager;
549 global $projectstatic, $taskstatic, $extrafields;
553 $projectsArrayId = explode(
',', $projectsListId);
554 if ($filterprogresscalc !==
'') {
555 foreach ($lines as $key => $line) {
556 if (!empty($line->planned_workload) && !empty($line->duration)) {
557 $filterprogresscalc = str_replace(
' = ',
' == ', $filterprogresscalc);
558 if (!eval($filterprogresscalc)) {
563 $lines = array_values($lines);
565 $numlines = count($lines);
568 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;
571 $total_projectlinesa_spent = 0;
572 $total_projectlinesa_planned = 0;
573 $total_projectlinesa_spent_if_planned = 0;
574 $total_projectlinesa_declared_if_planned = 0;
575 $total_projectlinesa_tobill = 0;
576 $total_projectlinesa_billed = 0;
577 $total_budget_amount = 0;
580 for ($i = 0; $i < $numlines; $i++) {
581 if ($parent == 0 && $level >= 0) {
588 if ($lines[$i]->fk_parent == $parent || $level < 0) {
594 if (is_array($taskrole)) {
596 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_parent) {
598 $foundtaskforuserdeeper = 0;
601 if ($foundtaskforuserdeeper > 0) {
610 if (empty($user->rights->projet->all->lire)) {
612 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
623 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
625 $lastprojectid = $lines[$i]->fk_project;
628 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
630 $projectstatic->id = $lines[$i]->fk_project;
631 $projectstatic->ref = $lines[$i]->projectref;
632 $projectstatic->public = $lines[$i]->public;
633 $projectstatic->title = $lines[$i]->projectlabel;
634 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
635 $projectstatic->status = $lines[$i]->projectstatus;
637 $taskstatic->id = $lines[$i]->id;
638 $taskstatic->ref = $lines[$i]->ref;
639 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
640 $taskstatic->projectstatus = $lines[$i]->projectstatus;
641 $taskstatic->progress = $lines[$i]->progress;
642 $taskstatic->fk_statut = $lines[$i]->status;
643 $taskstatic->date_start = $lines[$i]->date_start;
644 $taskstatic->date_end = $lines[$i]->date_end;
645 $taskstatic->datee = $lines[$i]->date_end;
646 $taskstatic->planned_workload = $lines[$i]->planned_workload;
647 $taskstatic->duration_effective = $lines[$i]->duration;
648 $taskstatic->budget_amount = $lines[$i]->budget_amount;
653 print
'<td class="nowraponall">';
655 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
656 print $projectstatic->getNomUrl(1);
658 print $projectstatic->getNomUrl(1,
'nolink');
665 $projectstatic->statut = $lines[$i]->projectstatus;
666 print $projectstatic->getLibStatut(2);
671 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
672 print
'<td class="nowraponall">';
673 if ($showlineingray) {
674 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
676 print $taskstatic->getNomUrl(1,
'withproject');
682 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
684 if ($showlineingray) {
685 $labeltoshow .=
'<i>';
688 for ($k = 0; $k < $level; $k++) {
689 $labeltoshow .=
'<div class="marginleftonly">';
692 for ($k = 0; $k < $level; $k++) {
693 $labeltoshow .=
'</div>';
695 if ($showlineingray) {
696 $labeltoshow .=
'</i>';
698 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
703 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
704 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
705 print $lines[$i]->description;
710 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
711 print
'<td class="center nowraponall">';
717 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
718 print
'<td class="center nowraponall">';
720 if ($taskstatic->hasDelay()) {
726 $plannedworkloadoutputformat =
'allhourmin';
727 $timespentoutputformat =
'allhourmin';
728 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
729 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
731 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
732 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
736 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
737 print
'<td class="right">';
738 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
740 if ($lines[$i]->planned_workload !=
'') {
750 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
751 print
'<td class="right">';
752 if ($showlineingray) {
755 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
757 if ($lines[$i]->duration) {
762 if ($showlineingray) {
771 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
772 print
'<td class="right">';
773 if ($lines[$i]->planned_workload || $lines[$i]->duration) {
774 if ($lines[$i]->planned_workload) {
775 print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).
' %';
777 print
'<span class="opacitymedium">'.$langs->trans(
'WorkloadNotDefined').
'</span>';
784 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
785 print
'<td class="right">';
786 if ($lines[$i]->progress !=
'') {
793 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
794 print
'<td class="right">';
795 if ($lines[$i]->progress !=
'' && $lines[$i]->duration) {
803 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
804 print
'<td class="right">';
805 if ($lines[$i]->usage_bill_time) {
807 $total_projectlinesa_tobill += $lines[$i]->tobill;
809 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
815 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
816 print
'<td class="right">';
817 if ($lines[$i]->usage_bill_time) {
819 $total_projectlinesa_billed += $lines[$i]->billed;
821 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
828 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
829 print
'<td class="center">';
830 if ($lines[$i]->budget_amount) {
831 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
832 $total_budget_amount += $lines[$i]->budget_amount;
838 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
839 print
'<td class="center">';
841 foreach (array(
'internal',
'external') as $source) {
842 $tab = $lines[$i]->liste_contact(-1, $source);
843 $numcontact = count($tab);
844 if (!empty($numcontact)) {
845 foreach ($tab as $contacttask) {
847 if ($source ==
'internal') {
852 $c->fetch($contacttask[
'id']);
853 if (!empty($c->photo)) {
854 if (get_class($c) ==
'User') {
855 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
857 print $c->getNomUrl(-2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
860 if (get_class($c) ==
'User') {
861 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
863 print $c->getNomUrl(2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
874 $extrafieldsobjectkey = $taskstatic->table_element;
876 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
878 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$lines[$i]);
879 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
880 print $hookmanager->resPrint;
883 print
'<td class="tdlineupdown center"></td>';
887 if (!$showlineingray) {
893 if ($lines[$i]->
id) {
894 projectLinesa($inc, $lines[$i]->
id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
899 $total_projectlinesa_spent += $lines[$i]->duration;
900 $total_projectlinesa_planned += $lines[$i]->planned_workload;
901 if ($lines[$i]->planned_workload) {
902 $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
904 if ($lines[$i]->planned_workload) {
905 $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
913 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
915 print
'<tr class="liste_total nodrag nodrop">';
916 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
918 print
'<td></td><td></td>';
920 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
923 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
926 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
929 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
930 print
'<td class="nowrap liste_total right">';
934 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
935 print
'<td class="nowrap liste_total right">';
936 if ($projectidfortotallink > 0) {
937 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
940 if ($projectidfortotallink > 0) {
946 if ($total_projectlinesa_planned) {
947 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
948 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
951 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
954 $progressBarClass =
'progress-bar-info';
955 $badgeClass =
'badge ';
957 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
958 $progressBarClass =
'progress-bar-danger';
959 $badgeClass .=
'badge-danger';
960 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
961 $progressBarClass =
'progress-bar-warning';
962 $badgeClass .=
'badge-warning';
964 $progressBarClass =
'progress-bar-success';
965 $badgeClass .=
'badge-success';
970 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
971 print
'<td class="nowrap liste_total right">';
972 if ($total_projectlinesa_planned) {
973 print $totalCalculatedProgress.
' %';
979 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
980 print
'<td class="nowrap liste_total right">';
981 if ($total_projectlinesa_planned) {
982 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
989 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
990 print
'<td class="right">';
991 if ($total_projectlinesa_planned) {
993 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
994 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1001 if ($showbilltime) {
1002 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1003 print
'<td class="nowrap liste_total right">';
1007 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1008 print
'<td class="nowrap liste_total right">';
1015 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1016 print
'<td class="nowrap liste_total center">';
1017 if (strcmp($total_budget_amount,
'')) {
1018 print
price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1024 if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
1028 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1031 print
'<td class=""></td>';
1056 function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1058 global $conf, $db, $user, $langs;
1059 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1062 $totalforeachline = array();
1063 $workloadforid = array();
1064 $lineswithoutlevel0 = array();
1066 $numlines = count($lines);
1070 for ($i = 0; $i < $numlines; $i++) {
1071 if ($lines[$i]->fk_task_parent) {
1072 $lineswithoutlevel0[] = $lines[$i];
1077 if (empty($oldprojectforbreak)) {
1078 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1082 for ($i = 0; $i < $numlines; $i++) {
1090 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1094 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1095 $lastprojectid = $lines[$i]->fk_project;
1096 if ($preselectedday) {
1097 $projectstatic->id = $lines[$i]->fk_project;
1101 if (empty($workloadforid[$projectstatic->id])) {
1102 if ($preselectedday) {
1103 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1104 $workloadforid[$projectstatic->id] = 1;
1108 $projectstatic->id = $lines[$i]->fk_project;
1109 $projectstatic->ref = $lines[$i]->project_ref;
1110 $projectstatic->title = $lines[$i]->project_label;
1111 $projectstatic->public = $lines[$i]->public;
1112 $projectstatic->status = $lines[$i]->project_status;
1114 $taskstatic->id = $lines[$i]->task_id;
1115 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1116 $taskstatic->label = $lines[$i]->task_label;
1117 $taskstatic->date_start = $lines[$i]->date_start;
1118 $taskstatic->date_end = $lines[$i]->date_end;
1120 $thirdpartystatic->id = $lines[$i]->socid;
1121 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1122 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1124 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1125 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1126 print
'<td colspan="11">';
1127 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1128 if ($projectstatic->title) {
1130 print $projectstatic->title;
1136 if ($oldprojectforbreak != -1) {
1137 $oldprojectforbreak = $projectstatic->id;
1140 print
'<tr class="oddeven">'.
"\n";
1151 if ($oldprojectforbreak == -1) {
1152 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1153 print
'<br>'.$projectstatic->title;
1158 print
'<td class="tdoverflowmax100">';
1159 if ($thirdpartystatic->id > 0) {
1160 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1166 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1167 for ($k = 0; $k < $level; $k++) {
1168 print
" ";
1170 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1173 for ($k = 0; $k < $level; $k++) {
1174 print
" ";
1176 print $taskstatic->label;
1183 print
'<td class="center">';
1187 $disabledproject = 1;
1193 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1194 $disabledproject = 0;
1198 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1203 print
'<td class="nowrap center">';
1208 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1209 $cssonholiday .=
'onholidayallday ';
1210 } elseif (!$isavailable[$preselectedday][
'morning']) {
1211 $cssonholiday .=
'onholidaymorning ';
1212 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1213 $cssonholiday .=
'onholidayafternoon ';
1217 print
'<td class="duration'.($cssonholiday ?
' '.$cssonholiday :
'').
' center">';
1219 $dayWorkLoad = $lines[$i]->timespent_duration;
1220 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1223 if ($dayWorkLoad > 0) {
1229 $modeinput =
'hours';
1231 print
'<script type="text/javascript">';
1232 print
"jQuery(document).ready(function () {\n";
1233 print
" jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput.
"') });";
1240 print
'<td class="center">';
1241 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1242 print $lines[$i]->timespent_note;
1243 print
'</textarea>';
1247 print
'<td class="right">';
1267 return $totalforeachline;
1290 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1292 global $conf, $db, $user, $langs;
1293 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1296 $totalforeachday = array();
1297 $workloadforid = array();
1298 $lineswithoutlevel0 = array();
1300 $numlines = count($lines);
1304 for ($i = 0; $i < $numlines; $i++) {
1305 if ($lines[$i]->fk_task_parent) {
1306 $lineswithoutlevel0[] = $lines[$i];
1311 if (empty($oldprojectforbreak)) {
1312 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1315 $restrictBefore = null;
1317 if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1318 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1323 for ($i = 0; $i < $numlines; $i++) {
1328 if ($lines[$i]->fk_task_parent == $parent) {
1332 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1335 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1340 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1341 $lastprojectid = $lines[$i]->fk_project;
1342 if ($preselectedday) {
1343 $projectstatic->id = $lines[$i]->fk_project;
1347 if (empty($workloadforid[$projectstatic->id])) {
1348 if ($preselectedday) {
1349 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1350 $workloadforid[$projectstatic->id] = 1;
1354 $projectstatic->id = $lines[$i]->fk_project;
1355 $projectstatic->ref = $lines[$i]->projectref;
1356 $projectstatic->title = $lines[$i]->projectlabel;
1357 $projectstatic->public = $lines[$i]->public;
1358 $projectstatic->status = $lines[$i]->projectstatus;
1360 $taskstatic->id = $lines[$i]->id;
1361 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1362 $taskstatic->label = $lines[$i]->label;
1363 $taskstatic->date_start = $lines[$i]->date_start;
1364 $taskstatic->date_end = $lines[$i]->date_end;
1366 $thirdpartystatic->id = $lines[$i]->socid;
1367 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1368 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1370 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1372 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1375 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1378 foreach ($arrayfields as $key => $val) {
1379 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1384 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1385 print
'<td colspan="'.(7 + $addcolspan).
'">';
1386 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1387 if ($thirdpartystatic->id > 0) {
1388 print
' - '.$thirdpartystatic->getNomUrl(1);
1390 if ($projectstatic->title) {
1392 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1459 if ($oldprojectforbreak != -1) {
1460 $oldprojectforbreak = $projectstatic->id;
1463 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1473 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1475 if ($oldprojectforbreak == -1) {
1476 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1482 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1483 print
'<td class="tdoverflowmax100">';
1484 if ($thirdpartystatic->id > 0) {
1485 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1492 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1493 for ($k = 0; $k < $level; $k++) {
1494 print
'<div class="marginleftonly">';
1496 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1499 print
'<span class="opacitymedium">'.$taskstatic->label.
'</a>';
1500 for ($k = 0; $k < $level; $k++) {
1506 $extrafieldsobjectkey =
'projet_task';
1507 $extrafieldsobjectprefix =
'efpt.';
1508 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1511 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1512 print
'<td class="leftborder plannedworkload right">';
1513 if ($lines[$i]->planned_workload) {
1522 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1523 print
'<td class="right">';
1524 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1528 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1530 print
'<td class="right">';
1532 if ($lines[$i]->duration) {
1533 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1542 print
'<td class="right">';
1543 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1544 if ($tmptimespent[
'total_duration']) {
1552 $disabledproject = 1;
1558 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1559 $disabledproject = 0;
1563 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1567 if ($restrictBefore && $preselectedday < $restrictBefore) {
1572 print
'<td class="nowraponall leftborder center minwidth150imp">';
1573 $tableCell = $form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1578 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1579 $cssonholiday .=
'onholidayallday ';
1580 } elseif (!$isavailable[$preselectedday][
'morning']) {
1581 $cssonholiday .=
'onholidaymorning ';
1582 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1583 $cssonholiday .=
'onholidayafternoon ';
1589 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1590 global $numstartworkingday, $numendworkingday;
1592 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1593 $cssweekend =
'weekend';
1597 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1598 $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1599 $totalforeachday[$preselectedday] += $dayWorkLoad;
1602 if ($dayWorkLoad > 0) {
1609 $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>';
1610 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1612 $tableCell .= $form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1616 $modeinput =
'hours';
1618 print
'<script type="text/javascript">';
1619 print
"jQuery(document).ready(function () {\n";
1620 print
" jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput.
"') });";
1627 print
'<td class="center">';
1628 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1629 print
'</textarea>';
1633 print
'<td class="right">';
1634 if ((!$lines[$i]->
public) && $disabledproject) {
1635 print $form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1636 } elseif ($disabledtask) {
1637 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1638 if ($fuser->id != $user->id) {
1639 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1642 print $form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1651 if ($lines[$i]->
id > 0) {
1654 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1657 foreach ($ret as $key => $val) {
1658 $totalforeachday[$key] += $val;
1669 return $totalforeachday;
1692 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
1694 global $conf, $db, $user, $langs;
1695 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1697 $numlines = count($lines);
1700 $workloadforid = array();
1701 $totalforeachday = array();
1702 $lineswithoutlevel0 = array();
1706 for ($i = 0; $i < $numlines; $i++) {
1707 if ($lines[$i]->fk_task_parent) {
1708 $lineswithoutlevel0[] = $lines[$i];
1715 if (empty($oldprojectforbreak)) {
1716 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1719 $restrictBefore = null;
1721 if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1722 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1726 for ($i = 0; $i < $numlines; $i++) {
1731 if ($lines[$i]->fk_task_parent == $parent) {
1735 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1738 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1743 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1744 $lastprojectid = $lines[$i]->fk_project;
1745 $projectstatic->id = $lines[$i]->fk_project;
1750 if (empty($workloadforid[$projectstatic->id])) {
1751 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1752 $workloadforid[$projectstatic->id] = 1;
1757 $projectstatic->id = $lines[$i]->fk_project;
1758 $projectstatic->ref = $lines[$i]->projectref;
1759 $projectstatic->title = $lines[$i]->projectlabel;
1760 $projectstatic->public = $lines[$i]->public;
1761 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1762 $projectstatic->status = $lines[$i]->projectstatus;
1764 $taskstatic->id = $lines[$i]->id;
1765 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1766 $taskstatic->label = $lines[$i]->label;
1767 $taskstatic->date_start = $lines[$i]->date_start;
1768 $taskstatic->date_end = $lines[$i]->date_end;
1770 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1771 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1772 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1774 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1776 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1779 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1782 foreach ($arrayfields as $key => $val) {
1783 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1788 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1789 print
'<td colspan="'.(11 + $addcolspan).
'">';
1790 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1791 if ($thirdpartystatic->id > 0) {
1792 print
' - '.$thirdpartystatic->getNomUrl(1);
1794 if ($projectstatic->title) {
1796 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1863 if ($oldprojectforbreak != -1) {
1864 $oldprojectforbreak = $projectstatic->id;
1867 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1877 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1878 print
'<td class="nowrap">';
1879 if ($oldprojectforbreak == -1) {
1880 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1886 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1887 print
'<td class="tdoverflowmax100">';
1888 if ($thirdpartystatic->id > 0) {
1889 print $thirdpartystatic->getNomUrl(1,
'project');
1895 print
'<td class="nowrap">';
1896 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1897 for ($k = 0; $k < $level; $k++) {
1898 print
'<div class="marginleftonly">';
1900 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1903 print
'<span class="opacitymedium">'.$taskstatic->label.
'</span>';
1904 for ($k = 0; $k < $level; $k++) {
1910 $extrafieldsobjectkey =
'projet_task';
1911 $extrafieldsobjectprefix =
'efpt.';
1912 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1915 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1916 print
'<td class="leftborder plannedworkload right">';
1917 if ($lines[$i]->planned_workload) {
1925 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1927 print
'<td class="right">';
1928 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1932 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1934 print
'<td class="right">';
1936 if ($lines[$i]->duration) {
1937 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1946 print
'<td class="right">';
1947 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1948 if ($tmptimespent[
'total_duration']) {
1956 $disabledproject = 1;
1962 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1963 $disabledproject = 0;
1967 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1975 $modeinput =
'hours';
1976 for ($idw = 0; $idw < 7; $idw++) {
1980 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
1981 $cssonholiday .=
'onholidayallday ';
1982 } elseif (!$isavailable[$tmpday][
'morning']) {
1983 $cssonholiday .=
'onholidaymorning ';
1984 } elseif (!$isavailable[$tmpday][
'afternoon']) {
1985 $cssonholiday .=
'onholidayafternoon ';
1989 $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
1990 $totalforeachday[$tmpday] += $dayWorkLoad;
1993 if ($dayWorkLoad > 0) {
1996 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", $tmparray[
'day'], $tmparray[
'mon']);
1998 global $numstartworkingday, $numendworkingday;
2000 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
2001 $cssweekend =
'weekend';
2004 $disabledtaskday = $disabledtask;
2006 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2007 $disabledtaskday = 1;
2010 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
2013 if ($alreadyspent) {
2014 $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>';
2018 $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"';
2019 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2020 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
2021 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
2022 $tableCell .= '</td>';
2027 print '<td class="right
">';
2028 if ((!$lines[$i]->public) && $disabledproject) {
2029 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2030 } elseif ($disabledtask) {
2031 $titleassigntask = $langs->trans("AssignTaskToMe
");
2032 if ($fuser->id != $user->id) {
2033 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2036 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2043 // Call to show task with a lower level (task under the current task)
2046 if ($lines[$i]->id > 0) {
2047 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2048 //var_dump($totalforeachday);
2049 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2050 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2052 foreach ($ret as $key => $val) {
2053 $totalforeachday[$key] += $val;
2055 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2056 //var_dump($totalforeachday);
2064 return $totalforeachday;
2085 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
2087 global $conf, $db, $user, $langs;
2088 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2090 $numlines = count($lines);
2093 $workloadforid = array();
2094 $totalforeachweek = array();
2095 $lineswithoutlevel0 = array();
2097 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2098 if ($parent == 0) { // Always and only if at first level
2099 for ($i = 0; $i < $numlines; $i++) {
2100 if ($lines[$i]->fk_task_parent) {
2101 $lineswithoutlevel0[] = $lines[$i];
2106 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
2108 if (empty($oldprojectforbreak)) {
2109 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
2112 $restrictBefore = null;
2114 if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
2115 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2116 $restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
2119 for ($i = 0; $i < $numlines; $i++) {
2124 if ($lines[$i]->fk_task_parent == $parent) {
2125 // If we want all or we have a role on task, we show it
2126 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2127 //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);
2129 // Break on a new project
2130 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2131 $lastprojectid = $lines[$i]->fk_project;
2132 $projectstatic->id = $lines[$i]->fk_project;
2135 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2136 //var_dump($projectstatic->weekWorkLoadPerTask);
2137 if (empty($workloadforid[$projectstatic->id])) {
2138 $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
2139 $workloadforid[$projectstatic->id] = 1;
2141 //var_dump($projectstatic->weekWorkLoadPerTask);
2142 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2144 $projectstatic->id = $lines[$i]->fk_project;
2145 $projectstatic->ref = $lines[$i]->projectref;
2146 $projectstatic->title = $lines[$i]->projectlabel;
2147 $projectstatic->public = $lines[$i]->public;
2148 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2149 $projectstatic->status = $lines[$i]->projectstatus;
2151 $taskstatic->id = $lines[$i]->id;
2152 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2153 $taskstatic->label = $lines[$i]->label;
2154 $taskstatic->date_start = $lines[$i]->date_start;
2155 $taskstatic->date_end = $lines[$i]->date_end;
2157 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2158 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2159 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2161 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2162 print '<tr class="oddeven trforbreak nobold
">'."\n
";
2163 print '<td colspan="'.(6 + count($TWeek)).'">';
2164 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2165 if ($thirdpartystatic->id > 0) {
2166 print ' - '.$thirdpartystatic->getNomUrl(1);
2168 if ($projectstatic->title) {
2170 print '<span class="secondary
">'.$projectstatic->title.'</span>';
2176 if ($oldprojectforbreak != -1) {
2177 $oldprojectforbreak = $projectstatic->id;
2179 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
2183 print '<td class="nowrap
">';
2184 print $fuser->getNomUrl(1, 'withproject', 'time');
2189 /*print '<td class="nowrap
">';
2190 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
2194 /*print '<td class="tdoverflowmax100
">';
2195 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2199 print '<td class="nowrap
">';
2200 print '<!-- Task id = '.$lines[$i]->id.' -->';
2201 for ($k = 0; $k < $level; $k++) {
2202 print '<div class="marginleftonly
">';
2204 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2207 print '<span class="opacitymedium
">'.$taskstatic->label.'</span>';
2208 for ($k = 0; $k < $level; $k++) {
2214 print '<td class="leftborder plannedworkload right
">';
2215 if ($lines[$i]->planned_workload) {
2216 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2222 // Progress declared %
2223 print '<td class="right
">';
2224 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2227 // Time spent by everybody
2228 print '<td class="right
">';
2229 // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
2230 if ($lines[$i]->duration) {
2231 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2232 print convertSecondToTime($lines[$i]->duration, 'allhourmin');
2239 // Time spent by user
2240 print '<td class="right
">';
2241 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2242 if ($tmptimespent['total_duration']) {
2243 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2249 $disabledproject = 1;
2251 //print "x
".$lines[$i]->fk_project;
2252 //var_dump($lines[$i]);
2253 //var_dump($projectsrole[$lines[$i]->fk_project]);
2254 // If at least one role for project
2255 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2256 $disabledproject = 0;
2259 // If $restricteditformytask is on and I have no role on task, i disable edit
2260 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2264 //var_dump($projectstatic->weekWorkLoadPerTask);
2266 // Fields to show current time
2268 $modeinput = 'hours';
2269 $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
2270 $TFirstDay[reset($TWeek)] = 1;
2272 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2273 $year = $firstdaytoshowarray['year'];
2274 $month = $firstdaytoshowarray['mon'];
2275 foreach ($TWeek as $weekIndex => $weekNb) {
2276 $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
2277 $totalforeachweek[$weekNb] += $weekWorkLoad;
2280 if ($weekWorkLoad > 0) {
2281 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2283 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2285 $disabledtaskweek = $disabledtask;
2286 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2288 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2289 $disabledtaskweek = 1;
2292 $tableCell = '<td class="center hide weekend
">';
2294 if ($alreadyspent) {
2295 $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>';
2296 //$placeholder=' placeholder="00:00
"';
2300 $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
"';
2301 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2302 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2303 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2304 $tableCell .= '</td>';
2309 print '<td class="right
">';
2310 if ((!$lines[$i]->public) && $disabledproject) {
2311 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2312 } elseif ($disabledtask) {
2313 $titleassigntask = $langs->trans("AssignTaskToMe
");
2314 if ($fuser->id != $user->id) {
2315 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2318 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2325 // Call to show task with a lower level (task under the current task)
2328 if ($lines[$i]->id > 0) {
2329 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2330 //var_dump($totalforeachday);
2331 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2332 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2334 foreach ($ret as $key => $val) {
2335 $totalforeachweek[$key] += $val;
2337 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2338 //var_dump($totalforeachday);
2346 return $totalforeachweek;
2359 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2361 //print 'Search in line with parent id = '.$parent.'<br>';
2362 $numlines = count($lines);
2363 for ($i = 0; $i < $numlines; $i++) {
2364 // Process line $lines[$i]
2365 if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) {
2366 // If task is legitimate to show, no more need to search deeper
2367 if (isset($taskrole[$lines[$i]->id])) {
2368 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2373 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2374 //print 'Found inc='.$inc.'<br>';
2398 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array())
2400 global $langs, $conf, $user;
2401 global $theme_datacolor;
2403 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2405 $listofstatus = array_keys($listofoppstatus);
2407 if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2408 // Define $themeColorId and array $statusOppList for each $listofstatus
2410 $statusOppList = array();
2411 foreach ($listofstatus as $oppStatus) {
2412 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2413 if ($oppStatusCode) {
2414 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2415 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2421 $projectstatic = new Project($db);
2422 $thirdpartystatic = new Societe($db);
2426 $project_year_filter = 0;
2428 $title = $langs->trans("Projects");
2429 if (strcmp($status, '') && $status >= 0) {
2430 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2433 $arrayidtypeofcontact = array();
2435 print '<div class="div-table-responsive-no-min
">';
2436 print '<table class="noborder centpercent
">';
2438 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2440 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2441 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2442 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2444 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2446 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2447 $sql .= " AND p.rowid IN (
".$db->sanitize($projectsListId).")
";
2449 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2452 $sql .= " AND p.rowid = t.fk_projet
";
2453 $sql .= " AND ec.element_id = t.rowid
";
2454 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2455 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2456 $sql .= " AND ctc.element =
'project_task'";
2459 $sql .= " AND p.fk_statut =
".(int) $status;
2461 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2462 $project_year_filter = GETPOST("project_year_filter
");
2463 //Check if empty or invalid year. Wildcard ignores the sql check
2464 if ($project_year_filter != "*
") {
2465 if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
2466 $project_year_filter = date("Y
");
2468 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")
";
2469 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")
";
2473 // Get id of project we must show tasks
2474 $arrayidofprojects = array();
2475 $sql1 = "SELECT p.rowid as projectid
";
2477 $resql = $db->query($sql1);
2480 $num = $db->num_rows($resql);
2482 $objp = $db->fetch_object($resql);
2483 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2487 dol_print_error($db);
2489 if (empty($arrayidofprojects)) {
2490 $arrayidofprojects[0] = -1;
2493 // Get list of project with calculation on tasks
2494 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2495 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2496 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2497 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2498 $sql2 .= " s.logo, s.email, s.entity,
";
2499 $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,
";
2500 $sql2 .= " p.dateo, p.datee,
";
2501 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2502 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2503 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.
rowid = p.fk_soc";
2504 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.
rowid = t.fk_projet";
2505 $sql2 .= " WHERE p.
rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")";
2506 $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,";
2507 $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";
2508 $sql2 .= " ORDER BY p.title, p.ref";
2510 $resql = $db->query($sql2);
2513 $total_opp_amount = 0;
2514 $ponderated_opp_amount = 0;
2516 $num = $db->num_rows($resql);
2519 print
'<tr class="liste_titre">';
2520 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);
2522 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2523 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2524 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2526 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 ');
2529 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2531 if (!in_array(
'plannedworkload', $hiddenfields)) {
2532 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2534 if (!in_array(
'declaredprogress', $hiddenfields)) {
2535 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2538 if (!in_array(
'projectstatus', $hiddenfields)) {
2543 $total_plannedworkload = 0;
2544 $total_declaredprogressworkload = 0;
2546 $objp = $db->fetch_object($resql);
2548 $projectstatic->id = $objp->projectid;
2549 $projectstatic->user_author_id = $objp->fk_user_creat;
2550 $projectstatic->public = $objp->public;
2553 $userAccess = $projectstatic->restrictedProjectArea($user);
2554 if ($userAccess >= 0) {
2555 $projectstatic->ref = $objp->ref;
2556 $projectstatic->status = $objp->status;
2557 $projectstatic->title = $objp->title;
2558 $projectstatic->date_end = $db->jdate($objp->datee);
2559 $projectstatic->date_start = $db->jdate($objp->dateo);
2561 print
'<tr class="oddeven">';
2563 print
'<td class="tdoverflowmax150">';
2564 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2565 if (!in_array(
'projectlabel', $hiddenfields)) {
2566 print
'<br><span class="opacitymedium">'.dol_trunc($objp->title, 24).
'</span>';
2570 print
'<td class="nowraponall tdoverflowmax100">';
2571 if ($objp->fk_soc > 0) {
2572 $thirdpartystatic->id = $objp->socid;
2573 $thirdpartystatic->name = $objp->socname;
2576 $thirdpartystatic->code_compta = $objp->code_compta;
2577 $thirdpartystatic->client = $objp->client;
2579 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2580 $thirdpartystatic->fournisseur = $objp->fournisseur;
2581 $thirdpartystatic->logo = $objp->logo;
2582 $thirdpartystatic->email = $objp->email;
2583 $thirdpartystatic->entity = $objp->entity;
2584 print $thirdpartystatic->getNomUrl(1);
2588 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2589 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2590 print
'<td class="center tdoverflowmax75">';
2592 if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2593 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2594 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2595 print $langs->trans(
"OppStatus".$oppStatusCode);
2598 if (isset($statusOppList[$objp->opp_status])) {
2599 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2600 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2602 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2603 $oppStatusColor =
'';
2605 if ($oppStatusCode) {
2606 if (!empty($oppStatusColor)) {
2607 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>';
2609 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2616 print
'<td class="right">';
2617 if ($objp->opp_percent && $objp->opp_amount) {
2618 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2619 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0, $conf->currency);
2620 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2622 if ($objp->opp_amount) {
2623 print
'<span class="amount" title="'.$alttext.
'">'.$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2628 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2629 print
'<td class="right">'.$objp->nb.
'</td>';
2631 $plannedworkload = $objp->planned_workload;
2632 $total_plannedworkload += $plannedworkload;
2633 if (!in_array(
'plannedworkload', $hiddenfields)) {
2634 print
'<td class="right">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2636 if (!in_array(
'declaredprogress', $hiddenfields)) {
2637 $declaredprogressworkload = $objp->declared_progess_workload;
2638 $total_declaredprogressworkload += $declaredprogressworkload;
2639 print
'<td class="right">';
2641 print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2646 if (!in_array(
'projectstatus', $hiddenfields)) {
2647 print
'<td class="right">';
2648 print $projectstatic->getLibStatut(3);
2654 $total_task = $total_task + $objp->nb;
2655 $total_opp_amount = $total_opp_amount + $objp->opp_amount;
2661 print
'<tr class="liste_total">';
2662 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2663 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2664 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2665 print
'<td class="liste_total"></td>';
2667 print
'<td class="liste_total right">';
2669 print $form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0, $conf->currency));
2672 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2673 print
'<td class="liste_total right">'.$total_task.
'</td>';
2674 if (!in_array(
'plannedworkload', $hiddenfields)) {
2675 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2677 if (!in_array(
'declaredprogress', $hiddenfields)) {
2678 print
'<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2681 if (!in_array(
'projectstatus', $hiddenfields)) {
2682 print
'<td class="liste_total"></td>';
2694 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2696 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2697 print
'<table width="100%">';
2699 print
'<td>'.$langs->trans(
"Year").
'</td>';
2700 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.
'"/>';
2702 print
'</table></form>';
2715 function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2717 global $langs, $conf;
2721 $plannedworkloadoutputformat =
'allhourmin';
2722 $timespentoutputformat =
'allhourmin';
2723 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
2724 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2726 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
2727 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2730 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2734 $spaced = !empty($spaced) ?
'spaced' :
'';
2739 $progressBarClass =
'progress-bar-info';
2740 $progressCalculated = 0;
2741 if ($task->planned_workload) {
2742 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2745 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2747 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.($task->progress ?
'%' :
'');
2748 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.($progressCalculated ?
'%' :
'');
2751 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2752 $progressBarClass =
'progress-bar-danger';
2753 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2754 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2755 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2756 $progressBarClass =
'progress-bar-warning';
2757 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2758 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2760 $progressBarClass =
'progress-bar-success';
2761 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2762 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2766 $out .=
'<div class="progress-group">';
2768 if ($label !==
false) {
2769 $out .=
' <span class="progress-text">';
2771 if ($label !==
true) {
2780 if ($progressNumber !==
false) {
2781 $out .=
' <span class="progress-number">';
2782 if ($progressNumber !==
true) {
2783 $out .= $progressNumber;
2785 if ($task->hasDelay()) {
2789 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2791 $out .= !empty($diff) ? $diff.
' ' :
'';
2792 $out .=
'<a href="'.$url.
'" >';
2793 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2794 if ($task->duration_effective) {
2804 $out .=
'<a href="'.$url.
'" >';
2805 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2806 if ($task->planned_workload) {
2818 $out .=
' <div class="progress sm '.$spaced.
'">';
2819 $diffval = floatval($task->progress) - floatval($progressCalculated);
2820 if ($diffval >= 0) {
2822 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.floatval($task->progress).
'%" title="'.floatval($task->progress).
'%">';
2823 if (!empty($task->progress)) {
2824 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated / $task->progress * 100).
'%" title="'.floatval($progressCalculated).
'%"></div>';
2829 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).
'%" title="'.floatval($progressCalculated).
'%">';
2830 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.($task->progress ? floatval($task->progress / $progressCalculated * 100).
'%' :
'1px').
'" title="'.floatval($task->progress).
'%"></div>';
2849 global $conf, $langs;
2853 if ($task->progress !=
'') {
2857 $badgeClass =
'badge ';
2858 if ($task->planned_workload) {
2859 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2862 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2864 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2865 $badgeClass .=
'badge-danger';
2866 if (empty($tooltip)) {
2867 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2869 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2870 $badgeClass .=
'badge-warning';
2871 if (empty($tooltip)) {
2872 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2875 $badgeClass .=
'badge-success';
2876 if (empty($tooltip)) {
2877 $tooltip = $task->progress.
'% >= '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2884 if (!empty($tooltip)) {
2885 $badgeClass .=
' classfortooltip';
2886 $title =
'title="'.dol_htmlentities($tooltip).
'"';
2889 if (empty($label)) {
2890 $label = $task->progress.
' %';
2893 if (!empty($label)) {
2894 $out =
'<span class="'.$badgeClass.
'" '.$title.
' >'.$label.
'</span>';
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
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 intput mode.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
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 intput mode.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId= '', $addordertick=0, $projectidfortotallink=0, $filterprogresscalc= '', $showbilltime=0, $arrayfields=array())
Show task lines with a particular parent.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
getElementCount($type, $tablename, $projectkey= 'fk_projet')
Return the count of a type of linked elements of this project.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
Search in task lines with a particular parent if there is a task for a particular user (in taskrole) ...
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0)
Output a task line into a pertime intput mode.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)
getTaskProgressBadge($task, $label= '', $tooltip= '')
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class for ConferenceOrBooth.
isModEnabled($module)
Is Dolibarr module enabled.
liste_contact($status=-1, $source= 'external', $list=0, $code= '')
Get array of all contacts for an object.
getNbComments()
Return nb comments already posted.
project_admin_prepare_head()
Prepare array with list of tabs.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
convertSecondToTime($iSecond, $format= 'all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
task_prepare_head($object)
Prepare array with list of tabs.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid