[Absences] Add the possibility to display eleve absences

This commit is contained in:
mckmonster 2024-07-04 20:20:36 +02:00
parent 33292c554a
commit 3dbd7e7f30
3 changed files with 32 additions and 17 deletions

View file

@ -2,9 +2,14 @@
use YesWiki\Core\YesWikiAction; use YesWiki\Core\YesWikiAction;
use YesWiki\Bazar\Service\EntryManager; 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 [];
@ -13,23 +18,33 @@ class AbsencesAction extends YesWikiAction
public function run() public function run()
{ {
$entryManager = $this->getService(EntryManager::class); $entryManager = $this->getService(EntryManager::class);
$entries = $entryManager->search(['formsIds' => '6']); $userManager = $this->getService(UserManager::class);
$grouped_entries = []; if ( $userManager->isInGroup($this->groupeEE, admincheck: false) ) {
foreach ($entries as $entry) { $entries = $entryManager->search(['formsIds' => $this->formId]);
$identifier = $entry['listefiche5bf_eleve']; $grouped_entries = [];
$nom = $entryManager->getOne($identifier)['bf_nom']; foreach ($entries as $entry) {
if (!isset($grouped_entries[$identifier])) { $identifier = $entry[$this->eleveIdentifier];
$grouped_entries[$identifier] = [ $nom = $entryManager->getOne($identifier)['bf_nom'];
'nom' => $nom, if (!isset($grouped_entries[$identifier])) {
'entries' => [] $grouped_entries[$identifier] = [
]; 'nom' => $nom,
'entries' => []
];
}
$grouped_entries[$identifier]['entries'][] = $entry;
} }
$grouped_entries[$identifier]['entries'][] = $entry;
}
return $this->render('@meeo/edu_absences.twig', [ return $this->render('@meeo/edu_absences.twig', [
"groups" => $grouped_entries, "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

@ -5,7 +5,7 @@
<h4 class="panel-title">{{ group['nom'] }}</h4> <h4 class="panel-title">{{ group['nom'] }}</h4>
</button> </button>
<div id="{{ identifier }}" class="panel-collapse collapse in" aria-expanded="false"> <div id="{{ identifier }}" class="panel-collapse collapse in" aria-expanded="false">
{% include '@meeo/eleve_absences.twig' %} {% include '@meeo/eleve_absences.twig' with { 'entries' : group['entries'] } %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View file

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