2024-07-04 05:32:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use YesWiki\Core\YesWikiAction;
|
2024-07-04 07:01:12 +00:00
|
|
|
use YesWiki\Bazar\Service\EntryManager;
|
2024-07-04 18:20:36 +00:00
|
|
|
use YesWiki\Core\Service\UserManager;
|
2024-07-04 05:32:34 +00:00
|
|
|
|
|
|
|
class AbsencesAction extends YesWikiAction
|
|
|
|
{
|
|
|
|
public function formatArguments($arg)
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run()
|
|
|
|
{
|
2024-07-04 19:27:28 +00:00
|
|
|
$formId = $this->params->get('meeo_formId');
|
|
|
|
$eleveIdentifier = $this->params->get('meeo_eleveIdentifier');
|
|
|
|
$groupeEE = $this->params->get('meeo_groupeEE');
|
|
|
|
|
2024-07-04 07:01:12 +00:00
|
|
|
$entryManager = $this->getService(EntryManager::class);
|
2024-07-04 18:20:36 +00:00
|
|
|
$userManager = $this->getService(UserManager::class);
|
2024-07-04 07:01:12 +00:00
|
|
|
|
2024-07-04 19:27:28 +00:00
|
|
|
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
|
|
|
$entries = $entryManager->search(['formsIds' => $formId]);
|
2024-07-04 18:20:36 +00:00
|
|
|
$grouped_entries = [];
|
|
|
|
foreach ($entries as $entry) {
|
2024-07-04 19:27:28 +00:00
|
|
|
$identifier = $entry[$eleveIdentifier];
|
2024-07-04 18:20:36 +00:00
|
|
|
$nom = $entryManager->getOne($identifier)['bf_nom'];
|
|
|
|
if (!isset($grouped_entries[$identifier])) {
|
|
|
|
$grouped_entries[$identifier] = [
|
|
|
|
'nom' => $nom,
|
|
|
|
'entries' => []
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$grouped_entries[$identifier]['entries'][] = $entry;
|
2024-07-04 07:01:12 +00:00
|
|
|
}
|
|
|
|
|
2024-07-04 18:20:36 +00:00
|
|
|
return $this->render('@meeo/edu_absences.twig', [
|
|
|
|
"groups" => $grouped_entries,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
$username = $userManager->getLoggedUsername();
|
2024-07-04 19:27:28 +00:00
|
|
|
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $username."2"]]);
|
2024-07-04 18:20:36 +00:00
|
|
|
|
|
|
|
return $this->render('@meeo/eleve_absences.twig', [
|
|
|
|
"entries" => $entries,
|
|
|
|
]);
|
|
|
|
}
|
2024-07-04 05:32:34 +00:00
|
|
|
}
|
|
|
|
}
|