pdo->query( "SELECT id_motif, code, libelle, compte_dans_quota FROM motif_planning WHERE actif = TRUE ORDER BY ordre_affichage, libelle" )->fetchAll(); } 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. */ 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) ); } }