<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('title', null, []); ?> 
        Picking de Almacén a Cocina
     <?php $__env->endSlot(); ?>

    <!-- Picking de Hoy -->
    <h5 class="fw-bold text-dark mb-3"><i class="bi bi-stars text-warning me-2"></i> Tareas de Traslado para HOY</h5>
    <div class="card mb-5 border-0 shadow rounded-4 bg-white overflow-hidden">
        <?php if($picking): ?>
            <div class="card-header bg-primary bg-opacity-10 border-bottom-0 p-4">
                <div class="row align-items-center">
                    <div class="col-md-6">
                        <h4 class="fw-bold text-primary mb-1">
                            Picking #<?php echo e(str_pad($picking->id, 5, '0', STR_PAD_LEFT)); ?>

                        </h4>
                        <div class="text-muted small">
                            Generado desde la Programación para cocina del <span class="fw-bold"><?php echo e(\Carbon\Carbon::parse($picking->programacion->fecha)->format('d/m/Y')); ?></span>
                        </div>
                    </div>
                    <div class="col-md-6 text-md-end mt-3 mt-md-0">
                        <div class="d-inline-block text-end">
                            <div class="small fw-bold text-muted mb-1">Progreso General</div>
                            <div class="d-flex align-items-center gap-3">
                                <div class="progress" style="width: 200px; height: 12px; border-radius: 6px;">
                                    <div class="progress-bar <?php echo e($picking->porcentaje_completado == 100 ? 'bg-success' : 'bg-primary'); ?>" role="progressbar" style="width: <?php echo e($picking->porcentaje_completado); ?>%;" aria-valuenow="<?php echo e($picking->porcentaje_completado); ?>" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                                <span class="fw-bold fs-5 <?php echo e($picking->porcentaje_completado == 100 ? 'text-success' : 'text-primary'); ?>"><?php echo e($picking->porcentaje_completado); ?>%</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="bg-light border-top border-bottom">
                            <tr>
                                <th class="ps-4 text-muted small py-3" style="width: 50px;">Estado</th>
                                <th class="text-muted small py-3">Insumo / Ingrediente</th>
                                <th class="text-center text-muted small py-3" style="width: 150px;">Solicitado</th>
                                <th class="text-center text-muted small py-3" style="width: 150px;">Despachado</th>
                                <th class="pe-4 text-end text-muted small py-3" style="width: 150px;">Acción</th>
                            </tr>
                        </thead>
                        <tbody class="border-top-0">
                            <?php $__currentLoopData = $picking->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr class="<?php echo e($item->completado ? 'bg-light' : ''); ?>">
                                    <td class="ps-4 text-center">
                                        <?php if($item->completado): ?>
                                            <i class="bi bi-check-circle-fill text-success fs-5"></i>
                                        <?php else: ?>
                                            <i class="bi bi-circle text-muted fs-5 opacity-50"></i>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <div class="fw-bold <?php echo e($item->completado ? 'text-muted text-decoration-line-through' : 'text-dark'); ?>">
                                            <?php echo e(optional($item->insumo)->nombre ?? 'Insumo Eliminado'); ?>

                                        </div>
                                    </td>
                                    <td class="text-center fw-bold fs-6">
                                        <?php echo e($item->cantidad_necesaria); ?> <span class="text-muted fw-normal small"><?php echo e($item->insumo->unidad_uso); ?></span>
                                    </td>
                                    <td class="text-center">
                                        <?php if($item->completado): ?>
                                            <span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25 px-3 py-1 rounded-pill fw-bold">
                                                <?php echo e($item->cantidad_despachada); ?> <?php echo e($item->insumo->unidad_uso); ?>

                                            </span>
                                        <?php else: ?>
                                            <span class="text-muted fst-italic small">Pendiente</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="pe-4 text-end">
                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('completar.picking')): ?>
                                            <?php if($item->completado): ?>
                                                <form action="<?php echo e(route('picking.deshacer', $item)); ?>" method="POST" class="d-inline" onsubmit="event.preventDefault(); confirmAction(this.querySelector('button'), '¿Está seguro de deshacer y devolver este ítem al almacén Kardex?');">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('PATCH'); ?>
                                                    <button type="submit" class="btn btn-sm btn-light text-danger border rounded-pill">
                                                        <i class="bi bi-arrow-counterclockwise me-1"></i> Deshacer
                                                    </button>
                                                </form>
                                            <?php else: ?>
                                                <button type="button" class="btn btn-sm btn-primary rounded-pill fw-bold shadow-sm" data-bs-toggle="modal" data-bs-target="#completarItemModal<?php echo e($item->id); ?>">
                                                    <i class="bi bi-box-arrow-right me-1"></i> Despachar
                                                </button>

                                                <!-- Modal para Completar Item -->
                                                <div class="modal fade text-start" id="completarItemModal<?php echo e($item->id); ?>" tabindex="-1" aria-hidden="true">
                                                    <div class="modal-dialog modal-dialog-centered modal-sm">
                                                        <div class="modal-content border-0 shadow-lg rounded-4">
                                                            <div class="modal-header bg-light border-bottom-0 pb-0 rounded-top-4 pt-4 px-4">
                                                                <h6 class="modal-title fw-bold">Despachar Insumo</h6>
                                                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                                            </div>
                                                            <div class="modal-body p-4 text-center">
                                                                <form method="POST" action="<?php echo e(route('picking.completar', $item)); ?>">
                                                                    <?php echo csrf_field(); ?>
                                                                    <?php echo method_field('PATCH'); ?>
                                                                    
                                                                    <div class="fs-5 fw-bold mb-1"><?php echo e(optional($item->insumo)->nombre); ?></div>
                                                                    <div class="text-muted small mb-4">Requerido: <?php echo e($item->cantidad_necesaria); ?> <?php echo e($item->insumo->unidad_uso); ?></div>

                                                                    <div class="mb-4 text-start">
                                                                        <label class="form-label fw-bold small text-muted">A Despachar Efectivamente (<span class="text-lowercase"><?php echo e($item->insumo->unidad_uso); ?></span>):</label>
                                                                        <input type="number" class="form-control form-control-lg text-center fw-bold" name="cantidad_despachada" required step="0.001" min="0.001" value="<?php echo e($item->cantidad_necesaria); ?>">
                                                                    </div>

                                                                    <button type="submit" class="btn btn-success w-100 rounded-pill fw-bold pb-2 pt-2">
                                                                        <i class="bi bi-check2-circle me-1"></i> Confirmar Despacho
                                                                    </button>
                                                                </form>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        <?php else: ?>
            <div class="card-body py-5 text-center text-muted">
                <div class="mb-3"><i class="bi bi-clipboard-check display-4 text-light"></i></div>
                <h5 class="fw-bold">Todo Despachado (o sin Programar)</h5>
                <p class="mb-0">No hay tareas de traslado de almacén a cocina programadas para HOY.</p>
            </div>
        <?php endif; ?>
    </div>


    <!-- Historial de Pickings -->
    <h5 class="fw-bold text-dark mb-3"><i class="bi bi-clock-history text-secondary me-2"></i> Historial Reciente (7 días)</h5>
    <div class="card border-0 shadow-sm rounded-4">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="bg-light">
                        <tr>
                            <th class="ps-4 text-muted small text-uppercase py-3">Código</th>
                            <th class="text-muted small text-uppercase py-3">Fecha Programada</th>
                            <th class="text-muted small text-uppercase py-3">Generado El</th>
                            <th class="text-muted small text-uppercase py-3" style="width: 250px;">Progreso Final</th>
                            <th class="pe-4 text-muted small text-uppercase py-3 text-end" style="width: 150px;">Acción</th>
                        </tr>
                    </thead>
                    <tbody class="border-top-0">
                        <?php $__empty_1 = true; $__currentLoopData = $recientes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reciente): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="ps-4 fw-bold text-secondary">#<?php echo e(str_pad($reciente->id, 5, '0', STR_PAD_LEFT)); ?></td>
                                <td>
                                    <span class="badge bg-light border text-dark px-3 py-2 rounded-pill">
                                        <i class="bi bi-calendar-event me-1 text-muted"></i> <?php echo e(optional($reciente->programacion)->fecha ?? 'Sin Fecha'); ?>

                                    </span>
                                </td>
                                <td class="text-muted small"><i class="bi bi-clock me-1"></i> <?php echo e($reciente->created_at->format('d/m/Y h:ia')); ?></td>
                                <td>
                                    <div class="d-flex align-items-center gap-2">
                                        <div class="progress flex-grow-1" style="height: 10px; border-radius: 5px;">
                                            <div class="progress-bar <?php echo e($reciente->porcentaje_completado == 100 ? 'bg-success' : 'bg-secondary'); ?>" 
                                                 role="progressbar" 
                                                 style="width: <?php echo e($reciente->porcentaje_completado); ?>%;"></div>
                                        </div>
                                        <span class="small fw-bold <?php echo e($reciente->porcentaje_completado == 100 ? 'text-success' : 'text-muted'); ?>"><?php echo e($reciente->porcentaje_completado); ?>%</span>
                                    </div>
                                </td>
                                <td class="pe-4 text-end">
                                    <a href="<?php echo e(route('picking.show', $reciente)); ?>" class="btn btn-sm btn-outline-primary rounded-pill fw-bold">
                                        <i class="bi bi-box-arrow-up-right me-1"></i> Abrir Detalle
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="4" class="text-center py-4 text-muted fst-italic">No hay historial reciente de Pickings.</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\laragon\www\gastrog\resources\views/picking/index.blade.php ENDPATH**/ ?>