ynh_extension_meeo/actions/AbsencesAction.php
2024-07-04 09:27:29 +02:00

36 lines
963 B
PHP

<?php
use YesWiki\Core\YesWikiAction;
use YesWiki\Bazar\Service\EntryManager;
class AbsencesAction extends YesWikiAction
{
public function formatArguments($arg)
{
return [];
}
public function run()
{
$entryManager = $this->getService(EntryManager::class);
$entries = $entryManager->search(['formsIds' => '6']);
$grouped_entries = [];
foreach ($entries as $entry) {
$identifier = $entry['listefiche5bf_eleve'];
$nom = $entryManager->getOne($identifier)['bf_nom'];
if (!isset($grouped_entries[$identifier])) {
$grouped_entries[$identifier] = [
'nom' => $nom,
'entries' => []
];
}
$grouped_entries[$identifier]['entries'][] = $entry;
}
return $this->render('@meeo/absences.twig', [
"groups" => $grouped_entries,
]);
}
}