Ejemplo n.º 1
0
 public function buscarGenericoID($id)
 {
     try {
         $generico = new BDGenerico();
         $busca = $generico->buscarGenericoID($id);
         return $busca;
     } catch (Exception $ex) {
         echo "Erro: {$ex}";
     }
 }
 public function pdfListarGenericoCidadao($id)
 {
     try {
         $obj = new BDGenerico();
         $busca = $obj->buscarGenericoID($id)->fetch(PDO::FETCH_OBJ);
         $mpdf = new mPDF();
         $mpdf->allow_charset_conversion = true;
         // Gerando conteúdo do PDF
         ob_start();
         $html = ob_get_clean();
         $html = utf8_encode($html);
         $html .= "<table class='table'>";
         $html .= "<thead>";
         $html .= "<tr>";
         $html .= "<th> ID </th>";
         $html .= "<td> CPF </th>";
         $html .= "<td> RG </th>";
         $html .= "<td> CNH </td>";
         $html .= "<th> Nome </th>";
         $html .= "<th> Endereço </th>";
         $html .= "<th> Bairro </th>";
         $html .= "<th> E-Mail </th>";
         $html .= "<th> Telefone </th>";
         $html .= "<th> Observações </th>";
         $html .= "</tr>";
         $html .= "</thead>";
         $html .= "<tbody>";
         $lista = $this->listarGenericoCidadaoID($id)->fetchAll(PDO::FETCH_OBJ);
         foreach ($lista as $linha) {
             $html .= "<tr>";
             $html .= "<td> {$linha->id_cidadao} </td>";
             $html .= "<td> {$linha->nome_cidadao} </td>";
             $html .= "<td> {$linha->cpf_cidadao} </td>";
             $html .= "<td> {$linha->rg_cidadao} </td>";
             $html .= "<td> {$linha->cnh_cidadao} </td>";
             $html .= "<td> {$linha->rua_cidada} </td>";
             $html .= "<td> {$linha->bairro_cidadao} </td>";
             $html .= "<td> {$linha->telefone1_cidadao} </td>";
             $html .= "<td> {$linha->email_cidadao}</td>";
             $html .= "<td> {$linha->info_cidadao} </td>";
             $html .= "</tr>";
         }
         $html .= "</tbody>";
         $html .= "</table>";
         $mpdf->WriteHTML($html);
         $mpdf->Output('lista de dados Genérica : ' . $busca->nome_generico_moradores . '-' . date("d-m-y") . '.pdf', 'D');
         header("Location : listaGenerico.php");
         exit;
     } catch (Exception $ex) {
         echo "Erro: {$ex}";
     }
 }