<?php
include ("header.php");
if (!empty($_GET))
 {
  $fi = $_GET['fi'];
  $ff = $_GET['ff'];
$sql="SELECT * FROM `agenda`,pacientes WHERE `age_pac_id` = pacientes.pac_id and TIMESTAMPDIFF(YEAR, agenda.age_fecha, now()) >= 1 and pac_activo = 1 GROUP BY pacientes.pac_id";
$resultado = mysqli_query($mysqli, $sql);
}
?>

        <div class="content-wrapper">
            <!-- START PAGE CONTENT-->
            <div class="page-heading">
                <h1 class="page-title">Pacientes</h1>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                    <button onclick="location.href='iinformes.php'" type="button" class="btn btn-primary">Regresar</button>
                    </li>
                    
                </ol>
            </div>
            <div class="page-content fade-in-up">
                <div class="ibox">
                    <div class="ibox-head">
                        <div class="ibox-title">Listado</div>
                    </div>
                    <div class="ibox-body">
                        <table class="table table-striped table-bordered table-hover display dataTable_width_auto" id="dataTablePacientes" cellspacing="0" width="100%">
                            <thead>
                                <tr>
                                        <th> NOMBRE </th>
                                        <th> FECHA ULTIMA ATENCION </th>
                                        <th> TELEFONO </th>
                                        <th> CELULAR </th>
                                        <th> EMAIL</th>
                                        <th> DOMICILIO</th>
                                        <th></th>

                                    </tr>
                            </thead>
                                <tbody>          
                                    <?php $NUM=0;while($row = mysqli_fetch_array($resultado)) { $NUM=$NUM+1?>
                                    <tr>
                                       
                                        <td><?php echo $row['pac_nombre']; ?></td>
                                        <td><?php echo $row['age_fecha']; ?></td>
                                        <td><?php echo $row['pac_telefono']; ?></td>
                                        <td><?php echo $row['pac_celular']; ?></td>
                                        <td> <?php echo $row['pac_email']; ?></td>									
                                        <td> <?php echo $row['pac_domicilio']; ?></td>
                                        <td>
                                            <div class=" col-12 ">
                                                <CENTER>
                                                <a href="npacientes.php?id=<?php echo $row['pac_id']; ?>&edt=1" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">MODIFICAR&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                                <a href="tiponota.php?id=<?php echo $row['pac_id']; ?>" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">NUEVA NOTA</a>
                                                <a href="rexpediente.php?id=<?php echo $row['pac_id']; ?>" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">EXPEDIENTE&nbsp;&nbsp;</a>
                                                <a href="estudios.php?id=<?php echo $row['pac_id']; ?>" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">ESTUDIOS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                                <a href="nagenda.php?id=<?php echo $row['pac_id']; ?>" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">AGENDAR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                                <a href="nventa.php?id=<?php echo $row['pac_id']; ?>" class="btn btn-success" tabindex="-1" role="button" aria-disabled="true">VENTAS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                                <a href="#" data-href="npacientes.php?id=<?php echo $row['pac_id'] . '&borrar=1'; ?>" data-toggle="modal" data-target="#confirm-delete" class="btn btn-danger" tabindex="-1" role="button" aria-disabled="true">ELIMINAR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                                </CENTER>
                                            </div>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                        </table>
                </div>
            </div>                
<?php 
    include ('footer.php');
?>