Skip to content

Commit

Permalink
Listing participant stats in education report
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Oct 8, 2023
1 parent d4ba055 commit 034733b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
28 changes: 26 additions & 2 deletions app/model/Export/ExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
use Model\DTO\Participant\Statistics;
use Model\Event\Camp;
use Model\Event\Education;
use Model\Event\EducationCourseParticipationStats;
use Model\Event\EducationParticipantParticipationStats;
use Model\Event\EducationTerm;
use Model\Event\Event;
use Model\Event\ReadModel\Queries\CampFunctions;
use Model\Event\ReadModel\Queries\CampQuery;
use Model\Event\ReadModel\Queries\EducationCourseParticipationStatsQuery;
use Model\Event\ReadModel\Queries\EducationFunctions;
use Model\Event\ReadModel\Queries\EducationParticipantParticipationStatsQuery;
use Model\Event\ReadModel\Queries\EducationQuery;
use Model\Event\ReadModel\Queries\EducationTermsQuery;
use Model\Event\ReadModel\Queries\EventFunctions;
Expand All @@ -48,6 +52,7 @@

use function array_column;
use function array_filter;
use function array_map;
use function array_sum;
use function array_values;
use function assert;
Expand Down Expand Up @@ -299,11 +304,30 @@ public function getEducationReport(SkautisEducationId $educationId): string
$finalRealBalance = MoneyFactory::toFloat($this->queryBus->handle(new FinalRealBalanceQuery($cashbookId)));
assert(is_float($finalRealBalance));

$terms = $this->queryBus->handle(new EducationTermsQuery($educationId->toInt()));
$education = $this->queryBus->handle(new EducationQuery($educationId));
$terms = $this->queryBus->handle(new EducationTermsQuery($educationId->toInt()));
$courseParticipationStats = $this->queryBus->handle(new EducationCourseParticipationStatsQuery($educationId->toInt()));
$participantParticipationStats = $this->queryBus->handle(new EducationParticipantParticipationStatsQuery($education->grantId->toInt()));

return $this->templateFactory->create(__DIR__ . '/templates/educationReport.latte', [
'education' => $this->queryBus->handle(new EducationQuery($educationId)),
'education' => $education,
'totalDays' => EducationTerm::countTotalDays($terms),
'participantsAccepted' => array_sum(
array_map(
static function (EducationCourseParticipationStats $stat) {
return $stat->accepted;
},
$courseParticipationStats,
),
),
'personDaysReal' => array_sum(
array_map(
static function (EducationParticipantParticipationStats $stat) {
return $stat->totalDays;
},
$participantParticipationStats,
),
),
'incomeCategories' => $incomeCategories[self::CATEGORY_REAL],
'expenseCategories' => $expenseCategories[self::CATEGORY_REAL],
'totalIncome' => $total['income'],
Expand Down
10 changes: 10 additions & 0 deletions app/model/Export/templates/educationReport.latte
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ $chits - paragony akce
</tr>
</table>

<h3>Účastníci</h3>
<table border="1" style="width:500px">
<tr>
<th style="width: 30%;">Účastníků</th>
<td style="width: 20%;">{$participantsAccepted}</td>
<th style="width: 30%;">Osobodnů</th>
<td style="width: 20%;">{$personDaysReal}</td>
</tr>
</table>

<h3>Výnosy a náklady</h3>
<table border="1" style="width:800px">
<tr>
Expand Down

0 comments on commit 034733b

Please sign in to comment.