Add link to parents and use it in absence to send message

This commit is contained in:
mckmonster 2024-09-04 15:25:23 +02:00
parent 7ea50c721d
commit e1078eb5ab
3 changed files with 41 additions and 1 deletions

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,6 +56,14 @@ 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;
}

View file

@ -0,0 +1,23 @@
<?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 getEmail() {
return $this->user['bf_mail'];
}
}