<?php
include "../conexion.php";
$vdc_id=$_GET['id']; 
$can1=mysqli_query($con,"SELECT * from venta_detalle_combo_temp where vdc_id='$vdc_id'") or die(mysqli_error($con)); 
$row1=mysqli_fetch_array($can1);
$combo_id=$row1['combo_id'];  
?>
<div id="resultados_sab"></div> 
<form role="form" id="sabores" >      
    <?php
        $can2=mysqli_query($con,"SELECT * from sabores_combos where combo_id='$combo_id'") or die(mysqli_error($con)); 
        while ($row=mysqli_fetch_array($can2))
        {
            $sab_id=$row['sab_id'];
            $can3=mysqli_query($con,"SELECT * from venta_detalle_combo_sabores_temp where sab_id='$sab_id' and vdc_id='$vdc_id'") or die(mysqli_error($con)); 
            $num=mysqli_num_rows($can3);
            if($num>0)
            {
                $checked='checked';
            }
            else
            {
                $checked='';
            }
    ?>
        <input type="checkbox" id="<?php echo $row['sab_id']; ?>" name="sabor[]" value="<?php echo $row['sab_id']; ?>" <?php echo $checked; ?>>
        <label class="lab" for="<?php echo $row['sab_id']; ?>"><?php echo $row['sab_nombre']; ?></label>
    <?php } ?>
        <input type="hidden" name="combo_id" value="<?php echo $combo_id; ?>">
        <input type="hidden" name="vdc_id" value="<?php echo $vdc_id; ?>">
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        <button type="submit" id="sab" class="btn btn-primary">Registrar</button>
    </div>
</form>
<script>
$("#sabores").submit(function(event) {
$('#sab').attr("disabled", true);
var parametros=$(this).serialize();
    $.ajax({
        type: "POST",
        url: "php_facturar/registrar_sabor_temp.php",
        data: parametros,
        beforeSend: function(objeto){
            $('#resultados_sab').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados_sab").html(datos);
        $('#sab').attr("disabled", false);
        $('#sabores_Modal').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        }
    });
    event.preventDefault();
    loadTabla();
})
</script>