Compare commits

..

5 commits

Author SHA1 Message Date
mckmonster
3dbd7e7f30 [Absences] Add the possibility to display eleve absences 2024-07-04 20:20:36 +02:00
mckmonster
33292c554a [Absence] Move eleve_absences in a specific twig 2024-07-04 18:40:03 +02:00
mckmonster
8a18c01cf9 [Absences] Change display 2024-07-04 11:34:16 +02:00
mckmonster
94f2d3a898 [Absences] Display the realname 2024-07-04 09:27:29 +02:00
mckmonster
c1fdd1100c First step to create AbsenceAction 2024-07-04 09:01:12 +02:00
4 changed files with 57 additions and 2 deletions

View file

@ -1,9 +1,15 @@
<?php <?php
use YesWiki\Core\YesWikiAction; use YesWiki\Core\YesWikiAction;
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Core\Service\UserManager;
class AbsencesAction extends YesWikiAction class AbsencesAction extends YesWikiAction
{ {
private $formId = '6';
private $eleveIdentifier = 'listefiche5bf_eleve';
private $groupeEE = 'EquipeEducative';
public function formatArguments($arg) public function formatArguments($arg)
{ {
return []; return [];
@ -11,6 +17,34 @@ class AbsencesAction extends YesWikiAction
public function run() public function run()
{ {
return $this->render('@meeo/absences.twig'); $entryManager = $this->getService(EntryManager::class);
$userManager = $this->getService(UserManager::class);
if ( $userManager->isInGroup($this->groupeEE, admincheck: false) ) {
$entries = $entryManager->search(['formsIds' => $this->formId]);
$grouped_entries = [];
foreach ($entries as $entry) {
$identifier = $entry[$this->eleveIdentifier];
$nom = $entryManager->getOne($identifier)['bf_nom'];
if (!isset($grouped_entries[$identifier])) {
$grouped_entries[$identifier] = [
'nom' => $nom,
'entries' => []
];
}
$grouped_entries[$identifier]['entries'][] = $entry;
}
return $this->render('@meeo/edu_absences.twig', [
"groups" => $grouped_entries,
]);
} else {
$username = $userManager->getLoggedUsername();
$entries = $entryManager->search(['formsIds' => $this->formId, 'queries' => [ $this->eleveIdentifier => $username."2"]]);
return $this->render('@meeo/eleve_absences.twig', [
"entries" => $entries,
]);
}
} }
} }

View file

@ -1 +0,0 @@
<p>Absences</p>

View file

@ -0,0 +1,12 @@
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
{% for identifier, group in groups %}
<div class="panel panel-default">
<button id="head_{{ identifier }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ identifier }}" data-toggle="collapse" aria-expanded="false">
<h4 class="panel-title">{{ group['nom'] }}</h4>
</button>
<div id="{{ identifier }}" class="panel-collapse collapse in" aria-expanded="false">
{% include '@meeo/eleve_absences.twig' with { 'entries' : group['entries'] } %}
</div>
</div>
{% endfor %}
</div>

View file

@ -0,0 +1,10 @@
<div class="panel-body">
{% for entry in entries %}
<div>
<h5>{{ entry['bf_date_debut_evenement'] }}</h5>
{% if entry['bf_commentaire']|default %}
<p>{{ entry['bf_commentaire'] }}</p>
{% endif %}
</div>
{% endfor %}
</div>