[Absences] Display "Aucune Absence" quand on n'a pas d'absence
Rajout de variable de configuration
This commit is contained in:
parent
3a74666a8f
commit
9f269a1c52
3 changed files with 13 additions and 10 deletions
|
@ -6,10 +6,6 @@ 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 [];
|
||||||
|
@ -17,14 +13,18 @@ class AbsencesAction extends YesWikiAction
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$formId = $this->params->get('meeo_formId');
|
||||||
|
$eleveIdentifier = $this->params->get('meeo_eleveIdentifier');
|
||||||
|
$groupeEE = $this->params->get('meeo_groupeEE');
|
||||||
|
|
||||||
$entryManager = $this->getService(EntryManager::class);
|
$entryManager = $this->getService(EntryManager::class);
|
||||||
$userManager = $this->getService(UserManager::class);
|
$userManager = $this->getService(UserManager::class);
|
||||||
|
|
||||||
if ( $userManager->isInGroup($this->groupeEE, admincheck: false) ) {
|
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
||||||
$entries = $entryManager->search(['formsIds' => $this->formId]);
|
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||||
$grouped_entries = [];
|
$grouped_entries = [];
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
$identifier = $entry[$this->eleveIdentifier];
|
$identifier = $entry[$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] = [
|
||||||
|
@ -40,7 +40,7 @@ class AbsencesAction extends YesWikiAction
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$username = $userManager->getLoggedUsername();
|
$username = $userManager->getLoggedUsername();
|
||||||
$entries = $entryManager->search(['formsIds' => $this->formId, 'queries' => [ $this->eleveIdentifier => $username."2"]]);
|
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $username."2"]]);
|
||||||
|
|
||||||
return $this->render('@meeo/eleve_absences.twig', [
|
return $this->render('@meeo/eleve_absences.twig', [
|
||||||
"entries" => $entries,
|
"entries" => $entries,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
parameters:
|
parameters:
|
||||||
Meeo:
|
meeo_formId: '6'
|
||||||
my_param: 'this is a test param defined in tools/meeo/config.yaml. It can be ovewritten in wakka.config.php'
|
meeo_eleveIdentifier: listefiche5bf_eleve
|
||||||
|
meeo_groupeEE: EquipeEducative
|
||||||
|
|
||||||
services:
|
services:
|
||||||
_defaults:
|
_defaults:
|
||||||
|
|
|
@ -11,4 +11,6 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div>Aucune absences</div>
|
||||||
{% endif %}
|
{% endif %}
|
Loading…
Reference in a new issue