From 5fde53b4c5d1667fece67fff5b94f85f038ccc3e Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 6 Sep 2024 11:54:14 +0200 Subject: [PATCH] try a fix to get parents link --- config.yaml | 1 + libs/eleves/eleve.lib.php | 11 +++++++++-- services/EleveManager.php | 11 ++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.yaml b/config.yaml index 57e282d..601a355 100644 --- a/config.yaml +++ b/config.yaml @@ -4,6 +4,7 @@ parameters: absencesFormId: 8 notesFormId: 9 yunohostFormId: 6 + parentsFormId: 10 groupeEE: 'equipeeducative' redirect: eleveUpdate: '?Eleves' diff --git a/libs/eleves/eleve.lib.php b/libs/eleves/eleve.lib.php index 85a2a1c..1650c52 100644 --- a/libs/eleves/eleve.lib.php +++ b/libs/eleves/eleve.lib.php @@ -12,14 +12,21 @@ class Eleve { private $user; private $parents; - public function __construct(EntryManager $entryManager, $yunoshostFormId, $data) { + public function __construct(EntryManager $entryManager, $meeo_config, $data) { $this->data = $data; // echo "

".var_dump($data)."

"; + $yunoshostFormId = $meeo_config['yunohostFormId']; + $parentsFormId = $meeo_config['parentsFormId']; + $elevesFormId = $meeo_config['elevesFormId']; + // echo "

Config : ".var_dump($meeo_config)."

"; $userId = $data['listefiche'.$yunoshostFormId.'bf_nom']; $this->user = $entryManager->getOne($userId); // echo "

".var_dump($userId)."

"; $this->parents = []; - foreach ($entryManager->search(['formsIds' => 10, 'queries' => ['listefiche7bf_eleve' => $userId]]) as $parent) { + $parents = $entryManager->search(['formsIds' => $parentsFormId, 'queries' => ['listefiche'.$elevesFormId.'bf_eleve' => $userId.'2']]); + // $parents = $entryManager->search(['formsIds' => $parentsFormId]); + // echo "

Parents : ".var_dump($parents)."

"; + foreach ( $parents as $parent) { array_push($this->parents, new ParentEleve($entryManager, $yunoshostFormId, $parent)); } // echo "

".var_dump($this)."

"; diff --git a/services/EleveManager.php b/services/EleveManager.php index 6135901..1e47885 100644 --- a/services/EleveManager.php +++ b/services/EleveManager.php @@ -17,13 +17,14 @@ class EleveManager { private $entryManager; private $listManager; private $wiki; + private $meeo_config; public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager) { - $meeo_config = $params->get('meeo'); + $this->meeo_config = $params->get('meeo'); $this->wiki = $wiki; - $this->formId = $meeo_config['elevesFormId']; - $this->yunoshostFormId = $meeo_config['yunohostFormId']; + $this->formId = $this->meeo_config['elevesFormId']; + $this->yunoshostFormId = $this->meeo_config['yunohostFormId']; $this->entryManager = $entryManager; $this->listManager = $listManager; } @@ -44,7 +45,7 @@ class EleveManager { $eleves = []; foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data) { - $eleve = new Eleve($this->entryManager, $this->yunoshostFormId, $data); + $eleve = new Eleve($this->entryManager, $this->meeo_config, $data); // echo "

".var_dump($eleve)."

"; $eleves[] = $eleve; } @@ -52,7 +53,7 @@ class EleveManager { } public function getEleve(string $id) { - return new Eleve($this->entryManager, $this->yunoshostFormId, $this->entryManager->getOne($id)); + return new Eleve($this->entryManager, $this->meeo_config, $this->entryManager->getOne($id)); } public function getCurrentEleve(string $username) {