<?php include('../fncr-geral/configuracao_geral.php');
@header("Content-Type: text/html; charset=ISO-8859-1",true);

$id_registro = $_GET['r'];
$tipo = $_GET['tipo'];

$sql = $bd->getConexao()->prepare('
SELECT
  *,
  DATE_FORMAT(data_hora,"%d/%m/%Y %H:%i") AS data_hora
FROM emails_envios
WHERE registro_id = :registro_id AND tipo LIKE CONCAT(:tipo, "%")
ORDER BY data_hora ASC');
$sql->bindValue(':registro_id', $id_registro, PDO::PARAM_STR);
$sql->bindValue(':tipo', $tipo, PDO::PARAM_STR);
if($sql->execute() ) { $emails = $sql->fetchall(PDO::FETCH_ASSOC);}

?>
<div class="row">
  <div class="col-lg-12">
    <section class="panel">
      <table class="table table-striped m-b-none text-small">
        <thead>
        <tr>
          <th width="140">Data</th>
          <th width="170">Tipo</th>
          <th>E-mail</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($emails as $l){?>
          <tr>
            <td><?php echo $l['data_hora']?></td>
            <td><?php echo $l['tipo']?></td>
            <td><?php echo $l['email']?></td>
          </tr>
        <?php } ?>
        </tbody>
      </table>
    </section>

  </div>
</div>
<?php $bd = null; $bd_fn = null;?>