<?php
include "../conexion.php";
$cdc_id=$_GET['id']; 
$can1=mysqli_query($con,"SELECT * from cotizacion_detalle_combo_temp where cdc_id='$cdc_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 cotizacion_sabores_combo_temp where sab_id='$sab_id' and cdc_id='$cdc_id'") or die(mysqli_error($con)); 
            $num=mysqli_num_rows($can3);
            if($num>0)
            {
                $checked='checked';
            }
            else
            {
                $checked='';
            }
    ?>
    <input type="checkbox" id="sabor<?php echo $sab_id; ?>" name="sabor[]" value="<?php  echo $sab_id; ?>" <?php echo $checked; ?>>
    <label class="lab" for="sabor<?php echo $sab_id; ?>"><?php echo mb_strtoupper($row['sab_nombre']); ?></label>
    <?php } ?>
    <input type="hidden" name="combo_id" value="<?php echo $combo_id; ?>">
    <input type="hidden" name="cdc_id" value="<?php echo $cdc_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_reservas/registrar_sabor_combo_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();
      loadTabla();
      }
  });
  event.preventDefault();
})
</script>
<link href="css/checkbox.css" rel="stylesheet" media="all"> 