fix Absence

This commit is contained in:
mckmonster 2024-09-01 10:30:33 +02:00
parent 100c1761db
commit 753f8d6483
3 changed files with 21 additions and 10 deletions

View file

@ -3,6 +3,7 @@
use YesWiki\Core\YesWikiAction;
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Core\Service\UserManager;
use YesWiki\Meeo\Service\EleveManager;
class AbsencesAction extends YesWikiAction
{
@ -20,16 +21,19 @@ class AbsencesAction extends YesWikiAction
$entryManager = $this->getService(EntryManager::class);
$userManager = $this->getService(UserManager::class);
$elevemanager = $this->getService(EleveManager::class);
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
$entries = $entryManager->search(['formsIds' => $formId]);
$grouped_entries = [];
foreach ($entries as $entry) {
// echo "<p>".var_dump($entry)."</p>";
$identifier = $entry[$eleveIdentifier];
$eleve = $entryManager->getOne($identifier);
echo "<p>".var_dump($eleve)."</p>";
$nom = $eleve['bf_nom'];
//echo "<p>".var_dump($identifier)."</p>";
$eleve = $elevemanager->getEleve($identifier);
// echo "<p>".var_dump($eleve)."</p>";
$nom = $eleve->getNom();
if (!isset($grouped_entries[$identifier])) {
$grouped_entries[$identifier] = [
'nom' => $nom,
@ -44,7 +48,15 @@ class AbsencesAction extends YesWikiAction
]);
} else {
$username = $userManager->getLoggedUsername();
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $username."2"]]);
$eleves = $elevemanager->getAll();
foreach ($eleves as $eleve) {
if ($eleve->getNom() == $username) {
$selectedEleve = $eleve;
}
}
$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,

View file

@ -1,9 +1,9 @@
parameters:
meeo:
elevesFormId: 6
absencesFormId: 7
notesFormId: 8
yunohostFormId: 5
elevesFormId: 7
absencesFormId: 8
notesFormId: 9
yunohostFormId: 6
groupeEE: 'equipeeducative'
redirect:
eleveUpdate: '?Eleves'

View file

@ -11,8 +11,7 @@ class Eleve {
public function __construct(EntryManager $entryManager, $yunoshostFormId, $data) {
$this->data = $data;
// echo "<p>".var_dump($data)."</p>";
$userId = $data['listefiche'.$yunoshostFormId.'Listebf_nom'];
$userId = $data['listefiche'.$yunoshostFormId.'bf_nom'];
$this->user = $entryManager->getOne($userId);
// echo "<p>".var_dump($this)."</p>";
}