43 global $db, $langs,
$conf, $user;
48 $head[$h][0] = DOL_URL_ROOT.
'/projet/card.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
49 $head[$h][1] = $langs->trans(
"Project");
50 $head[$h][2] =
'project';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
55 $cachekey =
'count_contacts_project_'.$project->id;
58 if (!is_null($dataretrieved)) {
59 $nbContacts = $dataretrieved;
61 $nbContacts = count($project->liste_contact(-1,
'internal')) + count($project->liste_contact(-1,
'external'));
64 $head[$h][0] = DOL_URL_ROOT.
'/projet/contact.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
65 $head[$h][1] = $langs->trans(
"ProjectContact");
66 if ($nbContacts > 0) {
67 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContacts.
'</span>';
69 $head[$h][2] =
'contact';
76 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
77 $cachekey =
'count_tasks_project_'.$project->id;
80 if (!is_null($dataretrieved)) {
81 $nbTasks = $dataretrieved;
83 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
84 $taskstatic =
new Task($db);
85 $nbTasks = count($taskstatic->getTasksArray(
null,
null, $project->id, 0, 0));
88 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks.php?id='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
89 $head[$h][1] = $langs->trans(
"Tasks");
91 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTasks).
'</span>';
93 $head[$h][2] =
'tasks';
98 $cachekey =
'count_timespent_project_'.$project->id;
100 if (!is_null($dataretrieved)) {
101 $nbTimeSpent = $dataretrieved;
103 $sql =
"SELECT t.rowid";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t, ".MAIN_DB_PREFIX.
"projet_task as pt";
107 $sql .=
" WHERE t.fk_element = pt.rowid";
108 $sql .=
" AND t.elementtype = 'task'";
109 $sql .=
" AND pt.fk_projet =".((int) $project->id);
110 $resql = $db->query($sql);
112 $obj = $db->fetch_object($resql);
122 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&projectid='.((int) $project->id).($moreparam ?
'&'.$moreparam :
'');
123 $head[$h][1] = $langs->trans(
"TimeSpent");
124 if ($nbTimeSpent > 0) {
125 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
127 $head[$h][2] =
'timespent';
131 if (isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")
132 || isModEnabled(
"propal") || isModEnabled(
'order')
133 || isModEnabled(
'invoice') || isModEnabled(
'contract')
134 || isModEnabled(
'intervention') || isModEnabled(
'agenda') || isModEnabled(
'deplacement') || isModEnabled(
'stock')) {
137 $cachekey =
'count_elements_project_'.$project->id;
139 if (!is_null($dataretrieved)) {
140 $nbElements = $dataretrieved;
142 if (isModEnabled(
'stock')) {
143 $nbElements += $project->getElementCount(
'stock',
'entrepot',
'fk_project');
145 if (isModEnabled(
"propal")) {
146 $nbElements += $project->getElementCount(
'propal',
'propal');
148 if (isModEnabled(
'order')) {
149 $nbElements += $project->getElementCount(
'order',
'commande');
151 if (isModEnabled(
'invoice')) {
152 $nbElements += $project->getElementCount(
'invoice',
'facture');
154 if (isModEnabled(
'invoice')) {
155 $nbElements += $project->getElementCount(
'invoice_predefined',
'facture_rec');
157 if (isModEnabled(
'supplier_proposal')) {
158 $nbElements += $project->getElementCount(
'proposal_supplier',
'supplier_proposal');
160 if (isModEnabled(
"supplier_order")) {
161 $nbElements += $project->getElementCount(
'order_supplier',
'commande_fournisseur');
163 if (isModEnabled(
"supplier_invoice")) {
164 $nbElements += $project->getElementCount(
'invoice_supplier',
'facture_fourn');
166 if (isModEnabled(
'contract')) {
167 $nbElements += $project->getElementCount(
'contract',
'contrat');
169 if (isModEnabled(
'intervention')) {
170 $nbElements += $project->getElementCount(
'intervention',
'fichinter');
172 if (isModEnabled(
"shipping")) {
173 $nbElements += $project->getElementCount(
'shipping',
'expedition');
175 if (isModEnabled(
'mrp')) {
176 $nbElements += $project->getElementCount(
'mrp',
'mrp_mo',
'fk_project');
178 if (isModEnabled(
'deplacement')) {
179 $nbElements += $project->getElementCount(
'trip',
'deplacement');
181 if (isModEnabled(
'expensereport')) {
182 $nbElements += $project->getElementCount(
'expensereport',
'expensereport');
184 if (isModEnabled(
'don')) {
185 $nbElements += $project->getElementCount(
'donation',
'don');
187 if (isModEnabled(
'loan')) {
188 $nbElements += $project->getElementCount(
'loan',
'loan');
190 if (isModEnabled(
'tax')) {
191 $nbElements += $project->getElementCount(
'chargesociales',
'chargesociales');
193 if (isModEnabled(
'project')) {
194 $nbElements += $project->getElementCount(
'project_task',
'projet_task');
196 if (isModEnabled(
'stock')) {
197 $nbElements += $project->getElementCount(
'stock_mouvement',
'stock');
199 if (isModEnabled(
'salaries')) {
200 $nbElements += $project->getElementCount(
'salaries',
'payment_salary');
202 if (isModEnabled(
"bank")) {
203 $nbElements += $project->getElementCount(
'variouspayment',
'payment_various');
207 $head[$h][0] = DOL_URL_ROOT.
'/projet/element.php?id='.$project->id;
208 $head[$h][1] = $langs->trans(
"ProjectOverview");
209 if ($nbElements > 0) {
210 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbElements.
'</span>';
212 $head[$h][2] =
'element';
216 if (isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
217 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
218 $Tickettatic =
new Ticket($db);
219 $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id,
'fk_project',
'ticket');
220 $head[$h][0] = DOL_URL_ROOT.
'/ticket/list.php?projectid='.((int) $project->id);
221 $head[$h][1] = $langs->trans(
"Ticket");
223 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbTicket).
'</span>';
225 $head[$h][2] =
'ticket';
229 if (isModEnabled(
'eventorganization') && !empty($project->usage_organize_event)) {
230 $langs->load(
'eventorganization');
231 $head[$h][0] = DOL_URL_ROOT .
'/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
232 $head[$h][1] = $langs->trans(
"EventOrganization");
237 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
238 $cachekey =
'count_conferenceorbooth_'.$project->id;
240 if (!is_null($dataretrieved)) {
241 $nbConfOrBooth = $dataretrieved;
243 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
245 $result = $conforbooth->fetchAll(
'',
'', 0, 0,
'(t.fk_project:=:'.((
int) $project->id).
")");
247 if (!is_array($result) && $result < 0) {
250 $nbConfOrBooth = count($result);
254 $cachekey =
'count_attendees_'.$project->id;
256 if (!is_null($dataretrieved)) {
257 $nbAttendees = $dataretrieved;
259 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
261 $result = $conforboothattendee->fetchAll(
'',
'', 0, 0,
'(t.fk_project:=:'.((
int) $project->id).
')');
263 if (!is_array($result) && $result < 0) {
264 setEventMessages($conforboothattendee->error, $conforboothattendee->errors,
'errors');
266 $nbAttendees = count($result);
270 if ($nbConfOrBooth > 0 || $nbAttendees > 0) {
271 $head[$h][1] .=
'<span class="badge marginleftonlyshort">';
272 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"ConferenceOrBooth")).
'">'.$nbConfOrBooth.
'</span>';
273 $head[$h][1] .=
' + ';
274 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"Attendees")).
'">'.$nbAttendees.
'</span>';
275 $head[$h][1] .=
'</span>';
277 $head[$h][2] =
'eventorganisation';
290 if (!empty($project->note_private)) {
293 if (!empty($project->note_public)) {
296 $head[$h][0] = DOL_URL_ROOT.
'/projet/note.php?id='.$project->id;
297 $head[$h][1] = $langs->trans(
'Notes');
299 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
301 $head[$h][2] =
'notes';
308 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
309 $cachekey =
'count_attached_project_'.$project->id;
311 if (!is_null($dataretrieved)) {
312 $totalAttached = $dataretrieved;
314 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
315 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
316 $upload_dir =
$conf->project->multidir_output[empty($project->entity) ? 1 : $project->entity].
"/".
dol_sanitizeFileName($project->ref);
317 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
318 $nbLinks =
Link::count($db, $project->element, $project->id);
319 $totalAttached = $nbFiles + $nbLinks;
322 $head[$h][0] = DOL_URL_ROOT.
'/projet/document.php?id='.$project->id;
323 $head[$h][1] = $langs->trans(
'Documents');
324 if (($totalAttached) > 0) {
325 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
327 $head[$h][2] =
'document';
334 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
335 $cachekey =
'count_attached_project_'.$project->id;
337 if (!is_null($dataretrieved)) {
338 $nbComments = $dataretrieved;
340 $nbComments = $project->getNbComments();
343 $head[$h][0] = DOL_URL_ROOT.
'/projet/comment.php?id='.$project->id;
344 $head[$h][1] = $langs->trans(
"CommentLink");
345 if ($nbComments > 0) {
346 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbComments.
'</span>';
348 $head[$h][2] =
'project_comment';
352 $head[$h][0] = DOL_URL_ROOT.
'/projet/messaging.php?id='.$project->id;
353 $head[$h][1] = $langs->trans(
"Events");
354 if (isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
356 $head[$h][1] .= $langs->trans(
"Agenda");
358 $head[$h][2] =
'agenda';
600function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId =
'', $addordertick = 0, $projectidfortotallink = 0, $dummy =
'', $showbilltime = 0, $arrayfields = array(), $arrayofselected = array())
602 global $user, $langs,
$conf, $db, $hookmanager;
603 global $projectstatic, $taskstatic, $extrafields;
606 @phan-var-force Project $projectstatic
607 @phan-var-force Task $taskstatic
608 @phan-var-force ExtraFields $extrafields
613 $projectsArrayId = array();
614 if ($projectsListId) {
615 $projectsArrayId = explode(
',', $projectsListId);
618 $numlines = count($lines);
621 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;
625 $total_projectlinesa_spent = 0;
626 $total_projectlinesa_planned = 0;
627 $total_projectlinesa_spent_if_planned = 0;
628 $total_projectlinesa_declared_if_planned = 0;
629 $total_projectlinesa_tobill = 0;
630 $total_projectlinesa_billed = 0;
631 $total_budget_amount = 0;
632 $totalarray = array();
635 for ($i = 0; $i < $numlines; $i++) {
636 if ($parent == 0 && $level >= 0) {
642 if ($lines[$i]->fk_task_parent == $parent || $level < 0) {
648 if (is_array($taskrole)) {
650 if (!isset($taskrole[$lines[$i]->
id]) && $lines[$i]->
id != $lines[$i]->fk_task_parent) {
652 $foundtaskforuserdeeper = 0;
655 if ($foundtaskforuserdeeper > 0) {
664 if (!$user->hasRight(
'projet',
'all',
'lire')) {
666 if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
677 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
678 $lastprojectid = $lines[$i]->fk_project;
681 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'">'.
"\n";
683 $projectstatic->id = $lines[$i]->fk_project;
684 $projectstatic->ref = $lines[$i]->projectref;
685 $projectstatic->public = $lines[$i]->public;
686 $projectstatic->title = $lines[$i]->projectlabel;
687 $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time;
688 $projectstatic->status = $lines[$i]->projectstatus;
690 $taskstatic->id = $lines[$i]->id;
691 $taskstatic->ref = $lines[$i]->ref;
692 $taskstatic->label = (!empty($taskrole[$lines[$i]->
id]) ? $langs->trans(
"YourRole").
': '.$taskrole[$lines[$i]->id] :
'');
693 $taskstatic->projectstatus = $lines[$i]->projectstatus;
694 $taskstatic->progress = $lines[$i]->progress;
695 $taskstatic->fk_statut = $lines[$i]->status;
696 $taskstatic->status = $lines[$i]->status;
697 $taskstatic->date_start = $lines[$i]->date_start;
698 $taskstatic->date_end = $lines[$i]->date_end;
699 $taskstatic->datee = $lines[$i]->date_end;
700 $taskstatic->planned_workload = $lines[$i]->planned_workload;
701 $taskstatic->duration_effective = $lines[$i]->duration_effective;
702 $taskstatic->budget_amount = $lines[$i]->budget_amount;
703 $taskstatic->billable = $lines[$i]->billable;
707 print
'<td class="nowrap center">';
709 if (in_array($lines[$i]->
id, $arrayofselected)) {
712 print
'<input id="cb' . $lines[$i]->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
718 print
'<td class="nowraponall">';
720 if ($lines[$i]->
public || in_array($lines[$i]->fk_project, $projectsArrayId) || $user->hasRight(
'projet',
'all',
'lire')) {
721 print $projectstatic->getNomUrl(1);
723 print $projectstatic->getNomUrl(1,
'nolink');
730 $projectstatic->statut = $lines[$i]->projectstatus;
731 print $projectstatic->getLibStatut(2);
736 if (count($arrayfields) > 0 && !empty($arrayfields[
't.ref'][
'checked'])) {
737 print
'<td class="nowraponall">';
738 if ($showlineingray) {
739 print
'<i>'.img_object(
'',
'projecttask').
' '.$lines[$i]->ref.
'</i>';
741 print $taskstatic->getNomUrl(1,
'withproject');
747 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
749 if ($showlineingray) {
750 $labeltoshow .=
'<i>';
753 for ($k = 0; $k < $level; $k++) {
754 $labeltoshow .=
'<div class="marginleftonly">';
757 for ($k = 0; $k < $level; $k++) {
758 $labeltoshow .=
'</div>';
760 if ($showlineingray) {
761 $labeltoshow .=
'</i>';
763 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshow).
'">';
768 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
769 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($lines[$i]->
description).
'">';
770 print $lines[$i]->description;
775 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
776 print
'<td class="center nowraponall">';
782 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
783 print
'<td class="center nowraponall">';
785 if ($taskstatic->hasDelay()) {
791 $plannedworkloadoutputformat =
'allhourmin';
792 $timespentoutputformat =
'allhourmin';
801 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
802 print
'<td class="right">';
803 $fullhour =
convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
805 if ($lines[$i]->planned_workload !=
'') {
815 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
816 print
'<td class="right">';
817 if ($showlineingray) {
820 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ?
'' :
'&withproject=1').
'">';
822 if ($lines[$i]->duration_effective) {
827 if ($showlineingray) {
836 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
839 if ($lines[$i]->planned_workload || $lines[$i]->duration_effective) {
840 if ($lines[$i]->planned_workload) {
841 $s = round(100 * (
float) $lines[$i]->duration_effective / (
float) $lines[$i]->planned_workload, 2).
' %';
844 $s = $langs->trans(
'WorkloadNotDefined');
845 $shtml =
'<span class="opacitymedium">'.$s.
'</span>';
848 print
'<td class="right tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
854 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
855 print
'<td class="right">';
856 if ($lines[$i]->progress !=
'') {
863 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
864 print
'<td class="right">';
865 if ($lines[$i]->progress !=
'' && $lines[$i]->duration_effective) {
873 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
874 print
'<td class="right">';
875 if ($lines[$i]->usage_bill_time) {
877 $total_projectlinesa_tobill += $lines[$i]->tobill;
879 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
885 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
886 print
'<td class="right">';
887 if ($lines[$i]->usage_bill_time) {
889 $total_projectlinesa_billed += $lines[$i]->billed;
891 print
'<span class="opacitymedium">'.$langs->trans(
"NA").
'</span>';
898 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
899 print
'<td class="center">';
900 if ($lines[$i]->budget_amount) {
901 print
'<span class="amount">'.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency).
'</span>';
902 $total_budget_amount += $lines[$i]->budget_amount;
908 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
909 print
'<td class="center">';
911 foreach (array(
'internal',
'external') as $source) {
913 $tab = $lines[$i]->liste_contact(-1, $source, 0,
'', 1);
915 $numcontact = count($tab);
916 if (!empty($numcontact)) {
917 foreach ($tab as $contacttask) {
919 if ($source ==
'internal') {
924 $c->fetch($contacttask[
'id']);
925 if (!empty($c->photo)) {
926 if (get_class($c) ==
'User') {
927 print $c->getNomUrl(-2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
929 print $c->getNomUrl(-2,
'', 0, 0, -1, 0, ($ifisrt ?
'' :
'notfirst'));
932 if (get_class($c) ==
'User') {
933 print $c->getNomUrl(2,
'', 0, 0, 24, 1,
'', ($ifisrt ?
'' :
'notfirst'));
935 print $c->getNomUrl(2,
'', 0, 0, -1, 0, ($ifisrt ?
'' :
'notfirst'));
946 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billable'][
'checked'])) {
947 print
'<td class="center">';
948 if ($lines[$i]->billable) {
949 print
'<span>'.$langs->trans(
'Yes').
'</span>';
951 print
'<span>'.$langs->trans(
'No').
'</span>';
957 $extrafieldsobjectkey = $taskstatic->table_element;
958 $extrafieldsobjectprefix =
'efpt.';
960 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
962 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $lines[$i]);
963 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
964 print $hookmanager->resPrint;
967 print
'<td class="tdlineupdown center"></td>';
971 print
'<td class="nowrap center">';
973 if (in_array($lines[$i]->
id, $arrayofselected)) {
976 print
'<input id="cb' . $lines[$i]->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id .
'"' . ($selected ?
' checked="checked"' :
'') .
'>';
983 if (!$showlineingray) {
989 if ($lines[$i]->
id) {
990 projectLinesa($inc, $lines[$i]->
id, $lines, $level,
'', $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink,
'', $showbilltime, $arrayfields);
995 $total_projectlinesa_spent += $lines[$i]->duration_effective;
996 $total_projectlinesa_planned += $lines[$i]->planned_workload;
997 if ($lines[$i]->planned_workload) {
998 $total_projectlinesa_spent_if_planned += $lines[$i]->duration_effective;
1000 if ($lines[$i]->planned_workload) {
1001 $total_projectlinesa_declared_if_planned += (float) $lines[$i]->planned_workload * $lines[$i]->progress / 100;
1010 if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0)
1012 print
'<tr class="liste_total nodrag nodrop">';
1015 print
'<td class="liste_total"></td>';
1018 print
'<td class="liste_total">'.$langs->trans(
"Total").
'</td>';
1020 print
'<td></td><td></td>';
1022 if (count($arrayfields) > 0 && !empty($arrayfields[
't.label'][
'checked'])) {
1025 if (count($arrayfields) > 0 && !empty($arrayfields[
't.description'][
'checked'])) {
1028 if (count($arrayfields) > 0 && !empty($arrayfields[
't.dateo'][
'checked'])) {
1031 if (count($arrayfields) > 0 && !empty($arrayfields[
't.datee'][
'checked'])) {
1034 if (count($arrayfields) > 0 && !empty($arrayfields[
't.planned_workload'][
'checked'])) {
1035 print
'<td class="nowrap liste_total right">';
1039 if (count($arrayfields) > 0 && !empty($arrayfields[
't.duration_effective'][
'checked'])) {
1040 print
'<td class="nowrap liste_total right">';
1041 if ($projectidfortotallink > 0) {
1042 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ?
'' :
'&withproject=1').
'">';
1045 if ($projectidfortotallink > 0) {
1051 $totalCalculatedProgress = 0;
1052 $totalAverageDeclaredProgress = 0;
1054 $progressBarClass =
'';
1055 if ($total_projectlinesa_planned) {
1056 $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2);
1057 $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2);
1060 $warningRatio =
getDolGlobalString(
'PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 +
$conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
1063 $progressBarClass =
'progress-bar-info';
1064 $badgeClass =
'badge ';
1066 if ($totalCalculatedProgress > $totalAverageDeclaredProgress) {
1067 $progressBarClass =
'progress-bar-danger';
1068 $badgeClass .=
'badge-danger';
1069 } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) {
1070 $progressBarClass =
'progress-bar-warning';
1071 $badgeClass .=
'badge-warning';
1073 $progressBarClass =
'progress-bar-success';
1074 $badgeClass .=
'badge-success';
1079 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_calculated'][
'checked'])) {
1080 print
'<td class="nowrap liste_total right">';
1081 if ($total_projectlinesa_planned) {
1082 print $totalCalculatedProgress.
' %';
1088 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress'][
'checked'])) {
1089 print
'<td class="nowrap liste_total right">';
1090 if ($total_projectlinesa_planned) {
1091 print
'<span class="'.$badgeClass.
'" >'.$totalAverageDeclaredProgress.
' %</span>';
1098 if (count($arrayfields) > 0 && !empty($arrayfields[
't.progress_summary'][
'checked'])) {
1099 print
'<td class="right">';
1100 if ($total_projectlinesa_planned) {
1102 print
' <div class="progress sm" title="'.$totalAverageDeclaredProgress.
'%" >';
1103 print
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.$totalAverageDeclaredProgress.
'%"></div>';
1110 if ($showbilltime) {
1111 if (count($arrayfields) > 0 && !empty($arrayfields[
't.tobill'][
'checked'])) {
1112 print
'<td class="nowrap liste_total right">';
1116 if (count($arrayfields) > 0 && !empty($arrayfields[
't.billed'][
'checked'])) {
1117 print
'<td class="nowrap liste_total right">';
1124 if (count($arrayfields) > 0 && !empty($arrayfields[
't.budget_amount'][
'checked'])) {
1125 print
'<td class="nowrap liste_total center">';
1126 if (strcmp((
string) $total_budget_amount,
'')) {
1127 print
price($total_budget_amount, 0, $langs, 1, 0, 0,
$conf->currency);
1137 if (count($arrayfields) > 0 && !empty($arrayfields[
'c.assigned'][
'checked'])) {
1142 if (!empty($extrafields->attributes[
'projet_task'][
'totalizable'])) {
1143 foreach ($extrafields->attributes[
'projet_task'][
'totalizable'] as $key => $value) {
1144 if (!empty($arrayfields[
'efpt.'.$key][
'checked']) && $arrayfields[
'efpt.'.$key][
'checked'] == 1) {
1145 print
'<td class="right">';
1147 print empty($totalarray[
'totalizable'][$key][
'total']) ?
'' : $totalarray[
'totalizable'][$key][
'total'];
1155 print
'<td class="liste_total"></td>';
1158 print
'<td class="liste_total"></td>';
1185function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
1187 global
$conf, $db, $user, $langs;
1188 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1190 @phan-var-force FormOther $formother
1191 @phan-var-force Project $projectstatic
1192 @phan-var-force Task $taskstatic
1193 @phan-var-force Societe $thirdpartystatic
1197 $totalforeachline = array();
1198 $workloadforid = array();
1199 $lineswithoutlevel0 = array();
1201 $numlines = count($lines);
1205 for ($i = 0; $i < $numlines; $i++) {
1206 if ($lines[$i]->fk_task_parent) {
1207 $lineswithoutlevel0[] = $lines[$i];
1212 if (empty($oldprojectforbreak)) {
1213 $oldprojectforbreak = (!
getDolGlobalString(
'PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1);
1217 for ($i = 0; $i < $numlines; $i++) {
1225 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1229 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1230 $lastprojectid = $lines[$i]->fk_project;
1231 if ($preselectedday) {
1232 $projectstatic->id = $lines[$i]->fk_project;
1236 if (empty($workloadforid[$projectstatic->id])) {
1237 if ($preselectedday) {
1238 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1239 $workloadforid[$projectstatic->id] = 1;
1243 $projectstatic->id = $lines[$i]->fk_project;
1244 $projectstatic->ref = $lines[$i]->project_ref;
1245 $projectstatic->title = $lines[$i]->project_label;
1246 $projectstatic->public = $lines[$i]->public;
1247 $projectstatic->status = $lines[$i]->project->status;
1249 $taskstatic->id = $lines[$i]->fk_statut;
1250 $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
1251 $taskstatic->label = $lines[$i]->task_label;
1252 $taskstatic->date_start = $lines[$i]->date_start;
1253 $taskstatic->date_end = $lines[$i]->date_end;
1255 $thirdpartystatic->id = $lines[$i]->socid;
1256 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1257 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1259 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1260 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1261 print
'<td colspan="11">';
1262 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1263 if ($projectstatic->title) {
1265 print $projectstatic->title;
1271 if ($oldprojectforbreak != -1) {
1272 $oldprojectforbreak = $projectstatic->id;
1275 print
'<tr class="oddeven">'.
"\n";
1286 if ($oldprojectforbreak == -1) {
1287 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1288 print
'<br>'.$projectstatic->title;
1293 print
'<td class="tdoverflowmax100">';
1294 if ($thirdpartystatic->id > 0) {
1295 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1301 print
'<!-- Task id = '.$lines[$i]->id.
' (projectlinesperaction) -->';
1302 for ($k = 0; $k < $level; $k++) {
1303 print
'<div class="marginleftonly">';
1305 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1308 print
'<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).
'">'.
dol_escape_htmltag($taskstatic->label).
'</div>';
1309 for ($k = 0; $k < $level; $k++) {
1315 print
'<td class="center">';
1319 $disabledproject = 1;
1325 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight(
'projet',
'all',
'creer')) {
1326 $disabledproject = 0;
1330 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1335 print
'<td class="nowrap center">';
1340 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1341 $cssonholiday .=
'onholidayallday ';
1342 } elseif (!$isavailable[$preselectedday][
'morning']) {
1343 $cssonholiday .=
'onholidaymorning ';
1344 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1345 $cssonholiday .=
'onholidayafternoon ';
1349 print
'<td class="duration'.($cssonholiday ?
' '.$cssonholiday :
'').
' center">';
1351 $dayWorkLoad = $lines[$i]->timespent_duration;
1352 if (!array_key_exists($preselectedday, $totalforeachline)) {
1353 $totalforeachline[$preselectedday] = 0;
1355 $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
1358 if ($dayWorkLoad > 0) {
1367 print
'<td class="center">';
1368 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1369 print $lines[$i]->timespent_note;
1370 print
'</textarea>';
1374 print
'<td class="right">';
1394 return $totalforeachline;
1417function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1419 global
$conf, $db, $user, $langs;
1420 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1422 @phan-var-force FormOther $formother
1423 @phan-var-force Project $projectstatic
1424 @phan-var-force Task $taskstatic
1425 @phan-var-force Societe $thirdpartystatic
1429 $totalforeachday = array();
1430 $workloadforid = array();
1431 $lineswithoutlevel0 = array();
1433 $numlines = count($lines);
1437 for ($i = 0; $i < $numlines; $i++) {
1438 if ($lines[$i]->fk_task_parent) {
1439 $lineswithoutlevel0[] = $lines[$i];
1444 if (empty($oldprojectforbreak)) {
1445 $oldprojectforbreak = (!
getDolGlobalString(
'PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1);
1448 $restrictBefore =
null;
1451 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1456 for ($i = 0; $i < $numlines; $i++) {
1461 if ($lines[$i]->fk_task_parent == $parent) {
1465 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1468 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1473 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1474 $lastprojectid = $lines[$i]->fk_project;
1475 if ($preselectedday) {
1476 $projectstatic->id = $lines[$i]->fk_project;
1480 if (empty($workloadforid[$projectstatic->id])) {
1481 if ($preselectedday) {
1482 $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
1483 $workloadforid[$projectstatic->id] = 1;
1487 $projectstatic->id = $lines[$i]->fk_project;
1488 $projectstatic->ref = $lines[$i]->projectref;
1489 $projectstatic->title = $lines[$i]->projectlabel;
1490 $projectstatic->public = $lines[$i]->public;
1491 $projectstatic->status = $lines[$i]->projectstatus;
1493 $taskstatic->id = $lines[$i]->id;
1494 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1495 $taskstatic->label = $lines[$i]->label;
1496 $taskstatic->date_start = $lines[$i]->date_start;
1497 $taskstatic->date_end = $lines[$i]->date_end;
1499 $thirdpartystatic->id = $lines[$i]->socid;
1500 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1501 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1503 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1505 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1508 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1511 foreach ($arrayfields as $key => $val) {
1512 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1517 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1518 print
'<td colspan="'.(7 + $addcolspan).
'">';
1519 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1520 if ($thirdpartystatic->id > 0) {
1521 print
' - '.$thirdpartystatic->getNomUrl(1);
1523 if ($projectstatic->title) {
1525 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1592 if ($oldprojectforbreak != -1) {
1593 $oldprojectforbreak = $projectstatic->id;
1596 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
1608 if ($oldprojectforbreak == -1) {
1609 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
1616 print
'<td class="tdoverflowmax100">';
1617 if ($thirdpartystatic->id > 0) {
1618 print $thirdpartystatic->getNomUrl(1,
'project', 10);
1625 print
'<!-- Task id = '.$lines[$i]->id.
' (projectlinesperday) -->';
1626 for ($k = 0; $k < $level; $k++) {
1627 print
'<div class="marginleftonly">';
1629 print $taskstatic->getNomUrl(1,
'withproject',
'time');
1632 print
'<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).
'">'.
dol_escape_htmltag($taskstatic->label).
'</div>';
1633 for ($k = 0; $k < $level; $k++) {
1639 $extrafieldsobjectkey =
'projet_task';
1640 $extrafieldsobjectprefix =
'efpt.';
1641 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1644 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1645 print
'<td class="leftborder plannedworkload right">';
1646 if ($lines[$i]->planned_workload) {
1655 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1656 print
'<td class="right">';
1657 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
1661 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
1663 print
'<td class="right">';
1665 if ($lines[$i]->duration_effective) {
1666 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$lines[$i]->id.
'">';
1675 print
'<td class="right">';
1676 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
1677 if ($tmptimespent[
'total_duration']) {
1685 $disabledproject = 1;
1691 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight(
'projet',
'all',
'creer')) {
1692 $disabledproject = 0;
1696 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
1700 if ($restrictBefore && $preselectedday < $restrictBefore) {
1705 print
'<td class="nowraponall leftborder center minwidth150imp borderleft">';
1706 $tableCell = $form->selectDate($preselectedday, $lines[$i]->
id, 1, 1, 2,
"addtime", 0, 0, $disabledtask);
1711 if (!$isavailable[$preselectedday][
'morning'] && !$isavailable[$preselectedday][
'afternoon']) {
1712 $cssonholiday .=
'onholidayallday ';
1713 } elseif (!$isavailable[$preselectedday][
'morning']) {
1714 $cssonholiday .=
'onholidaymorning ';
1715 } elseif (!$isavailable[$preselectedday][
'afternoon']) {
1716 $cssonholiday .=
'onholidayafternoon ';
1723 global $numstartworkingday, $numendworkingday;
1725 if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) {
1726 $cssweekend =
'weekend';
1730 print
'<td class="center duration'.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').
'">';
1731 $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
1732 if (!isset($totalforeachday[$preselectedday])) {
1733 $totalforeachday[$preselectedday] = 0;
1735 $totalforeachday[$preselectedday] += $dayWorkLoad;
1738 if ($dayWorkLoad > 0) {
1745 $tableCell .=
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center width40" disabled id="timespent['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="'.$alreadyspent.
'"></span>';
1746 $tableCell .=
'<span class="hideonsmartphone"> + </span>';
1748 $tableCell .= $form->select_duration($lines[$i]->
id.
'duration',
'', $disabledtask,
'text', 0, 1);
1755 print
'<td class="center">';
1756 print
'<textarea name="'.$lines[$i]->id.
'note" rows="'.ROWS_2.
'" id="'.$lines[$i]->id.
'note"'.($disabledtask ?
' disabled="disabled"' :
'').
'>';
1757 print
'</textarea>';
1761 print
'<td class="right">';
1762 if ((!$lines[$i]->
public) && $disabledproject) {
1763 print $form->textwithpicto(
'', $langs->trans(
"UserIsNotContactOfProject"));
1764 } elseif ($disabledtask) {
1765 $titleassigntask = $langs->trans(
"AssignTaskToMe");
1766 if ($fuser->id != $user->id) {
1767 $titleassigntask = $langs->trans(
"AssignTaskToUser",
'...');
1770 print $form->textwithpicto(
'', $langs->trans(
"TaskIsNotAssignedToUser", $titleassigntask));
1779 if ($lines[$i]->
id > 0) {
1782 $ret =
projectLinesPerDay($inc, $lines[$i]->
id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
1785 foreach ($ret as $key => $val) {
1786 $totalforeachday[$key] += $val;
1797 return $totalforeachday;
1820function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields =
null)
1822 global
$conf, $db, $user, $langs;
1823 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
1825 @phan-var-force FormOther $formother
1826 @phan-var-force Project $projectstatic
1827 @phan-var-force Task $taskstatic
1828 @phan-var-force Societe $thirdpartystatic
1831 $numlines = count($lines);
1834 $workloadforid = array();
1835 $totalforeachday = array();
1836 $lineswithoutlevel0 = array();
1840 for ($i = 0; $i < $numlines; $i++) {
1841 if ($lines[$i]->fk_task_parent) {
1842 $lineswithoutlevel0[] = $lines[$i];
1849 if (empty($oldprojectforbreak)) {
1850 $oldprojectforbreak = (!
getDolGlobalString(
'PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1);
1853 $restrictBefore =
null;
1856 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1860 for ($i = 0; $i < $numlines; $i++) {
1865 if ($lines[$i]->fk_task_parent == $parent) {
1869 if (empty($mine) || !empty($tasksrole[$lines[$i]->
id])) {
1872 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->
id])) {
1877 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
1878 $lastprojectid = $lines[$i]->fk_project;
1879 $projectstatic->id = $lines[$i]->fk_project;
1884 if (empty($workloadforid[$projectstatic->id])) {
1885 $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);
1886 $workloadforid[$projectstatic->id] = 1;
1891 $projectstatic->id = $lines[$i]->fk_project;
1892 $projectstatic->ref = $lines[$i]->projectref;
1893 $projectstatic->title = $lines[$i]->projectlabel;
1894 $projectstatic->public = $lines[$i]->public;
1895 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
1896 $projectstatic->status = $lines[$i]->projectstatus;
1898 $taskstatic->id = $lines[$i]->id;
1899 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
1900 $taskstatic->label = $lines[$i]->label;
1901 $taskstatic->date_start = $lines[$i]->date_start;
1902 $taskstatic->date_end = $lines[$i]->date_end;
1904 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
1905 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
1906 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
1908 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
1910 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
1913 if (!empty($arrayfields[
't.progress'][
'checked'])) {
1916 foreach ($arrayfields as $key => $val) {
1917 if ($val[
'checked'] && substr($key, 0, 5) ==
'efpt.') {
1922 print
'<tr class="oddeven trforbreak nobold">'.
"\n";
1923 print
'<td colspan="'.(11 + $addcolspan).
'">';
1924 print $projectstatic->getNomUrl(1,
'', 0,
'<strong>'.$langs->transnoentitiesnoconv(
"YourRole").
':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1925 if ($thirdpartystatic->id > 0) {
1926 print
' - '.$thirdpartystatic->getNomUrl(1);
1928 if ($projectstatic->title) {
1930 print
'<span class="secondary">'.$projectstatic->title.
'</span>';
1997 if ($oldprojectforbreak != -1) {
1998 $oldprojectforbreak = $projectstatic->id;
2001 print
'<tr class="oddeven" data-taskid="'.$lines[$i]->id.
'">'.
"\n";
2012 print
'<td class="nowrap">';
2013 if ($oldprojectforbreak == -1) {
2014 print $projectstatic->getNomUrl(1,
'', 0, $langs->transnoentitiesnoconv(
"YourRole").
': '.$projectsrole[$lines[$i]->fk_project]);
2021 print
'<td class="tdoverflowmax100">';
2022 if ($thirdpartystatic->id > 0) {
2023 print $thirdpartystatic->getNomUrl(1,
'project');
2029 print
'<td class="tdoverflowmax300">';
2030 print
'<!-- Task id = '.$lines[$i]->id.
' (projectlinesperweek) -->';
2031 for ($k = 0; $k < $level; $k++) {
2032 print
'<div class="marginleftonly">';
2034 print $taskstatic->getNomUrl(1,
'withproject',
'time');
2037 print
'<div class="opacitymedium tdoverflowmax500" title="'.dol_escape_htmltag($taskstatic->label).
'">'.
dol_escape_htmltag($taskstatic->label).
'</div>';
2038 for ($k = 0; $k < $level; $k++) {
2044 $extrafieldsobjectkey =
'projet_task';
2045 $extrafieldsobjectprefix =
'efpt.';
2046 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2049 if (!empty($arrayfields[
't.planned_workload'][
'checked'])) {
2050 print
'<td class="leftborder plannedworkload right">';
2051 if ($lines[$i]->planned_workload) {
2059 if (!empty($arrayfields[
't.progress'][
'checked'])) {
2061 print
'<td class="right">';
2062 print $formother->select_percent($lines[$i]->progress, $lines[$i]->
id.
'progress');
2066 if (!empty($arrayfields[
'timeconsumed'][
'checked'])) {
2068 print
'<td class="right">';
2070 if ($lines[$i]->duration_effective) {
2071 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.((int) $lines[$i]->
id).
'">';
2080 print
'<td class="right">';
2081 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2082 if ($tmptimespent[
'total_duration']) {
2083 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.((int) $lines[$i]->
id).
'&search_user='.((int) $fuser->id).
'">';
2092 $disabledproject = 1;
2098 if ($lines[$i]->
public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight(
'projet',
'all',
'creer')) {
2099 $disabledproject = 0;
2103 if ($restricteditformytask && empty($tasksrole[$lines[$i]->
id])) {
2111 $modeinput =
'hours';
2113 for ($idw = 0; $idw < 7; $idw++) {
2116 if (!isset($totalforeachday[$tmpday])) {
2117 $totalforeachday[$tmpday] = 0;
2120 if (!$isavailable[$tmpday][
'morning'] && !$isavailable[$tmpday][
'afternoon']) {
2121 $cssonholiday .=
'onholidayallday ';
2122 } elseif (!$isavailable[$tmpday][
'morning']) {
2123 $cssonholiday .=
'onholidaymorning ';
2124 } elseif (!$isavailable[$tmpday][
'afternoon']) {
2125 $cssonholiday .=
'onholidayafternoon ';
2129 $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
2130 $totalforeachday[$tmpday] += $dayWorkLoad;
2133 if ($dayWorkLoad > 0) {
2136 $alttitle = $langs->trans(
"AddHereTimeSpentForDay", !empty($tmparray[
'day']) ? $tmparray[
'day'] : 0, $tmparray[
'mon']);
2138 global $numstartworkingday, $numendworkingday;
2140 if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) {
2141 $cssweekend =
'weekend';
2144 $disabledtaskday = $disabledtask;
2146 if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
2147 $disabledtaskday = 1;
2150 $tableCell =
'<td class="center hide'.$idw.($cssonholiday ?
' '.$cssonholiday :
'').($cssweekend ?
' '.$cssweekend :
'').($j <= 1 ?
' borderleft' :
'').
'">';
2153 if ($alreadyspent) {
2154 $tableCell .=
'<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd width40" disabled id="timespent['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="'.$alreadyspent.
'"></span>';
2158 $tableCell .=
'<input type="text" alt="'.($disabledtaskday ?
'' : $alttitle).
'" title="'.($disabledtaskday ?
'' : $alttitle).
'" '.($disabledtaskday ?
'disabled' : $placeholder).
' class="center smallpadd width40" id="timeadded['.$inc.
']['.$idw.
']" name="task['.$lines[$i]->id.
']['.$idw.
']" value="" cols="2" maxlength="5"';
2159 $tableCell .=
' onkeypress="return regexEvent(this,event,\'timeChar\')"';
2160 $tableCell .=
' onkeyup="updateTotal('.$idw.
',\''.$modeinput.
'\')
"';
2161 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$idw.',\
''.$modeinput.
'\')
" />';
2162 $tableCell .= '</td>';
2167 print '<td class="right
">';
2168 if ((!$lines[$i]->public) && $disabledproject) {
2169 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2170 } elseif ($disabledtask) {
2171 $titleassigntask = $langs->trans("AssignTaskToMe
");
2172 if ($fuser->id != $user->id) {
2173 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2176 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2183 // Call to show task with a lower level (task under the current task)
2186 if ($lines[$i]->id > 0) {
2187 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2188 //var_dump($totalforeachday);
2189 $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
2190 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2192 foreach ($ret as $key => $val) {
2193 $totalforeachday[$key] += $val;
2195 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2196 //var_dump($totalforeachday);
2204 return $totalforeachday;
2227function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array(), $arrayfields = array(), $extrafields = null)
2229 global $conf, $db, $user, $langs;
2230 global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
2232 @phan-var-force FormOther $formother
2233 @phan-var-force Project $projectstatic
2234 @phan-var-force Task $taskstatic
2235 @phan-var-force Societe $thirdpartystatic
2238 $numlines = count($lines);
2241 $workloadforid = array();
2242 $totalforeachweek = array();
2243 $lineswithoutlevel0 = array();
2245 // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
2246 if ($parent == 0) { // Always and only if at first level
2247 for ($i = 0; $i < $numlines; $i++) {
2248 if ($lines[$i]->fk_task_parent) {
2249 $lineswithoutlevel0[] = $lines[$i];
2254 //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=
".$numlines." count(lineswithoutlevel0)=
".count($lineswithoutlevel0));
2256 if (empty($oldprojectforbreak)) {
2257 $oldprojectforbreak = (!getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break
2260 $restrictBefore = null;
2262 if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
2263 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2264 $restrictBefore = dol_time_plus_duree(dol_now(), -1 * getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'), 'm');
2267 for ($i = 0; $i < $numlines; $i++) {
2272 if ($lines[$i]->fk_task_parent == $parent) {
2273 // If we want all or we have a role on task, we show it
2274 if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
2275 //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);
2277 if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
2281 // Break on a new project
2282 if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
2283 $lastprojectid = $lines[$i]->fk_project;
2284 $projectstatic->id = $lines[$i]->fk_project;
2287 //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2288 //var_dump($projectstatic->weekWorkLoadPerTask);
2289 if (empty($workloadforid[$projectstatic->id])) {
2290 $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
2291 $workloadforid[$projectstatic->id] = 1;
2293 //var_dump($projectstatic->weekWorkLoadPerTask);
2294 //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
2296 $projectstatic->id = $lines[$i]->fk_project;
2297 $projectstatic->ref = $lines[$i]->projectref;
2298 $projectstatic->title = $lines[$i]->projectlabel;
2299 $projectstatic->public = $lines[$i]->public;
2300 $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
2301 $projectstatic->status = $lines[$i]->projectstatus;
2303 $taskstatic->id = $lines[$i]->id;
2304 $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
2305 $taskstatic->label = $lines[$i]->label;
2306 $taskstatic->date_start = $lines[$i]->date_start;
2307 $taskstatic->date_end = $lines[$i]->date_end;
2309 $thirdpartystatic->id = $lines[$i]->thirdparty_id;
2310 $thirdpartystatic->name = $lines[$i]->thirdparty_name;
2311 $thirdpartystatic->email = $lines[$i]->thirdparty_email;
2313 if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
2314 print '<tr class="oddeven trforbreak nobold
">'."\n
";
2315 print '<td colspan="'.(6 + count($TWeek)).'">';
2316 print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole
").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
2317 if ($thirdpartystatic->id > 0) {
2318 print ' - '.$thirdpartystatic->getNomUrl(1);
2320 if ($projectstatic->title) {
2322 print '<span class="secondary
">'.$projectstatic->title.'</span>';
2328 if ($oldprojectforbreak != -1) {
2329 $oldprojectforbreak = $projectstatic->id;
2331 print '<tr class="oddeven
" data-taskid="'.$lines[$i]->id.'">'."\n
";
2335 print '<td class="nowrap
">';
2336 print $fuser->getNomUrl(1, 'withproject', 'time');
2341 /*print '<td class="nowrap
">';
2342 if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole
").': '.$projectsrole[$lines[$i]->fk_project]);
2346 /*print '<td class="tdoverflowmax100
">';
2347 if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
2351 print '<td class="nowrap
">';
2352 print '<!-- Task id = '.$lines[$i]->id.' (projectlinespermonth) -->';
2353 for ($k = 0; $k < $level; $k++) {
2354 print '<div class="marginleftonly
">';
2356 print $taskstatic->getNomUrl(1, 'withproject', 'time');
2359 print '<div class="opacitymedium tdoverflowmax500
" title="'.dol_escape_htmltag($taskstatic->label).'">'.dol_escape_htmltag($taskstatic->label).'</div>';
2360 for ($k = 0; $k < $level; $k++) {
2366 if (!empty($arrayfields['t.planned_workload']['checked'])) {
2367 print '<td class="leftborder plannedworkload right
">';
2368 if ($lines[$i]->planned_workload) {
2369 print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
2376 // Progress declared %
2377 if (!empty($arrayfields['t.progress']['checked'])) {
2378 print '<td class="right
">';
2379 print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
2383 // Time spent by everybody
2384 if (!empty($arrayfields['timeconsumed']['checked'])) {
2385 print '<td class="right
">';
2386 // $lines[$i]->duration_effective is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user
2387 if ($lines[$i]->duration_effective) {
2388 print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?
id=
'.$lines[$i]->id.'">';
2389 print convertSecondToTime($lines[$i]->duration_effective, 'allhourmin');
2396 // Time spent by user
2397 print '<td class="right
">';
2398 $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
2399 if ($tmptimespent['total_duration']) {
2400 print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
2407 $disabledproject = 1;
2409 //print "x
".$lines[$i]->fk_project;
2410 //var_dump($lines[$i]);
2411 //var_dump($projectsrole[$lines[$i]->fk_project]);
2412 // If at least one role for project
2413 if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
2414 $disabledproject = 0;
2417 // If $restricteditformytask is on and I have no role on task, i disable edit
2418 if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
2422 //var_dump($projectstatic->weekWorkLoadPerTask);
2424 // Fields to show current time
2426 $modeinput = 'hours';
2427 $TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow));
2428 $TFirstDay[reset($TWeek)] = 1;
2430 $firstdaytoshowarray = dol_getdate($firstdaytoshow);
2431 $year = $firstdaytoshowarray['year'];
2432 $month = $firstdaytoshowarray['mon'];
2434 foreach ($TWeek as $weekIndex => $weekNb) {
2436 $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
2437 if (!isset($totalforeachweek[$weekNb])) {
2438 $totalforeachweek[$weekNb] = 0;
2440 $totalforeachweek[$weekNb] += $weekWorkLoad;
2443 if ($weekWorkLoad > 0) {
2444 $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
2446 $alttitle = $langs->trans("AddHereTimeSpentForWeek
", $weekNb);
2448 $disabledtaskweek = $disabledtask;
2449 $firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
2451 if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
2452 $disabledtaskweek = 1;
2455 $tableCell = '<td class="center hide
'.($j <= 1 ? ' borderleft
' : '').'">';
2457 if ($alreadyspent) {
2458 $tableCell .= '<span class="timesheetalreadyrecorded
" title="texttoreplace
"><input type="text
" class="center smallpadd width40
" disabled id="timespent[
'.$inc.'][
'.((int) $weekNb).']
" name="task[
'.$lines[$i]->id.'][
'.$weekNb.']
" value="'.$alreadyspent.'"></span>';
2459 //$placeholder=' placeholder="00:00
"';
2463 $tableCell .= '<input type="text
" alt="'.($disabledtaskweek ? '' : $alttitle).'" title="'.($disabledtaskweek ? '' : $alttitle).'" '.($disabledtaskweek ? 'disabled' : $placeholder).' class="center smallpadd width40
" id="timeadded[
'.$inc.'][
'.((int) $weekNb).']
" name="task[
'.$lines[$i]->id.'][
'.($TFirstDay[$weekNb] - 1).']
" value="" cols="2
" maxlength="5
"';
2464 $tableCell .= ' onkeypress="return regexEvent(
this,event,\
'timeChar\')"';
2465 $tableCell .=
' onkeyup="updateTotal('.$weekNb.
',\''.$modeinput.
'\')
"';
2466 $tableCell .= ' onblur="regexEvent(
this,event,\
''.$modeinput.
'\'); updateTotal(
'.$weekNb.',\
''.$modeinput.
'\')
" />';
2467 $tableCell .= '</td>';
2472 print '<td class="right
">';
2473 if ((!$lines[$i]->public) && $disabledproject) {
2474 print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject
"));
2475 } elseif ($disabledtask) {
2476 $titleassigntask = $langs->trans("AssignTaskToMe
");
2477 if ($fuser->id != $user->id) {
2478 $titleassigntask = $langs->trans("AssignTaskToUser
", '...');
2481 print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser
", $titleassigntask));
2488 // Call to show task with a lower level (task under the current task)
2491 if ($lines[$i]->id > 0) {
2492 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
2493 //var_dump($totalforeachday);
2494 $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
2495 //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
2497 foreach ($ret as $key => $val) {
2498 $totalforeachweek[$key] += $val;
2500 //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
2501 //var_dump($totalforeachday);
2509 return $totalforeachweek;
2562function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0)
2564 global $langs, $conf, $user;
2565 global $theme_datacolor;
2567 $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
2569 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2571 $listofstatus = array_keys($listofoppstatus);
2573 if (is_array($listofstatus) && getDolGlobalString('USE_COLOR_FOR_PROSPECTION_STATUS')) {
2574 // Define $themeColorId and array $statusOppList for each $listofstatus
2576 $statusOppList = array();
2577 foreach ($listofstatus as $oppStatus) {
2578 $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
2579 if ($oppStatusCode) {
2580 $statusOppList[$oppStatus]['code'] = $oppStatusCode;
2581 $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
2587 $projectstatic = new Project($db);
2588 $thirdpartystatic = new Societe($db);
2592 $project_year_filter = 0;
2594 $title = $langs->trans("
Projects");
2595 if (strcmp((string) $status, '') && $status >= 0) {
2596 $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->labelStatus[$status]);
2599 print '<!-- print_projecttasks_array -->';
2600 print '<div class="div-
table-responsive-no-min
">';
2601 print '<table class="noborder centpercent
">';
2603 $sql = " FROM
".MAIN_DB_PREFIX."projet as p
";
2605 $sql .= ",
".MAIN_DB_PREFIX."projet_task as t
";
2606 $sql .= ",
".MAIN_DB_PREFIX."element_contact as ec
";
2607 $sql .= ",
".MAIN_DB_PREFIX."c_type_contact as ctc
";
2609 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet
";
2611 $sql .= " WHERE p.entity IN (
".getEntity('project').")
";
2612 $sql .= " AND p.rowid IN (
".$db->sanitize((string) $projectsListId).")
";
2614 $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc =
".((int) $socid).")
";
2617 $sql .= " AND p.rowid = t.fk_projet
";
2618 $sql .= " AND ec.element_id = t.rowid
";
2619 $sql .= " AND ec.fk_socpeople =
".((int) $user->id);
2620 $sql .= " AND ec.fk_c_type_contact = ctc.rowid
"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
2621 $sql .= " AND ctc.element =
'project_task'";
2624 $sql .= " AND p.fk_statut =
".(int) $status;
2626 if (getDolGlobalString('PROJECT_LIMIT_YEAR_RANGE')) {
2627 $project_year_filter = GETPOST("project_year_filter
", 'alpha'); // '*' seems allowed
2628 //Check if empty or invalid year. Wildcard ignores the sql check
2629 if ($project_year_filter != "*
") {
2630 if (empty($project_year_filter) || !is_numeric($project_year_filter)) {
2631 $project_year_filter = date("Y
");
2633 $sql .= " AND (p.dateo IS NULL OR p.dateo <=
".$db->idate(dol_get_last_day((int) $project_year_filter, 12, false)).")
";
2634 $sql .= " AND (p.datee IS NULL OR p.datee >=
".$db->idate(dol_get_first_day((int) $project_year_filter, 1, false)).")
";
2638 // Get id of project we must show tasks
2639 $arrayidofprojects = array();
2641 $sql1 = "SELECT p.rowid as projectid
";
2643 $resql = $db->query($sql1);
2646 $num = $db->num_rows($resql);
2648 $objp = $db->fetch_object($resql);
2649 $arrayidofprojects[$objp->projectid] = $objp->projectid;
2653 dol_print_error($db);
2655 if (empty($arrayidofprojects)) {
2656 $arrayidofprojects[0] = -1;
2659 // Get list of project with calculation on tasks
2660 $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,
";
2661 $sql2 .= " s.rowid as socid, s.nom as socname, s.name_alias,
";
2662 $sql2 .= " s.code_client, s.code_compta, s.client,
";
2663 $sql2 .= " s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,
";
2664 $sql2 .= " s.logo, s.email, s.entity,
";
2665 $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,
";
2666 $sql2 .= " p.dateo, p.datee,
";
2667 $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
2668 $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
2669 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
2670 $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
2671 $sql2 .= " WHERE p.rowid IN (".$db->sanitize(implode(',', $arrayidofprojects)).")";
2672 $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,";
2673 $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";
2674 $sql2 .= " ORDER BY p.title, p.
ref";
2676 $resql = $db->query($sql2);
2680 $total_opp_amount = 0;
2681 $ponderated_opp_amount = 0;
2682 $total_plannedworkload = 0;
2683 $total_declaredprogressworkload = 0;
2685 $num = $db->num_rows($resql);
2686 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 :
$conf->global->MAIN_MAXLIST_OVERLOAD));
2689 print
'<tr class="liste_titre">';
2690 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);
2693 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2694 print_liste_field_titre(
"OpportunityStatus",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'center ');
2696 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 ');
2701 if (!in_array(
'plannedworkload', $hiddenfields)) {
2702 print_liste_field_titre(
"PlannedWorkload",
"",
"",
"",
"",
'style="max-width: 100px"', $sortfield, $sortorder,
'right ');
2704 if (!in_array(
'declaredprogress', $hiddenfields)) {
2705 print_liste_field_titre(
"%",
"",
"",
"",
"",
'', $sortfield, $sortorder,
'right ', $langs->trans(
"ProgressDeclared"));
2708 if (!in_array(
'projectstatus', $hiddenfields)) {
2713 while ($i < $nbofloop) {
2714 $objp = $db->fetch_object($resql);
2716 if ($max && $i >= $max) {
2719 $total_task += $objp->nb;
2720 $total_opp_amount += $objp->opp_amount;
2721 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2722 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2723 $plannedworkload = $objp->planned_workload;
2724 $total_plannedworkload += $plannedworkload;
2725 $declaredprogressworkload = $objp->declared_progess_workload;
2726 $total_declaredprogressworkload += $declaredprogressworkload;
2730 $projectstatic->id = $objp->projectid;
2731 $projectstatic->user_author_id = $objp->fk_user_creat;
2732 $projectstatic->public = $objp->public;
2735 $userAccess = $projectstatic->restrictedProjectArea($user);
2736 if ($userAccess >= 0) {
2737 $projectstatic->ref = $objp->ref;
2738 $projectstatic->status = $objp->status;
2739 $projectstatic->title = $objp->title;
2740 $projectstatic->date_end = $db->jdate($objp->datee);
2741 $projectstatic->date_start = $db->jdate($objp->dateo);
2743 print
'<tr class="oddeven">';
2745 print
'<td class="tdoverflowmax150">';
2746 print $projectstatic->getNomUrl(1,
'', 0,
'',
'-', 0, -1,
'nowraponall');
2747 if (!in_array(
'projectlabel', $hiddenfields)) {
2748 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->title).
'</span>';
2752 print
'<td class="nowraponall tdoverflowmax100">';
2753 if ($objp->fk_soc > 0) {
2754 $thirdpartystatic->id = $objp->socid;
2755 $thirdpartystatic->name = $objp->socname;
2758 $thirdpartystatic->code_compta = $objp->code_compta;
2759 $thirdpartystatic->code_compta_client = $objp->code_compta;
2760 $thirdpartystatic->client = $objp->client;
2762 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
2763 $thirdpartystatic->fournisseur = $objp->fournisseur;
2764 $thirdpartystatic->logo = $objp->logo;
2765 $thirdpartystatic->email = $objp->email;
2766 $thirdpartystatic->entity = $objp->entity;
2767 print $thirdpartystatic->getNomUrl(1);
2772 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2773 print
'<td class="center tdoverflowmax75">';
2776 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2777 if ($langs->trans(
"OppStatus".$oppStatusCode) !=
"OppStatus".$oppStatusCode) {
2778 print $langs->trans(
"OppStatus".$oppStatusCode);
2781 if (isset($statusOppList[$objp->opp_status])) {
2782 $oppStatusCode = $statusOppList[$objp->opp_status][
'code'];
2783 $oppStatusColor = $statusOppList[$objp->opp_status][
'color'];
2785 $oppStatusCode =
dol_getIdFromCode($db, $objp->opp_status,
'c_lead_status',
'rowid',
'code');
2786 $oppStatusColor =
'';
2788 if ($oppStatusCode) {
2789 if (!empty($oppStatusColor)) {
2790 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>';
2792 print
'<a href="'.dol_buildpath(
'/projet/list.php?search_opp_status='.$objp->opp_status, 1).
'" title="'.$langs->trans(
"OppStatus".$oppStatusCode).
'">'.$oppStatusCode.
'</a>';
2799 print
'<td class="right">';
2800 if ($objp->opp_percent && $objp->opp_amount) {
2801 $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
2802 $alttext = $langs->trans(
"OpportunityWeightedAmount").
' '.
price($opp_weighted_amount, 0,
'', 1, -1, 0,
$conf->currency);
2803 $ponderated_opp_amount +=
price2num($opp_weighted_amount);
2805 if ($objp->opp_amount) {
2806 print
'<span class="amount" title="'.$alttext.
'">'.$form->textwithpicto(
price($objp->opp_amount, 0,
'', 1, -1, 0), $alttext).
'</span>';
2812 print
'<td class="right">'.$objp->nb.
'</td>';
2814 $plannedworkload = $objp->planned_workload;
2815 $total_plannedworkload += $plannedworkload;
2816 if (!in_array(
'plannedworkload', $hiddenfields)) {
2817 print
'<td class="right nowraponall">'.($plannedworkload ?
convertSecondToTime($plannedworkload) :
'').
'</td>';
2819 if (!in_array(
'declaredprogress', $hiddenfields)) {
2820 $declaredprogressworkload = $objp->declared_progess_workload;
2821 $total_declaredprogressworkload += $declaredprogressworkload;
2822 print
'<td class="right nowraponall">';
2824 print($plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0).
'%' :
'');
2829 if (!in_array(
'projectstatus', $hiddenfields)) {
2830 print
'<td class="right">';
2831 print $projectstatic->getLibStatut(3);
2837 $total_task += $objp->nb;
2838 $total_opp_amount += $objp->opp_amount;
2845 print
'<tr class="oddeven">';
2846 print
'<td class="nowrap" colspan="5">';
2847 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
2852 print
'<tr class="liste_total">';
2853 print
'<td>'.$langs->trans(
"Total").
"</td><td></td>";
2855 if (!in_array(
'prospectionstatus', $hiddenfields)) {
2856 print
'<td class="liste_total"></td>';
2858 print
'<td class="liste_total right">';
2860 print $form->textwithpicto(
price($total_opp_amount, 0,
'', 1, -1, 0), $langs->trans(
"OpportunityPonderatedAmountDesc").
' : '.
price($ponderated_opp_amount, 0,
'', 1, -1, 0,
$conf->currency));
2864 print
'<td class="liste_total right">'.$total_task.
'</td>';
2865 if (!in_array(
'plannedworkload', $hiddenfields)) {
2866 print
'<td class="liste_total right">'.($total_plannedworkload ?
convertSecondToTime($total_plannedworkload) :
'').
'</td>';
2868 if (!in_array(
'declaredprogress', $hiddenfields)) {
2869 print
'<td class="liste_total right">'.($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).
'%' :
'').
'</td>';
2872 if (!in_array(
'projectstatus', $hiddenfields)) {
2873 print
'<td class="liste_total"></td>';
2887 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">';
2888 print
'<table width="100%">';
2890 print
'<td>'.$langs->trans(
"Year").
'</td>';
2891 print
'<td class="right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.((int) $project_year_filter).
'"/>';
2893 print
'</table></form>';
2906function getTaskProgressView($task, $label =
true, $progressNumber =
true, $hideOnProgressNull =
false, $spaced =
false)
2908 global $langs,
$conf;
2912 $plannedworkloadoutputformat =
'allhourmin';
2913 $timespentoutputformat =
'allhourmin';
2915 $plannedworkloadoutputformat =
getDolGlobalString(
'PROJECT_PLANNED_WORKLOAD_FORMAT');
2921 if (empty($task->progress) && !empty($hideOnProgressNull)) {
2925 $spaced = !empty($spaced) ?
'spaced' :
'';
2930 $progressBarClass =
'progress-bar-info';
2931 $progressCalculated = 0;
2932 if ($task->planned_workload) {
2933 $progressCalculated = round(100 * (
float) $task->duration_effective / (
float) $task->planned_workload, 2);
2936 $warningRatio =
getDolGlobalString(
'PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 +
$conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
2938 $diffTitle =
'<br>'.$langs->trans(
'ProgressDeclared').
' : '.$task->progress.(isset($task->progress) ?
'%' :
'');
2939 $diffTitle .=
'<br>'.$langs->trans(
'ProgressCalculated').
' : '.$progressCalculated.(isset($progressCalculated) ?
'%' :
'');
2942 if ((
float) $progressCalculated > (float) ($task->progress * $warningRatio)) {
2943 $progressBarClass =
'progress-bar-danger';
2944 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2945 $diff =
'<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-down"></i> '.($task->progress - $progressCalculated).
'%</span>';
2946 } elseif ((
float) $progressCalculated > (
float) $task->progress) {
2947 $progressBarClass =
'progress-bar-warning';
2948 $title = $langs->trans(
'TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2949 $diff =
'<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-left"></i> '.($task->progress - $progressCalculated).
'%</span>';
2951 $progressBarClass =
'progress-bar-success';
2952 $title = $langs->trans(
'TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress - $progressCalculated).
' '.$langs->trans(
"point"));
2953 $diff =
'<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).
'" ><i class="fa fa-caret-up"></i> '.($task->progress - $progressCalculated).
'%</span>';
2957 $out .=
'<div class="progress-group">';
2959 if ($label !==
false) {
2960 $out .=
' <span class="progress-text">';
2962 if ($label !==
true) {
2971 if ($progressNumber !==
false) {
2972 $out .=
' <span class="progress-number">';
2973 if ($progressNumber !==
true) {
2974 $out .= $progressNumber;
2976 if ($task->hasDelay()) {
2980 $url = DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$task->id;
2982 $out .= !empty($diff) ? $diff.
' ' :
'';
2983 $out .=
'<a href="'.$url.
'" >';
2984 $out .=
'<b title="'.$langs->trans(
'TimeSpent').
'" >';
2985 if ($task->duration_effective) {
2995 $out .=
'<a href="'.$url.
'" >';
2996 $out .=
'<span title="'.$langs->trans(
'PlannedWorkload').
'" >';
2997 if ($task->planned_workload) {
3009 $out .=
' <div class="progress sm'.($spaced ? $spaced :
'').
'">';
3010 $diffval = (float) $task->progress - (
float) $progressCalculated;
3011 if ($diffval >= 0) {
3013 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.(float) $task->progress.
'%" title="'.(
float) $task->progress.
'%">';
3014 if (!empty($task->progress)) {
3015 $out .=
' <div class="progress-bar progress-bar-consumed" style="width: '.(float) ($progressCalculated / ((
float) $task->progress == 0 ? 1 : $task->progress) * 100).
'%" title="'.(float) $progressCalculated.
'%"></div>';
3020 $out .=
' <div class="progress-bar progress-bar-consumed-late" style="width: '.(float) $progressCalculated.
'%" title="'.(
float) $progressCalculated.
'%">';
3021 $out .=
' <div class="progress-bar '.$progressBarClass.
'" style="width: '.($task->progress ? (float) ($task->progress / ((
float) $progressCalculated == 0 ? 1 : $progressCalculated) * 100).
'%' :
'1px').
'" title="'.(
float) $task->progress.
'%"></div>';