<?php
session_start();
include("config.php");
include('funciones.php');
validacion_usuario($con);
include "include/head.php"; ?>
</head>
<body>
<?php include("include/menu.php") ?>  
<div class="container margin-top">
    <div class="panel panel-info">
        <div class="panel-heading">Administrador de Noticias</div>
        <div class="panel-body">
              <?php
                    $id =$_POST['bannerver_id'];
                    $id_v = filter_var($id, FILTER_SANITIZE_STRING);
                    if($id_v){
                    ?>
                    <form id="formulario" name="formulario" method="post" enctype="multipart/form-data" action="bannerEdiGrabar.php?id=<?php echo $id_v ?>">
                        <?php
                        $id_real = mysqli_real_escape_string($con,$id_v);
                        $sql_edi = "select * from banner where id=".$id_real;                       
                        $result_edi=mysqli_query($con,$sql_edi);
                        if($result_edi){
                            $filas=mysqli_num_rows($result_edi);  
                            if($filas >0){ 
                                while ($fila_edi =mysqli_fetch_assoc($result_edi)) {
                                ?>
                                    <div class="row">
                                        <div class="col-sm-2">
                                            <a type="button" href="banner.php" class="btn btn-primary">Ver lista de Banner</a>
                                            <br><br>
                                        </div>
                                    </div>      
                                    <br>
                                    <div class="row">
                                        <div class="col-sm-2"><label>Publicado</label></div>
                                        <div class="col-sm-2">
                                            <select class="form-control" name="estado" disabled>
                                               <option value="1" <?php if (!(strcmp("1", $fila_edi['estado']))) {echo "selected=\"selected\"";} ?>>Publicada</option>
                                               <option value="2" <?php if (!(strcmp("2", $fila_edi['estado']))) {echo "selected=\"selected\"";} ?>>No Publicada</option>
                                            <select>
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">    
                                        <div class="col-sm-12"><label>Imágen Cabecera</label></div>
                                        <div class="col-sm-12"><input name="imagen_escritorio" type="file" id="imagen_escritorio" disabled  size="88" maxlength="170" disabled ><br></div>
                                    </div>  
                                    <div class="row">        
                                        <div class="col-sm-12"><img src="img/banner/<?php echo $fila_edi['imagen_escritorio']; ?>" width="150" class="img-rounded" alt=""/></div>
                                    </div>    
                                    <br>  
                                    <div class="row">  
                                        <div class="col-sm-12">  
                                            <label for="imagen"><label>Imágen Interna</label></label>
                                            <input name="imagen_mobile" type="file" id="imagen_mobile" disabled  size="88" maxlength="170" disabled><br>
                                            <img src="img/banner/<?php echo $fila_edi['imagen_mobile']; ?>" width="150" class="img-rounded" alt=""/>
                                        </div>
                                     </div>   
                                    <br>  
                                    <div class="row"> 
                                        <div class="col-sm-12"><label>Link</label></div>
                                        <div class="col-sm-12">
                                            <input name="link" class="form-control" type="text" id="link" size="88" disabled maxlength="170" value="<?php echo $fila_edi['link']; ?>">
                                        </div>
                                    </div>          
                                    <br>                     
                                    <div class="row"> 
                                        <div class="col-sm-12">
                                            <textarea name="cuerpo_interno" id="cuerpo_interno" rows="10" cols="80" disabled>
                                                 <?php echo $fila_edi['descripcion']; ?>
                                            </textarea>
                                        </div>
                                    </div>  
                                    <br>
                                    <br>   
                                    <?php } ?>    
                                        <div style="margin-top:10px">
                                            <a class="btn btn-default" href="banner.php" role="button">Regresar</a>                               
                                        </div>                             
                                    </div>                              
                                </form>
                                <?php
                                         }else{
                                        ?>
                                        <script>
                                        alert("No hay banner recientes, por favor agregue nuevos banner");
                                        window.location.href = "banner.php";
                                        </script>
                                        <?php
                                        }
                                    }else{
                                    ?>
                                    <script>
                                    alert("Error al ejecutar la consulta");
                                    window.location.href = "banner.php";
                                    </script>
                                    <?php
                                    }
                                }else{
                                ?>
                                    <script>
                                    alert("Lo sentimos, los datos son íncompletos o son incorrectos");
                                    window.location.href='banner.php';
                                    </script>
                                    <?php
                                }
                                ?>     
                      
        </div>
    </div>
</div>
                    
    <?php include("include/ckeditor.php");
          include("include/footer.php");?>    
     <script type="text/javascript" src="js/ckeditor/function_ckeditor.min.js"></script>          
</body>
</html>
