Create new page when changing ID

0

Good afternoon, I am generating a report in PDF and I need to generate a new page when I change the user code

It is thus generating

.

At the moment he is only inserting the line of the items and ignoring the order, he has to mount the same ones that are correct, creating in a new page a new header (Aspecto físico, habilidade motora e Inteligencia de jogo) and inserting the items in its place. / p>

PHP

 for ($i=0; $i < count($area_avaliar); $i++) {
        if ($area_avaliar_tecnica[$i]->descricao_tecnica != $area_avaliar_tecnica[$i-1]->descricao_tecnica) {
            $this->pdf->Ln();
            $this->pdf->SetFillColor(195, 195, 195);
            $this->pdf->SetTextColor(0);
            $this->pdf->SetDrawColor(51, 51, 51);
            $this->pdf->SetLineWidth(0.3);
            $this->pdf->SetFont('', 'B', 24);
            $this->pdf->Multicell(175, 5, $area_avaliar_tecnica[$i]->descricao_tecnica, 1, 'L', 1);
        }
        $this->pdf->SetFillColor(255, 255, 255);
        $this->pdf->SetTextColor(0);
        $this->pdf->SetDrawColor(51, 51, 51);
        $this->pdf->SetLineWidth(0.3);
        $this->pdf->SetFont('', 'N', 12);
        $this->pdf->Multicell(175, 5, $area_avaliar[$i]->desc_area_avaliar_item.' = '.$area_avaliar[$i]->avaliacao, 1, 'L', 1);
    }

This report I'm generating is dynamic, I currently have 3 headers (Aspecto físico, habilidade motora e Inteligencia de jogo) and some items inside them, I need to go through $area_avaliar (variable that receives all data) and generate the 3 headers and their items, and every time I change the ID, create a new page. $this->pdf->AddPage(); but I do not know how I can do this, since I currently have several items in $area_avaliar and it is difficult to scroll and print the way I need it.

    
asked by anonymous 21.11.2018 / 20:31

1 answer

0

I ended up doing what I needed in the following way.

$ultimo_header = '';
    for ($i=0; $i < count($area_avaliar); $i++) {
        if ($i == 0 || $area_avaliar[$i]->cod_atleta_area_avaliar != $area_avaliar[$i-1]->cod_atleta_area_avaliar) {
            $this->pdf->AddPage();
            $this->pdf->SetFillColor(255, 255, 255);
            $this->pdf->SetFont('', 'B', 18);
            $this->pdf->Multicell(175, 6, $area_avaliar[$i]->dt_avaliacao, 0, 'C', 1);
            $this->pdf->Ln();
            $this->pdf->SetTextColor(0);
            $this->pdf->SetFont('', 'N', 14);
            $this->pdf->Multicell(175, 6, 'Relatorio: '.$area_avaliar[$i]->relatorio, 0, 'L', 0);
            $this->pdf->Multicell(175, 6, 'Treinador: '.$area_avaliar[$i]->treinador, 0, 'L', 0);
            $this->pdf->Multicell(175, 6, 'Preparador Fisico: '.$area_avaliar[$i]->preparador_fisico, 0, 'L', 1);
            $this->pdf->Multicell(175, 6, 'Supervisor: '.$area_avaliar[$i]->supervisor, 0, 'L', 1);
            $this->pdf->Multicell(175, 6, 'Coordenador Técnico: '.$area_avaliar[$i]->coordenador_tecnico, 0, 'L', 1);
        }
        if ($i == 0 || $area_avaliar[$i]->descricao != $ultimo_header && $area_avaliar[$i]->descricao != null) {
            $this->pdf->Ln();
            $this->pdf->SetFillColor(195, 195, 195);
            $this->pdf->SetTextColor(0);
            $this->pdf->SetDrawColor(51, 51, 51);
            $this->pdf->SetLineWidth(0.3);

            $this->pdf->SetFont('', 'B', 24);
            $this->pdf->Multicell(175, 5, $area_avaliar[$i]->descricao, 1, 'L', 1);
            $ultimo_header = $area_avaliar[$i]->descricao;
        }
        $this->pdf->SetFillColor(255, 255, 255);
        $this->pdf->SetTextColor(0);
        $this->pdf->SetDrawColor(51, 51, 51);
        $this->pdf->SetLineWidth(0.3);
        $this->pdf->SetFont('', 'N', 12);
        $this->pdf->Multicell(175, 5, $area_avaliar[$i]->desc_area_avaliar_item.': '.$area_avaliar[$i]->avaliacao, 1, 'L', 1);

    }
    
23.11.2018 / 20:49