Compare commits

..

2 commits

Author SHA1 Message Date
mckmonster
3dc1aed82d Add access to absence for parent 2024-09-04 15:49:19 +02:00
mckmonster
e1078eb5ab Add link to parents and use it in absence to send message 2024-09-04 15:25:23 +02:00
4 changed files with 69 additions and 8 deletions

View file

@ -50,17 +50,22 @@ class AbsencesAction extends YesWikiAction
$username = $userManager->getLoggedUsername();
$eleves = $elevemanager->getAll();
foreach ($eleves as $eleve) {
if ($eleve->getNom() == $username) {
if ($eleve->getNom() == $username || $eleve->isParent($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,
]);
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;
}
}
}

View file

@ -98,7 +98,7 @@ class ApiController extends YesWikiController
// echo "Expediteur : ".var_dump($expediteur)."\n";
// Récupération du destinataire
$destinataire = $eleve->getEmail();
$destinataire = implode(";", $eleve->getParentEmails());
// echo "Envoyer à : ".$destinataire."\n";
// Génération du rendu du mail

View file

@ -2,17 +2,26 @@
namespace YesWiki\Meeo\Eleve;
include 'tools/meeo/libs/eleves/parent.lib.php';
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Meeo\Eleve\ParentEleve;
class Eleve {
private $data;
private $user;
private $parents;
public function __construct(EntryManager $entryManager, $yunoshostFormId, $data) {
$this->data = $data;
// echo "<p>".var_dump($data)."</p>";
$userId = $data['listefiche'.$yunoshostFormId.'bf_nom'];
$this->user = $entryManager->getOne($userId);
// echo "<p>".var_dump($userId)."</p>";
$this->parents = [];
foreach ($entryManager->search(['formsIds' => 9, 'queries' => ['listefiche7bf_eleve' => $userId."2"]]) as $parent) {
array_push($this->parents, new ParentEleve($entryManager, $yunoshostFormId, $parent));
}
// echo "<p>".var_dump($this)."</p>";
}
@ -47,7 +56,23 @@ class Eleve {
return $this->user['bf_mail'];
}
public function getParentEmails() {
$emails = [];
foreach ($this->parents as $parent) {
array_push($emails, $parent->getEmail());
}
return $emails;
}
public function getData() {
return $this->data;
}
public function isParent($username) {
foreach ($this->parents as $parent) {
if ($parent->getNom() == $username) {
return true;
}
}
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace YesWiki\Meeo\Eleve;
use YesWiki\Bazar\Service\EntryManager;
class ParentEleve {
private $data;
private $user;
public function __construct(EntryManager $entryManager, $yunoshostFormId, $data) {
$this->data = $data;
// echo "<p>".var_dump($data)."</p>";
$userId = $data['listefiche'.$yunoshostFormId.'bf_parent'];
$this->user = $entryManager->getOne($userId);
// echo "<p>".var_dump($userId)."</p>";
// echo "<p>".var_dump($this)."</p>";
}
public function getNom() {
if (empty($this->user['bf_nom'])) {
return $this->user['bf_titre'];
} else {
return $this->user['bf_nom'];
}
}
public function getEmail() {
return $this->user['bf_mail'];
}
}