[Absences] Add the possibility to display eleve absences
This commit is contained in:
parent
33292c554a
commit
3dbd7e7f30
3 changed files with 32 additions and 17 deletions
|
@ -2,9 +2,14 @@
|
|||
|
||||
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 [];
|
||||
|
@ -13,23 +18,33 @@ class AbsencesAction extends YesWikiAction
|
|||
public function run()
|
||||
{
|
||||
$entryManager = $this->getService(EntryManager::class);
|
||||
$entries = $entryManager->search(['formsIds' => '6']);
|
||||
$userManager = $this->getService(UserManager::class);
|
||||
|
||||
$grouped_entries = [];
|
||||
foreach ($entries as $entry) {
|
||||
$identifier = $entry['listefiche5bf_eleve'];
|
||||
$nom = $entryManager->getOne($identifier)['bf_nom'];
|
||||
if (!isset($grouped_entries[$identifier])) {
|
||||
$grouped_entries[$identifier] = [
|
||||
'nom' => $nom,
|
||||
'entries' => []
|
||||
];
|
||||
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;
|
||||
}
|
||||
$grouped_entries[$identifier]['entries'][] = $entry;
|
||||
}
|
||||
|
||||
return $this->render('@meeo/edu_absences.twig', [
|
||||
"groups" => $grouped_entries,
|
||||
]);
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<h4 class="panel-title">{{ group['nom'] }}</h4>
|
||||
</button>
|
||||
<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>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="panel-body">
|
||||
{% for entry in group['entries'] %}
|
||||
{% for entry in entries %}
|
||||
<div>
|
||||
<h5>{{ entry['bf_date_debut_evenement'] }}</h5>
|
||||
{% if entry['bf_commentaire']|default %}
|
||||
|
|
Loading…
Reference in a new issue