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 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
533 $head[$h][0] = DOL_URL_ROOT .
'/projet/admin/project_task_extrafields.php';
534 $head[$h][1] = $langs->trans(
"ExtraFieldsProjectTask");
535 $nbExtrafields = $extrafields->attributes[
'projet_task'][
'count'];
536 if ($nbExtrafields > 0) {
537 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbExtrafields .
'</span>';
539 $head[$h][2] =
'attributes_task';
543 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
544 $langs->load(
"members");
546 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/website.php';
547 $head[$h][1] = $langs->trans(
"BlankSubscriptionForm");
548 $head[$h][2] =
'website';
576 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc =
'', $showbilltime = 0, $arrayfields = array())
578 global $user, $langs, $conf, $db, $hookmanager;
579 global $projectstatic, $taskstatic, $extrafields;
583 $projectsArrayId = explode(
',', $projectsListId);
584 if ($filterprogresscalc !==
'') {
585 foreach ($lines as $key => $line) {
586 if (!empty($line->planned_workload) && !empty($line->duration)) {
587 $filterprogresscalc = str_replace(
' = ',
' == ', $filterprogresscalc);
588 if (!eval($filterprogresscalc)) {
593 $lines = array_values($lines);
595 $numlines = count($lines);
598 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;
601 $total_projectlinesa_spent = 0;
602 $total_projectlinesa_planned = 0;
603 $total_projectlinesa_spent_if_planned = 0;
604 $total_projectlinesa_declared_if_planned = 0;
605 $total_projectlinesa_tobill = 0;
606 $total_projectlinesa_billed = 0;
607 $total_budget_amount = 0;
610 for ($i = 0; $i < $numlines; $i++) {
611 if ($parent == 0 && $level >= 0) {
618 if ($lines[$i]->fk_parent == $parent || $level < 0) {
624 if (is_array($taskrole)) {
626 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_parent) {
628 $foundtaskforuserdeeper = 0;
631 if ($foundtaskforuserdeeper > 0) {
640 if (empty($user->rights->projet->all->lire)) {
642 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
653 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
655 $lastprojectid = $lines[$i]->fk_project;
658 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
660 $projectstatic->id = $lines[$i]->fk_project;
661 $projectstatic->ref = $lines[$i]->projectref;
662 $projectstatic->public = $lines[$i]->public;
663 $projectstatic->title = $lines[$i]->projectlabel;
664 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
665 $projectstatic->status = $lines[$i]->projectstatus;
667 $taskstatic->id = $lines[$i]->id;
668 $taskstatic->ref = $lines[$i]->ref;
669 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
670 $taskstatic->projectstatus = $lines[$i]->projectstatus;
671 $taskstatic->progress = $lines[$i]->progress;
672 $taskstatic->fk_statut = $lines[$i]->status;
673 $taskstatic->date_start = $lines[$i]->date_start;
674 $taskstatic->date_end = $lines[$i]->date_end;
675 $taskstatic->datee = $lines[$i]->date_end;
676 $taskstatic->planned_workload = $lines[$i]->planned_workload;
677 $taskstatic->duration_effective = $lines[$i]->duration;
678 $taskstatic->budget_amount = $lines[$i]->budget_amount;
683 print
'<td class="nowraponall">';
685 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
686 print $projectstatic->getNomUrl(1);
688 print $projectstatic->getNomUrl(1,
'nolink');
695 $projectstatic->statut = $lines[$i]->projectstatus;
696 print $projectstatic->getLibStatut(2);
701 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
702 print
'<td class="nowraponall">';
703 if ($showlineingray) {
704 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
706 print $taskstatic->getNomUrl(1,
'withproject');
712 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
714 if ($showlineingray) {
715 $labeltoshow .=
'<i>';
718 for ($k = 0; $k < $level; $k++) {
719 $labeltoshow .=
'<div class="marginleftonly">';
722 for ($k = 0; $k < $level; $k++) {
723 $labeltoshow .=
'</div>';
725 if ($showlineingray) {
726 $labeltoshow .=
'</i>';
728 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
733 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
734 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
735 print $lines[$i]->description;
740 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
741 print
'<td class="center nowraponall">';
747 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
748 print
'<td class="center nowraponall">';
750 if ($taskstatic->hasDelay()) {
756 $plannedworkloadoutputformat =
'allhourmin';
757 $timespentoutputformat =
'allhourmin';
758 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
759 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
761 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
762 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
766 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
767 print
'<td class="right">';
768 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
770 if ($lines[$i]->planned_workload !=
'') {
780 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
781 print
'<td class="right">';
782 if ($showlineingray) {
785 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
787 if ($lines[$i]->duration) {
792 if ($showlineingray) {
801 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
802 print
'<td class="right">';
803 if ($lines[$i]->planned_workload || $lines[$i]->duration) {
804 if ($lines[$i]->planned_workload) {
805 print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).
' %';
807 print
'<span class="opacitymedium">'.$langs->trans(
'WorkloadNotDefined').
'</span>';
814 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
815 print
'<td class="right">';
816 if ($lines[$i]->progress !=
'') {
823 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
824 print
'<td class="right">';
825 if ($lines[$i]->progress !=
'' && $lines[$i]->duration) {
833 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
834 print
'<td class="right">';
835 if ($lines[$i]->usage_bill_time) {
837 $total_projectlinesa_tobill += $lines[$i]->tobill;
839 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
845 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
846 print
'<td class="right">';
847 if ($lines[$i]->usage_bill_time) {
849 $total_projectlinesa_billed += $lines[$i]->billed;
851 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
858 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
859 print
'<td class="center">';
860 if ($lines[$i]->budget_amount) {
861 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
862 $total_budget_amount += $lines[$i]->budget_amount;
868 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
869 print
'<td class="center">';
871 foreach (array(
'internal',
'external') as $source) {
872 $tab = $lines[$i]->liste_contact(-1, $source);
873 $numcontact = count($tab);
874 if (!empty($numcontact)) {
875 foreach ($tab as $contacttask) {
877 if ($source ==
'internal') {
882 $c->fetch($contacttask[
'id']);
883 if (!empty($c->photo)) {
884 if (get_class($c) ==
'User') {
885 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
887 print $c->getNomUrl(-2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
890 if (get_class($c) ==
'User') {
891 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
893 print $c->getNomUrl(2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
904 $extrafieldsobjectkey = $taskstatic->table_element;
906 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
908 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$lines[$i]);
909 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
910 print $hookmanager->resPrint;
913 print
'<td class="tdlineupdown center"></td>';
917 if (!$showlineingray) {
923 if ($lines[$i]->
id) {
924 projectLinesa($inc, $lines[$i]->
id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
929 $total_projectlinesa_spent += $lines[$i]->duration;
930 $total_projectlinesa_planned += $lines[$i]->planned_workload;
931 if ($lines[$i]->planned_workload) {
932 $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
934 if ($lines[$i]->planned_workload) {
935 $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
943 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
945 print
'<tr class="liste_total nodrag nodrop">';
946 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
948 print
'<td></td><td></td>';
950 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.label'][
'checked'])) {
953 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.description'][
'checked'])) {
956 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.dateo'][
'checked'])) {
959 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.datee'][
'checked'])) {
962 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.planned_workload'][
'checked'])) {
963 print
'<td class="nowrap liste_total right">';
967 if (count($arrayfields) > 0 && ! empty($arrayfields[
't.duration_effective'][
'checked'])) {
968 print
'<td class="nowrap liste_total right">';
969 if ($projectidfortotallink > 0) {
970 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
973 if ($projectidfortotallink > 0) {
979 if ($total_projectlinesa_planned) {
980 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
981 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
984 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
987 $progressBarClass =
'progress-bar-info';
988 $badgeClass =
'badge ';
990 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
991 $progressBarClass =
'progress-bar-danger';
992 $badgeClass .=
'badge-danger';
993 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
994 $progressBarClass =
'progress-bar-warning';
995 $badgeClass .=
'badge-warning';
997 $progressBarClass =
'progress-bar-success';
998 $badgeClass .=
'badge-success';
1003 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
1004 print
'<td class="nowrap liste_total right">';
1005 if ($total_projectlinesa_planned) {
1006 print $totalCalculatedProgress.
' %';
1012 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
1013 print
'<td class="nowrap liste_total right">';
1014 if ($total_projectlinesa_planned) {
1015 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
1022 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
1023 print
'<td class="right">';
1024 if ($total_projectlinesa_planned) {
1026 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
1027 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1034 if ($showbilltime) {
1035 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1036 print
'<td class="nowrap liste_total right">';
1040 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1041 print
'<td class="nowrap liste_total right">';
1048 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1049 print
'<td class="nowrap liste_total center">';
1050 if (strcmp($total_budget_amount,
'')) {
1051 print
price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1057 if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
1061 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1064 if (! empty($totalarray[
'nbfield'])) {
1065 print
'<td colspan="'.$totalarray[
'nbfield'].
'" class=""></td>';
1067 print
'<td class=""></td>';
1094 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1096 global $conf, $db, $user, $langs;
1097 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1100 $totalforeachday = array();
1101 $workloadforid = array();
1102 $lineswithoutlevel0 = array();
1104 $numlines = count($lines);
1108 for ($i = 0; $i < $numlines; $i++) {
1109 if ($lines[$i]->fk_task_parent) {
1110 $lineswithoutlevel0[] = $lines[$i];
1115 if (empty($oldprojectforbreak)) {
1116 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1119 $restrictBefore =
null;
1121 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1122 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1127 for ($i = 0; $i < $numlines; $i++) {
1132 if ($lines[$i]->fk_task_parent == $parent) {
1136 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1139 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1144 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1145 $lastprojectid = $lines[$i]->fk_project;
1146 if ($preselectedday) {
1147 $projectstatic->id = $lines[$i]->fk_project;
1151 if (empty($workloadforid[$projectstatic->id])) {
1152 if ($preselectedday) {
1153 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1154 $workloadforid[$projectstatic->id] = 1;
1158 $projectstatic->id = $lines[$i]->fk_project;
1159 $projectstatic->ref = $lines[$i]->projectref;
1160 $projectstatic->title = $lines[$i]->projectlabel;
1161 $projectstatic->public = $lines[$i]->public;
1162 $projectstatic->status = $lines[$i]->projectstatus;
1164 $taskstatic->id = $lines[$i]->id;
1165 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1166 $taskstatic->label = $lines[$i]->label;
1167 $taskstatic->date_start = $lines[$i]->date_start;
1168 $taskstatic->date_end = $lines[$i]->date_end;
1170 $thirdpartystatic->id = $lines[$i]->socid;
1171 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1172 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1174 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1176 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1179 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1182 foreach ($arrayfields as $key => $val) {
1183 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1188 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1189 print
'<td colspan="'.(7 + $addcolspan).
'">';
1190 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1191 if ($thirdpartystatic->id > 0) {
1192 print
' - '.$thirdpartystatic->getNomUrl(1);
1194 if ($projectstatic->title) {
1196 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1263 if ($oldprojectforbreak != -1) {
1264 $oldprojectforbreak = $projectstatic->id;
1267 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1277 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1279 if ($oldprojectforbreak == -1) {
1280 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1286 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1287 print
'<td class="tdoverflowmax100">';
1288 if ($thirdpartystatic->id > 0) {
1289 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1296 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1297 for ($k = 0; $k < $level; $k++) {
1298 print
'<div class="marginleftonly">';
1300 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1303 print
'<span class="opacitymedium">'.$taskstatic->label.
'</a>';
1304 for ($k = 0; $k < $level; $k++) {
1310 $extrafieldsobjectkey =
'projet_task';
1311 $extrafieldsobjectprefix =
'efpt.';
1312 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1315 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1316 print
'<td class="leftborder plannedworkload right">';
1317 if ($lines[$i]->planned_workload) {
1326 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1327 print
'<td class="right">';
1328 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1332 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1334 print
'<td class="right">';
1336 if ($lines[$i]->duration) {
1337 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1346 print
'<td class="right">';
1347 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1348 if ($tmptimespent[
'total_duration']) {
1356 $disabledproject = 1;
1362 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1363 $disabledproject = 0;
1367 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1371 if ($restrictBefore && $preselectedday < $restrictBefore) {
1376 print
'<td class="nowraponall leftborder center minwidth150imp">';
1377 $tableCell =
$form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1382 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1383 $cssonholiday .=
'onholidayallday ';
1384 } elseif (!$isavailable[$preselectedday][
'morning']) {
1385 $cssonholiday .=
'onholidaymorning ';
1386 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1387 $cssonholiday .=
'onholidayafternoon ';
1393 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1394 global $numstartworkingday, $numendworkingday;
1396 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1397 $cssweekend =
'weekend';
1401 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1402 $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0;
1403 if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0;
1404 $totalforeachday[$preselectedday] += $dayWorkLoad;
1407 if ($dayWorkLoad > 0) {
1414 $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>';
1415 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1417 $tableCell .=
$form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1433 print
'<td class="center">';
1434 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1435 print
'</textarea>';
1439 print
'<td class="right">';
1440 if ((!$lines[$i]->
public) && $disabledproject) {
1441 print
$form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1442 } elseif ($disabledtask) {
1443 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1444 if ($fuser->id != $user->id) {
1445 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1448 print
$form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1457 if ($lines[$i]->
id > 0) {
1460 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1463 foreach ($ret as $key => $val) {
1464 $totalforeachday[$key] += $val;
1475 return $totalforeachday;
1498 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1500 global $conf, $db, $user, $langs;
1501 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1503 $numlines = count($lines);
1506 $workloadforid = array();
1507 $totalforeachday = array();
1508 $lineswithoutlevel0 = array();
1512 for ($i = 0; $i < $numlines; $i++) {
1513 if ($lines[$i]->fk_task_parent) {
1514 $lineswithoutlevel0[] = $lines[$i];
1521 if (empty($oldprojectforbreak)) {
1522 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1525 $restrictBefore =
null;
1527 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1528 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1532 for ($i = 0; $i < $numlines; $i++) {
1537 if ($lines[$i]->fk_task_parent == $parent) {
1541 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1544 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1549 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1550 $lastprojectid = $lines[$i]->fk_project;
1551 $projectstatic->id = $lines[$i]->fk_project;
1556 if (empty($workloadforid[$projectstatic->id])) {
1557 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1558 $workloadforid[$projectstatic->id] = 1;
1563 $projectstatic->id = $lines[$i]->fk_project;
1564 $projectstatic->ref = $lines[$i]->projectref;
1565 $projectstatic->title = $lines[$i]->projectlabel;
1566 $projectstatic->public = $lines[$i]->public;
1567 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1568 $projectstatic->status = $lines[$i]->projectstatus;
1570 $taskstatic->id = $lines[$i]->id;
1571 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1572 $taskstatic->label = $lines[$i]->label;
1573 $taskstatic->date_start = $lines[$i]->date_start;
1574 $taskstatic->date_end = $lines[$i]->date_end;
1576 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1577 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1578 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1580 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1582 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1585 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1588 foreach ($arrayfields as $key => $val) {
1589 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1594 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1595 print
'<td colspan="'.(11 + $addcolspan).
'">';
1596 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1597 if ($thirdpartystatic->id > 0) {
1598 print
' - '.$thirdpartystatic->getNomUrl(1);
1600 if ($projectstatic->title) {
1602 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1669 if ($oldprojectforbreak != -1) {
1670 $oldprojectforbreak = $projectstatic->id;
1673 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1683 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1684 print
'<td class="nowrap">';
1685 if ($oldprojectforbreak == -1) {
1686 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1692 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1693 print
'<td class="tdoverflowmax100">';
1694 if ($thirdpartystatic->id > 0) {
1695 print $thirdpartystatic->getNomUrl(1,
'project');
1701 print
'<td class="nowrap">';
1702 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1703 for ($k = 0; $k < $level; $k++) {
1704 print
'<div class="marginleftonly">';
1706 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1709 print
'<span class="opacitymedium">'.$taskstatic->label.
'</span>';
1710 for ($k = 0; $k < $level; $k++) {
1716 $extrafieldsobjectkey =
'projet_task';
1717 $extrafieldsobjectprefix =
'efpt.';
1718 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1721 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1722 print
'<td class="leftborder plannedworkload right">';
1723 if ($lines[$i]->planned_workload) {
1731 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1733 print
'<td class="right">';
1734 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1738 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1740 print
'<td class="right">';
1742 if ($lines[$i]->duration) {
1743 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1752 print
'<td class="right">';
1753 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1754 if ($tmptimespent[
'total_duration']) {
1762 $disabledproject = 1;
1768 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1769 $disabledproject = 0;
1773 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1781 $modeinput =
'hours';
1782 for ($idw = 0; $idw < 7; $idw++) {
1784 if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
1786 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
1787 $cssonholiday .=
'onholidayallday ';
1788 } elseif (!$isavailable[$tmpday][
'morning']) {
1789 $cssonholiday .=
'onholidaymorning ';
1790 } elseif (!$isavailable[$tmpday][
'afternoon']) {
1791 $cssonholiday .=
'onholidayafternoon ';
1795 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
1796 $totalforeachday[$tmpday] += $dayWorkLoad;
1799 if ($dayWorkLoad > 0) {
1802 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", !empty($tmparray[
'day']) ? $tmparray[
'day'] : 0, $tmparray[
'mon']);
1804 global $numstartworkingday, $numendworkingday;
1806 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
1807 $cssweekend =
'weekend';
1810 $disabledtaskday = $disabledtask;
1812 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
1813 $disabledtaskday = 1;
1816 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1819 if ($alreadyspent) {
1820 $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>';
1824 $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"';
1825 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1826 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
1827 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
1828 $tableCell .= '</td>';
1833 print '<td class="right
">';
1834 if ((!$lines[$i]->public) && $disabledproject) {
1835 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
1836 } elseif ($disabledtask) {
1837 $titleassigntask = $langs->trans("AssignTaskToMe
");
1838 if ($fuser->id != $user->id) {
1839 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
1842 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
1849 // Call to show task with a lower level (task under the current task)
1852 if ($lines[$i]->id > 0) {
1853 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
1854 //var_dump($totalforeachday);
1855 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1856 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
1858 foreach ($ret as $key => $val) {
1859 $totalforeachday[$key] += $val;
1861 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
1862 //var_dump($totalforeachday);
1870 return $totalforeachday;
1891 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
1893 global $conf, $db, $user, $langs;
1894 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1896 $numlines = count($lines);
1899 $workloadforid = array();
1900 $totalforeachweek = array();
1901 $lineswithoutlevel0 = array();
1903 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1904 if ($parent == 0) { // Always and only if at first level
1905 for ($i = 0; $i < $numlines; $i++) {
1906 if ($lines[$i]->fk_task_parent) {
1907 $lineswithoutlevel0[] = $lines[$i];
1912 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
1914 if (empty($oldprojectforbreak)) {
1915 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
1918 $restrictBefore = null;
1920 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1921 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1922 $restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
1925 for ($i = 0; $i < $numlines; $i++) {
1930 if ($lines[$i]->fk_task_parent == $parent) {
1931 // If we want all or we have a role on task, we show it
1932 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
1933 //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);
1935 // Break on a new project
1936 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1937 $lastprojectid = $lines[$i]->fk_project;
1938 $projectstatic->id = $lines[$i]->fk_project;
1941 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1942 //var_dump($projectstatic->weekWorkLoadPerTask);
1943 if (empty($workloadforid[$projectstatic->id])) {
1944 $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
1945 $workloadforid[$projectstatic->id] = 1;
1947 //var_dump($projectstatic->weekWorkLoadPerTask);
1948 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
1950 $projectstatic->id = $lines[$i]->fk_project;
1951 $projectstatic->ref = $lines[$i]->projectref;
1952 $projectstatic->title = $lines[$i]->projectlabel;
1953 $projectstatic->public = $lines[$i]->public;
1954 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1955 $projectstatic->status = $lines[$i]->projectstatus;
1957 $taskstatic->id = $lines[$i]->id;
1958 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1959 $taskstatic->label = $lines[$i]->label;
1960 $taskstatic->date_start = $lines[$i]->date_start;
1961 $taskstatic->date_end = $lines[$i]->date_end;
1963 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1964 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1965 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1967 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1968 print '<tr class="oddeven trforbreak nobold
">'."\n
";
1969 print '<td colspan="'.(6 + count($TWeek)).'">';
1970 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1971 if ($thirdpartystatic->id > 0) {
1972 print ' - '.$thirdpartystatic->getNomUrl(1);
1974 if ($projectstatic->title) {
1976 print '<span class="secondary
">'.$projectstatic->title.'</span>';
1982 if ($oldprojectforbreak != -1) {
1983 $oldprojectforbreak = $projectstatic->id;
1985 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
1989 print '<td class="nowrap
">';
1990 print $fuser->getNomUrl(1, 'withproject', 'time');
1995 /*print '<td class="nowrap
">';
1996 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
2000 /*print '<td class="tdoverflowmax100
">';
2001 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2005 print '<td class="nowrap
">';
2006 print '<!-- Task id = '.$lines[$i]->id.' -->';
2007 for ($k = 0; $k < $level; $k++) {
2008 print '<div class="marginleftonly
">';
2010 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2013 print '<span class="opacitymedium
">'.$taskstatic->label.'</span>';
2014 for ($k = 0; $k < $level; $k++) {
2020 print '<td class="leftborder plannedworkload right
">';
2021 if ($lines[$i]->planned_workload) {
2022 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2028 // Progress declared %
2029 print '<td class="right
">';
2030 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2033 // Time spent by everybody
2034 print '<td class="right
">';
2035 // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2036 if ($lines[$i]->duration) {
2037 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2038 print convertSecondToTime($lines[$i]->duration, 'allhourmin');
2045 // Time spent by user
2046 print '<td class="right
">';
2047 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2048 if ($tmptimespent['total_duration']) {
2049 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2055 $disabledproject = 1;
2057 //print "x
".$lines[$i]->fk_project;
2058 //var_dump($lines[$i]);
2059 //var_dump($projectsrole[$lines[$i]->fk_project]);
2060 // If at least one role for project
2061 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2062 $disabledproject = 0;
2065 // If $restricteditformytask is on and I have no role on task, i disable edit
2066 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2070 //var_dump($projectstatic->weekWorkLoadPerTask);
2072 // Fields to show current time
2074 $modeinput = 'hours';
2075 $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
2076 $TFirstDay[reset($TWeek)] = 1;
2078 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2079 $year = $firstdaytoshowarray['year'];
2080 $month = $firstdaytoshowarray['mon'];
2081 foreach ($TWeek as $weekIndex => $weekNb) {
2082 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2083 if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
2084 $totalforeachweek[$weekNb] += $weekWorkLoad;
2087 if ($weekWorkLoad > 0) {
2088 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2090 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2092 $disabledtaskweek = $disabledtask;
2093 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2095 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2096 $disabledtaskweek = 1;
2099 $tableCell = '<td class="center hide weekend
">';
2101 if ($alreadyspent) {
2102 $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>';
2103 //$placeholder=' placeholder="00:00
"';
2107 $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
"';
2108 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2109 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2110 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2111 $tableCell .= '</td>';
2116 print '<td class="right
">';
2117 if ((!$lines[$i]->public) && $disabledproject) {
2118 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2119 } elseif ($disabledtask) {
2120 $titleassigntask = $langs->trans("AssignTaskToMe
");
2121 if ($fuser->id != $user->id) {
2122 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2125 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2132 // Call to show task with a lower level (task under the current task)
2135 if ($lines[$i]->id > 0) {
2136 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2137 //var_dump($totalforeachday);
2138 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2139 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2141 foreach ($ret as $key => $val) {
2142 $totalforeachweek[$key] += $val;
2144 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2145 //var_dump($totalforeachday);
2153 return $totalforeachweek;
2166 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2168 //print 'Search in line with parent id = '.$parent.'<br>';
2169 $numlines = count($lines);
2170 for ($i = 0; $i < $numlines; $i++) {
2171 // Process line $lines[$i]
2172 if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) {
2173 // If task is legitimate to show, no more need to search deeper
2174 if (isset($taskrole[$lines[$i]->id])) {
2175 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2180 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2181 //print 'Found inc='.$inc.'<br>';
2206 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2208 global $langs, $conf, $user;
2209 global $theme_datacolor;
2211 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2213 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2215 $listofstatus = array_keys($listofoppstatus);
2217 if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2218 // Define $themeColorId and array $statusOppList for each $listofstatus
2220 $statusOppList = array();
2221 foreach ($listofstatus as $oppStatus) {
2222 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2223 if ($oppStatusCode) {
2224 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2225 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2231 $projectstatic = new Project($db);
2232 $thirdpartystatic = new Societe($db);
2236 $project_year_filter = 0;
2238 $title = $langs->trans("Projects");
2239 if (strcmp($status, '') && $status >= 0) {
2240 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2243 print '<!-- print_projecttasks_array -->';
2244 print '<div class="div-table-responsive-no-min
">';
2245 print '<table class="noborder centpercent
">';
2247 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2249 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2250 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2251 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2253 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2255 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2256 $sql .= " AND p.rowid IN (
".$db->sanitize($projectsListId).")
";
2258 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2261 $sql .= " AND p.rowid = t.fk_projet
";
2262 $sql .= " AND ec.element_id = t.rowid
";
2263 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2264 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2265 $sql .= " AND ctc.element =
'project_task'";
2268 $sql .= " AND p.fk_statut =
".(int) $status;
2270 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2271 $project_year_filter = GETPOST("project_year_filter
");
2272 //Check if empty or invalid year. Wildcard ignores the sql check
2273 if ($project_year_filter != "*
") {
2274 if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
2275 $project_year_filter = date("Y
");
2277 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")
";
2278 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")
";
2282 // Get id of project we must show tasks
2283 $arrayidofprojects = array();
2284 $sql1 = "SELECT p.rowid as projectid
";
2286 $resql = $db->query($sql1);
2289 $num = $db->num_rows($resql);
2291 $objp = $db->fetch_object($resql);
2292 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2296 dol_print_error($db);
2298 if (empty($arrayidofprojects)) {
2299 $arrayidofprojects[0] = -1;
2302 // Get list of project with calculation on tasks
2303 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2304 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2305 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2306 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2307 $sql2 .= " s.logo, s.email, s.entity,
";
2308 $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,
";
2309 $sql2 .= " p.dateo, p.datee,
";
2310 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2311 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2312 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.
rowid = p.fk_soc";
2313 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.
rowid = t.fk_projet";
2314 $sql2 .= " WHERE p.
rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")";
2315 $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,";
2316 $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";
2317 $sql2 .= " ORDER BY p.title, p.
ref";
2319 $resql = $db->query($sql2);
2323 $total_opp_amount = 0;
2324 $ponderated_opp_amount = 0;
2325 $total_plannedworkload = 0;
2326 $total_declaredprogressworkload = 0;
2328 $num = $db->num_rows(
$resql);
2329 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2332 print
'<tr class="liste_titre">';
2333 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);
2335 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2336 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2337 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2339 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 ');
2342 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2344 if (!in_array(
'plannedworkload', $hiddenfields)) {
2345 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2347 if (!in_array(
'declaredprogress', $hiddenfields)) {
2348 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2351 if (!in_array(
'projectstatus', $hiddenfields)) {
2356 while ($i < $nbofloop) {
2357 $objp = $db->fetch_object(
$resql);
2359 if ($max && $i >= $max) {
2362 $total_task += $objp->nb;
2363 $total_opp_amount += $objp->opp_amount;
2364 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2365 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2366 $plannedworkload = $objp->planned_workload;
2367 $total_plannedworkload += $plannedworkload;
2368 $declaredprogressworkload = $objp->declared_progess_workload;
2369 $total_declaredprogressworkload += $declaredprogressworkload;
2373 $projectstatic->id = $objp->projectid;
2374 $projectstatic->user_author_id = $objp->fk_user_creat;
2375 $projectstatic->public = $objp->public;
2378 $userAccess = $projectstatic->restrictedProjectArea($user);
2379 if ($userAccess >= 0) {
2380 $projectstatic->ref = $objp->ref;
2381 $projectstatic->status = $objp->status;
2382 $projectstatic->title = $objp->title;
2383 $projectstatic->date_end = $db->jdate($objp->datee);
2384 $projectstatic->date_start = $db->jdate($objp->dateo);
2386 print
'<tr class="oddeven">';
2388 print
'<td class="tdoverflowmax150">';
2389 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2390 if (!in_array(
'projectlabel', $hiddenfields)) {
2391 print
'<br><span class="opacitymedium">'.dol_trunc($objp->title, 24).
'</span>';
2395 print
'<td class="nowraponall tdoverflowmax100">';
2396 if ($objp->fk_soc > 0) {
2397 $thirdpartystatic->id = $objp->socid;
2398 $thirdpartystatic->name = $objp->socname;
2401 $thirdpartystatic->code_compta = $objp->code_compta;
2402 $thirdpartystatic->client = $objp->client;
2404 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2405 $thirdpartystatic->fournisseur = $objp->fournisseur;
2406 $thirdpartystatic->logo = $objp->logo;
2407 $thirdpartystatic->email = $objp->email;
2408 $thirdpartystatic->entity = $objp->entity;
2409 print $thirdpartystatic->getNomUrl(1);
2413 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2414 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2415 print
'<td class="center tdoverflowmax75">';
2417 if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2418 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2419 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2420 print $langs->trans(
"OppStatus".$oppStatusCode);
2423 if (isset($statusOppList[$objp->opp_status])) {
2424 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2425 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2427 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2428 $oppStatusColor =
'';
2430 if ($oppStatusCode) {
2431 if (!empty($oppStatusColor)) {
2432 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>';
2434 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2441 print
'<td class="right">';
2442 if ($objp->opp_percent && $objp->opp_amount) {
2443 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2444 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0, $conf->currency);
2445 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2447 if ($objp->opp_amount) {
2448 print
'<span class="amount" title="'.$alttext.
'">'.
$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2453 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2454 print
'<td class="right">'.$objp->nb.
'</td>';
2456 $plannedworkload = $objp->planned_workload;
2457 $total_plannedworkload += $plannedworkload;
2458 if (!in_array(
'plannedworkload', $hiddenfields)) {
2459 print
'<td class="right nowraponall">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2461 if (!in_array(
'declaredprogress', $hiddenfields)) {
2462 $declaredprogressworkload = $objp->declared_progess_workload;
2463 $total_declaredprogressworkload += $declaredprogressworkload;
2464 print
'<td class="right nowraponall">';
2466 print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2471 if (!in_array(
'projectstatus', $hiddenfields)) {
2472 print
'<td class="right">';
2473 print $projectstatic->getLibStatut(3);
2479 $total_task += $objp->nb;
2480 $total_opp_amount += $objp->opp_amount;
2487 print
'<tr class="oddeven">';
2488 print
'<td class="nowrap" colspan="5">';
2489 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
2494 print
'<tr class="liste_total">';
2495 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2496 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2497 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2498 print
'<td class="liste_total"></td>';
2500 print
'<td class="liste_total right">';
2502 print
$form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0, $conf->currency));
2505 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2506 print
'<td class="liste_total right">'.$total_task.
'</td>';
2507 if (!in_array(
'plannedworkload', $hiddenfields)) {
2508 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2510 if (!in_array(
'declaredprogress', $hiddenfields)) {
2511 print
'<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2514 if (!in_array(
'projectstatus', $hiddenfields)) {
2515 print
'<td class="liste_total"></td>';
2527 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2529 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2530 print
'<table width="100%">';
2532 print
'<td>'.$langs->trans(
"Year").
'</td>';
2533 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.
'"/>';
2535 print
'</table></form>';
2548 function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2550 global $langs, $conf;
2554 $plannedworkloadoutputformat =
'allhourmin';
2555 $timespentoutputformat =
'allhourmin';
2556 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
2557 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2559 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
2560 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2563 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2567 $spaced = !empty($spaced) ?
'spaced' :
'';
2572 $progressBarClass =
'progress-bar-info';
2573 $progressCalculated = 0;
2574 if ($task->planned_workload) {
2575 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2578 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2580 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.($task->progress ?
'%' :
'');
2581 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.($progressCalculated ?
'%' :
'');
2584 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2585 $progressBarClass =
'progress-bar-danger';
2586 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2587 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2588 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2589 $progressBarClass =
'progress-bar-warning';
2590 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2591 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2593 $progressBarClass =
'progress-bar-success';
2594 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2595 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2599 $out .=
'<div class="progress-group">';
2601 if ($label !==
false) {
2602 $out .=
' <span class="progress-text">';
2604 if ($label !==
true) {
2613 if ($progressNumber !==
false) {
2614 $out .=
' <span class="progress-number">';
2615 if ($progressNumber !==
true) {
2616 $out .= $progressNumber;
2618 if ($task->hasDelay()) {
2622 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2624 $out .= !empty($diff) ? $diff.
' ' :
'';
2625 $out .=
'<a href="'.$url.
'" >';
2626 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2627 if ($task->duration_effective) {
2637 $out .=
'<a href="'.$url.
'" >';
2638 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2639 if ($task->planned_workload) {
2651 $out .=
' <div class="progress sm '.$spaced.
'">';
2652 $diffval = floatval($task->progress) - floatval($progressCalculated);
2653 if ($diffval >= 0) {
2655 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.floatval($task->progress).
'%" title="'.floatval($task->progress).
'%">';
2656 if (!empty($task->progress)) {
2657 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated / (floatval($task->progress) === 0 ? 1 : $task->progress) * 100).
'%" title="'.floatval($progressCalculated).
'%"></div>';
2662 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).
'%" title="'.floatval($progressCalculated).
'%">';
2663 $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>';
2682 global $conf, $langs;
2686 if ($task->progress !=
'') {
2690 $badgeClass =
'badge ';
2691 if ($task->planned_workload) {
2692 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2695 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2697 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2698 $badgeClass .=
'badge-danger';
2699 if (empty($tooltip)) {
2700 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2702 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2703 $badgeClass .=
'badge-warning';
2704 if (empty($tooltip)) {
2705 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2708 $badgeClass .=
'badge-success';
2709 if (empty($tooltip)) {
2710 $tooltip = $task->progress.
'% >= '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2717 if (!empty($tooltip)) {
2718 $badgeClass .=
' classfortooltip';
2719 $title =
'title="'.dol_htmlentities($tooltip).
'"';
2722 if (empty($label)) {
2723 $label = $task->progress.
' %';
2726 if (!empty($label)) {
2727 $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.