Compare commits
5 commits
5b8898dfb9
...
3dbd7e7f30
Author | SHA1 | Date | |
---|---|---|---|
|
3dbd7e7f30 | ||
|
33292c554a | ||
|
8a18c01cf9 | ||
|
94f2d3a898 | ||
|
c1fdd1100c |
4 changed files with 57 additions and 2 deletions
|
@ -1,9 +1,15 @@
|
|||
<?php
|
||||
|
||||
use YesWiki\Core\YesWikiAction;
|
||||
use YesWiki\Bazar\Service\EntryManager;
|
||||
use YesWiki\Core\Service\UserManager;
|
||||
|
||||
class AbsencesAction extends YesWikiAction
|
||||
{
|
||||
private $formId = '6';
|
||||
private $eleveIdentifier = 'listefiche5bf_eleve';
|
||||
private $groupeEE = 'EquipeEducative';
|
||||
|
||||
public function formatArguments($arg)
|
||||
{
|
||||
return [];
|
||||
|
@ -11,6 +17,34 @@ class AbsencesAction extends YesWikiAction
|
|||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<p>Absences</p>
|
12
templates/edu_absences.twig
Normal file
12
templates/edu_absences.twig
Normal 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>
|
10
templates/eleve_absences.twig
Normal file
10
templates/eleve_absences.twig
Normal 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>
|
Loading…
Reference in a new issue