<?php use App\Core\Csrf; ?>
<link rel="stylesheet" href="/public/assets/css/cda-professors-pro.css">
<link rel="stylesheet" href="/public/assets/css/cda-professor-disciplines-9615.css">

<section class="page-intro">
<div>
<span class="page-kicker">Fiche professeur</span>
<h2>Disciplines de <?= htmlspecialchars((string)$professor['prenom'].' '.(string)$professor['nom']) ?></h2>
<p>Sélectionnez une ou plusieurs disciplines issues du référentiel.</p>
</div>
<a class="button button-secondary"
href="/public/professeurs-pro/voir?id=<?= (int)$professor['id'] ?>">
Retour
</a>
</section>

<form method="post"
action="/public/professeurs-pro/disciplines"
class="discipline-selector-form">
<?= Csrf::field() ?>
<input type="hidden" name="professeur_id" value="<?= (int)$professor['id'] ?>">

<div class="discipline-selector-grid">
<?php foreach($available as $discipline): ?>
<label class="discipline-choice <?=in_array((int)$discipline['id'],$selected,true)?'is-selected':''?>" style="--discipline-color:<?= htmlspecialchars((string)$discipline['couleur']) ?>">
<input type="checkbox"
name="disciplines[]"
value="<?= (int)$discipline['id'] ?>"
<?= in_array((int)$discipline['id'],$selected,true) ? 'checked' : '' ?>>

<span class="discipline-choice-icon">
<?= htmlspecialchars((string)$discipline['icone']) ?>
</span>

<div>
<strong><?= htmlspecialchars((string)$discipline['libelle']) ?></strong>
<small>
<?= htmlspecialchars((string)$discipline['pole_libelle']) ?>
·
<?= htmlspecialchars((string)$discipline['code']) ?>
</small>
</div>

<input type="radio"
name="discipline_principale"
value="<?= (int)$discipline['id'] ?>"
title="Définir comme discipline principale"
<?= (int)$main===(int)$discipline['id'] ? 'checked' : '' ?>>
<button type="button" class="discipline-remove" title="Retirer cette discipline">Retirer</button>
</label>
<?php endforeach; ?>
</div>

<div class="selector-help">
<strong>Case carrée :</strong> discipline enseignée.
<strong>Bouton rond :</strong> discipline principale.
</div>

<div class="sticky-actions">
<a class="button button-secondary"
href="/public/professeurs-pro/voir?id=<?= (int)$professor['id'] ?>">
Annuler
</a>
<button class="button button-primary">
Enregistrer les disciplines
</button>
</div>
</form>
<script src="/public/assets/js/cda-professor-disciplines-9615.js"></script>
