[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,11 +18,13 @@ 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);
if ( $userManager->isInGroup($this->groupeEE, admincheck: false) ) {
$entries = $entryManager->search(['formsIds' => $this->formId]);
$grouped_entries = []; $grouped_entries = [];
foreach ($entries as $entry) { foreach ($entries as $entry) {
$identifier = $entry['listefiche5bf_eleve']; $identifier = $entry[$this->eleveIdentifier];
$nom = $entryManager->getOne($identifier)['bf_nom']; $nom = $entryManager->getOne($identifier)['bf_nom'];
if (!isset($grouped_entries[$identifier])) { if (!isset($grouped_entries[$identifier])) {
$grouped_entries[$identifier] = [ $grouped_entries[$identifier] = [
@ -31,5 +38,13 @@ class AbsencesAction extends YesWikiAction
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 %}