Skip to content

Commit

Permalink
customer feedback: add details button and stats for projects (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
vazaha-nl committed Aug 24, 2024
1 parent 7463999 commit f8f7fc0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
8 changes: 5 additions & 3 deletions Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function viewCustomerAction(
Customer $customer,
string $shareKey,
Request $request,
CustomerStatisticService $statisticsService,
CustomerStatisticService $customerStatisticsService,
ProjectStatisticService $projectStatisticService,
ViewService $viewService,
SharedProjectTimesheetRepository $sharedProjectTimesheetRepository,
): Response
Expand Down Expand Up @@ -120,13 +121,13 @@ public function viewCustomerAction(
// we cannot call $this->getDateTimeFactory() as it throws a AccessDeniedException for anonymous users
$timezone = $customer->getTimezone() ?? date_default_timezone_get();
$date = new \DateTimeImmutable('now', new \DateTimeZone($timezone));
$stats = $statisticsService->getBudgetStatisticModel($customer, $date);
$stats = $customerStatisticsService->getBudgetStatisticModel($customer, $date);
$projects = $sharedProjectTimesheetRepository->getProjects($sharedProject);
$projectStats = $projectStatisticService->getBudgetStatisticModelForProjects($projects, $date);

return $this->render('@SharedProjectTimesheets/view/customer.html.twig', [
'sharedProject' => $sharedProject,
'customer' => $customer,
'projects' => $projects,
'shareKey' => $shareKey,
'timeRecords' => $timeRecords,
'rateSum' => $rateSum,
Expand All @@ -139,6 +140,7 @@ public function viewCustomerAction(
'statsPerDay' => $statsPerDay,
'detailsMode' => $detailsMode,
'stats' => $stats,
'projectStats' => $projectStats,
]);
}

Expand Down
36 changes: 24 additions & 12 deletions Resources/views/view/customer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@
{% if ((stats.hasBudget() and sharedProject.isBudgetStatsVisible()) or (stats.hasTimeBudget() and sharedProject.isTimeBudgetStatsVisible())) %}
{% import "macros/progressbar.html.twig" as progress %}
<div class="card mb-3">
<div class="card-header">
<h3 class="card-title">{{ 'shared_project_timesheets.view.stats.title' | trans }}</h3>
</div>
<div class="card-body p-0">
<table class="table table-hover dataTable">
{% if stats.hasBudget() and sharedProject.isBudgetStatsVisible() %}
Expand Down Expand Up @@ -214,26 +211,41 @@
<h3 class="card-title">{{ 'projects'|trans }}</h3>
</div>
<div class="card-body p-0 todocorrectclass">
{% if projects is empty %}
{% if projectStats is empty %}
{{ nothing_found() }}
{% else %}
<table class="table table-hovertable-vcenter table-hover dataTable">
<thead>
<tr>
<th class="w-min">NAME</th>
<th class="w-min">COMMENT</th>
<th>{{ 'name'|trans }}</th>
{% if (sharedProject.isBudgetStatsVisible() or sharedProject.isTimeBudgetStatsVisible()) %}
<th></th>
{% endif %}
<th class="w-min"></th>
</tr>
</thead>
{% for project in projects %}
<tr class="alternative-link" data-href="{{
url('view_shared_project_timesheets_project', {
{% for stats in projectStats %}
{% set project = stats.getProject() %}
{%
set project_url = url('view_shared_project_timesheets_project', {
'customer': customer.getId(),
'shareKey': shareKey,
'project': project.getId(),
}) }}">
})
%}
<tr class="alternative-link" data-href="{{ project_url }}">
<td>{{ project.name }}</td>
<td>{{ project.comment }}</td>
{% if (sharedProject.isBudgetStatsVisible() or sharedProject.isTimeBudgetStatsVisible()) %}
<td>
{% if stats.hasBudget() and sharedProject.isBudgetStatsVisible() %}
{{ progress.progressbar_budget(stats, currency) }}
{% endif %}
{% if stats.hasTimeBudget() and sharedProject.isTimeBudgetStatsVisible() %}
{{ progress.progressbar_timebudget(stats) }}
{% endif %}
</td>
{% endif %}
<td><a href="{{ project_url }}" class="btn btn-primary">{{ 'shared_project_timesheets.view.table.title' | trans }}</a></td>
</tr>
{% endfor %}
</table>
Expand Down

0 comments on commit f8f7fc0

Please sign in to comment.