<?php use App\Core\Csrf; ?>
<link rel="stylesheet" href="/public/assets/css/cda-v5-1.css">

<section class="page-intro">
<div>
<span class="page-kicker">Cours</span>
<h2>Modifier le cours</h2>
<p><?= htmlspecialchars((string)$workshop['code']) ?></p>
</div>
<a class="button button-secondary" href="/public/ateliers">Retour</a>
</section>

<form method="post" action="/public/ateliers/modifier" class="v51-card">
<?= Csrf::field() ?>
<input type="hidden" name="id" value="<?= (int)$workshop['id'] ?>">

<div class="v51-grid">
<label>
<span>Libellé *</span>
<input required name="libelle" value="<?= htmlspecialchars((string)$workshop['libelle']) ?>">
</label>

<label>
<span>Type</span>
<select name="type_atelier">
<?php foreach(['individuel','collectif','ponctuel','stage','master_class'] as $type): ?>
<option value="<?= $type ?>" <?= $workshop['type_atelier']===$type?'selected':'' ?>>
<?= ucfirst(str_replace('_',' ',$type)) ?>
</option>
<?php endforeach; ?>
</select>
</label>

<label>
<span>Durée standard</span>
<input type="number" min="5" step="5" name="duree_standard_minutes"
value="<?= (int)$workshop['duree_standard_minutes'] ?>">
</label>

<label>
<span>Capacité</span>
<input type="number" min="1" name="capacite_max"
value="<?= (int)$workshop['capacite_max'] ?>">
</label>
</div>

<div class="v51-publics">
<h3>Publics autorisés</h3>
<div>
<?php foreach($publics as $public): ?>
<label>
<input type="checkbox" name="public_ids[]" value="<?= (int)$public['id'] ?>"
<?= in_array((int)$public['id'],$selectedPublics,true)?'checked':'' ?>>
<span><?= $public['code']==='ENF'?'🧒':'👤' ?></span>
<strong><?= htmlspecialchars((string)$public['libelle']) ?></strong>
</label>
<?php endforeach; ?>
</div>
<p>Les deux cases cochées donnent un cours Mixte.</p>
</div>

<label class="full">
<span>Description</span>
<textarea name="description" rows="5"><?= htmlspecialchars((string)$workshop['description']) ?></textarea>
</label>

<div class="sticky-actions">
<a class="button button-secondary" href="/public/ateliers">Annuler</a>
<button class="button button-primary">Enregistrer</button>
</div>
</form>
