<?php
session_start();
include "../conexion.php";
require_once('../include/sesiones.php'); 
$art_id=$_GET['id'];  
$datoos=mysqli_query($con,"SELECT * FROM articulos where art_id='$art_id' and empresa='$empresa'") ;
$da=mysqli_fetch_array($datoos);

$can=mysqli_query($con,"SELECT * FROM articulos_has_bodegas WHERE articulos_art_id='$art_id' and empresa='$empresa' and sucursal='$sucursal' and bodegas='$bod_id'") or die(mysqli_error($con));
$c=mysqli_fetch_array($can);
$inventario=$c['art_id'];

$det=mysqli_query($con,"SELECT * FROM articulos_detallado where bodegas_art_id='$inventario'") ;
$det=mysqli_fetch_array($det);
$artd_id=$det['artd_id']; 
?>
<form  id="form_detallar">      
    <div class="modal-body">
        <div class="col-md-12">
            <h4><center><strong>
                <div class="alert alert-info alert-dismissable">
                    <strong><?php echo $da['art_nombre']; ?></strong>
                </div>
                </strong></center></h4>
                <input type="hidden" class="form-control" value="<?php echo $inventario; ?>" name="inventario" id="inventario" readonly>
                <input type="hidden" class="form-control" value="<?php echo $artd_id; ?>" name="artd_id" id="artd_id" readonly>
                <label class="pull-left" >Cantidad Disponible</label>
                <input type="text" class="form-control" value="<?php echo $c['art_cantidad']; ?>" name="can_dis" readonly>
                <label class="pull-left" >Tipo de Unidad</label>
                <input type="text" class="form-control" value="<?php echo $det['artd_unidad']; ?>" name="precio" readonly>
                <label class="pull-left" >Cantidad A Detallar</label>
                <input type="number" class="form-control" value="1" name="can_det" min="1" max="<?php echo $c['art_cantidad']; ?>" required>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
            <button type="submit" id="btn_detallar" class="btn btn-success">Detallar</button>
        </div>
    </div>      
</form>
<script>
$("#form_detallar").submit(function(event){
    $('#btn_detallar').attr("disabled", true);
    var parametros=$(this).serialize();
    $.ajax({
        type: "POST",
        url: "php_articulo/detallar_articulo.php",
        data: parametros,
        beforeSend: function(objeto){
        $('#loader').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#loader").html(datos);
        $('#btn_detallar').attr("disabled", false);
        $('#detallar').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        load(1);
        }
    });
event.preventDefault();
})
</script>                 