<?php
session_start();
include("config.php");
include('funciones.php');
validacion_usuario($con);
include('include/head.php');
?>
<link type="text/css" rel="stylesheet" href="css/jpagination/PaginateMyTable.min.css" />
<body>
<?php include("include/menu.php") ?>  
 <div class="container margin-top">
    <div class="panel panel-info">
          <div class="panel-heading">
             <h3 class="panel-title">Lista de Caso de Éxito</h3>
          </div>
          <div class="panel-body">
            <form id="formulario" name="formulario" method="post" action="casosexitoGrabar.php">
              <div class="row">
                  <div class="col-md-12">
                    <a class="btn btn-default" href="casosexitoNue.php" role="button">Nuevo Registro</a>
                    <button class="btn btn-default" type="submit">Grabar</button>    
                  </div>
                  <br><br>
                  <br><br>
                </div>
                <div id="div_tablacasoexito">
                  <div class="row">
                    <div class="col-md-12">
                        <?php
                          $sql =  "SELECT * FROM exito WHERE id ORDER BY id DESC LIMIT 0,100";
                          $result=mysqli_query($con,$sql);
                          $filas=mysqli_num_rows($result);                  
                        ?>
                        <div class="table-responsive">
                          <table class="paginacion table table-hover">
                              <thead>
                                  <tr>
                                    <th>N°</th>
                                    <th>Tipo</th>
                                    <th>Empresa</th>
                                    <th>Título</th>
                                    <th width="110px">Orden</th>
                                    <th>Publicación</th>
                                     <th width="110px">Fecha</th>
                                    <th>Ver</th>
                                    <th>Editar</th>
                                    <th>Eliminar</th>
                                  </tr>
                              </thead>                                
                              <tbody>
                                <?php if($filas >0){ 
                                  while ($fila =mysqli_fetch_assoc($result)) { ?>
                                    <tr>
                                      <td scope="row">
                                        <input name="id[]" type="hidden"  id="id[]" value="<?php echo $fila['id']; ?>" />
                                        <input name="imagen<?php echo $fila['id']; ?>" type="hidden"  id="imagen<?php echo $fila['id']; ?>" value="<?php echo $fila['imagen_cabecera']; ?>" />                               
                                        <?php echo $fila['id']; ?>
                                      </td>
                                      <td><?php $tipo= $fila['tipo']; 
                                          if($tipo == 1){
                                            echo "Imágen";
                                          }else{
                                             echo "Video";
                                          }
                                      ?></td>
                                      <td><?php $tipo= $fila['sector']; 
                                          if($tipo == 1){
                                            echo "Privado";
                                          }elseif($tipo == 2){
                                             echo "Público";
                                          }else{
                                             echo "Civil";

                                          }
                                      ?></td>
                                      <td><?php echo $fila['titulo']; ?></td>
                                      <td>
                                        <select name="orden[]" id="orden[]" title="<?= $fila['id']; ?>" class="form-control" style="width:110px">
                                          <option value="0" <?php if (!(strcmp(0, $fila['orden']))) {echo "selected=\"selected\"";} ?>>Ninguno</option>
                                          <option value="1" <?php if (!(strcmp(1, $fila['orden']))) {echo "selected=\"selected\"";} ?>>1</option>
                                          <option value="2" <?php if (!(strcmp(2, $fila['orden']))) {echo "selected=\"selected\"";} ?>>2</option>
                                          <option value="3" <?php if (!(strcmp(3, $fila['orden']))) {echo "selected=\"selected\"";} ?>>3</option>
                                          <option value="4" <?php if (!(strcmp(4, $fila['orden']))) {echo "selected=\"selected\"";} ?>>4</option>
                                          <option value="5" <?php if (!(strcmp(5, $fila['orden']))) {echo "selected=\"selected\"";} ?>>5</option>
                                        </select>                                                
                                      </td>
                                      <td style="width:100px">
                                        <select name="estado[]" id="estado[]" title="<?= $fila['id']; ?>" class="form-control">
                                              <option value="1" <?php if (!(strcmp("1", $fila['estado']))) {echo "selected=\"selected\"";} ?>>Si</option>
                                              <option value="0" <?php if (!(strcmp("0", $fila['estado']))) {echo "selected=\"selected\"";} ?>>No</option>
                                        </select>
                                      </td> 
                                      <td><?php echo $fila['fecha_creacion']; ?></td>                                         
                                       <td width="82">                                    
                                        <a class="btn btn-default btn-sm" onClick="ver_casoexito(<?php echo $fila['id'];?>,<?php echo $fila['tipo'];?>);">
                                          <span class="glyphicon glyphicon-search"></span>Ver
                                        </a>
                                      </td>
                                       <td width="82">
                                        <a class="btn btn-default btn-sm" onClick="edi_casoexito(<?php echo $fila['id'];?>,<?php echo $fila['tipo'];?>);">
                                          <span class="glyphicon glyphicon-edit"></span> Editar
                                        </a> 
                                      </td>
                                      <td width="82">
                                        <a class="deletecasoexito btn btn-default btn-sm"><span class="glyphicon glyphicon-remove"></span>Eliminar</a>
                                      </td>
                                    </tr>
                            <?php }
                          }else{ ?><tr><td colspan="10" align="center"><b><?php echo "No hay registros";?></b></td> </tr><?php }// fin del bucle de ordenes  ?>
                          </tbody>
                          </table>                                  
                        </div>
                    </div>
                 </div>
                </div> 
          </form>

          <form id="casosexitoEdi" action="casosexitoEdi.php"  method="post"> 
            <input type="hidden" id="casosexitoeditar_id" name="casosexitoeditar_id" value=""/>
            <input type="hidden" id="casosexitoeditar_tipo" name="casosexitoeditar_tipo" value=""/>
          </form>

           <form id="casosexitoVer" action="casosexitoVer.php"  method="post"> 
            <input type="hidden" id="casosexitover_id" name="casosexitover_id" value=""/>
            <input type="hidden" id="casosexitoever_tipo" name="casosexitoever_tipo" value=""/>
          </form>
        </div>
    </div>
  </div>         
<?php include "include/footer.php"; ?>
<script src="<?php echo $host; ?>admin/js/jpagination/PaginateMyTable.min.js"></script>
  <script>
  $(document).ready(function() {
    $(".paginacion").paginate();
  });
  </script>
</body>
</html>
