<?php use App\Core\Csrf;$h=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8');?>
<link rel="stylesheet" href="/public/assets/css/cda-professor-consents-9616.css"><main class="pcons"><a class="pcons-back" href="/public/professeurs-pro/voir?id=<?=(int)$professor['id']?>">← Retour au dossier professeur</a><header><div><span>DOCUMENTS ET CONSENTEMENTS</span><h1><?=$h($professor['prenom'].' '.$professor['nom'])?></h1><p>RGPD et droit à l’image : e-mail sécurisé, impression, signature ou import.</p></div></header>
<?php foreach(['success','error'] as$key):if(!empty($_SESSION[$key])):?><div class="pcons-flash <?=$key?>"><?=$h($_SESSION[$key])?></div><?php unset($_SESSION[$key]);endif;endforeach?>
<section class="pcons-create"><article><h2>Protection des données</h2><p>Préparer le consentement RGPD du professeur.</p><form method="post" action="/public/professeurs/consentements"><?=Csrf::field()?><input type="hidden" name="professeur_id" value="<?=(int)$professor['id']?>"><input type="hidden" name="type_document" value="rgpd"><label>Année scolaire<input name="annee_scolaire" value="2026-2027"></label><label class="check"><input type="checkbox" name="communications_email"> Communications facultatives par e-mail</label><button>Préparer le RGPD</button></form></article><article><h2>Droit à l’image</h2><form method="post" action="/public/professeurs/consentements"><?=Csrf::field()?><input type="hidden" name="professeur_id" value="<?=(int)$professor['id']?>"><input type="hidden" name="type_document" value="droit_image"><label>Année scolaire<input name="annee_scolaire" value="2026-2027"></label><label>Décision<select name="decision"><option value="accorde">Autorisation accordée</option><option value="refuse">Autorisation refusée</option></select></label><?php foreach(['photo_individuelle'=>'Photo individuelle','photo_groupe'=>'Photo de groupe','site_internet'=>'Site internet','reseaux_sociaux'=>'Réseaux sociaux','affiches'=>'Affiches','presse'=>'Presse','video'=>'Vidéo'] as$key=>$label):?><label class="check"><input type="checkbox" name="<?=$key?>"> <?=$label?></label><?php endforeach?><button>Préparer le droit à l’image</button></form></article></section>
<section class="pcons-list"><h2>Documents préparés</h2><?php foreach($documents as$d):$status=$d['display_status']??$d['statut'];?><article><header><div><span><?=$d['type_document']==='rgpd'?'RGPD':'DROIT À L’IMAGE'?></span><h3><?=$h($d['annee_scolaire'])?></h3></div><em class="status-<?=$h($status)?>"><?=$h(str_replace('_',' ',$status))?></em></header><?php if($d['token_expires_at']&&!in_array($status,['signe','importe'],true)):?><small>Lien valable jusqu’au <?=$h(date('d/m/Y H:i',strtotime($d['token_expires_at'])))?></small><?php endif?><div class="pcons-actions"><a target="_blank" href="/public/professeurs/consentements/imprimer?id=<?=(int)$d['id']?>">Imprimer</a><form method="post" action="/public/professeurs/consentements/envoyer"><?=Csrf::field()?><input type="hidden" name="id" value="<?=(int)$d['id']?>"><input required type="email" name="email" value="<?=$h($d['email_destinataire']?:$professor['email'])?>"><button>Envoyer le jeton</button></form><button type="button" data-sign-toggle="<?=(int)$d['id']?>">Signer sur place</button></div><form hidden data-sign-form="<?=(int)$d['id']?>" method="post" action="/public/professeurs/consentements/signature" class="sign-form"><?=Csrf::field()?><input type="hidden" name="id" value="<?=(int)$d['id']?>"><input type="hidden" name="signature_data" data-signature-output><label>Nom du signataire<input required name="nom_signataire" value="<?=$h($professor['prenom'].' '.$professor['nom'])?>"></label><canvas width="650" height="180"></canvas><div><button type="button" data-clear>Effacer</button><button>Valider la signature</button></div></form><form method="post" action="/public/professeurs/consentements/importer" enctype="multipart/form-data" class="import-form"><?=Csrf::field()?><input type="hidden" name="id" value="<?=(int)$d['id']?>"><label>Document signé papier/PDF<input required type="file" name="document_signe" accept="application/pdf,image/png,image/jpeg"></label><button>Importer</button></form><?php if($d['email_error']):?><small class="mail-error"><?=$h($d['email_error'])?></small><?php endif?></article><?php endforeach?><?php if(!$documents):?><p>Aucun document préparé.</p><?php endif?></section></main><script src="/public/assets/js/cda-professor-consents-9616.js"></script>
