Skip to content

Commit

Permalink
include budget/time budget statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
vazaha-nl authored Jul 5, 2024
1 parent 169bc95 commit 4121405
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use App\Controller\AbstractController;
use App\Entity\Project;
use App\Project\ProjectStatisticService;
use KimaiPlugin\SharedProjectTimesheetsBundle\Repository\SharedProjectTimesheetRepository;
use KimaiPlugin\SharedProjectTimesheetsBundle\Service\ViewService;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -28,7 +29,7 @@ public function __construct(
}

#[Route(path: '/{id}/{shareKey}', name: 'view_shared_project_timesheets', methods: ['GET', 'POST'])]
public function indexAction(Project $project, string $shareKey, Request $request): Response
public function indexAction(Project $project, string $shareKey, Request $request, ProjectStatisticService $statisticsService): Response
{
$givenPassword = $request->get('spt-password');
$year = (int) $request->get('year', date('Y'));
Expand Down Expand Up @@ -79,6 +80,8 @@ public function indexAction(Project $project, string $shareKey, Request $request
$statsPerDay = ($monthlyChartVisible && $detailsMode === 'chart')
? $this->viewService->getMonthlyStats($sharedProject, $year, $month) : null;

$stats = $statisticsService->getBudgetStatisticModel($project, $this->getDateTimeFactory()->createDateTime());

return $this->render('@SharedProjectTimesheets/view/timesheet.html.twig', [
'sharedProject' => $sharedProject,
'timeRecords' => $timeRecords,
Expand All @@ -91,6 +94,7 @@ public function indexAction(Project $project, string $shareKey, Request $request
'monthlyChartVisible' => $monthlyChartVisible,
'statsPerDay' => $statsPerDay,
'detailsMode' => $detailsMode,
'stats' => $stats,
]);
}
}
2 changes: 2 additions & 0 deletions Resources/translations/messages.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ shared_project_timesheets:
details:
table: Tabelle
chart: Diagramm
stats:
title: "Projektstatistiken"

model:
merge_record_mode:
Expand Down
2 changes: 2 additions & 0 deletions Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ shared_project_timesheets:
details:
table: Table
chart: Chart
stats:
title: "Project statistics"

model:
merge_record_mode:
Expand Down
35 changes: 34 additions & 1 deletion Resources/views/view/timesheet.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</div>
{% endif %}

<div class="card">
<div class="card mb-3">
<div class="card-header">
<h3 class="card-title">{{ 'shared_project_timesheets.view.table.title' | trans }}</h3>
{% if monthlyChartVisible %}
Expand Down Expand Up @@ -167,5 +167,38 @@
</div>
</div>

{% if stats.hasBudget() or stats.hasTimeBudget() %}
{% import "macros/progressbar.html.twig" as progress %}
<div class="card">
<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() %}
<tr>
<td>
{{ 'budget' | trans }}
</td>
<td>
{{ progress.progressbar_budget(stats, currency) }}
</td>
</tr>
{% endif %}
{% if stats.hasTimeBudget() %}
<tr>
<td>
{{ 'timeBudget' | trans }}
</td>
<td>
{{ progress.progressbar_timebudget(stats) }}
</td>
</tr>
{% endif %}
</table>
</div>
</div>
{% endif %}

</div>
{% endblock %}

0 comments on commit 4121405

Please sign in to comment.