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';
291 $upload_dir = $conf->project->multidir_output[$project->entity].
"/".
dol_sanitizeFileName($project->ref);
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';
574 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc =
'', $showbilltime = 0, $arrayfields = array())
576 global $user, $langs, $conf, $db, $hookmanager;
577 global $projectstatic, $taskstatic, $extrafields;
581 $projectsArrayId = explode(
',', $projectsListId);
582 if ($filterprogresscalc !==
'') {
583 foreach ($lines as $key => $line) {
584 if (!empty($line->planned_workload) && !empty($line->duration)) {
585 $filterprogresscalc = str_replace(
' = ',
' == ', $filterprogresscalc);
586 if (!eval($filterprogresscalc)) {
591 $lines = array_values($lines);
593 $numlines = count($lines);
596 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;
599 $total_projectlinesa_spent = 0;
600 $total_projectlinesa_planned = 0;
601 $total_projectlinesa_spent_if_planned = 0;
602 $total_projectlinesa_declared_if_planned = 0;
603 $total_projectlinesa_tobill = 0;
604 $total_projectlinesa_billed = 0;
605 $total_budget_amount = 0;
608 for ($i = 0; $i < $numlines; $i++) {
609 if ($parent == 0 && $level >= 0) {
616 if ($lines[$i]->fk_parent == $parent || $level < 0) {
622 if (is_array($taskrole)) {
624 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_parent) {
626 $foundtaskforuserdeeper = 0;
629 if ($foundtaskforuserdeeper > 0) {
638 if (empty($user->rights->projet->all->lire)) {
640 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
651 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
653 $lastprojectid = $lines[$i]->fk_project;
656 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
658 $projectstatic->id = $lines[$i]->fk_project;
659 $projectstatic->ref = $lines[$i]->projectref;
660 $projectstatic->public = $lines[$i]->public;
661 $projectstatic->title = $lines[$i]->projectlabel;
662 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
663 $projectstatic->status = $lines[$i]->projectstatus;
665 $taskstatic->id = $lines[$i]->id;
666 $taskstatic->ref = $lines[$i]->ref;
667 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
668 $taskstatic->projectstatus = $lines[$i]->projectstatus;
669 $taskstatic->progress = $lines[$i]->progress;
670 $taskstatic->fk_statut = $lines[$i]->status;
671 $taskstatic->date_start = $lines[$i]->date_start;
672 $taskstatic->date_end = $lines[$i]->date_end;
673 $taskstatic->datee = $lines[$i]->date_end;
674 $taskstatic->planned_workload = $lines[$i]->planned_workload;
675 $taskstatic->duration_effective = $lines[$i]->duration;
676 $taskstatic->budget_amount = $lines[$i]->budget_amount;
681 print
'<td class="nowraponall">';
683 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
684 print $projectstatic->getNomUrl(1);
686 print $projectstatic->getNomUrl(1,
'nolink');
693 $projectstatic->statut = $lines[$i]->projectstatus;
694 print $projectstatic->getLibStatut(2);
699 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
700 print
'<td class="nowraponall">';
701 if ($showlineingray) {
702 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
704 print $taskstatic->getNomUrl(1,
'withproject');
710 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
712 if ($showlineingray) {
713 $labeltoshow .=
'<i>';
716 for ($k = 0; $k < $level; $k++) {
717 $labeltoshow .=
'<div class="marginleftonly">';
720 for ($k = 0; $k < $level; $k++) {
721 $labeltoshow .=
'</div>';
723 if ($showlineingray) {
724 $labeltoshow .=
'</i>';
726 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
731 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
732 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
733 print $lines[$i]->description;
738 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
739 print
'<td class="center nowraponall">';
745 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
746 print
'<td class="center nowraponall">';
748 if ($taskstatic->hasDelay()) {
754 $plannedworkloadoutputformat =
'allhourmin';
755 $timespentoutputformat =
'allhourmin';
756 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
757 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
759 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
760 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
764 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
765 print
'<td class="right">';
766 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
768 if ($lines[$i]->planned_workload !=
'') {
778 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
779 print
'<td class="right">';
780 if ($showlineingray) {
783 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
785 if ($lines[$i]->duration) {
790 if ($showlineingray) {
799 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
800 print
'<td class="right">';
801 if ($lines[$i]->planned_workload || $lines[$i]->duration) {
802 if ($lines[$i]->planned_workload) {
803 print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).
' %';
805 print
'<span class="opacitymedium">'.$langs->trans(
'WorkloadNotDefined').
'</span>';
812 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
813 print
'<td class="right">';
814 if ($lines[$i]->progress !=
'') {
821 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
822 print
'<td class="right">';
823 if ($lines[$i]->progress !=
'' && $lines[$i]->duration) {
831 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
832 print
'<td class="right">';
833 if ($lines[$i]->usage_bill_time) {
835 $total_projectlinesa_tobill += $lines[$i]->tobill;
837 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
843 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
844 print
'<td class="right">';
845 if ($lines[$i]->usage_bill_time) {
847 $total_projectlinesa_billed += $lines[$i]->billed;
849 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
856 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
857 print
'<td class="center">';
858 if ($lines[$i]->budget_amount) {
859 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
860 $total_budget_amount += $lines[$i]->budget_amount;
866 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
867 print
'<td class="center">';
869 foreach (array(
'internal',
'external') as $source) {
870 $tab = $lines[$i]->liste_contact(-1, $source);
871 $numcontact = count($tab);
872 if (!empty($numcontact)) {
873 foreach ($tab as $contacttask) {
875 if ($source ==
'internal') {
880 $c->fetch($contacttask[
'id']);
881 if (!empty($c->photo)) {
882 if (get_class($c) ==
'User') {
883 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
885 print $c->getNomUrl(-2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
888 if (get_class($c) ==
'User') {
889 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
891 print $c->getNomUrl(2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
902 $extrafieldsobjectkey = $taskstatic->table_element;
904 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
906 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$lines[$i]);
907 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
908 print $hookmanager->resPrint;
911 print
'<td class="tdlineupdown center"></td>';
915 if (!$showlineingray) {
921 if ($lines[$i]->
id) {
922 projectLinesa($inc, $lines[$i]->
id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
927 $total_projectlinesa_spent += $lines[$i]->duration;
928 $total_projectlinesa_planned += $lines[$i]->planned_workload;
929 if ($lines[$i]->planned_workload) {
930 $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
932 if ($lines[$i]->planned_workload) {
933 $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
941 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
943 print
'<tr class="liste_total nodrag nodrop">';
944 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
946 print
'<td></td><td></td>';
948 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.label'][
'checked'])) {
951 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.description'][
'checked'])) {
954 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.dateo'][
'checked'])) {
957 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.datee'][
'checked'])) {
960 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.planned_workload'][
'checked'])) {
961 print
'<td class="nowrap liste_total right">';
965 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.duration_effective'][
'checked'])) {
966 print
'<td class="nowrap liste_total right">';
967 if ($projectidfortotallink > 0) {
968 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
971 if ($projectidfortotallink > 0) {
977 if ($total_projectlinesa_planned) {
978 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
979 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
982 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
985 $progressBarClass =
'progress-bar-info';
986 $badgeClass =
'badge ';
988 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
989 $progressBarClass =
'progress-bar-danger';
990 $badgeClass .=
'badge-danger';
991 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
992 $progressBarClass =
'progress-bar-warning';
993 $badgeClass .=
'badge-warning';
995 $progressBarClass =
'progress-bar-success';
996 $badgeClass .=
'badge-success';
1001 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
1002 print
'<td class="nowrap liste_total right">';
1003 if ($total_projectlinesa_planned) {
1004 print $totalCalculatedProgress.
' %';
1010 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
1011 print
'<td class="nowrap liste_total right">';
1012 if ($total_projectlinesa_planned) {
1013 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
1020 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
1021 print
'<td class="right">';
1022 if ($total_projectlinesa_planned) {
1024 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
1025 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1032 if ($showbilltime) {
1033 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1034 print
'<td class="nowrap liste_total right">';
1038 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1039 print
'<td class="nowrap liste_total right">';
1046 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1047 print
'<td class="nowrap liste_total center">';
1048 if (strcmp($total_budget_amount,
'')) {
1049 print
price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1055 if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
1059 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1062 if (! empty($totalarray[
'nbfield'])) {
1063 print
'<td colspan="'.$totalarray[
'nbfield'].
'" class=""></td>';
1065 print
'<td class=""></td>';
1092 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1094 global $conf, $db, $user, $langs;
1095 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1098 $totalforeachday = array();
1099 $workloadforid = array();
1100 $lineswithoutlevel0 = array();
1102 $numlines = count($lines);
1106 for ($i = 0; $i < $numlines; $i++) {
1107 if ($lines[$i]->fk_task_parent) {
1108 $lineswithoutlevel0[] = $lines[$i];
1113 if (empty($oldprojectforbreak)) {
1114 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1117 $restrictBefore =
null;
1119 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1120 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1125 for ($i = 0; $i < $numlines; $i++) {
1130 if ($lines[$i]->fk_task_parent == $parent) {
1134 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1137 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1142 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1143 $lastprojectid = $lines[$i]->fk_project;
1144 if ($preselectedday) {
1145 $projectstatic->id = $lines[$i]->fk_project;
1149 if (empty($workloadforid[$projectstatic->id])) {
1150 if ($preselectedday) {
1151 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1152 $workloadforid[$projectstatic->id] = 1;
1156 $projectstatic->id = $lines[$i]->fk_project;
1157 $projectstatic->ref = $lines[$i]->projectref;
1158 $projectstatic->title = $lines[$i]->projectlabel;
1159 $projectstatic->public = $lines[$i]->public;
1160 $projectstatic->status = $lines[$i]->projectstatus;
1162 $taskstatic->id = $lines[$i]->id;
1163 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1164 $taskstatic->label = $lines[$i]->label;
1165 $taskstatic->date_start = $lines[$i]->date_start;
1166 $taskstatic->date_end = $lines[$i]->date_end;
1168 $thirdpartystatic->id = $lines[$i]->socid;
1169 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1170 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1172 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1174 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1177 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1180 foreach ($arrayfields as $key => $val) {
1181 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1186 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1187 print
'<td colspan="'.(7 + $addcolspan).
'">';
1188 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1189 if ($thirdpartystatic->id > 0) {
1190 print
' - '.$thirdpartystatic->getNomUrl(1);
1192 if ($projectstatic->title) {
1194 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1261 if ($oldprojectforbreak != -1) {
1262 $oldprojectforbreak = $projectstatic->id;
1265 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1275 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1277 if ($oldprojectforbreak == -1) {
1278 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1284 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1285 print
'<td class="tdoverflowmax100">';
1286 if ($thirdpartystatic->id > 0) {
1287 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1294 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1295 for ($k = 0; $k < $level; $k++) {
1296 print
'<div class="marginleftonly">';
1298 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1301 print
'<span class="opacitymedium">'.$taskstatic->label.
'</a>';
1302 for ($k = 0; $k < $level; $k++) {
1308 $extrafieldsobjectkey =
'projet_task';
1309 $extrafieldsobjectprefix =
'efpt.';
1310 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1313 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1314 print
'<td class="leftborder plannedworkload right">';
1315 if ($lines[$i]->planned_workload) {
1324 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1325 print
'<td class="right">';
1326 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1330 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1332 print
'<td class="right">';
1334 if ($lines[$i]->duration) {
1335 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1344 print
'<td class="right">';
1345 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1346 if ($tmptimespent[
'total_duration']) {
1354 $disabledproject = 1;
1360 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1361 $disabledproject = 0;
1365 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1369 if ($restrictBefore && $preselectedday < $restrictBefore) {
1374 print
'<td class="nowraponall leftborder center minwidth150imp">';
1375 $tableCell =
$form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1380 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1381 $cssonholiday .=
'onholidayallday ';
1382 } elseif (!$isavailable[$preselectedday][
'morning']) {
1383 $cssonholiday .=
'onholidaymorning ';
1384 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1385 $cssonholiday .=
'onholidayafternoon ';
1391 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1392 global $numstartworkingday, $numendworkingday;
1394 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1395 $cssweekend =
'weekend';
1399 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1400 $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0;
1401 if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0;
1402 $totalforeachday[$preselectedday] += $dayWorkLoad;
1405 if ($dayWorkLoad > 0) {
1412 $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>';
1413 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1415 $tableCell .=
$form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1431 print
'<td class="center">';
1432 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1433 print
'</textarea>';
1437 print
'<td class="right">';
1438 if ((!$lines[$i]->
public) && $disabledproject) {
1439 print
$form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1440 } elseif ($disabledtask) {
1441 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1442 if ($fuser->id != $user->id) {
1443 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1446 print
$form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1455 if ($lines[$i]->
id > 0) {
1458 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1461 foreach ($ret as $key => $val) {
1462 $totalforeachday[$key] += $val;
1473 return $totalforeachday;
1496 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1498 global $conf, $db, $user, $langs;
1499 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1501 $numlines = count($lines);
1504 $workloadforid = array();
1505 $totalforeachday = array();
1506 $lineswithoutlevel0 = array();
1510 for ($i = 0; $i < $numlines; $i++) {
1511 if ($lines[$i]->fk_task_parent) {
1512 $lineswithoutlevel0[] = $lines[$i];
1519 if (empty($oldprojectforbreak)) {
1520 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1523 $restrictBefore =
null;
1525 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1526 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1530 for ($i = 0; $i < $numlines; $i++) {
1535 if ($lines[$i]->fk_task_parent == $parent) {
1539 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1542 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1547 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1548 $lastprojectid = $lines[$i]->fk_project;
1549 $projectstatic->id = $lines[$i]->fk_project;
1554 if (empty($workloadforid[$projectstatic->id])) {
1555 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1556 $workloadforid[$projectstatic->id] = 1;
1561 $projectstatic->id = $lines[$i]->fk_project;
1562 $projectstatic->ref = $lines[$i]->projectref;
1563 $projectstatic->title = $lines[$i]->projectlabel;
1564 $projectstatic->public = $lines[$i]->public;
1565 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1566 $projectstatic->status = $lines[$i]->projectstatus;
1568 $taskstatic->id = $lines[$i]->id;
1569 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1570 $taskstatic->label = $lines[$i]->label;
1571 $taskstatic->date_start = $lines[$i]->date_start;
1572 $taskstatic->date_end = $lines[$i]->date_end;
1574 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1575 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1576 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1578 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1580 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1583 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1586 foreach ($arrayfields as $key => $val) {
1587 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1592 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1593 print
'<td colspan="'.(11 + $addcolspan).
'">';
1594 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1595 if ($thirdpartystatic->id > 0) {
1596 print
' - '.$thirdpartystatic->getNomUrl(1);
1598 if ($projectstatic->title) {
1600 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1667 if ($oldprojectforbreak != -1) {
1668 $oldprojectforbreak = $projectstatic->id;
1671 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1681 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1682 print
'<td class="nowrap">';
1683 if ($oldprojectforbreak == -1) {
1684 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1690 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1691 print
'<td class="tdoverflowmax100">';
1692 if ($thirdpartystatic->id > 0) {
1693 print $thirdpartystatic->getNomUrl(1,
'project');
1699 print
'<td class="nowrap">';
1700 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1701 for ($k = 0; $k < $level; $k++) {
1702 print
'<div class="marginleftonly">';
1704 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1707 print
'<span class="opacitymedium">'.$taskstatic->label.
'</span>';
1708 for ($k = 0; $k < $level; $k++) {
1714 $extrafieldsobjectkey =
'projet_task';
1715 $extrafieldsobjectprefix =
'efpt.';
1716 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1719 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1720 print
'<td class="leftborder plannedworkload right">';
1721 if ($lines[$i]->planned_workload) {
1729 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1731 print
'<td class="right">';
1732 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1736 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1738 print
'<td class="right">';
1740 if ($lines[$i]->duration) {
1741 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1750 print
'<td class="right">';
1751 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1752 if ($tmptimespent[
'total_duration']) {
1760 $disabledproject = 1;
1766 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1767 $disabledproject = 0;
1771 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1779 $modeinput =
'hours';
1780 for ($idw = 0; $idw < 7; $idw++) {
1782 if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
1784 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
1785 $cssonholiday .=
'onholidayallday ';
1786 } elseif (!$isavailable[$tmpday][
'morning']) {
1787 $cssonholiday .=
'onholidaymorning ';
1788 } elseif (!$isavailable[$tmpday][
'afternoon']) {
1789 $cssonholiday .=
'onholidayafternoon ';
1793 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
1794 $totalforeachday[$tmpday] += $dayWorkLoad;
1797 if ($dayWorkLoad > 0) {
1800 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", !empty($tmparray[
'day']) ? $tmparray[
'day'] : 0, $tmparray[
'mon']);
1802 global $numstartworkingday, $numendworkingday;
1804 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
1805 $cssweekend =
'weekend';
1808 $disabledtaskday = $disabledtask;
1810 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
1811 $disabledtaskday = 1;
1814 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1817 if ($alreadyspent) {
1818 $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>';
1822 $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"';
1823 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1824 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
1825 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
1826 $tableCell .= '</td>';
1831 print '<td class="right
">';
1832 if ((!$lines[$i]->public) && $disabledproject) {
1833 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
1834 } elseif ($disabledtask) {
1835 $titleassigntask = $langs->trans("AssignTaskToMe
");
1836 if ($fuser->id != $user->id) {
1837 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
1840 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
1847 // Call to show task with a lower level (task under the current task)
1850 if ($lines[$i]->id > 0) {
1851 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1852 //var_dump($totalforeachday);
1853 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1854 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1856 foreach ($ret as $key => $val) {
1857 $totalforeachday[$key] += $val;
1859 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1860 //var_dump($totalforeachday);
1868 return $totalforeachday;
1889 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
1891 global $conf, $db, $user, $langs;
1892 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1894 $numlines = count($lines);
1897 $workloadforid = array();
1898 $totalforeachweek = array();
1899 $lineswithoutlevel0 = array();
1901 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1902 if ($parent == 0) { // Always and only if at first level
1903 for ($i = 0; $i < $numlines; $i++) {
1904 if ($lines[$i]->fk_task_parent) {
1905 $lineswithoutlevel0[] = $lines[$i];
1910 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
1912 if (empty($oldprojectforbreak)) {
1913 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
1916 $restrictBefore = null;
1918 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1919 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1920 $restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
1923 for ($i = 0; $i < $numlines; $i++) {
1928 if ($lines[$i]->fk_task_parent == $parent) {
1929 // If we want all or we have a role on task, we show it
1930 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1931 //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);
1933 // Break on a new project
1934 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1935 $lastprojectid = $lines[$i]->fk_project;
1936 $projectstatic->id = $lines[$i]->fk_project;
1939 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1940 //var_dump($projectstatic->weekWorkLoadPerTask);
1941 if (empty($workloadforid[$projectstatic->id])) {
1942 $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
1943 $workloadforid[$projectstatic->id] = 1;
1945 //var_dump($projectstatic->weekWorkLoadPerTask);
1946 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1948 $projectstatic->id = $lines[$i]->fk_project;
1949 $projectstatic->ref = $lines[$i]->projectref;
1950 $projectstatic->title = $lines[$i]->projectlabel;
1951 $projectstatic->public = $lines[$i]->public;
1952 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1953 $projectstatic->status = $lines[$i]->projectstatus;
1955 $taskstatic->id = $lines[$i]->id;
1956 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1957 $taskstatic->label = $lines[$i]->label;
1958 $taskstatic->date_start = $lines[$i]->date_start;
1959 $taskstatic->date_end = $lines[$i]->date_end;
1961 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1962 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1963 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1965 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1966 print '<tr class="oddeven trforbreak nobold
">'."\n
";
1967 print '<td colspan="'.(6 + count($TWeek)).'">';
1968 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1969 if ($thirdpartystatic->id > 0) {
1970 print ' - '.$thirdpartystatic->getNomUrl(1);
1972 if ($projectstatic->title) {
1974 print '<span class="secondary
">'.$projectstatic->title.'</span>';
1980 if ($oldprojectforbreak != -1) {
1981 $oldprojectforbreak = $projectstatic->id;
1983 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
1987 print '<td class="nowrap
">';
1988 print $fuser->getNomUrl(1, 'withproject', 'time');
1993 /*print '<td class="nowrap
">';
1994 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
1998 /*print '<td class="tdoverflowmax100
">';
1999 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2003 print '<td class="nowrap
">';
2004 print '<!-- Task id = '.$lines[$i]->id.' -->';
2005 for ($k = 0; $k < $level; $k++) {
2006 print '<div class="marginleftonly
">';
2008 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2011 print '<span class="opacitymedium
">'.$taskstatic->label.'</span>';
2012 for ($k = 0; $k < $level; $k++) {
2018 print '<td class="leftborder plannedworkload right
">';
2019 if ($lines[$i]->planned_workload) {
2020 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2026 // Progress declared %
2027 print '<td class="right
">';
2028 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2031 // Time spent by everybody
2032 print '<td class="right
">';
2033 // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2034 if ($lines[$i]->duration) {
2035 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2036 print convertSecondToTime($lines[$i]->duration, 'allhourmin');
2043 // Time spent by user
2044 print '<td class="right
">';
2045 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2046 if ($tmptimespent['total_duration']) {
2047 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2053 $disabledproject = 1;
2055 //print "x
".$lines[$i]->fk_project;
2056 //var_dump($lines[$i]);
2057 //var_dump($projectsrole[$lines[$i]->fk_project]);
2058 // If at least one role for project
2059 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2060 $disabledproject = 0;
2063 // If $restricteditformytask is on and I have no role on task, i disable edit
2064 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2068 //var_dump($projectstatic->weekWorkLoadPerTask);
2070 // Fields to show current time
2072 $modeinput = 'hours';
2073 $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
2074 $TFirstDay[reset($TWeek)] = 1;
2076 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2077 $year = $firstdaytoshowarray['year'];
2078 $month = $firstdaytoshowarray['mon'];
2079 foreach ($TWeek as $weekIndex => $weekNb) {
2080 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2081 if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
2082 $totalforeachweek[$weekNb] += $weekWorkLoad;
2085 if ($weekWorkLoad > 0) {
2086 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2088 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2090 $disabledtaskweek = $disabledtask;
2091 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2093 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2094 $disabledtaskweek = 1;
2097 $tableCell = '<td class="center hide weekend
">';
2099 if ($alreadyspent) {
2100 $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>';
2101 //$placeholder=' placeholder="00:00
"';
2105 $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
"';
2106 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2107 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2108 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2109 $tableCell .= '</td>';
2114 print '<td class="right
">';
2115 if ((!$lines[$i]->public) && $disabledproject) {
2116 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2117 } elseif ($disabledtask) {
2118 $titleassigntask = $langs->trans("AssignTaskToMe
");
2119 if ($fuser->id != $user->id) {
2120 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2123 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2130 // Call to show task with a lower level (task under the current task)
2133 if ($lines[$i]->id > 0) {
2134 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2135 //var_dump($totalforeachday);
2136 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2137 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2139 foreach ($ret as $key => $val) {
2140 $totalforeachweek[$key] += $val;
2142 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2143 //var_dump($totalforeachday);
2151 return $totalforeachweek;
2164 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2166 //print 'Search in line with parent id = '.$parent.'<br>';
2167 $numlines = count($lines);
2168 for ($i = 0; $i < $numlines; $i++) {
2169 // Process line $lines[$i]
2170 if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) {
2171 // If task is legitimate to show, no more need to search deeper
2172 if (isset($taskrole[$lines[$i]->id])) {
2173 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2178 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2179 //print 'Found inc='.$inc.'<br>';
2204 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2206 global $langs, $conf, $user;
2207 global $theme_datacolor;
2209 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2211 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2213 $listofstatus = array_keys($listofoppstatus);
2215 if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2216 // Define $themeColorId and array $statusOppList for each $listofstatus
2218 $statusOppList = array();
2219 foreach ($listofstatus as $oppStatus) {
2220 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2221 if ($oppStatusCode) {
2222 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2223 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2229 $projectstatic = new Project($db);
2230 $thirdpartystatic = new Societe($db);
2234 $project_year_filter = 0;
2236 $title = $langs->trans("Projects");
2237 if (strcmp($status, '') && $status >= 0) {
2238 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2241 print '<!-- print_projecttasks_array -->';
2242 print '<div class="div-table-responsive-no-min
">';
2243 print '<table class="noborder centpercent
">';
2245 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2247 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2248 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2249 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2251 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2253 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2254 $sql .= " AND p.rowid IN (
".$db->sanitize($projectsListId).")
";
2256 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2259 $sql .= " AND p.rowid = t.fk_projet
";
2260 $sql .= " AND ec.element_id = t.rowid
";
2261 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2262 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2263 $sql .= " AND ctc.element =
'project_task'";
2266 $sql .= " AND p.fk_statut =
".(int) $status;
2268 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2269 $project_year_filter = GETPOST("project_year_filter
");
2270 //Check if empty or invalid year. Wildcard ignores the sql check
2271 if ($project_year_filter != "*
") {
2272 if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
2273 $project_year_filter = date("Y
");
2275 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")
";
2276 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")
";
2280 // Get id of project we must show tasks
2281 $arrayidofprojects = array();
2282 $sql1 = "SELECT p.rowid as projectid
";
2284 $resql = $db->query($sql1);
2287 $num = $db->num_rows($resql);
2289 $objp = $db->fetch_object($resql);
2290 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2294 dol_print_error($db);
2296 if (empty($arrayidofprojects)) {
2297 $arrayidofprojects[0] = -1;
2300 // Get list of project with calculation on tasks
2301 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2302 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2303 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2304 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2305 $sql2 .= " s.logo, s.email, s.entity,
";
2306 $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,
";
2307 $sql2 .= " p.dateo, p.datee,
";
2308 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2309 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2310 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.
rowid = p.fk_soc";
2311 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.
rowid = t.fk_projet";
2312 $sql2 .= " WHERE p.
rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")";
2313 $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,";
2314 $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";
2315 $sql2 .= " ORDER BY p.title, p.
ref";
2317 $resql = $db->query($sql2);
2321 $total_opp_amount = 0;
2322 $ponderated_opp_amount = 0;
2323 $total_plannedworkload = 0;
2324 $total_declaredprogressworkload = 0;
2326 $num = $db->num_rows(
$resql);
2327 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2330 print
'<tr class="liste_titre">';
2331 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);
2333 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2334 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2335 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2337 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 ');
2340 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2342 if (!in_array(
'plannedworkload', $hiddenfields)) {
2343 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2345 if (!in_array(
'declaredprogress', $hiddenfields)) {
2346 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2349 if (!in_array(
'projectstatus', $hiddenfields)) {
2354 while ($i < $nbofloop) {
2355 $objp = $db->fetch_object(
$resql);
2357 if ($max && $i >= $max) {
2360 $total_task += $objp->nb;
2361 $total_opp_amount += $objp->opp_amount;
2362 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2363 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2364 $plannedworkload = $objp->planned_workload;
2365 $total_plannedworkload += $plannedworkload;
2366 $declaredprogressworkload = $objp->declared_progess_workload;
2367 $total_declaredprogressworkload += $declaredprogressworkload;
2371 $projectstatic->id = $objp->projectid;
2372 $projectstatic->user_author_id = $objp->fk_user_creat;
2373 $projectstatic->public = $objp->public;
2376 $userAccess = $projectstatic->restrictedProjectArea($user);
2377 if ($userAccess >= 0) {
2378 $projectstatic->ref = $objp->ref;
2379 $projectstatic->status = $objp->status;
2380 $projectstatic->title = $objp->title;
2381 $projectstatic->date_end = $db->jdate($objp->datee);
2382 $projectstatic->date_start = $db->jdate($objp->dateo);
2384 print
'<tr class="oddeven">';
2386 print
'<td class="tdoverflowmax150">';
2387 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2388 if (!in_array(
'projectlabel', $hiddenfields)) {
2389 print
'<br><span class="opacitymedium">'.dol_trunc($objp->title, 24).
'</span>';
2393 print
'<td class="nowraponall tdoverflowmax100">';
2394 if ($objp->fk_soc > 0) {
2395 $thirdpartystatic->id = $objp->socid;
2396 $thirdpartystatic->name = $objp->socname;
2399 $thirdpartystatic->code_compta = $objp->code_compta;
2400 $thirdpartystatic->client = $objp->client;
2402 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2403 $thirdpartystatic->fournisseur = $objp->fournisseur;
2404 $thirdpartystatic->logo = $objp->logo;
2405 $thirdpartystatic->email = $objp->email;
2406 $thirdpartystatic->entity = $objp->entity;
2407 print $thirdpartystatic->getNomUrl(1);
2411 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2412 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2413 print
'<td class="center tdoverflowmax75">';
2415 if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2416 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2417 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2418 print $langs->trans(
"OppStatus".$oppStatusCode);
2421 if (isset($statusOppList[$objp->opp_status])) {
2422 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2423 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2425 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2426 $oppStatusColor =
'';
2428 if ($oppStatusCode) {
2429 if (!empty($oppStatusColor)) {
2430 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>';
2432 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2439 print
'<td class="right">';
2440 if ($objp->opp_percent && $objp->opp_amount) {
2441 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2442 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0, $conf->currency);
2443 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2445 if ($objp->opp_amount) {
2446 print
'<span class="amount" title="'.$alttext.
'">'.
$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2451 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2452 print
'<td class="right">'.$objp->nb.
'</td>';
2454 $plannedworkload = $objp->planned_workload;
2455 $total_plannedworkload += $plannedworkload;
2456 if (!in_array(
'plannedworkload', $hiddenfields)) {
2457 print
'<td class="right nowraponall">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2459 if (!in_array(
'declaredprogress', $hiddenfields)) {
2460 $declaredprogressworkload = $objp->declared_progess_workload;
2461 $total_declaredprogressworkload += $declaredprogressworkload;
2462 print
'<td class="right nowraponall">';
2464 print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2469 if (!in_array(
'projectstatus', $hiddenfields)) {
2470 print
'<td class="right">';
2471 print $projectstatic->getLibStatut(3);
2477 $total_task += $objp->nb;
2478 $total_opp_amount += $objp->opp_amount;
2485 print
'<tr class="oddeven">';
2486 print
'<td class="nowrap" colspan="5">';
2487 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
2492 print
'<tr class="liste_total">';
2493 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2494 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2495 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2496 print
'<td class="liste_total"></td>';
2498 print
'<td class="liste_total right">';
2500 print
$form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0, $conf->currency));
2503 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2504 print
'<td class="liste_total right">'.$total_task.
'</td>';
2505 if (!in_array(
'plannedworkload', $hiddenfields)) {
2506 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2508 if (!in_array(
'declaredprogress', $hiddenfields)) {
2509 print
'<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2512 if (!in_array(
'projectstatus', $hiddenfields)) {
2513 print
'<td class="liste_total"></td>';
2525 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2527 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2528 print
'<table width="100%">';
2530 print
'<td>'.$langs->trans(
"Year").
'</td>';
2531 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.
'"/>';
2533 print
'</table></form>';
2546 function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2548 global $langs, $conf;
2552 $plannedworkloadoutputformat =
'allhourmin';
2553 $timespentoutputformat =
'allhourmin';
2554 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
2555 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2557 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
2558 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2561 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2565 $spaced = !empty($spaced) ?
'spaced' :
'';
2570 $progressBarClass =
'progress-bar-info';
2571 $progressCalculated = 0;
2572 if ($task->planned_workload) {
2573 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2576 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2578 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.($task->progress ?
'%' :
'');
2579 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.($progressCalculated ?
'%' :
'');
2582 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2583 $progressBarClass =
'progress-bar-danger';
2584 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2585 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2586 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2587 $progressBarClass =
'progress-bar-warning';
2588 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2589 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2591 $progressBarClass =
'progress-bar-success';
2592 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2593 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2597 $out .=
'<div class="progress-group">';
2599 if ($label !==
false) {
2600 $out .=
' <span class="progress-text">';
2602 if ($label !==
true) {
2611 if ($progressNumber !==
false) {
2612 $out .=
' <span class="progress-number">';
2613 if ($progressNumber !==
true) {
2614 $out .= $progressNumber;
2616 if ($task->hasDelay()) {
2620 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2622 $out .= !empty($diff) ? $diff.
' ' :
'';
2623 $out .=
'<a href="'.$url.
'" >';
2624 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2625 if ($task->duration_effective) {
2635 $out .=
'<a href="'.$url.
'" >';
2636 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2637 if ($task->planned_workload) {
2649 $out .=
' <div class="progress sm '.$spaced.
'">';
2650 $diffval = floatval($task->progress) - floatval($progressCalculated);
2651 if ($diffval >= 0) {
2653 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.floatval($task->progress).
'%" title="'.floatval($task->progress).
'%">';
2654 if (!empty($task->progress)) {
2655 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated / (floatval($task->progress) === 0 ? 1 : $task->progress) * 100).
'%" title="'.floatval($progressCalculated).
'%"></div>';
2660 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).
'%" title="'.floatval($progressCalculated).
'%">';
2661 $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>';
2680 global $conf, $langs;
2684 if ($task->progress !=
'') {
2688 $badgeClass =
'badge ';
2689 if ($task->planned_workload) {
2690 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2693 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2695 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2696 $badgeClass .=
'badge-danger';
2697 if (empty($tooltip)) {
2698 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2700 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2701 $badgeClass .=
'badge-warning';
2702 if (empty($tooltip)) {
2703 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2706 $badgeClass .=
'badge-success';
2707 if (empty($tooltip)) {
2708 $tooltip = $task->progress.
'% >= '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2715 if (!empty($tooltip)) {
2716 $badgeClass .=
' classfortooltip';
2717 $title =
'title="'.dol_htmlentities($tooltip).
'"';
2720 if (empty($label)) {
2721 $label = $task->progress.
' %';
2724 if (!empty($label)) {
2725 $out =
'<span class="'.$badgeClass.
'" '.$title.
' >'.$label.
'</span>';
Class for ConferenceOrBooth.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
Class to generate the form for creating a new ticket.
projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a pertime intput mode.
task_prepare_head($object)
Prepare array with list of tabs.
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.
searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)
project_timesheet_prepare_head($mode, $fuser=null)
Prepare array with list of tabs.
project_admin_prepare_head()
Prepare array with list of tabs.
getTaskProgressBadge($task, $label='', $tooltip='')
projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $arrayfields=array(), $extrafields=null)
Output a task line into a perday intput mode.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.