Generate PivotTable with TCPDF

5

Good afternoon, I'm using TCPDF to generate an evaluation report, and I need this report to be divided into the weeks the user has activity.

The report is currently

WhatIneedistogothroughthearray,startingonMondayandendingonSunday,whenIarriveonSundayIneedtoclosethetableandstartanewoneonMonday,generatingtheheaderandtheactivitiesofthedayagain,butIdonothaveideaofhowtodoit.

Functionthatgeneratesthereport

publicfunctiongerar_relatorio($__cod){$sessao=$this->session->userdata('portal');$ativ_semanal=utf8_string_array_encode($this->atleta_model->get_atividade_semanal($__cod));$nome_atleta=$this->atleta_model->get_atleta($__cod);$borda=0;$header_titulo=array('SEG','TER','QUA','QUI','SEX','SAB','DOM');for($j=0;$j<count($header_titulo);++$j){$this->pdf->SetFillColor(0,0,255);$this->pdf->SetTextColor(255);$this->pdf->SetDrawColor(0,0,255);$this->pdf->SetLineWidth(0.3);$this->pdf->SetFont('','B');$this->pdf->Cell(25,6,$header_titulo[$j],1,0,'C',1);}$this->pdf->Ln();$this->pdf->SetFillColor(224,235,255);$this->pdf->SetTextColor(0);$this->pdf->SetFont('');$ultimo_dow=1;$x=20;$y=39;$contador=0;$cont=0;$ultimo_dia=0;$ultimo_dia_semana=0;$num_atividades_semana=0;for($i=0;$i<count($ativ_semanal);$i++){$this->pdf->SetFillColor(255,255,255);$this->pdf->SetTextColor(0);$this->pdf->SetFont('');$num_atividades_semana=$ativ_max[$ativ_semanal[$i]->num_semana];if(($ativ_semanal[$i]->num_dia-$ultimo_dow)>1){/*Esseblocoprintaosintervalosmaioresque1atéquechegueemumdiapreenchido*/$cont=$ativ_max[$ativ_semanal[$i]->num_semana]-$contador;for($j=0;$j<$cont;$j++){$this->pdf->SetFillColor(100,100,150);//Roxo$this->pdf->SetY($y);$this->pdf->SetX($x);$this->pdf->Multicell(25,15,'',1,0,'C',1);$y+=15;}$ultimo_dow+=1;$ultimo_dia_semana=$ativ_semanal[$i]->num_dia;$x+=25;$y=39;$contador=0;if($ultimo_dow!=7){$i--;}}else{/*Printaapartirdoultimodowencontradoacima*/if($ativ_semanal[$i]->num_dia==$ultimo_dow){$this->pdf->SetY($y);$this->pdf->SetX($x);$this->pdf->Multicell(25,15,$ativ_semanal[$i]->descricao,1,0,'C',1);$y+=15;$contador+=1;/*Diadasemanaquepossuiomaximodeatividadesdasemana*/if(($ativ_max[$ativ_semanal[$i]->num_semana]-$contador)==0){$contador=0;$y=39;$x+=25;$ultimo_dow+=1;}$ultimo_dia_semana=$ativ_semanal[$i]->num_dia;}else{$cont=$ativ_max[$ativ_semanal[$i]->num_semana]-$contador;for($j=0;$j<$cont;$j++){$this->pdf->SetFillColor(90,255,255);//Azulclaro$this->pdf->SetY($y);$this->pdf->SetX($x);$this->pdf->Multicell(25,15,'',1,0,'C',1);$y+=15;}$ultimo_dow=$ativ_semanal[$i]->num_dia;$x+=25;$y=39;$contador=0;$ultimo_dia_semana=$ativ_semanal[$i]->num_dia;if($i!=count($ativ_semanal)-1){$i--;}}}}if($contador==0){$x+=25;$y=39;$contador=$ultimo_dia_semana;}else{$x-=25;}$x-=25;$contador=$ultimo_dia_semana;for($i=0;$i<(8-$contador);$i++){$cont=$contador-$num_atividades_semana;for($j=0;$j<$cont;$j++){$this->pdf->SetFillColor(0,50,255);//AzulEscuro$this->pdf->SetY($y);$this->pdf->SetX($x);$this->pdf->Multicell(25,15,'',1,0,'C',1);$y+=15;}$x+=25;$y=39;$contador=0;}$this->pdf->Output($nome_atleta[0]->nome.'_'.date("d/m/Y").'.pdf', 'I');
    return;
 }

Return example with the data to mount the table

array(1) {
 [0]=>
  object(stdClass)#26 (7) {
   ["dia_semana"]=>
    string(7) "Segunda"
   ["num_dia"]=>
    string(1) "2"
   ["data_hora"]=>
    string(16) "26/11/2018 15:20"
   ["num_semana"]=>
    string(2) "48"
   ["descricao"]=>
    string(3) "Seg"
 }
}
    
asked by anonymous 12.11.2018 / 18:38

0 answers