<?php $__env->startSection('content'); ?>


<div id="contenedor_interno" class="container-fluid">
    <div class="row ">
      <div class="col-md-12">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="<?php echo e(route('fabricacion.dashboard')); ?>">Ajuste de inventario Materia Prima</a></li>
            <li class="breadcrumb-item active" aria-current="page">Nueva</li>
          </ol>
        </nav>
        <form action="<?php echo e(route('inventario.ajuste_inventario_prima_guardar')); ?>" method="POST" id="formEnviar">
          <?php echo csrf_field(); ?>
          <input type="submit" id="botonEnviar" href="<?php echo e(route('ventas.cliente')); ?>" class="botonColor" value="Ingresar Ajuste" />
      </div>
      <hr>
    </div>
</div>

<div id="contenedor_contenido" class="container-fluid px-lg-5">
  <div class="row">
    <div class="col-md-12">
      <h2>Ajuste de inventario</h2>
    </div>
    <div class="col-md-12">
     
        <div class="row">
          <div class="col-md-6">
            <input type="hidden" name="id_cliente" value="999999">
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Tipo de solicitud</label>
              <div class="col-sm-8">
                <select class="form-control" name="tipo_solicitud" id="exampleFormControlSelect1" required>
                  <option value="1">Entrada por ajuste</option>
                  <option value="2">Salida por ajuste</option>
                </select>
              </div>
            </div>
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Producto</label>
              <div class="col-sm-8">                
                <input type="text" id="nombre_productos" class="form-control-plaintext" value="" placeholder="">
                <input type="hidden" id='id_producto' class="id_producto" name="id_producto">
              </div>
            </div>
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Cantidades</label>
              <div class="col-sm-8">
                <input type="text" id="cantidad" onchange="materialProcesar(this)" class="form-control-plaintext" name="cantidad" value="0" placeholder="">
              </div>
            </div>
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Unidad de medida</label>
              <div class="col-sm-8">
                <input type="text" id="unidad_medida" readonly class="form-control-plaintext" name="id_medida" value="" placeholder="">
              </div>
            </div>   
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Kilogramos</label>
              <div class="col-sm-8">
                <input type="text" id="kilogramos" readonly class="form-control-plaintext" name="kilogramos" value="0" placeholder="">
              </div>
            </div> 
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">TOTAL</label>
              <div class="col-sm-8">
                <input type="text" id="total" readonly class="form-control-plaintext" name="total" value="" placeholder="">
              </div>
            </div> 
            <div class="form-group row">
              <label for="" class="col-sm-4 col-form-label">Observaciones</label>
              <div class="col-sm-8">
                <input type="text"  class="form-control-plaintext" name="observaciones" value="" placeholder="">
              </div>
            </div>         
          </div>

        </div>
        
      </form>

    </div>
  </div>
</div>
<link href="<?php echo e(asset('js/jquery_ui/jquery-ui.css')); ?>" rel="stylesheet">
<script src="<?php echo e(asset('js/jquery_ui/jquery-ui.js')); ?>"></script>
<script>
  function materialProcesar(element){
    
    var cantidad=document.getElementById('cantidad').value;
    var kgMillar=document.getElementById('kilogramos').value;
    var total=parseFloat(kgMillar)*parseFloat(cantidad);
    document.getElementById('total').value=total.toFixed( 2 );
    console.log(total);
    
  }
  $( function() {
    
    $("#nombre_productos").autocomplete({
        source: function(request, response) {
          $.ajax({
            url: "<?php echo e(route('ventas.buscar_producto_prima')); ?>",
            dataType: 'json',
            data: {
              term: request.term
            },
            success: function(data) {
              response(data)
            }
           })
        },
        minLength: 2,
        select: function(event, ui) {
            document.getElementById('id_producto').value=ui.item.id;
            document.getElementById('unidad_medida').value=ui.item.unidad;
            document.getElementById('kilogramos').value=ui.item.factor_conversion_kilos;
            console.log('precioSinIva',ui);
        }
    })
  } );

  document.getElementById('botonEnviar').addEventListener('click',(btn)=>{
      btn.preventDefault();
      console.log(btn);
      document.getElementById('botonEnviar').disabled = true;
      let formEnviar = document.getElementById('formEnviar');
      formEnviar.submit();
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('inventario.menu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/devpwg5/laravelrp.com/resources/views/inventario/ajuste_inventario_prima.blade.php ENDPATH**/ ?>