29 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
41 global $db, $langs, $conf, $user;
46 $head[$h][0] = DOL_URL_ROOT.
'/projet/card.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
47 $head[$h][1] = $langs->trans(
"Project");
48 $head[$h][2] =
'project';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
53 $cachekey =
'count_contacts_project_'.$project->id;
56 if (!is_null($dataretrieved)) {
57 $nbContacts = $dataretrieved;
59 $nbContacts = count($project->liste_contact(-1,
'internal')) + count($project->liste_contact(-1,
'external'));
62 $head[$h][0] = DOL_URL_ROOT.
'/projet/contact.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
63 $head[$h][1] = $langs->trans(
"ProjectContact");
64 if ($nbContacts > 0) {
65 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContacts.
'</span>';
67 $head[$h][2] =
'contact';
70 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
74 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
75 $cachekey =
'count_tasks_project_'.$project->id;
78 if (!is_null($dataretrieved)) {
79 $nbTasks = $dataretrieved;
81 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
82 $taskstatic =
new Task($db);
83 $nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0));
86 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
87 $head[$h][1] = $langs->trans(
"Tasks");
89 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTasks).
'</span>';
91 $head[$h][2] =
'tasks';
96 $cachekey =
'count_timespent_project_'.$project->id;
98 if (!is_null($dataretrieved)) {
99 $nbTimeSpent = $dataretrieved;
101 $sql =
"SELECT t.rowid";
104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t, ".MAIN_DB_PREFIX.
"projet_task as pt";
105 $sql .=
" WHERE t.fk_element = pt.rowid";
106 $sql .=
" AND t.elementtype = 'task'";
107 $sql .=
" AND pt.fk_projet =".((int) $project->id);
108 $resql = $db->query(
$sql);
110 $obj = $db->fetch_object($resql);
120 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&projectid='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
121 $head[$h][1] = $langs->trans(
"TimeSpent");
122 if ($nbTimeSpent > 0) {
123 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
125 $head[$h][2] =
'timespent';
135 $cachekey =
'count_elements_project_'.$project->id;
137 if (!is_null($dataretrieved)) {
138 $nbElements = $dataretrieved;
141 $nbElements += $project->getElementCount(
'stock',
'entrepot',
'fk_project');
144 $nbElements += $project->getElementCount(
'propal',
'propal');
147 $nbElements += $project->getElementCount(
'order',
'commande');
150 $nbElements += $project->getElementCount(
'invoice',
'facture');
153 $nbElements += $project->getElementCount(
'invoice_predefined',
'facture_rec');
156 $nbElements += $project->getElementCount(
'proposal_supplier',
'supplier_proposal');
159 $nbElements += $project->getElementCount(
'order_supplier',
'commande_fournisseur');
162 $nbElements += $project->getElementCount(
'invoice_supplier',
'facture_fourn');
165 $nbElements += $project->getElementCount(
'contract',
'contrat');
168 $nbElements += $project->getElementCount(
'intervention',
'fichinter');
171 $nbElements += $project->getElementCount(
'shipping',
'expedition');
174 $nbElements += $project->getElementCount(
'mrp',
'mrp_mo',
'fk_project');
177 $nbElements += $project->getElementCount(
'trip',
'deplacement');
180 $nbElements += $project->getElementCount(
'expensereport',
'expensereport');
183 $nbElements += $project->getElementCount(
'donation',
'don');
186 $nbElements += $project->getElementCount(
'loan',
'loan');
189 $nbElements += $project->getElementCount(
'chargesociales',
'chargesociales');
192 $nbElements += $project->getElementCount(
'project_task',
'projet_task');
195 $nbElements += $project->getElementCount(
'stock_mouvement',
'stock');
198 $nbElements += $project->getElementCount(
'salaries',
'payment_salary');
201 $nbElements += $project->getElementCount(
'variouspayment',
'payment_various');
205 $head[$h][0] = DOL_URL_ROOT.
'/projet/element.php?id='.$project->id;
206 $head[$h][1] = $langs->trans(
"ProjectOverview");
207 if ($nbElements > 0) {
208 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbElements.
'</span>';
210 $head[$h][2] =
'element';
214 if (
isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
215 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
216 $Tickettatic =
new Ticket($db);
217 $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id,
'*',
'fk_project',
'ticket'));
218 $head[$h][0] = DOL_URL_ROOT.
'/ticket/list.php?projectid='.((int) $project->id);
219 $head[$h][1] = $langs->trans(
"Ticket");
221 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTicket).
'</span>';
223 $head[$h][2] =
'ticket';
227 if (
isModEnabled(
'eventorganization') && !empty($project->usage_organize_event)) {
228 $langs->load(
'eventorganization');
229 $head[$h][0] = DOL_URL_ROOT .
'/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
230 $head[$h][1] = $langs->trans(
"EventOrganization");
233 $nbConfOrBooth = 0; $nbAttendees = 0;
234 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
235 $cachekey =
'count_conferenceorbooth_'.$project->id;
237 if (!is_null($dataretrieved)) {
238 $nbConfOrBooth = $dataretrieved;
240 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
242 $result = $conforbooth->fetchAll(
'',
'', 0, 0, array(
't.fk_project'=>$project->id));
244 if (!is_array($result) && $result<0) {
247 $nbConfOrBooth = count($result);
251 $cachekey =
'count_attendees_'.$project->id;
253 if (!is_null($dataretrieved)) {
254 $nbAttendees = $dataretrieved;
256 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
258 $result = $conforboothattendee->fetchAll(
'',
'', 0, 0, array(
't.fk_project'=>$project->id));
260 if (!is_array($result) && $result<0) {
261 setEventMessages($conforboothattendee->error, $conforboothattendee->errors,
'errors');
263 $nbAttendees = count($result);
267 if ($nbConfOrBooth > 0 || $nbAttendees > 0) {
268 $head[$h][1] .=
'<span class="badge marginleftonlyshort">';
269 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"ConferenceOrBooth")).
'">'.$nbConfOrBooth.
'</span>';
270 if ($nbConfOrBooth > 0 && $nbAttendees > 0) {
271 $head[$h][1] .=
' / ';
273 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"Attendees")).
'">'.$nbAttendees.
'</span>';
274 $head[$h][1] .=
'</span>';
276 $head[$h][2] =
'eventorganisation';
287 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
289 if (!empty($project->note_private)) {
292 if (!empty($project->note_public)) {
295 $head[$h][0] = DOL_URL_ROOT.
'/projet/note.php?id='.$project->id;
296 $head[$h][1] = $langs->trans(
'Notes');
298 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
300 $head[$h][2] =
'notes';
307 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
308 $cachekey =
'count_attached_project_'.$project->id;
310 if (!is_null($dataretrieved)) {
311 $totalAttached = $dataretrieved;
313 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
314 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
315 $upload_dir = $conf->project->multidir_output[$project->entity].
"/".
dol_sanitizeFileName($project->ref);
316 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
317 $nbLinks =
Link::count($db, $project->element, $project->id);
318 $totalAttached = $nbFiles + $nbLinks;
321 $head[$h][0] = DOL_URL_ROOT.
'/projet/document.php?id='.$project->id;
322 $head[$h][1] = $langs->trans(
'Documents');
323 if (($totalAttached) > 0) {
324 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
326 $head[$h][2] =
'document';
330 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) {
333 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
334 $cachekey =
'count_attached_project_'.$project->id;
336 if (!is_null($dataretrieved)) {
337 $nbComments = $dataretrieved;
339 $nbComments = $project->getNbComments();
342 $head[$h][0] = DOL_URL_ROOT.
'/projet/comment.php?id='.$project->id;
343 $head[$h][1] = $langs->trans(
"CommentLink");
344 if ($nbComments > 0) {
345 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
347 $head[$h][2] =
'project_comment';
351 $head[$h][0] = DOL_URL_ROOT.
'/projet/messaging.php?id='.$project->id;
352 $head[$h][1] = $langs->trans(
"Events");
353 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
355 $head[$h][1] .= $langs->trans(
"Agenda");
357 $head[$h][2] =
'agenda';
376 global $db, $langs, $conf, $user;
380 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/task.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
381 $head[$h][1] = $langs->trans(
"Task");
382 $head[$h][2] =
'task_task';
385 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
386 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/contact.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
387 $head[$h][1] = $langs->trans(
"TaskRessourceLinks");
388 if ($nbContact > 0) {
389 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
391 $head[$h][2] =
'task_contact';
396 $sql =
"SELECT t.rowid";
399 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
400 $sql .=
" WHERE t.elementtype='task' AND t.fk_element = ".((int) $object->id);
401 $resql = $db->query(
$sql);
403 $obj = $db->fetch_object($resql);
411 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
412 $head[$h][1] = $langs->trans(
"TimeSpent");
413 if ($nbTimeSpent > 0) {
414 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
416 $head[$h][2] =
'task_time';
425 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
427 if (!empty($object->note_private)) {
430 if (!empty($object->note_public)) {
433 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/note.php?id='.urlencode($object->id).(GETPOST(
'withproject') ?
'&withproject=1' :
'');
434 $head[$h][1] = $langs->trans(
'Notes');
436 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
438 $head[$h][2] =
'task_notes';
442 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/document.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
444 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
445 include_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
446 $nbFiles = count(
dol_dir_list($filesdir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
447 $nbLinks =
Link::count($db, $object->element, $object->id);
448 $head[$h][1] = $langs->trans(
'Documents');
449 if (($nbFiles + $nbLinks) > 0) {
450 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
452 $head[$h][2] =
'task_document';
456 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) {
457 $nbComments = $object->getNbComments();
458 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/comment.php?id='.$object->id.(GETPOST(
'withproject') ?
'&withproject=1' :
'');
459 $head[$h][1] = $langs->trans(
"CommentLink");
460 if ($nbComments > 0) {
461 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
463 $head[$h][2] =
'task_comment';
483 global $langs, $conf, $user;
490 $param .= ($mode ?
'&mode='.$mode :
'');
491 if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
492 $param .=
'&search_usertoprocessid='.$fuser->id;
495 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) {
496 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/permonth.php".($param ?
'?'.$param :
'');
497 $head[$h][1] = $langs->trans(
"InputPerMonth");
498 $head[$h][2] =
'inputpermonth';
502 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) {
503 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perweek.php".($param ?
'?'.$param :
'');
504 $head[$h][1] = $langs->trans(
"InputPerWeek");
505 $head[$h][2] =
'inputperweek';
509 if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) {
510 $head[$h][0] = DOL_URL_ROOT.
"/projet/activity/perday.php".($param ?
'?'.$param :
'');
511 $head[$h][1] = $langs->trans(
"InputPerDay");
512 $head[$h][2] =
'inputperday';
531 global $langs, $conf, $user, $db;
534 $extrafields->fetch_name_optionals_label(
'projet');
535 $extrafields->fetch_name_optionals_label(
'projet_task');
540 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project.php";
541 $head[$h][1] = $langs->trans(
"Projects");
542 $head[$h][2] =
'project';
547 $head[$h][0] = DOL_URL_ROOT.
"/projet/admin/project_extrafields.php";
548 $head[$h][1] = $langs->trans(
"ExtraFieldsProject");
549 $nbExtrafields = $extrafields->attributes[
'projet'][
'count'];
550 if ($nbExtrafields > 0) {
551 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
553 $head[$h][2] =
'attributes';
556 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/project_task_extrafields.php';
557 $head[$h][1] = $langs->trans(
"ExtraFieldsProjectTask");
558 $nbExtrafields = $extrafields->attributes[
'projet_task'][
'count'];
559 if ($nbExtrafields > 0) {
560 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
562 $head[$h][2] =
'attributes_task';
565 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
566 $langs->load(
"members");
568 $head[$h][0] = DOL_URL_ROOT.
'/projet/admin/website.php';
569 $head[$h][1] = $langs->trans(
"BlankSubscriptionForm");
570 $head[$h][2] =
'website';
599 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $dummy =
'', $showbilltime = 0, $arrayfields = array(), $arrayofselected = array())
601 global $user, $langs, $conf, $db, $hookmanager;
602 global $projectstatic, $taskstatic, $extrafields;
606 $projectsArrayId = explode(
',', $projectsListId);
608 $numlines = count($lines);
611 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;
615 $total_projectlinesa_spent = 0;
616 $total_projectlinesa_planned = 0;
617 $total_projectlinesa_spent_if_planned = 0;
618 $total_projectlinesa_declared_if_planned = 0;
619 $total_projectlinesa_tobill = 0;
620 $total_projectlinesa_billed = 0;
621 $total_budget_amount = 0;
622 $totalarray = array();
625 for ($i = 0; $i < $numlines; $i++) {
626 if ($parent == 0 && $level >= 0) {
632 if ($lines[$i]->fk_task_parent == $parent || $level < 0) {
638 if (is_array($taskrole)) {
640 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_task_parent) {
642 $foundtaskforuserdeeper = 0;
645 if ($foundtaskforuserdeeper > 0) {
654 if (empty($user->rights->projet->all->lire)) {
656 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
667 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
669 $lastprojectid = $lines[$i]->fk_project;
672 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
674 $projectstatic->id = $lines[$i]->fk_project;
675 $projectstatic->ref = $lines[$i]->projectref;
676 $projectstatic->public = $lines[$i]->public;
677 $projectstatic->title = $lines[$i]->projectlabel;
678 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
679 $projectstatic->status = $lines[$i]->projectstatus;
681 $taskstatic->id = $lines[$i]->id;
682 $taskstatic->ref = $lines[$i]->ref;
683 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
684 $taskstatic->projectstatus = $lines[$i]->projectstatus;
685 $taskstatic->progress = $lines[$i]->progress;
686 $taskstatic->fk_statut = $lines[$i]->status;
687 $taskstatic->date_start = $lines[$i]->date_start;
688 $taskstatic->date_end = $lines[$i]->date_end;
689 $taskstatic->datee = $lines[$i]->date_end;
690 $taskstatic->planned_workload = $lines[$i]->planned_workload;
691 $taskstatic->duration_effective = $lines[$i]->duration_effective;
692 $taskstatic->budget_amount = $lines[$i]->budget_amount;
696 print
'<td class="nowrap center">';
698 if (in_array($lines[$i]->
id, $arrayofselected)) {
701 print
'<input id="cb' . $lines[$i]->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
707 print
'<td class="nowraponall">';
709 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
710 print $projectstatic->getNomUrl(1);
712 print $projectstatic->getNomUrl(1,
'nolink');
719 $projectstatic->statut = $lines[$i]->projectstatus;
720 print $projectstatic->getLibStatut(2);
725 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
726 print
'<td class="nowraponall">';
727 if ($showlineingray) {
728 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
730 print $taskstatic->getNomUrl(1,
'withproject');
736 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
738 if ($showlineingray) {
739 $labeltoshow .=
'<i>';
742 for ($k = 0; $k < $level; $k++) {
743 $labeltoshow .=
'<div class="marginleftonly">';
746 for ($k = 0; $k < $level; $k++) {
747 $labeltoshow .=
'</div>';
749 if ($showlineingray) {
750 $labeltoshow .=
'</i>';
752 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
757 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
758 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
759 print $lines[$i]->description;
764 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
765 print
'<td class="center nowraponall">';
771 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
772 print
'<td class="center nowraponall">';
774 if ($taskstatic->hasDelay()) {
780 $plannedworkloadoutputformat =
'allhourmin';
781 $timespentoutputformat =
'allhourmin';
782 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
783 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
785 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
786 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
790 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
791 print
'<td class="right">';
792 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
794 if ($lines[$i]->planned_workload !=
'') {
804 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
805 print
'<td class="right">';
806 if ($showlineingray) {
809 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
811 if ($lines[$i]->duration_effective) {
816 if ($showlineingray) {
825 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
826 $s =
''; $shtml =
'';
827 if ($lines[$i]->planned_workload || $lines[$i]->duration_effective) {
828 if ($lines[$i]->planned_workload) {
829 $s = round(100 * $lines[$i]->duration_effective / $lines[$i]->planned_workload, 2).
' %';
832 $s = $langs->trans(
'WorkloadNotDefined');
833 $shtml =
'<span class="opacitymedium">'.$s.
'</span>';
836 print
'<td class="right tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
842 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
843 print
'<td class="right">';
844 if ($lines[$i]->progress !=
'') {
851 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
852 print
'<td class="right">';
853 if ($lines[$i]->progress !=
'' && $lines[$i]->duration_effective) {
861 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
862 print
'<td class="right">';
863 if ($lines[$i]->usage_bill_time) {
865 $total_projectlinesa_tobill += $lines[$i]->tobill;
867 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
873 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
874 print
'<td class="right">';
875 if ($lines[$i]->usage_bill_time) {
877 $total_projectlinesa_billed += $lines[$i]->billed;
879 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
886 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
887 print
'<td class="center">';
888 if ($lines[$i]->budget_amount) {
889 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
890 $total_budget_amount += $lines[$i]->budget_amount;
896 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
897 print
'<td class="center">';
899 foreach (array(
'internal',
'external') as $source) {
901 $tab = $lines[$i]->liste_contact(-1, $source, 0,
'', 1);
903 $numcontact = count($tab);
904 if (!empty($numcontact)) {
905 foreach ($tab as $contacttask) {
907 if ($source ==
'internal') {
912 $c->fetch($contacttask[
'id']);
913 if (!empty($c->photo)) {
914 if (get_class($c) ==
'User') {
915 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
917 print $c->getNomUrl(-2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
920 if (get_class($c) ==
'User') {
921 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
923 print $c->getNomUrl(2,
'', 0,
'', -1, 0, ($ifisrt ?
'' :
'notfirst'));
934 $extrafieldsobjectkey = $taskstatic->table_element;
936 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
938 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$lines[$i]);
939 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
940 print $hookmanager->resPrint;
943 print
'<td class="tdlineupdown center"></td>';
947 print
'<td class="nowrap center">';
949 if (in_array($lines[$i]->
id, $arrayofselected)) {
952 print
'<input id="cb' . $lines[$i]->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
959 if (!$showlineingray) {
965 if ($lines[$i]->
id) {
966 projectLinesa($inc, $lines[$i]->
id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink,
'', $showbilltime, $arrayfields);
971 $total_projectlinesa_spent += $lines[$i]->duration_effective;
972 $total_projectlinesa_planned += $lines[$i]->planned_workload;
973 if ($lines[$i]->planned_workload) {
974 $total_projectlinesa_spent_if_planned += $lines[$i]->duration_effective;
976 if ($lines[$i]->planned_workload) {
977 $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
986 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
988 print
'<tr class="liste_total nodrag nodrop">';
991 print
'<td class="liste_total"></td>';
994 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
996 print
'<td></td><td></td>';
998 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
1001 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
1004 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
1007 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
1010 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
1011 print
'<td class="nowrap liste_total right">';
1015 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
1016 print
'<td class="nowrap liste_total right">';
1017 if ($projectidfortotallink > 0) {
1018 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
1021 if ($projectidfortotallink > 0) {
1027 if ($total_projectlinesa_planned) {
1028 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
1029 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
1032 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
1035 $progressBarClass =
'progress-bar-info';
1036 $badgeClass =
'badge ';
1038 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
1039 $progressBarClass =
'progress-bar-danger';
1040 $badgeClass .=
'badge-danger';
1041 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
1042 $progressBarClass =
'progress-bar-warning';
1043 $badgeClass .=
'badge-warning';
1045 $progressBarClass =
'progress-bar-success';
1046 $badgeClass .=
'badge-success';
1051 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
1052 print
'<td class="nowrap liste_total right">';
1053 if ($total_projectlinesa_planned) {
1054 print $totalCalculatedProgress.
' %';
1060 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
1061 print
'<td class="nowrap liste_total right">';
1062 if ($total_projectlinesa_planned) {
1063 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
1070 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
1071 print
'<td class="right">';
1072 if ($total_projectlinesa_planned) {
1074 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
1075 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1082 if ($showbilltime) {
1083 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1084 print
'<td class="nowrap liste_total right">';
1088 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1089 print
'<td class="nowrap liste_total right">';
1096 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1097 print
'<td class="nowrap liste_total center">';
1098 if (strcmp($total_budget_amount,
'')) {
1099 print
price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
1105 if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
1109 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1114 foreach ($extrafields->attributes[
'projet_task'][
'totalizable'] as $key => $value) {
1115 if (!empty($arrayfields[
'ef.'.$key][
'checked']) && $arrayfields[
'ef.'.$key][
'checked'] == 1) {
1116 print
'<td class="right">';
1118 print empty($totalarray[
'totalizable'][$key][
'total']) ?
'' : $totalarray[
'totalizable'][$key][
'total'];
1125 print
'<td class="liste_total"></td>';
1128 print
'<td class="liste_total"></td>';
1155 function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1157 global $conf, $db, $user, $langs;
1158 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1161 $totalforeachline = array();
1162 $workloadforid = array();
1163 $lineswithoutlevel0 = array();
1165 $numlines = count($lines);
1169 for ($i = 0; $i < $numlines; $i++) {
1170 if ($lines[$i]->fk_task_parent) {
1171 $lineswithoutlevel0[] = $lines[$i];
1176 if (empty($oldprojectforbreak)) {
1177 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1181 for ($i = 0; $i < $numlines; $i++) {
1189 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1193 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1194 $lastprojectid = $lines[$i]->fk_project;
1195 if ($preselectedday) {
1196 $projectstatic->id = $lines[$i]->fk_project;
1200 if (empty($workloadforid[$projectstatic->id])) {
1201 if ($preselectedday) {
1202 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1203 $workloadforid[$projectstatic->id] = 1;
1207 $projectstatic->id = $lines[$i]->fk_project;
1208 $projectstatic->ref = $lines[$i]->project_ref;
1209 $projectstatic->title = $lines[$i]->project_label;
1210 $projectstatic->public = $lines[$i]->public;
1211 $projectstatic->status = $lines[$i]->project->status;
1213 $taskstatic->id = $lines[$i]->fk_statut;
1214 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1215 $taskstatic->label = $lines[$i]->task_label;
1216 $taskstatic->date_start = $lines[$i]->date_start;
1217 $taskstatic->date_end = $lines[$i]->date_end;
1219 $thirdpartystatic->id = $lines[$i]->socid;
1220 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1221 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1223 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1224 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1225 print
'<td colspan="11">';
1226 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1227 if ($projectstatic->title) {
1229 print $projectstatic->title;
1235 if ($oldprojectforbreak != -1) {
1236 $oldprojectforbreak = $projectstatic->id;
1239 print
'<tr class="oddeven">'.
"\n";
1250 if ($oldprojectforbreak == -1) {
1251 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1252 print
'<br>'.$projectstatic->title;
1257 print
'<td class="tdoverflowmax100">';
1258 if ($thirdpartystatic->id > 0) {
1259 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1265 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1266 for ($k = 0; $k < $level; $k++) {
1267 print
" ";
1269 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1272 for ($k = 0; $k < $level; $k++) {
1273 print
" ";
1275 print $taskstatic->label;
1282 print
'<td class="center">';
1286 $disabledproject = 1;
1292 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1293 $disabledproject = 0;
1297 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1302 print
'<td class="nowrap center">';
1307 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1308 $cssonholiday .=
'onholidayallday ';
1309 } elseif (!$isavailable[$preselectedday][
'morning']) {
1310 $cssonholiday .=
'onholidaymorning ';
1311 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1312 $cssonholiday .=
'onholidayafternoon ';
1316 print
'<td class="duration'.($cssonholiday ?
' '.$cssonholiday :
'').
' center">';
1318 $dayWorkLoad = $lines[$i]->timespent_duration;
1319 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1322 if ($dayWorkLoad > 0) {
1331 print
'<td class="center">';
1332 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1333 print $lines[$i]->timespent_note;
1334 print
'</textarea>';
1338 print
'<td class="right">';
1358 return $totalforeachline;
1381 function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1383 global $conf, $db, $user, $langs;
1384 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1387 $totalforeachday = array();
1388 $workloadforid = array();
1389 $lineswithoutlevel0 = array();
1391 $numlines = count($lines);
1395 for ($i = 0; $i < $numlines; $i++) {
1396 if ($lines[$i]->fk_task_parent) {
1397 $lineswithoutlevel0[] = $lines[$i];
1402 if (empty($oldprojectforbreak)) {
1403 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1406 $restrictBefore =
null;
1408 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1409 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1414 for ($i = 0; $i < $numlines; $i++) {
1419 if ($lines[$i]->fk_task_parent == $parent) {
1423 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1426 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1431 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1432 $lastprojectid = $lines[$i]->fk_project;
1433 if ($preselectedday) {
1434 $projectstatic->id = $lines[$i]->fk_project;
1438 if (empty($workloadforid[$projectstatic->id])) {
1439 if ($preselectedday) {
1440 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1441 $workloadforid[$projectstatic->id] = 1;
1445 $projectstatic->id = $lines[$i]->fk_project;
1446 $projectstatic->ref = $lines[$i]->projectref;
1447 $projectstatic->title = $lines[$i]->projectlabel;
1448 $projectstatic->public = $lines[$i]->public;
1449 $projectstatic->status = $lines[$i]->projectstatus;
1451 $taskstatic->id = $lines[$i]->id;
1452 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1453 $taskstatic->label = $lines[$i]->label;
1454 $taskstatic->date_start = $lines[$i]->date_start;
1455 $taskstatic->date_end = $lines[$i]->date_end;
1457 $thirdpartystatic->id = $lines[$i]->socid;
1458 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1459 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1461 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1463 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1466 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1469 foreach ($arrayfields as $key => $val) {
1470 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1475 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1476 print
'<td colspan="'.(7 + $addcolspan).
'">';
1477 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1478 if ($thirdpartystatic->id > 0) {
1479 print
' - '.$thirdpartystatic->getNomUrl(1);
1481 if ($projectstatic->title) {
1483 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1550 if ($oldprojectforbreak != -1) {
1551 $oldprojectforbreak = $projectstatic->id;
1554 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1564 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1566 if ($oldprojectforbreak == -1) {
1567 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1573 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1574 print
'<td class="tdoverflowmax100">';
1575 if ($thirdpartystatic->id > 0) {
1576 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1583 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1584 for ($k = 0; $k < $level; $k++) {
1585 print
'<div class="marginleftonly">';
1587 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1590 print
'<span class="opacitymedium">'.$taskstatic->label.
'</a>';
1591 for ($k = 0; $k < $level; $k++) {
1597 $extrafieldsobjectkey =
'projet_task';
1598 $extrafieldsobjectprefix =
'efpt.';
1599 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1602 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1603 print
'<td class="leftborder plannedworkload right">';
1604 if ($lines[$i]->planned_workload) {
1613 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1614 print
'<td class="right">';
1615 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1619 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1621 print
'<td class="right">';
1623 if ($lines[$i]->duration_effective) {
1624 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1633 print
'<td class="right">';
1634 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1635 if ($tmptimespent[
'total_duration']) {
1643 $disabledproject = 1;
1649 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
1650 $disabledproject = 0;
1654 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1658 if ($restrictBefore && $preselectedday < $restrictBefore) {
1663 print
'<td class="nowraponall leftborder center minwidth150imp">';
1664 $tableCell =
$form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1669 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1670 $cssonholiday .=
'onholidayallday ';
1671 } elseif (!$isavailable[$preselectedday][
'morning']) {
1672 $cssonholiday .=
'onholidaymorning ';
1673 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1674 $cssonholiday .=
'onholidayafternoon ';
1680 $idw = ($tmparray[
'wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
1681 global $numstartworkingday, $numendworkingday;
1683 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1684 $cssweekend =
'weekend';
1688 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1689 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1690 if (!isset($totalforeachday[$preselectedday])) {
1691 $totalforeachday[$preselectedday] = 0;
1693 $totalforeachday[$preselectedday] += $dayWorkLoad;
1696 if ($dayWorkLoad > 0) {
1703 $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>';
1704 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1706 $tableCell .=
$form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1713 print
'<td class="center">';
1714 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1715 print
'</textarea>';
1719 print
'<td class="right">';
1720 if ((!$lines[$i]->
public) && $disabledproject) {
1721 print
$form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1722 } elseif ($disabledtask) {
1723 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1724 if ($fuser->id != $user->id) {
1725 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1728 print
$form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1737 if ($lines[$i]->
id > 0) {
1740 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1743 foreach ($ret as $key => $val) {
1744 $totalforeachday[$key] += $val;
1755 return $totalforeachday;
1778 function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1780 global $conf, $db, $user, $langs;
1781 global
$form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1783 $numlines = count($lines);
1786 $workloadforid = array();
1787 $totalforeachday = array();
1788 $lineswithoutlevel0 = array();
1792 for ($i = 0; $i < $numlines; $i++) {
1793 if ($lines[$i]->fk_task_parent) {
1794 $lineswithoutlevel0[] = $lines[$i];
1801 if (empty($oldprojectforbreak)) {
1802 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1);
1805 $restrictBefore =
null;
1807 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
1808 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1812 for ($i = 0; $i < $numlines; $i++) {
1817 if ($lines[$i]->fk_task_parent == $parent) {
1821 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1824 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1829 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1830 $lastprojectid = $lines[$i]->fk_project;
1831 $projectstatic->id = $lines[$i]->fk_project;
1836 if (empty($workloadforid[$projectstatic->id])) {
1837 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1838 $workloadforid[$projectstatic->id] = 1;
1843 $projectstatic->id = $lines[$i]->fk_project;
1844 $projectstatic->ref = $lines[$i]->projectref;
1845 $projectstatic->title = $lines[$i]->projectlabel;
1846 $projectstatic->public = $lines[$i]->public;
1847 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1848 $projectstatic->status = $lines[$i]->projectstatus;
1850 $taskstatic->id = $lines[$i]->id;
1851 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1852 $taskstatic->label = $lines[$i]->label;
1853 $taskstatic->date_start = $lines[$i]->date_start;
1854 $taskstatic->date_end = $lines[$i]->date_end;
1856 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1857 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1858 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1860 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1862 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1865 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1868 foreach ($arrayfields as $key => $val) {
1869 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1874 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1875 print
'<td colspan="'.(11 + $addcolspan).
'">';
1876 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1877 if ($thirdpartystatic->id > 0) {
1878 print
' - '.$thirdpartystatic->getNomUrl(1);
1880 if ($projectstatic->title) {
1882 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1949 if ($oldprojectforbreak != -1) {
1950 $oldprojectforbreak = $projectstatic->id;
1953 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1963 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1964 print
'<td class="nowrap">';
1965 if ($oldprojectforbreak == -1) {
1966 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1972 if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
1973 print
'<td class="tdoverflowmax100">';
1974 if ($thirdpartystatic->id > 0) {
1975 print $thirdpartystatic->getNomUrl(1,
'project');
1981 print
'<td class="nowrap">';
1982 print
'<!-- Task id = '.$lines[$i]->id.
' -->';
1983 for ($k = 0; $k < $level; $k++) {
1984 print
'<div class="marginleftonly">';
1986 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1989 print
'<span class="opacitymedium">'.$taskstatic->label.
'</span>';
1990 for ($k = 0; $k < $level; $k++) {
1996 $extrafieldsobjectkey =
'projet_task';
1997 $extrafieldsobjectprefix =
'efpt.';
1998 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2001 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
2002 print
'<td class="leftborder plannedworkload right">';
2003 if ($lines[$i]->planned_workload) {
2011 if (!empty($arrayfields[
't.progress'][
'checked'])) {
2013 print
'<td class="right">';
2014 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
2018 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
2020 print
'<td class="right">';
2022 if ($lines[$i]->duration_effective) {
2023 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
2032 print
'<td class="right">';
2033 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2034 if ($tmptimespent[
'total_duration']) {
2042 $disabledproject = 1;
2048 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2049 $disabledproject = 0;
2053 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
2061 $modeinput =
'hours';
2062 for ($idw = 0; $idw < 7; $idw++) {
2064 if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
2066 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
2067 $cssonholiday .=
'onholidayallday ';
2068 } elseif (!$isavailable[$tmpday][
'morning']) {
2069 $cssonholiday .=
'onholidaymorning ';
2070 } elseif (!$isavailable[$tmpday][
'afternoon']) {
2071 $cssonholiday .=
'onholidayafternoon ';
2075 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2076 $totalforeachday[$tmpday] += $dayWorkLoad;
2079 if ($dayWorkLoad > 0) {
2082 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", !empty($tmparray[
'day']) ? $tmparray[
'day'] : 0, $tmparray[
'mon']);
2084 global $numstartworkingday, $numendworkingday;
2086 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
2087 $cssweekend =
'weekend';
2090 $disabledtaskday = $disabledtask;
2092 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2093 $disabledtaskday = 1;
2096 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
2099 if ($alreadyspent) {
2100 $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>';
2104 $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"';
2105 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2106 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
2107 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
2108 $tableCell .= '</td>';
2113 print '<td class="right
">';
2114 if ((!$lines[$i]->public) && $disabledproject) {
2115 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2116 } elseif ($disabledtask) {
2117 $titleassigntask = $langs->trans("AssignTaskToMe
");
2118 if ($fuser->id != $user->id) {
2119 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2122 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2129 // Call to show task with a lower level (task under the current task)
2132 if ($lines[$i]->id > 0) {
2133 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2134 //var_dump($totalforeachday);
2135 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2136 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2138 foreach ($ret as $key => $val) {
2139 $totalforeachday[$key] += $val;
2141 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2142 //var_dump($totalforeachday);
2150 return $totalforeachday;
2171 function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
2173 global $conf, $db, $user, $langs;
2174 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2176 $numlines = count($lines);
2179 $workloadforid = array();
2180 $totalforeachweek = array();
2181 $lineswithoutlevel0 = array();
2183 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2184 if ($parent == 0) { // Always and only if at first level
2185 for ($i = 0; $i < $numlines; $i++) {
2186 if ($lines[$i]->fk_task_parent) {
2187 $lineswithoutlevel0[] = $lines[$i];
2192 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
2194 if (empty($oldprojectforbreak)) {
2195 $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
2198 $restrictBefore = null;
2200 if (!empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
2201 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2202 $restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
2205 for ($i = 0; $i < $numlines; $i++) {
2210 if ($lines[$i]->fk_task_parent == $parent) {
2211 // If we want all or we have a role on task, we show it
2212 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2213 //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);
2215 // Break on a new project
2216 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2217 $lastprojectid = $lines[$i]->fk_project;
2218 $projectstatic->id = $lines[$i]->fk_project;
2221 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2222 //var_dump($projectstatic->weekWorkLoadPerTask);
2223 if (empty($workloadforid[$projectstatic->id])) {
2224 $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
2225 $workloadforid[$projectstatic->id] = 1;
2227 //var_dump($projectstatic->weekWorkLoadPerTask);
2228 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2230 $projectstatic->id = $lines[$i]->fk_project;
2231 $projectstatic->ref = $lines[$i]->projectref;
2232 $projectstatic->title = $lines[$i]->projectlabel;
2233 $projectstatic->public = $lines[$i]->public;
2234 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2235 $projectstatic->status = $lines[$i]->projectstatus;
2237 $taskstatic->id = $lines[$i]->id;
2238 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2239 $taskstatic->label = $lines[$i]->label;
2240 $taskstatic->date_start = $lines[$i]->date_start;
2241 $taskstatic->date_end = $lines[$i]->date_end;
2243 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2244 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2245 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2247 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2248 print '<tr class="oddeven trforbreak nobold
">'."\n
";
2249 print '<td colspan="'.(6 + count($TWeek)).'">';
2250 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2251 if ($thirdpartystatic->id > 0) {
2252 print ' - '.$thirdpartystatic->getNomUrl(1);
2254 if ($projectstatic->title) {
2256 print '<span class="secondary
">'.$projectstatic->title.'</span>';
2262 if ($oldprojectforbreak != -1) {
2263 $oldprojectforbreak = $projectstatic->id;
2265 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
2269 print '<td class="nowrap
">';
2270 print $fuser->getNomUrl(1, 'withproject', 'time');
2275 /*print '<td class="nowrap
">';
2276 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
2280 /*print '<td class="tdoverflowmax100
">';
2281 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2285 print '<td class="nowrap
">';
2286 print '<!-- Task id = '.$lines[$i]->id.' -->';
2287 for ($k = 0; $k < $level; $k++) {
2288 print '<div class="marginleftonly
">';
2290 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2293 print '<span class="opacitymedium
">'.$taskstatic->label.'</span>';
2294 for ($k = 0; $k < $level; $k++) {
2300 print '<td class="leftborder plannedworkload right
">';
2301 if ($lines[$i]->planned_workload) {
2302 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2308 // Progress declared %
2309 print '<td class="right
">';
2310 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2313 // Time spent by everybody
2314 print '<td class="right
">';
2315 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2316 if ($lines[$i]->duration_effective) {
2317 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2318 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2325 // Time spent by user
2326 print '<td class="right
">';
2327 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2328 if ($tmptimespent['total_duration']) {
2329 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2335 $disabledproject = 1;
2337 //print "x
".$lines[$i]->fk_project;
2338 //var_dump($lines[$i]);
2339 //var_dump($projectsrole[$lines[$i]->fk_project]);
2340 // If at least one role for project
2341 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
2342 $disabledproject = 0;
2345 // If $restricteditformytask is on and I have no role on task, i disable edit
2346 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2350 //var_dump($projectstatic->weekWorkLoadPerTask);
2352 // Fields to show current time
2354 $modeinput = 'hours';
2355 $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
2356 $TFirstDay[reset($TWeek)] = 1;
2358 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2359 $year = $firstdaytoshowarray['year'];
2360 $month = $firstdaytoshowarray['mon'];
2361 foreach ($TWeek as $weekIndex => $weekNb) {
2362 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2363 if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
2364 $totalforeachweek[$weekNb] += $weekWorkLoad;
2367 if ($weekWorkLoad > 0) {
2368 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2370 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2372 $disabledtaskweek = $disabledtask;
2373 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2375 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2376 $disabledtaskweek = 1;
2379 $tableCell = '<td class="center hide weekend
">';
2381 if ($alreadyspent) {
2382 $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>';
2383 //$placeholder=' placeholder="00:00
"';
2387 $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
"';
2388 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2389 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2390 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2391 $tableCell .= '</td>';
2396 print '<td class="right
">';
2397 if ((!$lines[$i]->public) && $disabledproject) {
2398 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2399 } elseif ($disabledtask) {
2400 $titleassigntask = $langs->trans("AssignTaskToMe
");
2401 if ($fuser->id != $user->id) {
2402 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2405 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2412 // Call to show task with a lower level (task under the current task)
2415 if ($lines[$i]->id > 0) {
2416 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2417 //var_dump($totalforeachday);
2418 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2419 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2421 foreach ($ret as $key => $val) {
2422 $totalforeachweek[$key] += $val;
2424 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2425 //var_dump($totalforeachday);
2433 return $totalforeachweek;
2446 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
2448 //print 'Search in line with parent id = '.$parent.'<br>';
2449 $numlines = count($lines);
2450 for ($i = 0; $i < $numlines; $i++) {
2451 // Process line $lines[$i]
2452 if ($lines[$i]->fk_task_parent == $parent && $lines[$i]->id != $lines[$i]->fk_task_parent) {
2453 // If task is legitimate to show, no more need to search deeper
2454 if (isset($taskrole[$lines[$i]->id])) {
2455 //print 'Found a legitimate task id='.$lines[$i]->id.'<br>';
2460 searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
2461 //print 'Found inc='.$inc.'<br>';
2486 function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2488 global $langs, $conf, $user;
2489 global $theme_datacolor;
2491 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2493 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2495 $listofstatus = array_keys($listofoppstatus);
2497 if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2498 // Define $themeColorId and array $statusOppList for each $listofstatus
2500 $statusOppList = array();
2501 foreach ($listofstatus as $oppStatus) {
2502 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2503 if ($oppStatusCode) {
2504 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2505 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2511 $projectstatic = new Project($db);
2512 $thirdpartystatic = new Societe($db);
2516 $project_year_filter = 0;
2518 $title = $langs->trans("Projects");
2519 if (strcmp($status, '') && $status >= 0) {
2520 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
2523 print '<!-- print_projecttasks_array -->';
2524 print '<div class="div-table-responsive-no-min
">';
2525 print '<table class="noborder centpercent
">';
2527 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2529 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2530 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2531 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2533 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2535 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2536 $sql .= " AND p.rowid IN (
".$db->sanitize($projectsListId).")
";
2538 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2541 $sql .= " AND p.rowid = t.fk_projet
";
2542 $sql .= " AND ec.element_id = t.rowid
";
2543 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2544 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2545 $sql .= " AND ctc.element =
'project_task'";
2548 $sql .= " AND p.fk_statut =
".(int) $status;
2550 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2551 $project_year_filter = GETPOST("project_year_filter
");
2552 //Check if empty or invalid year. Wildcard ignores the sql check
2553 if ($project_year_filter != "*
") {
2554 if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
2555 $project_year_filter = date("Y
");
2557 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")
";
2558 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")
";
2562 // Get id of project we must show tasks
2563 $arrayidofprojects = array();
2564 $sql1 = "SELECT p.rowid as projectid
";
2566 $resql = $db->query($sql1);
2569 $num = $db->num_rows($resql);
2571 $objp = $db->fetch_object($resql);
2572 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2576 dol_print_error($db);
2578 if (empty($arrayidofprojects)) {
2579 $arrayidofprojects[0] = -1;
2582 // Get list of project with calculation on tasks
2583 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2584 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2585 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2586 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2587 $sql2 .= " s.logo, s.email, s.entity,
";
2588 $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,
";
2589 $sql2 .= " p.dateo, p.datee,
";
2590 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2591 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2592 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.
rowid = p.fk_soc";
2593 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.
rowid = t.fk_projet";
2594 $sql2 .= " WHERE p.
rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")";
2595 $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,";
2596 $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";
2597 $sql2 .= " ORDER BY p.title, p.
ref";
2599 $resql = $db->query($sql2);
2603 $total_opp_amount = 0;
2604 $ponderated_opp_amount = 0;
2605 $total_plannedworkload = 0;
2606 $total_declaredprogressworkload = 0;
2608 $num = $db->num_rows($resql);
2609 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
2612 print
'<tr class="liste_titre">';
2613 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);
2615 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2616 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2617 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2619 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 ');
2622 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2624 if (!in_array(
'plannedworkload', $hiddenfields)) {
2625 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2627 if (!in_array(
'declaredprogress', $hiddenfields)) {
2628 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2631 if (!in_array(
'projectstatus', $hiddenfields)) {
2636 while ($i < $nbofloop) {
2637 $objp = $db->fetch_object($resql);
2639 if ($max && $i >= $max) {
2642 $total_task += $objp->nb;
2643 $total_opp_amount += $objp->opp_amount;
2644 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2645 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2646 $plannedworkload = $objp->planned_workload;
2647 $total_plannedworkload += $plannedworkload;
2648 $declaredprogressworkload = $objp->declared_progess_workload;
2649 $total_declaredprogressworkload += $declaredprogressworkload;
2653 $projectstatic->id = $objp->projectid;
2654 $projectstatic->user_author_id = $objp->fk_user_creat;
2655 $projectstatic->public = $objp->public;
2658 $userAccess = $projectstatic->restrictedProjectArea($user);
2659 if ($userAccess >= 0) {
2660 $projectstatic->ref = $objp->ref;
2661 $projectstatic->status = $objp->status;
2662 $projectstatic->title = $objp->title;
2663 $projectstatic->date_end = $db->jdate($objp->datee);
2664 $projectstatic->date_start = $db->jdate($objp->dateo);
2666 print
'<tr class="oddeven">';
2668 print
'<td class="tdoverflowmax150">';
2669 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2670 if (!in_array(
'projectlabel', $hiddenfields)) {
2671 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).
'</span>';
2675 print
'<td class="nowraponall tdoverflowmax100">';
2676 if ($objp->fk_soc > 0) {
2677 $thirdpartystatic->id = $objp->socid;
2678 $thirdpartystatic->name = $objp->socname;
2681 $thirdpartystatic->code_compta = $objp->code_compta;
2682 $thirdpartystatic->client = $objp->client;
2684 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2685 $thirdpartystatic->fournisseur = $objp->fournisseur;
2686 $thirdpartystatic->logo = $objp->logo;
2687 $thirdpartystatic->email = $objp->email;
2688 $thirdpartystatic->entity = $objp->entity;
2689 print $thirdpartystatic->getNomUrl(1);
2693 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2694 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2695 print
'<td class="center tdoverflowmax75">';
2697 if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
2698 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2699 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2700 print $langs->trans(
"OppStatus".$oppStatusCode);
2703 if (isset($statusOppList[$objp->opp_status])) {
2704 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2705 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2707 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2708 $oppStatusColor =
'';
2710 if ($oppStatusCode) {
2711 if (!empty($oppStatusColor)) {
2712 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>';
2714 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2721 print
'<td class="right">';
2722 if ($objp->opp_percent && $objp->opp_amount) {
2723 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2724 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0, $conf->currency);
2725 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2727 if ($objp->opp_amount) {
2728 print
'<span class="amount" title="'.$alttext.
'">'.
$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2733 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2734 print
'<td class="right">'.$objp->nb.
'</td>';
2736 $plannedworkload = $objp->planned_workload;
2737 $total_plannedworkload += $plannedworkload;
2738 if (!in_array(
'plannedworkload', $hiddenfields)) {
2739 print
'<td class="right nowraponall">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2741 if (!in_array(
'declaredprogress', $hiddenfields)) {
2742 $declaredprogressworkload = $objp->declared_progess_workload;
2743 $total_declaredprogressworkload += $declaredprogressworkload;
2744 print
'<td class="right nowraponall">';
2746 print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2751 if (!in_array(
'projectstatus', $hiddenfields)) {
2752 print
'<td class="right">';
2753 print $projectstatic->getLibStatut(3);
2759 $total_task += $objp->nb;
2760 $total_opp_amount += $objp->opp_amount;
2767 print
'<tr class="oddeven">';
2768 print
'<td class="nowrap" colspan="5">';
2769 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
2774 print
'<tr class="liste_total">';
2775 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2776 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
2777 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2778 print
'<td class="liste_total"></td>';
2780 print
'<td class="liste_total right">';
2782 print
$form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0, $conf->currency));
2785 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
2786 print
'<td class="liste_total right">'.$total_task.
'</td>';
2787 if (!in_array(
'plannedworkload', $hiddenfields)) {
2788 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2790 if (!in_array(
'declaredprogress', $hiddenfields)) {
2791 print
'<td class="liste_total right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2794 if (!in_array(
'projectstatus', $hiddenfields)) {
2795 print
'<td class="liste_total"></td>';
2807 if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
2809 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2810 print
'<table width="100%">';
2812 print
'<td>'.$langs->trans(
"Year").
'</td>';
2813 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.
'"/>';
2815 print
'</table></form>';
2828 function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2830 global $langs, $conf;
2834 $plannedworkloadoutputformat =
'allhourmin';
2835 $timespentoutputformat =
'allhourmin';
2836 if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
2837 $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
2839 if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
2840 $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
2843 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2847 $spaced = !empty($spaced) ?
'spaced' :
'';
2852 $progressBarClass =
'progress-bar-info';
2853 $progressCalculated = 0;
2854 if ($task->planned_workload) {
2855 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2858 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2860 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.(isset($task->progress) ?
'%' :
'');
2861 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.(isset($progressCalculated) ?
'%' :
'');
2864 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2865 $progressBarClass =
'progress-bar-danger';
2866 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2867 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2868 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2869 $progressBarClass =
'progress-bar-warning';
2870 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2871 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2873 $progressBarClass =
'progress-bar-success';
2874 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2875 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2879 $out .=
'<div class="progress-group">';
2881 if ($label !==
false) {
2882 $out .=
' <span class="progress-text">';
2884 if ($label !==
true) {
2893 if ($progressNumber !==
false) {
2894 $out .=
' <span class="progress-number">';
2895 if ($progressNumber !==
true) {
2896 $out .= $progressNumber;
2898 if ($task->hasDelay()) {
2902 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2904 $out .= !empty($diff) ? $diff.
' ' :
'';
2905 $out .=
'<a href="'.$url.
'" >';
2906 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2907 if ($task->duration_effective) {
2917 $out .=
'<a href="'.$url.
'" >';
2918 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2919 if ($task->planned_workload) {
2931 $out .=
' <div class="progress sm '.$spaced.
'">';
2932 $diffval = floatval($task->progress) - floatval($progressCalculated);
2933 if ($diffval >= 0) {
2935 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.floatval($task->progress).
'%" title="'.floatval($task->progress).
'%">';
2936 if (!empty($task->progress)) {
2937 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated / (floatval($task->progress) == 0 ? 1 : $task->progress) * 100).
'%" title="'.floatval($progressCalculated).
'%"></div>';
2942 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).
'%" title="'.floatval($progressCalculated).
'%">';
2943 $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>';
2962 global $conf, $langs;
2966 if ($task->progress !=
'') {
2970 $badgeClass =
'badge ';
2971 if ($task->planned_workload) {
2972 $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2);
2975 $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2977 if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) {
2978 $badgeClass .=
'badge-danger';
2979 if (empty($tooltip)) {
2980 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2982 } elseif (floatval($progressCalculated) > floatval($task->progress)) {
2983 $badgeClass .=
'badge-warning';
2984 if (empty($tooltip)) {
2985 $tooltip = $task->progress.
'% < '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2988 $badgeClass .=
'badge-success';
2989 if (empty($tooltip)) {
2990 $tooltip = $task->progress.
'% >= '.$langs->trans(
"TimeConsumed").
' '.$progressCalculated.
'%';
2997 if (!empty($tooltip)) {
2998 $badgeClass .=
' classfortooltip';
2999 $title =
'title="'.dol_htmlentities($tooltip).
'"';
3002 if (empty($label)) {
3003 $label = $task->progress.
' %';
3006 if (!empty($label)) {
3007 $out =
'<span class="'.$badgeClass.
'" '.$title.
' >'.$label.
'</span>';