D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso_ant
/
adm
/
app
/
gre
/
Views
/
ContasCPCR
/
Filename :
ImprimeFluxo.php
back
Copy
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ob_start(); $Dados = $_POST; //var_dump($Dados ); $fluxo = new \App\gre\Models\GreLerFluxo(); $dados = $fluxo->listarFluxo($Dados); // Obtenha as chaves do primeiro elemento // Remove as três primeiras chaves, que não são datas válidas $datas = array_keys($dados[0]); array_splice($datas, 0, 3); // Ordena as datas asort($datas); // Obtenha a primeira data $primeiraData = reset($datas); //var_dump($primeiraData); //die; // Obtenha a última data $ultimaData = end($datas); REQUIRE($_SERVER['DOCUMENT_ROOT'].'/idoso/adm/app/gre/Views/include/fpdf/fpdf.php'); class PDF extends FPDF { function Header() { $this->Image(URLADM . 'assets/imagens/logo_login/'.$_SESSION['id_user'].'/logo_header.png',10,10,10,0,'PNG'); $this->SetFont('Arial', 'B', 12); $this->Cell(20, 10, '', 0, 0, 'L'); $this->Cell(30, 10, 'Fluxo de Caixa', 0, 0, 'L'); $this->SetFont('Arial', 'BI', 12); $this->Cell(140, 10, utf8_decode(' - período de: '). $this->primeiraData .utf8_decode(' à ').$this->ultimaData , 0, 1, 'L'); $this->Ln(2); } function Footer() { $this->SetY(-15); $this->SetFont('Arial', 'I', 8); $this->Cell(0, 7, utf8_decode('Página ') . $this->PageNo(), 0, 0, 'C'); } function ChapterTitle($title) { $this->SetFont('Arial', 'B', 8); $this->Cell(0, 6, $title, 0, 1, 'C'); $this->Ln(4); } function ChapterBody($data) { $this->SetFont('Arial', '', 7); $pageWidth = 297; $numCols = count($data[0]) -3; // var_dump('$numCols: '. $numCols); $colWidth = $pageWidth / $numCols; // var_dump('$colWidth: '. $colWidth); $dateColWidth = 180; $otherColWidth = ($pageWidth - $dateColWidth) / ($numCols - 1); // var_dump('$otherColWidth : '. $otherColWidth ); // die; $this->SetFont('Arial', "B", 7); $this->Cell(55, 7, 'Nome da Conta', 1); $header = array_keys($data[0]); $header = array_slice($header, 3); foreach ($header as $col) { if (is_numeric($col)) { $colName = date('d/m', strtotime($col)); $this->SetFont('Arial', 'B', 7); $this->Cell($dateColWidth, 7, $colName, 1, 0, 'C'); } else { $this->SetFont('Arial', 'B', 7); $this->Cell($otherColWidth, 7, $col, 1, 0, 'C'); } $this->SetFont('Arial', '', 7); } $this->Ln(); foreach ($data as $col) { //var_dump($col); //die; $bold = ($col['tipo'] == '0' || $col['conta'] == '0') ? 'B' : ''; $bold = ($col['tipo'] == '0' || $col['conta'] == '99') ? 'B' : ''; if($col['tipo'] == '9' and $col['conta'] == '999') {$bold = 'B';}; $this->SetFont('Arial', $bold, 7); $this->Cell(55, 7, $col['nome_conta'], 1); foreach ($header as $colName) { if (is_numeric($colName)) { $formattedValue = number_format($col[$colName], 0, ',', '.'); $alignment = ($colName != 'Nome Conta') ? 'C' : 'L'; $bold = ($col['tipo'] == '0' || $col['tipo'] == '0') ? 'B' : ''; // $bold = ($col['tipo'] == '9' || $col['conta'] == '999') ? 'B' : ''; $this->SetFont('Arial', $bold, 7); $this->Cell($dateColWidth, 10, $formattedValue, 1, 0, $alignment); } else { if (strpos($col[$colName], '-') !== false) { $this->SetTextColor(255, 0, 0); } else { $this->SetTextColor(0,0,0); } $formattedValue = number_format($col[$colName], 0, ',', '.'); $bold = ($col['tipo'] == '0' || $col['tipo'] == '9') ? 'B' : ''; $bold = ($col['tipo'] == '0' || $col['conta'] == '99') ? 'B' : ''; if($col['tipo'] == '9' and $col['conta'] == '999') {$bold = 'B';}; $this->SetFont('Arial', $bold, 7); $this->Cell($otherColWidth, 7, $formattedValue, 1, 0, 'R'); } $this->SetTextColor(0,0,0); $this->SetFont('Arial', '', 7); } $this->Ln(); } } } $pdf = new PDF('L'); $pdf->primeiraData = $primeiraData; $pdf->ultimaData = $ultimaData; $pdf->AddPage(); $pdf->ChapterBody($dados); $pdf->Output();