182 lines
6.8 KiB
PHP
Executable File
182 lines
6.8 KiB
PHP
Executable File
<?php
|
|
$_SESSION['p_messageFace'] = "";
|
|
?>
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
|
|
<div class="modal fade" id="pop_rec_faciale" role="dialog" data-backdrop="static" data-keyboard="false" >
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
<div class="d-flex justify-content-between align-items-center w-100">
|
|
<h4 class="modal-title mb-0"><?= _("RECONNAISSANCE FACIALE") ?></h4>
|
|
<button id="btn_close_pop_rec_faciale" name="btn_close_pop_rec_faciale" type="button" class="btn-close" data-bs-dismiss="modal" onclick="javascript:fiche_beneficiaire();" aria-label="<?= _("Fermer") ?>"></button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<!-- Boutons d'action - disposition responsive -->
|
|
<div class="row g-2 mb-3">
|
|
<div class="col-12 col-sm-6">
|
|
<button id="ebene_take_photo_face" name="ebene_take_photo_face" type="button" class="btn btn-primary w-100 py-2 btn_autre" onclick="javascript:takephoto();">
|
|
<i class="bi bi-camera me-2"></i><?= _("PRENDRE UNE PHOTO") ?>
|
|
</button>
|
|
</div>
|
|
|
|
<?php if ($faceRegistered == "1") : ?>
|
|
<div class="col-12 col-sm-6">
|
|
<button disabled id="ebene_confirmer_photo_face" name="ebene_confirmer_photo_face" type="button" class="btn btn-primary w-100 py-2 btn_autre" onclick="javascript:ebene_confirmer_photo_face();">
|
|
<i class="bi bi-check-circle me-2"></i><?= _("CONFIRMER LA PHOTO") ?>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($faceRegistered != "1") : ?>
|
|
<div class="col-12 col-sm-6">
|
|
<button disabled id="ebene_enregistrer_photo_face" name="ebene_enregistrer_photo_face" type="button" class="btn btn-primary w-100 py-2 btn_autre" onclick="javascript:ebene_enregistrer_photo_face();">
|
|
<i class="bi bi-save me-2"></i><?= _("ENREGISTRER LA PHOTO") ?>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Zone webcam et photo - disposition responsive -->
|
|
<div class="row g-3">
|
|
<div class="col-12 col-md-6">
|
|
<div class="text-center mb-2">
|
|
<legend class="h6"><?= _("Webcam") ?></legend>
|
|
</div>
|
|
<div class="ratio ratio-4x3 bg-dark rounded">
|
|
<video id="video_face" name="video_face" autoplay playsinline class="w-100 h-100 object-fit-cover"></video>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-12 col-md-6">
|
|
<div class="text-center mb-2">
|
|
<legend class="h6"><?= _("Photo") ?></legend>
|
|
</div>
|
|
<div class="ratio ratio-4x3 bg-light border rounded">
|
|
<img id="photo_face" name="photo_face" src="" class="w-100 h-100 object-fit-cover" alt="<?= _("Photo capturée") ?>" />
|
|
</div>
|
|
|
|
<form id="form_face" name="form_face" enctype="multipart/form-data" method="post" action="Fichebeneficiaire/ebeneenregistrerface">
|
|
<input class="sr-only" type="text" id="compare_face" name="compare_face" value="<?= $faceRegistered ?>">
|
|
<input class="sr-only" type="text" id="del_face" name="del_face" value="0">
|
|
<input class="image-tag" type="hidden" id="image_face" name="image_face">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Canvas caché -->
|
|
<canvas id="canvas" name="canvas" style="display: none;" width="350" height="260"></canvas>
|
|
|
|
<!-- Messages -->
|
|
<div id="message_face" name="message_face" class="mt-3">
|
|
<div class="alert alert-warning mb-0" role="alert">
|
|
<div class="d-flex align-items-center">
|
|
<i class="bi bi-info-circle me-2"></i>
|
|
<marquee behavior="scroll" direction="left" scrollamount="3" class="flex-grow-1"></marquee>
|
|
</div>
|
|
</div>
|
|
<input class="sr-only" type="text" id="photo_succes" name="photo_succes" value="0">
|
|
</div>
|
|
|
|
<!-- Zone d'attente -->
|
|
<div id="div_wait_face_ebene" class="mt-3"></div>
|
|
|
|
<script type="text/javascript">
|
|
var video = document.getElementById('video_face');
|
|
var canvas = document.getElementById('canvas');
|
|
var photo = document.getElementById('photo_face');
|
|
var image_face = document.getElementById('image_face');
|
|
|
|
navigator.getMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.mediaDevices.getUserMedia || navigator.moxGetUserMedia;
|
|
|
|
if (navigator.mediaDevices.getUserMedia)
|
|
{
|
|
navigator.mediaDevices.getUserMedia({
|
|
video: {
|
|
facingMode: 'user',
|
|
width: { ideal: 1280 },
|
|
height: { ideal: 720 }
|
|
}
|
|
})
|
|
.then(function (stream) {
|
|
video.srcObject = stream;
|
|
})
|
|
.catch(function (e) {
|
|
console.error("Erreur caméra:", e);
|
|
alert("Erreur d'accès à la caméra: " + e.message);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
navigator.getMedia({
|
|
video: {
|
|
mandatory: {
|
|
maxWidth: 350,
|
|
maxHeight: 260
|
|
}
|
|
}
|
|
}, function(stream) {
|
|
video.src = stream;
|
|
}, function(e) {
|
|
console.error("Erreur caméra:", e);
|
|
alert("Erreur d'accès à la caméra: " + e.message);
|
|
});
|
|
}
|
|
|
|
function takephoto() {
|
|
$('#message_face').html("");
|
|
$("#div_wait_face_ebene").html('');
|
|
|
|
// Ajustement de la taille du canvas pour mobile
|
|
var context = canvas.getContext('2d');
|
|
canvas.width = video.videoWidth;
|
|
canvas.height = video.videoHeight;
|
|
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
|
|
var data = canvas.toDataURL('image/jpeg', 0.8);
|
|
photo.setAttribute('src', data);
|
|
$("#image_face").val(data);
|
|
|
|
var faceRegistered = $("#faceRegistered").val();
|
|
|
|
// Activation des boutons
|
|
$("#ebene_enregistrer_photo_face").prop('disabled', false);
|
|
if(faceRegistered == "1") {
|
|
$("#ebene_confirmer_photo_face").prop('disabled', false);
|
|
$("#ebene_supprimer_photo_face").prop('disabled', false);
|
|
$("#motif").prop('disabled', false);
|
|
}
|
|
}
|
|
|
|
// Gestion du redimensionnement pour mobile
|
|
$(window).on('resize', function() {
|
|
if($(window).width() < 768) {
|
|
$('.modal-dialog').addClass('modal-fullscreen-sm-down');
|
|
} else {
|
|
$('.modal-dialog').removeClass('modal-fullscreen-sm-down');
|
|
}
|
|
});
|
|
|
|
// Initialisation au chargement
|
|
$(document).ready(function() {
|
|
if($(window).width() < 768) {
|
|
$('.modal-dialog').addClass('modal-fullscreen-sm-down');
|
|
}
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button id="close_poprec_faciane" name="close_poprec_faciane" type="button" class="btn btn-secondary" data-bs-dismiss="modal" onclick="javascript:fiche_beneficiaire();">
|
|
<i class="bi bi-x-circle me-2 btn_autre"></i><?= _("Fermer") ?>
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|