<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');

$sli_id=$_GET['id'];

 $sql=mysqli_query($con, "SELECT * from slider where sli_id='$sli_id' and empresa='$empresa'");
    while ($rew=mysqli_fetch_array($sql))
    {
        $sli_nombre=$rew['sli_nombre'];
        $sli_url=$rew['sli_url'];
        $sli_ubicacion=$rew['sli_ubicacion'];
       
    }
 ?>
<form method="post" name="modif_image" id="modif_image" action="" enctype="multipart/form-data">

    <div id="resultados_mar"></div> 
    <div class="form-group  ">
        <label for="nombres" class="col-sm-4 control-label">Nombre</label>
        <input type="text" class="form-control" id="nombre" name="nombre" value="<?php echo $sli_nombre ?>" required>
    </div>
    <div class="form-group  ">
        <label for="nombres" class="col-sm-4 control-label">URL</label>
        <input type="text" class="form-control" id="url" name="url" value="<?php echo $sli_url ?>" required>
    </div>
    <input type="hidden" class="form-control" id="sli_id" name="sli_id" value="<?php echo $sli_id ?>" required>

    <label>&nbsp</label>
    <label for="edit_imagen" style="width: 100%;">Cambiar Imagen </label>
    <input type="file" name="edit_imagen" id="edit_imagen" >

    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        <button type="submit" id="submit"  class="btn btn-success">Modificar</button>
    </div>



</form>
<script >

$( "#modif_image" ).submit(function( event ) 
{ 
    $('#submit').attr("disabled", true);
    var formData = new FormData($("#modif_image")[0]);
    var ruta = "php_pagina_online/editar_imagen.php";
    $.ajax({
        type: "POST",
        url: ruta,
        data: formData,
        contentType: false,
        processData: false, 
        beforeSend: function(objeto){
            $('#resultados').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados").html(datos);
        $('#submit').attr("disabled", false);
        $('#Modaldetalle').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        loadTablaslider();
    }
});
event.preventDefault();
}); 


</script>


<style type="text/css">
input[type="file"]#edit_imagen {
 width: 0.1px;
 height: 0.1px;
 opacity: 0;
 overflow: hidden;
 position: absolute;
 z-index: -1;
 }

label[for="edit_imagen"] {
 font-size: 14px;
 font-weight: 600;
 color: #fff;
 background-color: #106BA0;
 display: inline-block;
 cursor: pointer;
 padding: 5px 40px ;
 width: fit-content;
 text-align: center;
 }
</style>