> */ public function allActive(): array { return $this->pdo->query( "SELECT id_motif, code, libelle, compte_dans_quota FROM motif_planning WHERE actif = TRUE ORDER BY ordre_affichage, libelle" )->fetchAll(); } /** * Identifiants des motifs actifs. * * @return int[] */ public function activeIds(): array { return array_map( 'intval', $this->pdo->query('SELECT id_motif FROM motif_planning WHERE actif = TRUE')->fetchAll(\PDO::FETCH_COLUMN) ); } /** * Motifs réellement affectables à un agent : « Formation » disparaît de la * liste dès lors que l'agent n'a pas droit à l'enveloppe de formation. * * C'est la liste de référence des contrôles de saisie : tout motif absent * d'ici est refusé côté serveur, quelle que soit l'interface utilisée. * * @param array $agent Fiche agent (doit porter * droit_enveloppe_formation). * * @return array> */ public function allActiveForAgent(array $agent): array { if (AgentModel::hasTrainingRight($agent)) { return $this->allActive(); } return array_values(array_filter( $this->allActive(), static fn(array $motif): bool => !MotifCategories::requiresTrainingRight((string) $motif['code']) )); } /** @return int[] */ public function activeIdsForAgent(array $agent): array { return array_map( static fn(array $motif): int => (int) $motif['id_motif'], $this->allActiveForAgent($agent) ); } }