<?php $__env->startSection('headers'); ?>
<style>
    td
    {
        text-align:center;
        font-size:0.9em;
    }
    .oversized-col
    {
        min-width:150px;
        overflow:hidden;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<!-- Page Heading -->
<header class="bg-white shadow">
    <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            Inventario.
        </h2>
    </div>
</header>

<!-- Page Content -->

<div class="py-12">
<div class="max-w-full mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">

        <h5 class="separtor">Filtros:</h5>

        <form action="/int/inventory" method="get">
        <div class="row">
            <div class="col-lg-2 controlDiv" >
                <label class="form-label">Cliente:</label>
                <select class="form-select" id = "txtCliente" name = "txtCliente">
                <option value=0 selected></option>
                <?php $__currentLoopData = $clientes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $clienteOp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($clienteOp->id); ?>" <?php if( $cliente == $clienteOp->id): ?> selected <?php endif; ?> ><?php echo e($clienteOp->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-lg-2 controlDiv" >
                <label class="form-label">Rango:</label>
                <select class="form-select" id = "txtRango" name = "txtRango">
                    <option value="30" selected>30 días</option>
                    <option value="5" <?php if( $rango == 5): ?> selected <?php endif; ?> >5 días</option>
                    <option value="15" <?php if( $rango == 15): ?> selected <?php endif; ?> >15 días</option>
                    <option value="90" <?php if( $rango == 90): ?> selected <?php endif; ?> >90 días</option>
                    <option value="190" <?php if( $rango == 190): ?> selected <?php endif; ?> >6 meses</option>
                    <option value="365" <?php if( $rango == 365): ?> selected <?php endif; ?> >1 año</option>
                    <option value="1095" <?php if( $rango == 1095): ?> selected <?php endif; ?> >3 años</option>
                </select>
            </div>
            <!--
            <div class="col-lg-2 controlDiv" style="">
                <label class="form-label">Tracking:</label>
                <input type="text" class="form-control" id="txtOtros" name="txtOtros" value="<?php echo e($otros); ?>" placeholder="Tracking">       
            </div>
            -->

            <div class="col-lg-2 controlDiv" style="position:relative;top:30px;">
                <button type="submit" class="btn btn-primary">Buscar</button>     
            </div>
            <div class="col-lg-2 controlDiv" style="position:relative;top:30px;">
                <button type="button" class="btn btn-success" onclick="descargar()"><i class="far fa-file-excel"></i></button>     
            </div>
        </div>
            
        </form>

        <h5 class="separtor"></h5>

        <table class="table table-sm table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th scope="col">Entrada #</th>
                    <th scope="col">Fecha</th>
                    <th scope="col">Cliente</th>
                    <th scope="col">Materia/Equipo</th>
                    <th scope="col">Numero_de_parte</th>
                    <th scope="col">Piezas</th>
                    <th scope="col">Bultos</th>
                    <th scope="col">PesoNeto</th>
                    <th scope="col">Locación</th>
                    <th scope="col">Descripcion Ing</th>
                    <th scope="col">PO</th>
                    <th scope="col">Pais</th>
                    <th scope="col">Fraccion</th>
                    <th scope="col">Marca</th>
                    <th scope="col">Modelo</th>
                    <th scope="col">Serie</th>
                    <th scope="col">SKID</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $partidas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $partida): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr id="inv_row_<?php echo e($partida->id); ?>">
                    <td><?php echo e($partida->income->getIncomeNumber()); ?></td>
                    <td><?php echo e(explode(" ", $partida->income->cdate)[0]); ?></td>
                    <td><?php echo e($partida->income->customer->name); ?></td>
                    <td><?php echo e($partida->income->type); ?></td>
                    <td><?php echo e($partida->part_number()->part_number); ?></td>
                    <td><?php echo e($partida->units); ?></td>
                    <td class="oversized-col"><input style="text-align:center; border: 1px solid #ccd; border-radius:4px; height: 30px; width:60px;" type="number" id="txtBultosInv_<?php echo e($partida->id); ?>" min="0" value="<?php echo e($partida->getBultos()); ?>" onfocusout="editarBultos(<?php echo e($partida->id); ?>,<?php echo e($partida->getBultos()); ?>)"> <?php echo e($partida->umb); ?></td>
                    <td><?php echo e($partida->net_weight); ?></td>
                    <td><?php echo e($partida->location); ?></td>
                    <td><?php echo e($partida->desc_ing); ?></td>
                    <td><?php echo e($partida->po); ?></td>
                    <td><?php echo e($partida->origin_country); ?></td>
                    <td><?php echo e($partida->fraccion); ?>.<?php echo e($partida->nico); ?></td>
                    <td><?php echo e($partida->brand); ?></td>
                    <td><?php echo e($partida->model); ?></td>
                    <td><?php echo e($partida->serial); ?></td>
                    <td><?php echo e($partida->skids); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script>

function editarBultos(row_id,original)
{
    let cantidad = $("#txtBultosInv_"+row_id).val();
    if(isNaN(cantidad))
    {
        $("#txtBultosInv_"+row_id).val(original);
        return;
    }
    if(cantidad == '')
    {
        $("#txtBultosInv_"+row_id).val(original);
        return;
    }
    if(cantidad < 0)
    {
        $("#txtBultosInv_"+row_id).val(original);
        return;
    }
    $.ajax({url: "/bultos_inventario_edit/"+row_id+"/"+cantidad,context: document.body}).done(function(result) 
        {
            
        });
}
function descargar()
{
    var path = "/int/inventory_xls?txtCliente="+$("#txtCliente").val()+"&txtRango="+$("#txtRango").val();
    location.href=path;
}

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.common', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/juanjacobo/Documents/GitHub/goDaddy/ecexv2/ecex-portal/resources/views/intern/inventario/index.blade.php ENDPATH**/ ?>