<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');
include ('../php_caja/totales_caja.php');
?>
<form method="post" action="" id="form_traspaso" name="form_traspaso">
    <div class="form-group">
        <label class="pull-left">Caja destino</label>
        <section id="intro" >
            <select name="caja" id="caja" class="form-control name_list" required>
                <?php
                    $datos=mysqli_query($con,"SELECT * FROM cajas WHERE caja_estado='1' and empresa='$empresa' and caja_id<>'$cajas_caja_id'");
                    while( $fila=mysqli_fetch_array($datos))
                    {
                    echo' <option value="'.$fila['caja_id'].'">'.$fila['caja_nombre'].'</option>';
                    }
                ?>
              </select>
        </section>
    </div>
     <div class="form-group">
        <label>Efectivo en Caja</label>
        <input type="text" name="efectivo" value="<?php echo number_format($saldoencaja,0); ?>" class="form-control name_list" autocomplete="off" readonly >
    </div>
    <div class="form-group">
        <label>Valor de traspaso</label>
        <input type="number" name="valor_traspaso" value="" class="form-control name_list" autocomplete="off"  >
        </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        <button type="submit" class="btn btn-info" name="btn_traspaso" value="btn_traspaso" id="btn_traspaso">Aceptar</button>
    </div>
</form>
           
<script>
$("#form_traspaso").submit(function( event ) {
$('#btn_traspaso').attr("disabled", true);
var parametros=$(this).serialize();
    $.ajax({
    type: "POST",
    url: "php_movimientos/registrar_traspaso.php",
    data: parametros,
    beforeSend: function(objeto){
     $('#resultados').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
    },
    success: function(datos){
    $("#resultados").html(datos);
    $('#btn_traspaso').attr("disabled", false);
    $('#traspaso').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();
    load(1);
    }
    });
    event.preventDefault();
})
</script>