<?php
include "../conexion.php";
$cott_id=$_GET['id']; 
$can1=mysqli_query($con,"SELECT * from cotizacion_detalle_temp where cott_id='$cott_id'") or die(mysqli_error($con)); 
$row1=mysqli_fetch_array($can1);
$cott_art_id=$row1['cott_art_id'];  
?>
<div id="resultados_sab"></div> 
<form role="form" id="sabores">      
    <?php
        $can2=mysqli_query($con,"SELECT * from sabores_productos where articulo_art_id='$cott_art_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_producto_temp where sab_id='$sab_id' and cott_id='$cott_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="cott_art_id" value="<?php echo $cott_art_id; ?>">
    <input type="hidden" name="cott_id" value="<?php echo $cott_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_articulo_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"> 