diff --git a/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
index 5f67524b..be503ff7 100644
--- a/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
+++ b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
@@ -157,9 +157,9 @@
@break
@case('file')
- @if(!isset($form->is_approval) || $form->is_approval != 'yes')
-
+ @if(!isset($form->is_approval) || $form->is_approval != 'yes')
@if($question->code == 'upload_photo')
+
- @else
-
- @endif
-
- @elseif(isset($question->value))
-
+
+
+
+
![Captured photo]()
+
+
+
+
+
+
+
+
+
+
+ @else
+ required == 'yes' ? 'required' : ''}}>
@endif
- @break
+
+ @elseif(isset($question->value))
+
+ @endif
+ @break
@case('multitextbox')
@@ -366,47 +397,63 @@
const photoInput = document.getElementById('field-upload_photo');
$('#start-photo-camera').on('click', async function () {
- try {
- if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
- throw new Error('Camera access requires HTTPS or localhost.');
- }
+ try {
+ if (!navigator.mediaDevices ||
+ !navigator.mediaDevices.getUserMedia) {
+ throw new Error('Camera API is unavailable. Use HTTPS or localhost.');
+ }
- // This triggers the browser's native camera permission prompt
- photoStream = await navigator.mediaDevices.getUserMedia({
- video: { facingMode: { ideal: 'environment' } },
- audio: false
- });
+ // Request camera permission
+ photoStream = await navigator.mediaDevices.getUserMedia({
+ video: {
+ facingMode: { ideal: 'environment' }
+ },
+ audio: false
+ });
- video.srcObject = photoStream;
- video.style.display = 'block';
- preview.style.display = 'none';
+ // Check required elements
+ if (!video || !preview || !photoInput) {
+ throw new Error('Camera elements are missing from the page.');
+ }
- $('#start-photo-camera').hide();
- $('#capture-photo').show();
- $('#retake-photo').hide();
+ video.srcObject = photoStream;
+ video.style.display = 'block';
+ preview.style.display = 'none';
- } catch (error) {
- console.error('Camera error:', error);
+ await video.play();
- if (error.name === 'NotAllowedError' ||
- error.name === 'PermissionDeniedError') {
+ $('#start-photo-camera').hide();
+ $('#capture-photo').show();
+ $('#retake-photo').hide();
- Swal.fire({
- icon: 'warning',
- title: 'Camera Permission Required',
- text: 'Please allow camera access in your browser settings and click Open Camera again.'
+ } catch (error) {
+ console.error('Camera error:', error);
+
+ // Stop any partially opened camera stream
+ if (photoStream) {
+ photoStream.getTracks().forEach(track => track.stop());
+ photoStream = null;
+ }
+
+ if (error.name === 'NotAllowedError' ||
+ error.name === 'PermissionDeniedError') {
+
+ Swal.fire({
+ icon: 'warning',
+ title: 'Camera Access Denied',
+ text: 'Please enable camera permission for this website in your browser settings, then try again.'
+ });
+
+ } else {
+ Swal.fire({
+ icon: 'error',
+ title: 'Unable to Open Camera',
+ text: error.message || 'Please check your camera and try again.'
+ });
+ }
+ }
});
- } else {
- Swal.fire({
- icon: 'error',
- title: 'Camera Unavailable',
- text: 'Unable to access your camera. Please check your camera and try again.'
- });
- }
- }
-});
-
$('#capture-photo').on('click', function () {
if (!photoStream || !video.videoWidth) {
return;