Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("app.library/fpdf/fpdf.php");
- include_once "app.ado/TConnection.class.php";
- include_once "app.ado/TTransaction.class.php";
- include_once "app.ado/TRecord.class.php";
- include_once "app.ado/TSqlInstruction.class.php";
- include_once "app.ado/TSqlSelect.class.php";
- include_once "app.ado/TRepository.class.php";
- include_once "app.ado/TExpression.class.php";
- include_once "app.ado/TCriteria.class.php";
- include_once "app.ado/TFilter.class.php";
- include_once "app.model/vw_nota_entrega_leiteRecord.class.php";
- include_once "app.library/funcdate.php";
- session_start();
- //define o diretorio de fontes que s�o utilizadas pelo FPDF
- define('FPDF_FONTPATH', 'app.library/fpdf/font/');
- class PDF extends FPDF {
- //Page header
- function Header() {
- $situacao = $_REQUEST["situacao"];
- $mes = $_REQUEST["mes"];
- $ano = $_REQUEST["ano"];
- //endereco da imagem,posicao X(horizontal),posicao Y(vertical), tamanho altura, tamanho largura
- $this->Image("app.images/logo_relatorio.jpg", 8, 11, 26, 18);
- //Arial bold 15
- $this->SetFont('Arial', 'B', 12);
- $this->SetY("12");
- $this->SetX("35");
- $this->Cell(0, 5, utf8_decode("GOVERNO DO ESTADO DO RIO GRANDE DO NORTE"), 0, 1, 'C');
- if ($situacao == "0") {
- $situacao = "TODAS";
- }
- if ($mes == "0") {
- $mes = "TODOS OS MESES";
- } else if ($mes == "1") {
- $mes = "JANEIRO";
- } else if ($mes == "2") {
- $mes = "FEVEREIRO";
- } else if ($mes == "3") {
- $mes = "MARÇO";
- } else if ($mes == "4") {
- $mes = "ABRIL";
- } else if ($mes == "5") {
- $mes = "MAIO";
- } else if ($mes == "6") {
- $mes = "JUNHO";
- } else if ($mes == "7") {
- $mes = "JULHO";
- } else if ($mes == "8") {
- $mes = "AGOSTO";
- } else if ($mes == "9") {
- $mes = "SETEMBRO";
- } else if ($mes == "10") {
- $mes = "OUTUBRO";
- } else if ($mes == "11") {
- $mes = "NOVEMBRO";
- } else if ($mes == "12") {
- $mes = "DEZEMBRO";
- }
- $this->SetY("17");
- $this->SetX("35");
- $this->Cell(0, 5, utf8_decode("INSTITUTO DE ASSISTÊNCIA TÉCNICA E EXTENSÃO RURAL - EMATER"), 0, 1, 'C');
- $this->SetY("22");
- $this->SetX("35");
- $this->Cell(0, 5, utf8_decode("SIAP"), 0, 1, 'C');
- $this->SetY("27");
- $this->SetX("35");
- $this->Cell(0, 5, utf8_decode("RELATÓRIO DE PROJETOS POR SITUAÇÃO: " . $situacao), 0, 1, 'C');
- $this->SetY("32");
- $this->SetX("35");
- $this->Cell(0, 5, utf8_decode($mes." - ". $ano), 0, 1, 'C');
- }
- function ColumnHeader() {
- //define a fonte a ser usada
- $this->SetFont('arial', 'B', 11);
- $this->Cell(0, 0, '', 1, 1, 'L');
- }
- function ColumnDetail() {
- $agenciamunicipio_id = $_REQUEST["agenciamunicipio_id"];
- $municipio_id = $_REQUEST["municipio_id"];
- $regional_id = $_REQUEST["regional_id"];
- $servidor_id = $_REQUEST["servidor_id"];
- $situacao = $_REQUEST["situacao"];
- $laudosemitidos = $_REQUEST["laudosemitidos"];
- $mes = $_REQUEST["mes"];
- $ano = $_REQUEST["ano"];
- // inicia transacao com o banco 'pg_ceres'
- TTransaction::open('pg_ceres');
- // instancia um repositorio para Carros
- $repository = new TRepository('vw_relatorio_projetos_situacao');
- $filtros = "";
- $filtros2 = "";
- $numerofiltros = 0;
- $criteria = new TCriteria;
- if ($agenciamunicipio_id >= 1) {
- $criteria->add(new TFilter('agenciamunicipio_id', '=', $agenciamunicipio_id));
- /* $numerofiltros ++;
- $rows2 = $repository->load($criteria);
- foreach($rows2 as $row2){
- $filtros .= 'Agencia Municipio: '.$row2->nome_agenciamunicipio;
- break;
- } */
- }
- if ($municipio_id >= 1) {
- $criteria->add(new TFilter('municipio_id', '=', $municipio_id));
- /* $numerofiltros ++;
- $rows2 = $repository->load($criteria);
- foreach($rows2 as $row2){
- if($filtros == ""){
- $filtros .= 'Municipio: '.$row2->nome_municipio;
- } else {
- $filtros .= ' - Municipio: '.$row2->nome_municipio;
- }
- break;
- } */
- }
- if ($regional_id >= 1) {
- $criteria->add(new TFilter('regional_id', '=', $regional_id));
- /* $numerofiltros ++;
- $rows2 = $repository->load($criteria);
- foreach($rows2 as $row2){
- if($filtros == ""){
- $filtros .= 'Regional: '.$row2->nome_regional;
- } else {
- $filtros .= ' - Regional: '.$row2->nome_regional;
- }
- break;
- } */
- }
- if ($servidor_id >= 1) {
- $criteria->add(new TFilter('servidor_id', '=', $servidor_id));
- /* $numerofiltros ++;
- $rows2 = $repository->load($criteria);
- foreach($rows2 as $row2){
- if($filtros == ''){
- $filtros .= 'Tecnico: '.$row2->nome_servidor;
- } else {
- $filtros .= ' - Tecnico: '.$row2->nome_servidor;
- }
- break;
- } */
- }
- if ($situacao != "TODAS") {
- $criteria->add(new TFilter('situacao', '=', $situacao));
- }
- if ($ano != "") {
- if ($situacao == 'CONTRATADO') {
- $criteria->add(new TFilter('ano_cont', '=', $ano));
- } else {
- $criteria->add(new TFilter('ano_elab', '=', $ano));
- }
- }
- if ($laudosemitidos === 0) {
- $criteria->add(new TFilter('laudosemitidos', '=', 0));
- } elseif ($laudosemitidos >= 1) {
- $criteria->add(new TFilter('laudosemitidos', '>=', 1));
- }
- /*
- if($filtros != ''){
- $this->SetFont('Arial','I',10);
- $this->SetY("37");
- $this->SetX("35");
- $this->Cell(0,5,utf8_decode("FILTRADO POR: ".$filtros),0,1,'C');
- }
- if($filtros2 != ''){
- $this->SetFont('Arial','I',10);
- $this->SetY("42");
- $this->SetX("35");
- $this->Cell(0,5,utf8_decode($filtros2),0,1,'C');
- } */
- //FINALIZANDO O CABEÇALHO DA PAGINA
- $this->Ln();
- $this->ColumnHeader();
- $this->Ln();
- $criteria->setProperty('order', 'nome_servidor,nome_regional,nome_municipio,nome_produtor');
- // carrega os objetos de acordo com o criterio
- $rows = $repository->load($criteria);
- if ($rows) {
- $regional = '';
- $municipio = '';
- $nome_servidor = '';
- $agenciamunicipio = '';
- $projeto_id_anterior = '';
- $contMunicipio = 0;
- $contRegional = 0;
- $contTotal = 0;
- $contador = 0;
- // percorre os objetos retornados
- foreach ($rows as $row) {
- //define a fonte a ser usada
- $this->SetFont('arial', '', 11);
- if ($regional != $row->nome_regional) {
- if ($contRegional != 0) {
- $this->SetFont('Arial', 'B', 10);
- $this->SetX("10");
- $this->Ln(5);
- $this->SetFillColor(215, 215, 215);
- $this->Cell(0, 5, "Total de Produtores por Municipio: " . $contMunicipio, 1, 1, 'L', 1);
- $this->Cell(0, 5, "Total de Produtores por Regional: " . $contRegional, 1, 1, 'L', 1);
- $contRegional = 0;
- }
- $municipio = '';
- $agenciamunicipio = '';
- $this->Ln();
- $this->SetX("10");
- $this->SetFont('arial', 'B', 11);
- $this->SetFillColor(100, 180, 118);
- $this->Cell(0, 5, utf8_decode("REGIONAL: " . $row->nome_regional), 1, 1, 'J', 1);
- $regional = $row->nome_regional;
- }
- if (($regional == $row->nome_regional) && ($municipio != $row->nome_municipio)) {
- if ($municipio != '') {
- $this->SetFont('Arial', 'B', 10);
- $this->SetX("10");
- $this->Ln(5);
- $this->Cell(0, 0, '', 1, 1, 'L');
- $this->SetFillColor(215, 215, 215);
- $this->Cell(0, 5, "Total de Produtores por Municipio: " . $contMunicipio, 1, 1, 'L', 1);
- $contMunicipio = 0;
- // $contMun=0;
- }
- $municipio = $row->nome_municipio;
- $agenciamunicipio = '';
- $this->Ln();
- $this->SetX("10");
- $this->SetFont('arial', 'B', 10);
- // $this->SetFillColor(124, 205, 124);
- $this->SetFillColor(162, 234, 150);
- $this->Cell(0, 5, utf8_decode("MUNIC�PIO: " . $row->nome_municipio), 1, 1, 'J', 1);
- $this->Cell(0, 0, '', 1, 1, 'L');
- }
- //exibir produtores por tecnico
- if ($nome_servidor != $row->nome_servidor) {
- $this->Ln();
- $this->SetX("10");
- $this->SetFont('arial', 'B', 10);
- $this->SetFillColor(162, 234, 150);
- // $this->SetFillColor(215, 215, 215);
- // $this->SetFillColor(124, 205, 124);
- $this->Cell(0, 5, utf8_decode("TÉCNICO: " . strtoupper($row->nome_servidor)), 1, 1, 'J', 1);
- $this->Cell(0, 0, '', 1, 1, 'L');
- $this->SetFont('arial', '', 9);
- }
- $nome_servidor = $row->nome_servidor;
- if (($regional == $row->nome_regional) && ($municipio == $row->nome_municipio) && ($agenciamunicipio != $row->nome_agenciamunicipio)) {
- //$contador = 1;
- // $contMunicipio+=$contador;
- $agenciamunicipio = $row->nome_agenciamunicipio;
- $this->Ln();
- $this->SetX("10");
- $this->SetFont('arial', 'B', 10);
- $this->SetFillColor(215, 215, 215);
- $this->Cell(0, 5, utf8_decode("AGÊNCIA: " . $row->agencia . " - " . $row->nome_agenciamunicipio), 1, 1, 'J', 1);
- $this->SetFont('arial', 'B', 9);
- $this->SetX("10");
- $this->Cell(0, 5, utf8_decode("PRODUTOR"), 1, 0, 'J');
- $this->SetX("68");
- $this->Cell(0, 5, utf8_decode("CPF"), 1, 0, 'J');
- $this->SetX("93");
- $this->Cell(0, 5, utf8_decode("DATA SITUACÃO"), 1, 0, 'J');
- $this->SetX("124");
- $this->Cell(0, 5, utf8_decode("SITUACÃO"), 1, 0, 'J');
- $this->SetX("150");
- $this->Cell(0, 5, utf8_decode("TX/ATER"), 1, 0, 'J');
- $this->SetX("170");
- $this->Cell(0, 5, utf8_decode("VALOR PROJETO"), 1, 0, 'J');
- }
- if ($contador % 2 == 0) {
- $this->SetFillColor(235, 235, 235);
- } else {
- $this->SetFillColor(255, 255, 255);
- }
- $this->SetFont('arial', '', 9);
- if ($row->id != $projeto_id_anterior) {
- $this->Ln();
- $this->SetX("10");
- $this->Cell(0, 5, utf8_decode(strtoupper(substr($row->nome_produtor, 0, 26))), 1, 0, 'J', 1);
- $this->SetX("68");
- $this->Cell(0, 5, utf8_decode($row->cpf_produtor), 1, 0, 'J');
- $this->SetX("93");
- if ($row->datasituacao != null) {
- $this->Cell(0, 5, utf8_decode(formatar_data($row->datasituacao)), 1, 0, 'J', 1);
- } else {
- $this->Cell(0, 5, utf8_decode(formatar_data($row->dataelaboracao)), 1, 0, 'J', 1);
- }
- $this->SetX("124");
- $this->Cell(0, 5, utf8_decode($row->situacao), 1, 0, 'J');
- $this->SetX("150");
- $this->Cell(0, 5, utf8_decode("R$ ".$row->valortaxa), 1, 0, 'J');
- $this->SetX("170");
- $this->Cell(0, 5, utf8_decode("R$ ".$row->valorprojeto), 1, 0, 'J');
- $contRegional++;
- $contMunicipio++;
- $contador++;
- }
- $projeto_id_anterior = $row->id;
- }
- $this->Ln(5);
- $this->SetFont('arial', 'B', 10);
- $this->SetX("10");
- $this->Cell(0, 0, '', 1, 1, 'L');
- $this->SetFillColor(215, 215, 215);
- $this->Cell(0, 5, "Total de Produtores por Municipio: " . $contMunicipio, 1, 1, 'J', 1);
- $this->Cell(0, 5, "Total de Produtores por Regional: " . $contRegional, 1, 1, 'J', 1);
- } else {
- $this->SetFont('arial', 'B', 14);
- $this->Cell(0, 5, utf8_decode("NENHUM REGISTRO FOI ENCONTRADO."), 0, 0, 'C');
- }
- $contTotal +=$contador;
- $this->SetFont('arial', 'B', 10);
- $this->SetX("10");
- $this->Ln(5);
- $this->Cell(0, 0, '', 1, 1, 'L');
- $this->SetFillColor(215, 215, 215);
- $this->Cell(0, 5, "Total de Produtores: " . $contador, 1, 1, 'J', 1);
- TTransaction::close();
- }
- function Footer() {
- //Position at 1.5 cm from bottom
- $this->SetY(-15);
- //Arial italic 8
- $this->SetFont('Arial', 'I', 8);
- //Page number
- //data atual
- $data = date("d/m/Y H:i:s");
- $conteudo = "impresso em " . $data;
- $texto = "http://www.emater.rn.gov.br";
- //imprime uma linha... largura,altura, texto,borda,quebra de linha, alinhamento
- $this->Cell(0, 0, '', 1, 1, 'L');
- //imprime uma celula... largura,altura, texto,borda,quebra de linha, alinhamento
- $this->Cell(0, 5, $texto, 0, 0, 'L');
- $this->Cell(0, 5, 'Pag. ' . $this->PageNo() . ' de ' . '{nb}' . ' - ' . $conteudo, 0, 0, 'R');
- $this->Ln();
- }
- }
- $pdf = new PDF("P", "mm", "A4");
- $pdf->SetTitle(utf8_decode("Relatorio Projeto Situação - EMATER-RN"));
- $pdf->SetSubject(utf8_decode("Relatorio Projeto Situação - EMATER-RN"));
- $pdf->AliasNbPages();
- $pdf->AddPage();
- $pdf->SetFont('Times', '', 12);
- $pdf->ColumnDetail();
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement