GENERATE PHP REPORT

-1

I have a database in which you have two tables:

CLIENTS

TICKETS

InmyVIEW(Codeigniter),theuserwillselectaperiod(Ex01/03/2018to03/31/2018)togenerateareportofalltheticketsthatwerepaidwithinthisperiod.

Inthisreport,Ineedalltheinformationfromthatperiodtoappearinthereportbutbygrouping,eg:

I'm using Codeigniter3 and thinking of using mPDF for reporting. Could someone help me with this logic?

    
asked by anonymous 10.03.2018 / 04:55

1 answer

1

Below an example working with mPDF with codeigniter, in case I import PDF driver, and sending $ date to the report / pdf / body and report / pdf / body , in which I store PHP that will generate the view in HTML with my information. Then just write to the file.

Detail $ result is a result of Codeigniter's Query

$this->load->library('pdf');
$pdf = $this->pdf->load();
$data['titulo_relatorio'] = 'Relatório';
$header = $this->load->view('relatorio/pdf/header', $data, true);
$pdf->SetHTMLHeader($header);
$pdf->SetFooter('Titulo Relatório' . '|Página {PAGENO}|' . date("d.m.Y") . '   ');

$dataResult['result'] = $result;
$pdf->WriteHTML($this->load->view('relatorio/pdf/body', $dataResult, true));
$pdf->Output($pdfFilePath, 'I');

And below is an example of the view's code

<div>
    <table>
        <tr>
            <th>COLUNA 1</th>
            <th>COLUNA 2/th>
        </tr>
        <?php 
            foreach ($result as $row) {
        ?>
            <tr>
                <td><?php echo $row['campo1']; ?></td>
                <td><?php echo $row['campo2']; ?></td>
            </tr>
        <?php
            }
        ?>
    </table>
</div>

In short, basically you will generate HTML and write it in a PDF file

    
10.03.2018 / 06:10