Compare commits
2 commits
7ea50c721d
...
3dc1aed82d
Author | SHA1 | Date | |
---|---|---|---|
|
3dc1aed82d | ||
|
e1078eb5ab |
4 changed files with 69 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
libs/eleves/parent.lib.php
Normal file
31
libs/eleves/parent.lib.php
Normal 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'];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue