Skip to content

Commit

Permalink
Merge pull request Evarisk#3615 from evarisk-micka/fix_check_hook
Browse files Browse the repository at this point in the history
Evarisk#3613 Evarisk#3614 [Hook/Ticket] fix: translate rangeName and display calculated field on project
  • Loading branch information
nicolas-eoxia authored Dec 7, 2023
2 parents 8442cb4 + 4ad0f0c commit db14868
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion admin/ticket/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@
}
print '<tr>';
print '<td>';
print $rangeName;
print $langs->transnoentities($rangeName);
print '</td>';
print '<td>';
print $rangeComparator;
Expand Down
89 changes: 46 additions & 43 deletions class/actions_digiriskdolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function printCommonFooter($parameters)
<?php
}
}
} else if (in_array($parameters['currentcontext'], array('projectcard', 'projectcontactcard', 'projecttaskscard', 'projecttaskcard', 'projecttasktime', 'projectOverview', 'projecttaskscard', 'tasklist'))) {
} else if (in_array($parameters['currentcontext'], array('projectcard', 'projectcontactcard', 'projecttaskscard', 'projecttaskcard', 'projecttasktime', 'projectOverview', 'projecttaskscard', 'tasklist', 'category'))) {
if ((GETPOST('action') == '' || empty(GETPOST('action')) || GETPOST('action') != 'edit')) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
Expand Down Expand Up @@ -435,49 +435,52 @@ public function printCommonFooter($parameters)
}
}

if (in_array($parameters['currentcontext'], ['projectcard', 'projectcontactcard', 'projecttaskcard', 'projecttaskscard', 'projecttasktime', 'projectOverview'])) {
if (GETPOSTISSET('projectid') || GETPOSTISSET('project_ref')) {
$project->fetch( GETPOST('projectid'), GETPOST('project_ref'));
$projectId = $project->id;
} else if (in_array($parameters['currentcontext'], ['projectcard', 'projectcontactcard', 'projecttaskscard'])) {
$projectId = GETPOST('id');
if (in_array($parameters['currentcontext'], ['projectcard', 'projectcontactcard', 'projecttaskcard', 'projecttaskscard', 'projecttasktime', 'projectOverview']) || ($parameters['currentcontext'] == 'category' && preg_match('/contacttpl/', $parameters['context']))) {
if (in_array($parameters['currentcontext'], ['projecttaskcard']) && !GETPOSTISSET('withproject')) {
return 0;
} else {
$task->fetch(GETPOST('id'));
$projectId = $task->fk_project;
}
$allTasks = $task->getTasksArray(null, null, $projectId, 0, 0, '', '-1', '', 0, 0, $extrafields);
if (is_array($allTasks) && !empty($allTasks)) {
$nbTasks = count($allTasks);
foreach ($allTasks as $taskSingle) {
$filter = ' AND fk_element = ' . $taskSingle->id;
$allTimespent = $task->fetchAllTimeSpentAllUsers($filter);
foreach ($allTimespent as $timespent) {
$totatConsumedTimeAmount += convertSecondToTime($timespent->timespent_duration, 'allhourmin') * $timespent->timespent_thm;
}
$totalConsumedTime += $taskSingle->duration;
$totalProgress += $taskSingle->progress;
$totalTasksBudget += $taskSingle->budget_amount;
}
} else {
$totalConsumedTime = 0;
$totatConsumedTimeAmount = 0;
$nbTasks = 0;
$totalProgress = 0;
$totalTasksBudget = 0;
}
$outTotatConsumedTime = '<tr><td>' . $langs->trans('TotalConsumedTime') . '</td><td>' . convertSecondToTime($totalConsumedTime, 'allhourmin') . '</td></tr>';
$outTotatConsumedTimeAmount = '<tr><td>' . $langs->trans('TotalConsumedTimeAmount') . '</td><td>' . price($totatConsumedTimeAmount, 0, $langs, 1, -1, 2, $conf->currency) . '</td></tr>';
$outNbtasks = '<tr><td>' . $langs->trans('NbTasks') . '</td><td>' . $nbTasks . '</td></tr>';
$outTotalProgress = '<tr><td>' . $langs->trans('TotalProgress') . '</td><td>' . (($totalProgress) ? price2num($totalProgress/$nbTasks, 2) . ' %' : '0 %') . '</td></tr>';
$outTotalTasksBudget = '<tr><td>' . $langs->trans('TotalBudget') . '</td><td>' . price($totalTasksBudget, 0, $langs, 1, -1, 2, $conf->currency) . '</td></tr>'; ?>
<script>
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotatConsumedTime) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotatConsumedTimeAmount) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outNbtasks) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotalProgress) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotalTasksBudget) ?>);
</script>
<?php
if (GETPOSTISSET('projectid') || GETPOSTISSET('project_ref')) {
$project->fetch( GETPOST('projectid'), GETPOST('project_ref'));
$projectId = $project->id;
} else if (in_array($parameters['currentcontext'], ['projectcard', 'projectcontactcard', 'projecttaskscard'])) {
$projectId = GETPOST('id');
} else {
$task->fetch(GETPOST('id'));
$projectId = $task->fk_project;
}
$allTasks = $task->getTasksArray(null, null, $projectId, 0, 0, '', '-1', '', 0, 0, $extrafields);
if (is_array($allTasks) && !empty($allTasks)) {
$nbTasks = count($allTasks);
foreach ($allTasks as $taskSingle) {
$filter = ' AND fk_element = ' . $taskSingle->id;
$allTimespent = $task->fetchAllTimeSpentAllUsers($filter);
foreach ($allTimespent as $timespent) {
$totatConsumedTimeAmount += convertSecondToTime($timespent->timespent_duration, 'allhourmin') * $timespent->timespent_thm;
}
$totalConsumedTime += $taskSingle->duration;
$totalProgress += $taskSingle->progress;
$totalTasksBudget += $taskSingle->budget_amount;
}
} else {
$totalConsumedTime = 0;
$totatConsumedTimeAmount = 0;
$nbTasks = 0;
$totalProgress = 0;
$totalTasksBudget = 0;
}
$outTotatConsumedTime = '<tr><td>' . $langs->trans('TotalConsumedTime') . '</td><td>' . convertSecondToTime($totalConsumedTime, 'allhourmin') . '</td></tr>';
$outTotatConsumedTimeAmount = '<tr><td>' . $langs->trans('TotalConsumedTimeAmount') . '</td><td>' . price($totatConsumedTimeAmount, 0, $langs, 1, -1, 2, $conf->currency) . '</td></tr>';
$outNbtasks = '<tr><td>' . $langs->trans('NbTasks') . '</td><td>' . $nbTasks . '</td></tr>';
$outTotalProgress = '<tr><td>' . $langs->trans('TotalProgress') . '</td><td>' . (($totalProgress) ? price2num($totalProgress/$nbTasks, 2) . ' %' : '0 %') . '</td></tr>';
$outTotalTasksBudget = '<tr><td>' . $langs->trans('TotalBudget') . '</td><td>' . price($totalTasksBudget, 0, $langs, 1, -1, 2, $conf->currency) . '</td></tr>';?>
<script>
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotatConsumedTime) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotatConsumedTimeAmount) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outNbtasks) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotalProgress) ?>);
jQuery('.fichecenter .fichehalfright .tableforfield tbody tr:last-child').first().after(<?php echo json_encode($outTotalTasksBudget) ?>);
</script> <?php
}
}
}
} else if ($parameters['currentcontext'] == 'publicnewticketcard') {
Expand Down

0 comments on commit db14868

Please sign in to comment.