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-09-01 08:30:33 +00:00
|
|
|
use YesWiki\Meeo\Service\EleveManager;
|
2024-07-04 05:32:34 +00:00
|
|
|
|
|
|
|
class AbsencesAction extends YesWikiAction
|
|
|
|
{
|
|
|
|
public function formatArguments($arg)
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run()
|
|
|
|
{
|
2024-07-09 15:08:42 +00:00
|
|
|
$meeo_config = $this->params->get('meeo');
|
2024-07-17 08:52:17 +00:00
|
|
|
$formId = $meeo_config['absencesFormId'];
|
2024-07-10 09:09:20 +00:00
|
|
|
$eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'].'bf_eleve';
|
2024-07-09 15:08:42 +00:00
|
|
|
$groupeEE = $meeo_config['groupeEE'];
|
2024-07-04 19:27:28 +00:00
|
|
|
|
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-09-01 08:30:33 +00:00
|
|
|
$elevemanager = $this->getService(EleveManager::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 = [];
|
2024-07-09 15:08:42 +00:00
|
|
|
|
2024-07-04 18:20:36 +00:00
|
|
|
foreach ($entries as $entry) {
|
2024-09-01 08:30:33 +00:00
|
|
|
// echo "<p>".var_dump($entry)."</p>";
|
2024-07-04 19:27:28 +00:00
|
|
|
$identifier = $entry[$eleveIdentifier];
|
2024-09-01 08:30:33 +00:00
|
|
|
//echo "<p>".var_dump($identifier)."</p>";
|
|
|
|
$eleve = $elevemanager->getEleve($identifier);
|
|
|
|
// echo "<p>".var_dump($eleve)."</p>";
|
|
|
|
$nom = $eleve->getNom();
|
2024-07-04 18:20:36 +00:00
|
|
|
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-08-06 06:58:32 +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-09-01 08:30:33 +00:00
|
|
|
$eleves = $elevemanager->getAll();
|
|
|
|
foreach ($eleves as $eleve) {
|
2024-09-04 13:49:19 +00:00
|
|
|
if ($eleve->getNom() == $username || $eleve->isParent($username)) {
|
2024-09-01 08:30:33 +00:00
|
|
|
$selectedEleve = $eleve;
|
|
|
|
}
|
|
|
|
}
|
2024-07-04 18:20:36 +00:00
|
|
|
|
2024-09-04 13:49:19 +00:00
|
|
|
if ($selectedEleve != null) {
|
|
|
|
$identifier = $selectedEleve->getId();
|
|
|
|
// echo "<p>".var_dump($selectedEleve)."</p>";
|
|
|
|
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $identifier]]);
|
|
|
|
|
|
|
|
return $this->render('@meeo/eleve_absences.twig', [
|
|
|
|
"entries" => $entries,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return "Utilisateur non connus : ". $username;
|
2024-07-04 18:20:36 +00:00
|
|
|
}
|
2024-07-04 05:32:34 +00:00
|
|
|
}
|
|
|
|
}
|