<?php
session_start();
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"]==null):
   print "<script>alert(\"Acceso Invalido!\");
   window.location='login.php';</script>";
endif;
if ($_SESSION["user_at"] < 2):
   print "<script>alert(\"Sin Acceso a Transaccion!\");
   window.location='vt000.php';</script>";
endif;
include_once ("lib/fpdf/funci.php");
date_default_timezone_set('America/La_Paz');
$conex = conectar();
$bucli = trim($_POST["buscli"]);
?>
<body bgcolor="#E0FFFF">
<div class="main-wrapper">
<link href="css/tabla.css" rel="stylesheet" type="text/css" />
<link href="bootstrap/css/bootstrap.css" rel="stylesheet" />
<center><h1>Consulta de Agenda</h1></center>
<center><a class="btn btn-success" href="vt235.php">Nuevo</a>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;&nbsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;&nbsp;
<a class="btn btn-danger" href="vt000.php">Salir</a></center>
<center><table border="0" cellpadding="0" cellspacing="0" class="tabla">
   <thead>
	<th><center>Codigo</center></th>
	<th>Nombre</th>
	<th>Tipo</th>
	<th>Direccion</th>
	<th><center>Telefono</center></th>
	<th><center>Seleccion</center></th>
	<th><center>Seleccion</center></th>
   </thead>
<?php
if (strlen($bucli) > 0):
   $mysql = "select adagendoc,adagenomb,adtipdesc,adagedire,adagetelf from adage
             inner join adtip on adagetipo = adtiptipo
             where adagenomb like '%$bucli%'
             and   adagestat = 0
             order by 2";
else:
   $mysql = "select adagendoc,adagenomb,adtipdesc,adagedire,adagetelf from adage
             inner join adtip on adagetipo = adtiptipo
             where adagestat = 0
             order by 2";
endif;
$result = mysql_query($mysql);
while ($row = mysql_fetch_array($result)): ?>
   <tr class="modo1">
   <td><center><?php echo $row[0];?></center></td>
   <td><?php echo $row[1];?></td>
   <td><?php echo $row[2];?></td>
   <td><?php echo $row[3];?></td>
   <td><center><?php echo $row[4];?></center></td>
   <?php
   if ($row[adagestat] == 0): ?>
      <td><center><a class="btn btn-primary btn-xs" href="vt232.php?id=<?php echo $row[0];?>">Modificar</a></center></td>
      <td><center><a class="btn btn-danger btn-xs" href="vt233.php?id=<?php echo $row[0];?>">Dar de Baja</a>
      </center></td><?php
   else: ?>
      <td><center><a href="?id=<?php echo $row[adageccli];?>"></a></center></td>
      <td><center><a class="btn btn-success btn-xs" href="vt234.php?id=<?php echo $row[0];?>">Dar de Alta</a>
      </center></font></td><?php
   endif; ?>
   </tr>
   <?php
endwhile; ?>
</table></center>
</div>
</body>
