blank pdf with mpdf

Asked

Viewed 499 times

1

Galera I have this code where it returns me values direct from the bank, but at the time I click pdf, it appears only the company logo.

 $conteudo_html = "";

 if (isset($_POST['pdf'])) {


 if((isset($_POST["AS_ASS_DATE_ANO1"])) || (isset($_GET["AS_ASS_DATE_ANO1"]))) {

  if(isset($_POST["AS_ASS_DATE_ANO1"])){
     $AS_ASS_DATE_DIA1 = $_POST["AS_ASS_DATE_DIA1"];
     $AS_ASS_DATE_MES1 = $_POST["AS_ASS_DATE_MES1"];
     $AS_ASS_DATE_ANO1 = $_POST["AS_ASS_DATE_ANO1"];

     $AS_ASS_DATE_DIA2 = $_POST["AS_ASS_DATE_DIA2"];
     $AS_ASS_DATE_MES2 = $_POST["AS_ASS_DATE_MES2"];
     $AS_ASS_DATE_ANO2 = $_POST["AS_ASS_DATE_ANO2"];

     $TIPO = "POST";
     } else {
     $AS_ASS_DATE_DIA1 = $_GET["AS_ASS_DATE_DIA1"];
     $AS_ASS_DATE_MES1 = $_GET["AS_ASS_DATE_MES1"];
     $AS_ASS_DATE_ANO1 = $_GET["AS_ASS_DATE_ANO1"];

     $AS_ASS_DATE_DIA2 = $_GET["AS_ASS_DATE_DIA2"];
     $AS_ASS_DATE_MES2 = $_GET["AS_ASS_DATE_MES2"];
     $AS_ASS_DATE_ANO2 = $_GET["AS_ASS_DATE_ANO2"];

     $TIPO = "GET";
     } 

     if(isset($_POST['AS_STATUS'])){
        if($_POST['AS_STATUS'] == "")
            $FilterStatus = "    AS_STATUS IN ('AGUARDANDO RETORNO','EM ANDAMENTO', 'LIBERADA', 'AGUARDANDO SAIDA
         ', 'AGUARDANDO RESPOSTA DO OPERADOR', 'RECUSADA PELO OPERADOR', 'AGUARDANDO RETORNO')";*/
 $FilterStatus = " AS_STATUS IS NOT NULL ";
        else
            $FilterStatus = "  AS_STATUS = '".$_POST['AS_STATUS']."' ";
     }

     $SQL_EMPRESAS = $mysqli->query("select * from db_conveniado_empresa where CE_ID_C = '" . $LUS_ID . "'");
     $lista = "";
    // $lista .= "AS_ATEND_POR = '". $LOG_NOME . "' ";
     while($FET_EMPRESAS = mysqli_fetch_array($SQL_EMPRESAS)){
        $lista .= $FET_EMPRESAS['CE_ID_E'];
        $lista .= ', ';
     }
     if($lista != ""){
        $clausula = " AND ( AS_EMPRESA_ID IN (";
        $lista = substr($lista, 0, strlen($lista) - 2); 
        $lista .= ")";
        $clausula .= $lista;
        $FilterStatus .= $clausula;
        //$FilterStatus .= " OR (AS_ATEND_POR = '". $LOG_NOME . "') ";
        $FilterStatus .= ")";
     }

       $FilterStatus .= " AND (AS_ASS_DATE>='".$AS_ASS_DATE_ANO1."-".$AS_ASS_DATE_MES1."-".$AS_ASS_DATE_DIA1."' AND AS_ASS_DATE<='".$AS_ASS_DATE_ANO2."-".$AS_ASS_DATE_MES2."-".$AS_ASS_DATE_DIA2."')";
     //$lista .= 
    // var_dump("SELECT * FROM db_assistencias WHERE ".$FilterStatus." ORDER BY AS_ASS_TIME DESC ");
    // exit();


$SQL_ASSISTENCIA = $mysqli->query("SELECT * FROM db_assistencias WHERE ".$FilterStatus." ORDER BY AS_ASS_TIME DESC ");

$TOT_ASSISTENCIA = $SQL_ASSISTENCIA->num_rows;

$conteudo_html .= '<img src="http://suporteyed.esy.es/remocenter/img/logotipo_swf.jpg" width="150" height="100">';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_EMPRESA_NOME'].'</b></font></td>';
$conteudo_html .= '<table>';
$conteudo_html .= '<tr align="left" bgcolor="#666666" cellpadding="0" cellspacing="0" >';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Data/Hora do Servico</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Guia</b></font></td>     ';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Status</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Nome Paciente</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Idade</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>HD</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Tipo VTR</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Origem</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.C.O</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.S.O</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>Destino</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.C.D</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.S.D</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.C.R</b></font></td>';
$conteudo_html .= '<td align="left" height="25"><font face="Verdana" size="1" color="#CCCCCC">&nbsp;&nbsp;<b>H.S.R</b></font></td>';
$conteudo_html .= '</tr>';

  while ($FET_ASSISTENCIA = mysqli_fetch_array($SQL_ASSISTENCIA)) {


  if ($i % 2 == 0){ $color = "#F4F4F4"; } else { $color = "#E9E9E9";    }




  $conteudo_html .=  '<tr align="left" bgcolor="'.$color.'" cellpadding="0" cellspacing="0"  id="tr'.$FET_ASSISTENCIA["AS_ID"].'">
  <td align="left" height="25"><font face="Verdana" size="1" color="#666666">&nbsp;&nbsp;<a class="a" target="_blank" href="relatorioDetalheAssistencia.php?ID='.$FET_ASSISTENCIA['AS_ID'].'">'.date("d/m/Y H:i", $FET_ASSISTENCIA['AS_ASS_TIME']).'</b></font></td>
  <td align="left" height="25"><font face="Verdana" size="1" color="#666666"><a class="a" target="_blank" href="relatorioDetalheAssistencia.php?ID='.$FET_ASSISTENCIA['AS_ID'].'" rel="modal">'.$FET_ASSISTENCIA['AS_ATEND_GUIA'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666"><a class="a" target="_blank" href="relatorioDetalheAssistencia.php?ID='.$FET_ASSISTENCIA['AS_ID'].'" rel="modal">'.$FET_ASSISTENCIA['AS_STATUS'].'</b></font></td>';

  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_PACIENTE_NOME'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_PACIENTE_IDADE'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_SERVICO_HD'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_SERVICO_TIPO'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_ORIGEM_NOME'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_CO'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_SO'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_DESTINO_NOME'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_CD'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_SD'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_CR'].'</b></font></td>';
  $conteudo_html .='<td align="left" height="25"><font face="Verdana" size="1" color="#666666">'.$FET_ASSISTENCIA['AS_HORARIO_SR'].'</b></font></td>';


  $conteudo_html .='</tr>';

  $i++;
  $TOT_ASSISTENCIA = $i;

  }


  } else {

     $AS_ASS_DATE_DIA1 = "01";
     $AS_ASS_DATE_MES1 = date("m");
     $AS_ASS_DATE_ANO1 = date("Y");

     $AS_ASS_DATE_DIA2 = date("d");
     $AS_ASS_DATE_MES2 = date("m");
     $AS_ASS_DATE_ANO2 = date("Y");


  }

$mpdf = new mPDF();
$mpdf->allow_charset_conversion=true;
$mpdf->charset_in='iso-8859-1';
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($conteudo_html);
$mpdf->SetFooter('{DATE j/m/Y&nbsp; H:i}|{PAGENO}/{nb}|SEDUC / SIGETI');
$arquivo = date("ymdhis").'relatorio.pdf';
$mpdf->Output($arquivo,'D');
exit();
}

TABELA

PDF

1 answer

3


Carol, I don’t know this class mPDF, but see if closing the table at the end if it appears in the pdf.

Before the line:

$mpdf = new mPDF();

Add:

$conteudo_html .='</table>';
  • 1

    Pow man, thanks , show, worked here. Thanks really

  • 1

    Good! give me a moral and mark the answer answered and click the arrow up!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.