<?php $__env->startSection('title', 'Demande #'.$serviceRequest->id); ?>
<?php $__env->startSection('content'); ?>
<a href="<?php echo e(route('courier.requests.index')); ?>" class="mb-3 d-inline-block">&laquo; Retour</a>

<div class="card p-4" style="max-width:700px;">
    <h4><?php echo e(\App\Models\ServiceRequest::types()[$serviceRequest->type]); ?> — <?php echo e($serviceRequest->partner->name); ?></h4>
    <p class="text-muted mb-2"><?php echo e($serviceRequest->partner->address); ?> — <?php echo e($serviceRequest->partner->phone); ?></p>
    <p><strong>Statut actuel :</strong> <span class="badge bg-secondary"><?php echo e(\App\Models\ServiceRequest::statuses()[$serviceRequest->status]); ?></span></p>
    <p><strong>Quantite demandee :</strong> <?php echo e($serviceRequest->requested_quantity ?? '-'); ?></p>
    <?php if($serviceRequest->requested_slot): ?>
        <p><strong>Creneau souhaite :</strong> <?php echo e($serviceRequest->requested_slot); ?></p>
    <?php endif; ?>

    <hr>
    <h6>Details</h6>
    <ul class="small">
        <?php $__currentLoopData = $serviceRequest->details ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <li><strong><?php echo e(ucfirst(str_replace('_', ' ', $key))); ?> :</strong> <?php echo e($value); ?></li>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </ul>

    <?php if(in_array($serviceRequest->status, ['assigne'])): ?>
    <hr>
    <h5>Confirmer la collecte</h5>
    <p class="small text-muted">Seule cette confirmation, faite par vous sur le terrain, fait foi. Toute difference avec la quantite demandee sera automatiquement signalee a l'administration — pas besoin de discuter, ecris simplement ce que tu as reellement recupere.</p>
    <form method="POST" action="<?php echo e(route('courier.requests.collect', $serviceRequest)); ?>" enctype="multipart/form-data" class="mb-4">
        <?php echo csrf_field(); ?>
        <div class="mb-3">
            <label class="form-label">Quantite reellement collectee</label>
            <input type="number" name="collected_quantity" class="form-control" min="0" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Photo (optionnel)</label>
            <input type="file" name="photo" accept="image/*" capture="environment" class="form-control">
        </div>
        <div class="mb-3">
            <label class="form-label">Commentaire (optionnel)</label>
            <input type="text" name="comment" class="form-control">
        </div>
        <button class="btn btn-success">Confirmer la collecte</button>
    </form>

    <h6>Ou signaler une indisponibilite</h6>
    <form method="POST" action="<?php echo e(route('courier.requests.unavailable', $serviceRequest)); ?>" class="d-flex gap-2">
        <?php echo csrf_field(); ?>
        <select name="unavailable_reason" class="form-select" required>
            <option value="">Motif...</option>
            <option value="Pas encore pret">Pas encore pret</option>
            <option value="Clinique fermee">Clinique fermee</option>
            <option value="Refuse par le client">Refuse par le client</option>
            <option value="Autre">Autre</option>
        </select>
        <button class="btn btn-outline-warning">Signaler</button>
    </form>
    <?php endif; ?>

    <?php if(in_array($serviceRequest->status, ['collecte', 'ecart'])): ?>
    <hr>
    <form method="POST" action="<?php echo e(route('courier.requests.deliver', $serviceRequest)); ?>">
        <?php echo csrf_field(); ?>
        <button class="btn btn-primary">Confirmer la livraison au laboratoire</button>
    </form>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/smartch/capara/resources/views/courier/requests/show.blade.php ENDPATH**/ ?>