<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');
$gard_id=$_GET['id'];
$can11=mysqli_query($con,"SELECT * FROM garantia_pro_detalle where gard_id='$gard_id'") or die(mysqli_error($con));  
$dato=mysqli_fetch_array($can11);
$gard_cantidad=$dato['gard_cantidad'];
?>
<form name="form_solucion" id="form_solucion" method="post" action="">
    <label>Solucion</label>
    <input type="hidden" name="gar_id" id="gar_id"  value="<?php echo $dato['garntias_proveedor_gar_id']; ?>">
    <input type="hidden" name="gard_id" id="gard_id"  value="<?php echo $dato['gard_id']; ?>">
    <input type="hidden" name="gar_art_id" id="gar_art_id" value="<?php echo $dato['gar_art_id']; ?>">
    <SELECT NAME="solucion" id="solucion" onChange="pagoOnChange(this)" class="form-control name_list input-sm"  >
        <OPTION VALUE="Reparado">Reparado</OPTION>
        <OPTION VALUE="Cambio">Cambiado Por Otro</OPTION>
        <OPTION VALUE="Nota Credito">Nota Credito</OPTION>
        <OPTION VALUE="No Reparado">No Reparado</OPTION>
    </SELECT>
    <div id="Cambio" style="display:none;">
        <?php $i = 1; while ($i <= $gard_cantidad) { ?>
            <label class="control-label">Serial <?php echo $i++; ?> </label>
            <input type="text" class="form-control" name="serial[]" value="" autocomplete="off">
        <?php } ?>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        <button name="btn_solucion" id="btn_solucion" type="submit" class="btn btn-success"><i class="icon-ok"></i> <strong>Aceptar</strong></button>
    </div>
</form>
<script type="text/javascript">
function pagoOnChange(sel) 
{
    if (sel.value=="Cambio"){
       divC = document.getElementById("Cambio");
       divC.style.display = "";
    }else{
       divC = document.getElementById("Cambio");
       divC.style.display="none";
    }
}

$("#form_solucion" ).submit(function( event ) {
$('#btn_solucion').attr("disabled", true);
var parametros = $(this).serialize();
$.ajax({
    type: "POST",
    url: "php_garantias_proveedor/registrar_solucion.php",
    data: parametros,
    beforeSend: function(objeto){
         $('#resul').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
    success: function(datos){
    $("#resul").html(datos);
    $('#btn_solucion').attr("disabled", false);
    $('#pdf').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();
    loadTabla();
    }
});
event.preventDefault();
})
</script>