<form method="POST" action="/eagle_client_istanbulcups/api/caisses/affecter_utilisateur_caisses.php">
<input type="hidden" name="utilisateur_id" id="affect_user_id">

<div class="modal fade" id="modalAffectation" tabindex="-1">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">

      <div class="modal-header bg-primary text-white">
        <h5 id="affect_user_name">Affectation caisses</h5>
        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
      </div>

      <div class="modal-body">

        <!-- PIN POS -->
        <div class="mb-3">
          <label class="form-label">Code PIN POS</label>
          <input type="password"
                 name="pos_pin"
                 class="form-control"
                 inputmode="numeric"
                 pattern="[0-9]{4,6}"
                 minlength="4"
                 maxlength="6"
                 placeholder="PIN 4 à 6 chiffres">
          <small class="text-muted">
            Laisser vide pour conserver le PIN actuel
          </small>
        </div>

        <hr>

        <!-- Caisses -->
        <?php foreach ($caisses as $c): ?>
          <div class="form-check">
            <input class="form-check-input caisse-checkbox"
                   type="checkbox"
                   name="caisses[]"
                   value="<?= $c['id'] ?>"
                   id="caisse<?= $c['id'] ?>">
            <label class="form-check-label" for="caisse<?= $c['id'] ?>">
              <?= htmlspecialchars($c['nom']) ?>
            </label>
          </div>
        <?php endforeach; ?>

      </div>

      <div class="modal-footer">
        <button class="btn btn-success">
          💾 Enregistrer
        </button>
      </div>

    </div>
  </div>
</div>
</form>
