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

<section class="member-card">
<h2>Signature du document</h2>
<p><?= htmlspecialchars($member['prenom'].' '.$member['nom']) ?></p>

<form method="post" action="/public/consentements/signature" class="member-form">
<?= Csrf::field() ?>
<input type="hidden" name="id" value="<?= (int)$document['id'] ?>">
<input type="hidden" name="signature_data" id="signature-data">

<label><span>Nom du signataire</span><input required name="nom_signataire"></label>
<label><span>Qualité</span><input required name="qualite_signataire" placeholder="Adhérent titulaire / représentant légal"></label>

<div class="wide">
<span>Signature</span>
<canvas id="signature-pad" width="700" height="220"></canvas>
<button type="button" id="signature-clear">Effacer</button>
</div>

<div class="member-form-actions">
<button class="button button-primary">Signer et conserver</button>
</div>
</form>

<hr>

<form method="post" action="/public/consentements/envoyer" class="member-form">
<?= Csrf::field() ?>
<input type="hidden" name="id" value="<?= (int)$document['id'] ?>">
<label class="wide"><span>Envoyer pour signature</span><input required type="email" name="email" value="<?= htmlspecialchars((string)$document['email_envoi']) ?>"></label>
<button class="button button-secondary">Générer un lien sécurisé</button>
</form>
</section>

<script src="/public/assets/js/cda-signature-pad.js"></script>
