D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
crsys_ant
/
adm
/
vendor_Ant
/
api
/
Filename :
imprimeOrcamento_erro.php
back
Copy
<?php ini_set('display_errors', 1); error_reporting(E_ALL); ob_start(); require($_SERVER['DOCUMENT_ROOT'].'/crsys/adm/app/gre/Views/include/fpdf/fpdf.php'); define('FPDF_FONTPATH','font/'); $dados = $this->Dados['listpedido'] ?? []; $parcelas = $this->Dados['listparcela'] ?? []; $mensa = $dados[0]['mensagem'] ?? ''; var_dump($dados); function txt($v){ return utf8_decode($v ?? ''); } class PDF extends FPDF { function Footer() { global $dados, $parcelas, $mensa; if (empty($dados)) return; $this->SetY(-85); $this->SetFont('Arial','',9); // =============================== // OBSERVAÇÃO // =============================== if (!empty(trim($dados[0]['obs_obra'] ?? ''))) { $this->SetTextColor(255,0,0); $this->MultiCell(0,5,txt('Obs: '.$dados[0]['obs_obra'])); $this->SetTextColor(0,0,0); $this->Ln(3); } // =============================== // CÁLCULOS // =============================== $valorTotal = $dados[0]['vlr_total'] ?? 0; $valorEntrada = $dados[0]['valor_entrada'] ?? 0; $frete = $dados[0]['vlr_frete'] ?? 0; $vlr_ns = $dados[0]['vlr_ns'] ?? 0; $desconto = ($dados[0]['vlr_desc'] ?? 0) + $vlr_ns; $totalPagar = $valorTotal - $vlr_ns; // =============================== // FORMA PAGAMENTO // =============================== if (!empty($parcelas) && ($parcelas[0]['tipo_pagto_id'] ?? null) == 6) { $resultado = []; foreach ($parcelas as $item) { $resultado[] = $item['nome'].' '.$item['perc_cronograma'].'%'; } $formaPag = implode('; ', $resultado); } else { if (($dados[0]['perc_entrada'] ?? 0) == 100) { $formaPag = "À Vista"; } else { $formaPag = "Entrada de ". number_format($dados[0]['perc_entrada'] ?? 0,2,',','.'). "% mais ". ($dados[0]['num_parcelas'] ?? 0). " parcelas vencendo a partir de ". date('d/m/Y', strtotime($dados[0]['data_parcela'] ?? date('Y-m-d'))); } } // =============================== // QUADRO RESUMO // =============================== $this->SetFont('Arial','B',9); $this->Cell(0,6,txt('Resumo dos Valores'),1,1,'C'); $this->SetFont('Arial','',9); $subtotal = $valorTotal - $frete + $desconto - $vlr_ns; $this->Cell(100,6,txt('Sub-Total'),1,0,'L'); $this->Cell(0,6,'R$ '.number_format($subtotal,2,',','.'),1,1,'R'); $this->Cell(100,6,txt('Frete'),1,0,'L'); $this->Cell(0,6,'R$ '.number_format($frete,2,',','.'),1,1,'R'); if($desconto > 0){ $this->Cell(100,6,txt('Desconto (-)'),1,0,'L'); $this->Cell(0,6,'R$ '.number_format($desconto,2,',','.'),1,1,'R'); } $this->SetFont('Arial','B',9); $this->Cell(100,6,txt('Valor Final'),1,0,'L'); $this->Cell(0,6,'R$ '.number_format($totalPagar,2,',','.'),1,1,'R'); $this->Ln(3); $this->SetFont('Arial','',9); $this->MultiCell(0,5,txt('Forma de Pagamento: '.$formaPag),1,'C'); } } // =============================== // GERA PDF // =============================== $pdf = new PDF(); $pdf->SetAutoPageBreak(true, 85); $pdf->AddPage(); $pdf->SetFont('Arial','',12); // =============================== // CABEÇALHO // =============================== if (!empty($dados)) { $cab = $dados[0]; $pdf->Cell( 0,8, txt('Orçamento Nº '.$cab['orca_id'].'/'.date('Y',strtotime($cab['created'] ?? date('Y-m-d')))), 0,1,'R' ); $pdf->Cell( 0,8, txt('Data: '.date('d/m/Y',strtotime($cab['created'] ?? date('Y-m-d')))), 0,1,'R' ); $pdf->Cell( 0,8, txt('Revisão Nº: '.$cab['num_revisao']), 0,1,'R' ); $pdf->Ln(5); $pdf->Cell( 0,8, txt('Cliente: '.$cab['cliente']), 0,1,'L' ); } $pdf->Ln(20); // Limpa buffer antes de enviar o PDF ob_end_clean(); $pdf->Output('I','orcamento.pdf'); exit;