$clquery->sql_record($clquery->sql);
$numrows = $clquery->numrows;
$result = $clquery->result;
for ($x = 0; $x < $numrows; $x++) {
    $alterar = "alterar_" . $x;
    if (isset(${$alterar})) {
        $alterando = true;
        $numer = $x;
        break;
    }
}
if ($alterando == true) {
    $clquery->sql_result($result, $numer, 0);
    $codigopla = $clquery->resultado;
    $clquery->sql_result($result, $numer, 5);
    db_redireciona("opcoesissqn.php?" . base64_encode("modificando=true&alter=true&nomecontri=" . $nomecontri . "&fonecontri=" . $fonecontri . "&mes=" . $mes . "&ano=" . $ano . "&numcgm=" . $numcgm . "&nomes=" . $nomes . "&inscricaow=" . $inscricaow . "&planilha=" . $codigopla));
    exit;
}
$anocorreto = $ano;
$mescorreto = $mes;
$clquery->sql_query("db_confplan", " * ", "", "");
$clquery->sql_record($clquery->sql);
if (pg_numrows($clquery->result) == 0) {
    $w10_valor = 0;
}
db_fieldsmemory($clquery->result, 0);
//#######################    Excluir planilha  #########################
$cl_issplan = new cl_issplan();
$cl_issplanit = new cl_issplanit();
$cl_issplaninscr = new cl_issplaninscr();
$cl_issplanitinscr = new cl_issplanitinscr();
                    } else {
                        db_redireciona("cai3_gerfinanc007.php?erro1=1");
                    }
                } else {
                    if (isset($inscr) && !empty($inscr)) {
                        if ($result = debitos_inscricao($inscr, 0, $tipo, $DB_DATACALC, db_getsession("DB_anousu"))) {
                            echo "<script> inscr = '{$inscr}'; </script>\n";
                        } else {
                            db_redireciona("cai3_gerfinanc007.php?erro1=1");
                        }
                    } else {
                        if (isset($numpre) && !empty($numpre)) {
                            if ($result = debitos_numpre($numpre, 0, $tipo, $DB_DATACALC, db_getsession("DB_anousu"))) {
                                echo "<script> numpre = '{$numpre}'; </script>\n";
                            } else {
                                db_redireciona("cai3_gerfinanc007.php?erro1=1");
                            }
                        }
                    }
                }
            }
        }
        ?>
<script> document.getElementById('int_perc2').style.width='85%'; </script><?php 
        $numrows = pg_numrows($result);
        echo "<form name=\"form1\" id=\"form1\" method=\"post\" target=\"reciboweb2\">\n";
        echo "<input type=\"hidden\" name=\"H_ANOUSU\" value=\"" . db_getsession("DB_anousu") . "\">\n";
        echo "<input type=\"hidden\" name=\"H_DATAUSU\" value=\"" . $DB_DATACALC . "\">\n";
        if ($numrows > 0) {
            echo "<input type=\"hidden\" id=\"ver_matric\" name=\"ver_matric\" value=\"" . @pg_result($result, 0, "k00_matric") . "\">\n";
            echo "<input type=\"hidden\" id=\"ver_inscr\" name=\"ver_inscr\" value=\"" . @pg_result($result, 0, "k00_inscr") . "\">\n";
 function imprime()
 {
     if ($this->modelo == 1) {
         // MODELO 1  - CARNES DE PARCELAMENTO
         if ($this->qtdcarne % 4 == 0) {
             $this->objpdf->AddPage();
         }
         $this->objpdf->SetLineWidth(0.05);
         $this->qtdcarne += 1;
         $top = $this->objpdf->GetY() - 5;
         $this->objpdf->SetFont('Arial', 'B', 8);
         $this->objpdf->SetTextColor(0, 0, 0);
         $this->objpdf->SetFillColor(250, 250, 250);
         $this->objpdf->SetX(17);
         $this->objpdf->Text(17, $top, $this->prefeitura, 0, 0, "L", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Text(105, $top, $this->prefeitura, 0, 1, "L", 0);
         $this->objpdf->SetX(170);
         $this->objpdf->SetX(17);
         $this->objpdf->SetFont('Arial', '', 7);
         $this->objpdf->Text(17, $top + 3, $this->secretaria, 0, 0, "L", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Text(105, $top + 3, $this->secretaria, 0, 1, "L", 0);
         $this->objpdf->Ln(2);
         $this->objpdf->SetFont('Arial', 'B', 8);
         $this->objpdf->SetX(10);
         $this->objpdf->Cell(90, 4, $this->tipodebito, 0, 0, "C", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Cell(90, 4, $this->tipodebito, 0, 1, "C", 0);
         $y = $this->objpdf->GetY() - 1;
         $this->objpdf->Image('imagens/files/' . $this->logo, 8, $y - 14, 8);
         $this->objpdf->Image('imagens/files/' . $this->logo, 95, $y - 14, 8);
         $this->objpdf->SetFont('Times', '', 5);
         $this->objpdf->RoundedRect(10, $y + 1, 32, 6, 2, 'DF', '1234');
         // matricula/ inscrição
         $this->objpdf->RoundedRect(43, $y + 1, 27, 6, 2, 'DF', '1234');
         // cod. de arrecadação
         $this->objpdf->RoundedRect(71, $y + 1, 20, 6, 2, 'DF', '1234');
         // parcela
         $this->objpdf->RoundedRect(10, $y + 8, 81, 12, 2, 'DF', '1234');
         // nome / endereço
         $this->objpdf->RoundedRect(10, $y + 21, 81, 14, 2, 'DF', '1234');
         // instruçoes
         $this->objpdf->RoundedRect(10, $y + 36, 39, 7, 2, 'DF', '1234');
         // vencimento
         $this->objpdf->RoundedRect(50, $y + 36, 41, 7, 2, 'DF', '1234');
         // valor
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 3, $this->titulo1);
         // matricula/ inscrição
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(13, $y + 6, $this->descr1);
         // numero da matricula ou inscricao
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(45, $y + 3, $this->titulo2);
         // cod. de arrecadação
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(47, $y + 6, $this->descr2);
         // numpre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(73, $y + 3, $this->titulo5);
         // Parcela
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(76, $y + 6, $this->descr5);
         // Parcela inicial e total de parcelas
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 10, $this->titulo3);
         // contribuinte/endereço
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(13, $y + 13, $this->descr3_1);
         // nome do contribuinte
         $this->objpdf->Text(13, $y + 16, $this->descr3_2);
         // endereço
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 23, $this->titulo4);
         // Instruções
         $this->objpdf->SetFont('Arial', 'B', 7);
         $xx = $this->objpdf->getx();
         $yy = $this->objpdf->gety();
         $this->objpdf->setleftmargin(10);
         $this->objpdf->setrightmargin(120);
         $this->objpdf->sety($y + 23);
         $this->objpdf->multicell(0, 3, $this->descr4_1);
         // Instruções 1 - linha 1
         $this->objpdf->multicell(0, 3, $this->descr4_2);
         // Instruções 1 - linha 2
         $this->objpdf->setxy($xx, $yy);
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 38, $this->titulo6);
         // Vencimento
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(20, $y + 41, $this->descr6);
         // Data de Vencimento
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(53, $y + 38, $this->titulo7);
         // valor
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(56, $y + 41, $this->descr7);
         // qtd de URM ou valor
         $this->objpdf->RoundedRect(95, $y + 1, 33, 6, 2, 'DF', '1234');
         // matricula / inscricao
         $this->objpdf->RoundedRect(129, $y + 1, 27, 6, 2, 'DF', '1234');
         // cod. arrecadacao
         $this->objpdf->RoundedRect(157, $y + 1, 20, 6, 2, 'DF', '1234');
         // parcela
         $this->objpdf->RoundedRect(178, $y + 1, 31, 6, 2, 'DF', '1234');
         // livre
         $this->objpdf->RoundedRect(95, $y + 8, 82, 13, 2, 'DF', '1234');
         // nome / endereco
         $this->objpdf->RoundedRect(95, $y + 22, 114, 13, 2, 'DF', '1234');
         // instrucoes
         $this->objpdf->RoundedRect(178, $y + 8, 31, 6, 2, 'DF', '1234');
         // vencimento
         $this->objpdf->RoundedRect(178, $y + 15, 31, 6, 2, 'DF', '1234');
         // valor
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 3, $this->titulo8);
         // matricula / inscricao
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(97, $y + 6, $this->descr8);
         // numero da matricula ou inscricao
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(131, $y + 3, $this->titulo9);
         // cod. de arrecadação
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(133, $y + 6, $this->descr9);
         // numpre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(159, $y + 3, $this->titulo10);
         // parcela
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(162, $y + 6, $this->descr10);
         // parcela e total das parcelas
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 3, $this->titulo13);
         // livre
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(183, $y + 6, $this->descr13);
         // livre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 10, $this->titulo11);
         // contribuinte / endereço
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(97, $y + 13, $this->descr11_1);
         // nome do contribuinte
         $this->objpdf->Text(97, $y + 16, $this->descr11_2);
         // endereço
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 24, $this->titulo12);
         // instruções
         $this->objpdf->SetFont('Arial', 'B', 7);
         $xx = $this->objpdf->getx();
         $yy = $this->objpdf->gety();
         $this->objpdf->setleftmargin(97);
         $this->objpdf->setrightmargin(2);
         $this->objpdf->sety($y + 24);
         $this->objpdf->multicell(0, 3, $this->descr12_1);
         // Instruções 2 - linha 1
         $this->objpdf->multicell(0, 3, $this->descr12_2);
         // Instruções 2 - linha 2
         $this->objpdf->setxy($xx, $yy);
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 10, $this->titulo14);
         // vencimento
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(180, $y + 13, $this->descr14);
         // data de vencimento
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 17, $this->titulo15);
         // valor
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(180, $y + 20, $this->descr15);
         // total de URM ou valor
         $this->objpdf->SetLineWidth(0.05);
         $this->objpdf->SetDash(1, 1);
         //        $this->objpdf->Line(5,$y+58,205,$y+58); // linha tracejada horizontal
         $this->objpdf->Line(93, $y - 30, 93, $y + 60);
         // linha tracejada vertical
         $this->objpdf->SetDash();
         $this->objpdf->Ln(70);
         $this->objpdf->SetFillColor(0, 0, 0);
         $this->objpdf->SetFont('Arial', '', 10);
         $this->objpdf->SetFont('Arial', '', 4);
         $this->objpdf->TextWithDirection(2, $y + 30, $this->texto, 'U');
         // texto no canhoto do carne
         $this->objpdf->SetFont('Arial', '', 9);
         $this->objpdf->Text(10, $y + 46, $this->descr16_1);
         //
         $this->objpdf->Text(10, $y + 50, $this->descr16_2);
         //
         $this->objpdf->Text(10, $y + 54, $this->descr16_3);
         //
         $this->objpdf->Text(105, $y + 38, $this->linha_digitavel);
         $this->objpdf->int25(95, $y + 39, $this->codigo_barras, 15, 0.341);
         /*
                 $y = $this->objpdf->gety();
                 $this->objpdf->setleftmargin(10);
                 $this->objpdf->setrightmargin(120);
                 $this->objpdf->sety($y+28);
                 $this->objpdf->multicell(0,3,$this->descr4_1); // Instruções 1 - linha 1
                 $this->objpdf->ln(39.5);
         */
     } else {
         if ($this->modelo == 22) {
             $this->objpdf->AliasNbPages();
             $this->objpdf->AddPage();
             $this->objpdf->Setfont('Arial', 'B', 12);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->roundedrect(05, 05, 200, 288, 2, 'DF', '1234');
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->roundedrect(10, 07, 190, 183, 2, 'DF', '1234');
             $this->objpdf->Image('imagens/files/' . $this->logo, 45, 9, 20);
             $this->objpdf->text(70, 15, $this->prefeitura);
             $this->objpdf->Setfont('Arial', '', 12);
             $this->objpdf->text(70, 20, $this->enderpref);
             $this->objpdf->text(70, 25, $this->municpref);
             $this->objpdf->text(70, 30, $this->telefpref);
             $this->objpdf->text(70, 35, $this->emailpref);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(15, 45, 110, 35, 2, 'DF', '1234');
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(16, 47, 'Identificação:');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(16, 51, 'Nome :');
             $this->objpdf->text(32, 51, $this->nome);
             $this->objpdf->text(16, 56, 'Endereço :');
             $this->objpdf->text(32, 56, $this->ender);
             $this->objpdf->text(16, 60, 'Município :');
             $this->objpdf->text(32, 60, $this->munic);
             $this->objpdf->text(16, 64, 'CEP :');
             $this->objpdf->text(32, 64, $this->cep);
             $this->objpdf->text(16, 68, 'Data :');
             $this->objpdf->text(32, 68, date('d/m/Y'));
             $this->objpdf->text(50, 68, 'Hora: ' . date("H:i:s"));
             $this->objpdf->text(16, 72, $this->tipoinscr);
             $this->objpdf->text(32, 72, $this->nrinscr);
             $this->objpdf->text(16, 76, 'IP :');
             $this->objpdf->text(32, 76, $this->ip);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->Roundedrect(130, 45, 65, 35, 2, 'DF', '1234');
             $this->objpdf->text(132, 47, $this->tipoinscr);
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 50, $this->nrinscr);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 55, 'Logradouro :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 58, $this->nomepri);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 63, 'Número/Complemento :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 66, $this->nrpri . "      " . $this->complpri);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 71, 'Bairro :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 74, $this->bairropri);
             $this->objpdf->Setfont('Arial', 'B', 11);
             $this->objpdf->text(70, 87, 'RECIBO VÁLIDO ATÉ: ' . $this->datacalc);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(15, 90, 180, 65, 2, 'DF', '1234');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->SetXY(17, 96);
             if ($this->taxabanc != 0) {
                 $this->objpdf->Cell(20, 4, 'Taxa Bancária', 0, 0, "L", 0);
                 $this->objpdf->Cell(20, 4, db_formatar($this->taxabanc, 'f'), 0, 1, "R", 0);
             }
             for ($i = 0; $i < $this->linhasdadospagto; $i++) {
                 $this->objpdf->setx(17);
                 $this->objpdf->cell(5, 4, trim(pg_result($this->recorddadospagto, $i, $this->receita)), 0, 0, "C", 0);
                 if (trim(pg_result($this->recorddadospagto, $i, $this->ddreceita)) == '') {
                     $this->objpdf->cell(70, 4, trim(pg_result($this->recorddadospagto, $i, $this->dreceita)), 0, 0, "L", 0);
                 } else {
                     $this->objpdf->cell(70, 4, trim(pg_result($this->recorddadospagto, $i, $this->ddreceita)), 0, 0, "L", 0);
                 }
                 $this->objpdf->cell(15, 4, db_formatar(pg_result($this->recorddadospagto, $i, $this->valor), 'f'), 0, 1, "R", 0);
             }
             $this->objpdf->SetXY(15, 158);
             $this->objpdf->multicell(0, 4, 'HISTÓRICO :   ' . $this->historico);
             $this->objpdf->setx(15);
             $this->objpdf->multicell(0, 4, $this->histparcel);
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->Roundedrect(10, 195, 190, 46, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 6);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(40, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(93, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(146, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->text(42, 202, 'Vencimento');
             $this->objpdf->text(95, 202, 'Código de Arrecadação');
             $this->objpdf->text(148, 202, 'Valor a Pagar');
             $this->objpdf->setfont('Arial', '', 10);
             $this->objpdf->text(48, 207, $this->dtvenc);
             $this->objpdf->text(101, 207, $this->numpre);
             $this->objpdf->text(153, 207, $this->valtotal);
             $this->objpdf->SetDash(0.8, 0.8);
             $this->objpdf->line(5, 242.5, 205, 242.5);
             $this->objpdf->SetDash();
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->Roundedrect(10, 244, 190, 46, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 12);
             $this->objpdf->setfillcolor(0, 0, 0);
             $this->objpdf->Image('imagens/files/' . $this->logo, 12, 200, 25);
             $this->objpdf->text(60, 218, $this->linhadigitavel);
             $this->objpdf->int25(60, 220, $this->codigobarras, 15, 0.341);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(40, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(93, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(146, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 6);
             $this->objpdf->text(42, 252, 'Vencimento');
             $this->objpdf->text(95, 252, 'Código de Arrecadação');
             $this->objpdf->text(148, 252, 'Valor a Pagar');
             $this->objpdf->setfont('Arial', '', 10);
             $this->objpdf->text(48, 257, $this->dtvenc);
             $this->objpdf->text(101, 257, $this->numpre);
             $this->objpdf->text(153, 257, $this->valtotal);
             $this->objpdf->Image('imagens/files/' . $this->logo, 12, 250, 25);
             $this->objpdf->SetFont('Arial', '', 5);
             $this->objpdf->text(10, $this->objpdf->h - 2, 'Base: ' . @$GLOBALS["DB_NBASE"]);
             $this->objpdf->setfillcolor(0, 0, 0);
             $this->objpdf->setfont('Arial', '', 12);
             $this->objpdf->text(60, 268, $this->linhadigitavel);
             $this->objpdf->int25(60, 270, $this->codigobarras, 15, 0.341);
         } else {
             if ($this->modelo == 3) {
                 $this->objpdf->SetTextColor(0, 0, 0);
                 $this->objpdf->SetFont('Arial', 'B', 12);
                 $coluna = 44;
                 $linha = 35;
                 $this->objpdf->SetLineWidth(1);
                 $this->objpdf->RoundedRect(37, 0.2, 137, 195, 2, '1234');
                 $this->objpdf->SetLineWidth(0.5);
                 $this->objpdf->roundedrect(39, 2, 133, 191, 2, '1234');
                 $this->objpdf->SetLineWidth(0.2);
                 $this->objpdf->Image('imagens/files/Brasao.png', 43, 5, 20);
                 $this->objpdf->Image('imagens/files/Brasao.jpg', 60, 30, 100);
                 //	$this->objpdf->roundedrect(42,$linha+30,127,35,2,'1234');
                 //	$this->objpdf->roundedrect(42,$linha+72,127,15,2,'1234'); // obs da atividade principal
                 //  	$this->objpdf->roundedrect(42,$linha+88,127,5,2,'1234'); // descricao da atividade secundaria
                 //	$this->objpdf->roundedrect(42,$linha+94,127,15,2,'1234'); // obs da atividade secundaria
                 //	$this->objpdf->setdrawcolor(235);
                 $this->objpdf->setxy(65, 5);
                 $this->objpdf->setfont('Arial', 'B', 13);
                 $this->objpdf->Multicell(0, 8, $this->prefeitura, "C");
                 // prefeitura
                 $this->objpdf->setxy(65, 10);
                 $this->objpdf->setfont('Arial', 'B', 13);
                 $this->objpdf->setleftmargin(50);
                 $this->objpdf->setrightmargin(50);
                 $this->objpdf->Multicell(0, 8, $this->tipoalvara, 0, "C", 0);
                 // tipo de alvara
                 $this->objpdf->settextcolor(150);
                 $this->objpdf->setxy(85, 25);
                 $this->objpdf->setfont('Arial', 'B', 60);
                 $this->objpdf->Multicell(0, 8, date('Y'), "C");
                 // exercicio
                 $this->objpdf->settextcolor(0, 0, 0);
                 $this->objpdf->setxy(84, 24);
                 $this->objpdf->setfont('Arial', 'B', 60);
                 $this->objpdf->Multicell(0, 8, date('Y'), "C");
                 // exercicio
                 $this->objpdf->Ln(6);
                 //	$this->objpdf->sety(38);
                 $this->objpdf->SetFont('Arial', '', 11);
                 $this->objpdf->Multicell(0, 6, $this->texto);
                 // texto
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 35, 'CCM:');
                 // atividade / inscricao
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 35, $this->ativ . ' / ' . $this->nrinscr);
                 // atividade / inscricao
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 39, "NOME/RAZAO SOCIAL: ");
                 // nome
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 39, $this->nome);
                 // nome
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 43, "ENDEREÇO: ");
                 // endereco
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 43, $this->ender);
                 // endereco
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 47, "NÚMERO: ");
                 // endereco
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 47, $this->numero == "" ? "" : $this->numero);
                 if ($this->compl != "") {
                     $this->objpdf->SetFont('Arial', 'B', 9);
                     $this->objpdf->Text($coluna + 60, $linha + 47, "COMPLEMENTO: ");
                     // endereco
                     $this->objpdf->SetFont('Arial', '', 9);
                     $this->objpdf->Text($coluna + 90, $linha + 47, $this->compl == "" ? "" : $this->compl);
                 }
                 $this->objpdf->setx(40);
                 if ($this->q02_memo != '') {
                     $this->objpdf->SetFont('Arial', 'B', 9);
                     $this->objpdf->Text($coluna, $linha + 51, "OBSERVAÇÃO: ");
                     // observação
                     $this->objpdf->SetFont('Arial', '', 9);
                     $this->objpdf->sety($linha + 52);
                     $this->objpdf->Multicell(0, 3, $this->q02_memo);
                     // texto
                     $this->objpdf->SetFont('Arial', 'B', 10);
                     $this->objpdf->roundedrect(42, $linha + 30, 127, 35, 2, '1234');
                     $linha = 102;
                 } else {
                     $this->objpdf->roundedrect(42, $linha + 30, 127, 20, 2, '1234');
                     $linha = 87;
                 }
                 $this->objpdf->sety($linha);
                 $this->objpdf->roundedrect(42, $linha - 1, 127, 5, 2, '1234');
                 $this->objpdf->SetFont('Arial', 'B', 8);
                 $this->objpdf->Ln(0.5);
                 $this->objpdf->setx(45);
                 $this->objpdf->Multicell(0, 3, "ATIVIDADE PRINCIPAL: " . $this->descrativ);
                 // descrição da atividade principal
                 $linha += 6;
                 $obs = '';
                 if (isset($this->q03_atmemo[$this->ativ])) {
                     if ($this->q03_atmemo[$this->ativ] != '') {
                         $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                         // obs da atividade principal
                         $obs = $this->q03_atmemo[$this->ativ];
                         $this->objpdf->Ln(3);
                         $this->objpdf->SetFont('Arial', '', 7);
                         $this->objpdf->Multicell(0, 3, $this->q03_atmemo[$this->ativ]);
                         // texto
                         $linha += 16;
                     }
                 }
                 $this->objpdf->sety($linha);
                 $num_outras = count($this->outrasativs);
                 $x = 105;
                 if ($num_outras > 0) {
                     $x = $x + 4;
                     reset($this->outrasativs);
                     for ($i = 0; $i < $num_outras; $i++) {
                         $yyy = $this->objpdf->gety();
                         $chave = key($this->outrasativs);
                         $obs = '';
                         if (isset($this->q03_atmemo[$chave])) {
                             $obs = $this->q03_atmemo[$chave];
                         }
                         $this->objpdf->SetFont('Arial', 'B', 8);
                         //             $this->objpdf->roundedrect(42,$yyy-1,127,5,2,'1234'); // descricao da atividade secundaria
                         $this->objpdf->Ln(0.5);
                         $this->objpdf->setx(45);
                         $this->objpdf->Multicell(0, 3, "ATIVIDADE SECUNDÁRIA: " . $this->outrasativs[$chave]);
                         // texto
                         $linha += 6;
                         if ($obs != "") {
                             $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                             // obs da atividade secundaria
                             $this->objpdf->Ln(3);
                             $this->objpdf->SetFont('Arial', '', 7);
                             $this->objpdf->Multicell(0, 3, $obs);
                             // texto
                             $linha += 16;
                         }
                         $x = $x + 4;
                         next($this->outrasativs);
                         //             $this->objpdf->ln(2.5);
                         $this->objpdf->sety($linha);
                     }
                 }
                 $x = 64;
                 //        if($this->q02_obs!=''){
                 //	  $this->objpdf->Text($coluna,$linha+$x,"OBSERVAÇÃO: "); // descrição da atividade principal
                 //	  $this->objpdf->Text($coluna + 45,$linha+$x,$this->q02_obs); // descrição da atividade principal
                 //	  $x=$x+4;
                 //	}
                 //        $linha = $this->objpdf->gety();
                 $this->objpdf->SetFont('Arial', 'B', 12);
                 $this->objpdf->Text($coluna + 55, $linha + 5, "Sapiranga, " . date('d') . " de " . db_mes(date('m')) . " de " . date('Y') . ".");
                 // data
                 $this->objpdf->sety(125);
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Multicell(0, 6, $this->obs);
                 // observação
                 $this->objpdf->setfont('arial', '', 6);
                 $this->objpdf->SetXY($coluna - 18, 165);
                 $this->objpdf->MultiCell(90, 4, '..........................................................................................' . "\n" . 'SECRETÁRIO DA IND. COM. E TURISMO', 0, "C", 0);
                 $this->objpdf->SetXY($coluna + 50, 165);
                 $this->objpdf->MultiCell(90, 4, '..........................................................................................', 0, "C", 0);
                 //        $this->objpdf->SetXY($coluna-35,160);
                 //        $this->objpdf->MultiCell(90,4,'..........................................................................................'."\n".'SECRETÁRIO DA IND. COM. E TURISMO',0,"C",0);
                 //        $this->objpdf->SetXY($coluna+35,160);
                 //        $this->objpdf->MultiCell(90,4,'..........................................................................................',0,"C",0);
                 $this->objpdf->sety(180);
                 $this->objpdf->setfont('arial', 'B', 12);
                 $this->objpdf->multicell(0, 8, 'FIXAR EM LUGAR VISÍVEL', 1, "C");
                 $this->objpdf->SetFont('Arial', 'B', 10);
             } else {
                 if ($this->modelo == 4) {
                     // BOLETO BANCÁRIO
                     $linha = 186;
                     $pdf->Line(47, $linha, 47, $linha + 9);
                     $pdf->Line(63, $linha, 63, $linha + 9);
                     $pdf->SetLineWidth(0.6);
                     $pdf->Line(10, $linha + 9, 195, $linha + 9);
                     $pdf->SetLineWidth(0.2);
                     $pdf->Line(10, $linha + 17, 195, $linha + 17);
                     $pdf->Line(10, $linha + 25, 195, $linha + 25);
                     $pdf->Line(10, $linha + 33, 195, $linha + 33);
                     $pdf->Line(10, $linha + 41, 195, $linha + 41);
                     $pdf->Line(149, $linha + 49, 195, $linha + 49);
                     $pdf->Line(149, $linha + 57, 195, $linha + 57);
                     $pdf->Line(149, $linha + 65, 195, $linha + 65);
                     $pdf->Line(149, $linha + 73, 195, $linha + 73);
                     $pdf->Line(10, $linha + 81, 195, $linha + 81);
                     $pdf->Line(149, $linha + 9, 149, $linha + 81);
                     $pdf->Line(169, $linha + 9, 169, $linha + 17);
                     $pdf->Line(40, $linha + 25, 40, $linha + 33);
                     $pdf->Line(86, $linha + 25, 86, $linha + 33);
                     $pdf->Line(112, $linha + 25, 112, $linha + 33);
                     $pdf->Line(125, $linha + 25, 125, $linha + 33);
                     $pdf->Line(45, $linha + 33, 45, $linha + 41);
                     $pdf->Line(65, $linha + 33, 65, $linha + 41);
                     $pdf->Line(91, $linha + 33, 91, $linha + 41);
                     $pdf->Line(121, $linha + 33, 121, $linha + 41);
                     $pdf->Line(10, $linha + 93, 195, $linha + 93);
                     //codigo de barras
                     $this->objpdf->SetFillColor(0, 0, 0);
                     $this->objpdf->int25(10, $linha + 94, $this->codigo_barras, 20, 0.341);
                     // quadrado inferior //
                     $this->objpdf->Image('imagens/files/Brasao.png', 10, 187, 35, 7);
                     $this->objpdf->SetFont('Arial', 'b', 14);
                     $this->objpdf->Text(49, $linha + 7, $this->numbanco);
                     // numero do banco
                     $this->objpdf->SetFont('Arial', 'b', 11);
                     $this->objpdf->Text(70, $linha + 7, $this->linha_digitavel);
                     $this->objpdf->SetFont('Arial', 'b', 5);
                     $this->objpdf->Text(13, $linha + 11, "Local de Pagamento");
                     $this->objpdf->Text(151, $linha + 11, "Parcela");
                     $this->objpdf->Text(171, $linha + 11, "Vencimento");
                     $this->objpdf->Text(13, $linha + 19, "Cedente");
                     $this->objpdf->Text(151, $linha + 19, "Agência/Código Cedente");
                     $this->objpdf->Text(13, $linha + 27, "Data do Documento");
                     $this->objpdf->Text(42, $linha + 27, "Número do Documento");
                     $this->objpdf->Text(88, $linha + 27, "Espécie Doc.");
                     $this->objpdf->Text(114, $linha + 27, "Aceite");
                     $this->objpdf->Text(127, $linha + 27, "Data do Processamento");
                     $this->objpdf->Text(151, $linha + 27, "Nosso Número");
                     $this->objpdf->Text(13, $linha + 35, "Código do Cedente");
                     $this->objpdf->Text(47, $linha + 35, "Carteira");
                     $this->objpdf->Text(67, $linha + 35, "Espécie");
                     $this->objpdf->Text(93, $linha + 35, "Quantidade");
                     $this->objpdf->Text(123, $linha + 35, "Valor");
                     $this->objpdf->Text(151, $linha + 35, "( = ) Valor do Documento");
                     $this->objpdf->Text(13, $linha + 43, "Instruções");
                     $this->objpdf->Text(151, $linha + 43, "( - ) Desconto / Abatimento");
                     $this->objpdf->Text(151, $linha + 51, "( - ) Outras Deduções");
                     $this->objpdf->Text(151, $linha + 59, "( + ) Mora / Multa");
                     $this->objpdf->Text(151, $linha + 67, "( + ) Outros Acrécimos");
                     $this->objpdf->Text(151, $linha + 75, "( = ) Valor Cobrado");
                     $this->objpdf->Text(13, $linha + 83, "Sacado");
                     $this->objpdf->Text(13, $linha + 91, "Sacador/Avalista");
                     $this->objpdf->Text(160, $linha + 99, "Autenticação Mecânica");
                     $this->objpdf->SetFont('Arial', 'b', 8);
                     $this->objpdf->Text(13, $linha + 15, $this->localpagamento);
                     // local de pagamento
                     $this->objpdf->SetFont('Arial', '', 10);
                     $this->objpdf->Text(151, $linha + 15, $this->parcela);
                     // parcela
                     $this->objpdf->Text(171, $linha + 15, $this->dtvenc);
                     // vencimento
                     $this->objpdf->Text(13, $linha + 23, $this->cedente);
                     // cedente
                     $this->objpdf->Text(151, $linha + 23, $this->agencia_cedente);
                     // agencia do cedente
                     $this->objpdf->Text(13, $linha + 31, $this->data_documento);
                     // data do documento
                     $this->objpdf->Text(42, $linha + 31, $this->numero_documento);
                     // numero do documento
                     $this->objpdf->Text(88, $linha + 31, $this->especie_doc);
                     // especie do documento
                     $this->objpdf->Text(114, $linha + 31, $this->aceite);
                     // aceite
                     $this->objpdf->Text(127, $linha + 31, $this->data_processamento);
                     // data do processamento
                     $this->objpdf->Text(151, $linha + 31, $this->nosso_numero);
                     // nosso numero
                     $this->objpdf->Text(13, $linha + 39, $this->codigo_cedente);
                     // codigo do cedente
                     $this->objpdf->Text(47, $linha + 39, $this->carteira);
                     // carteira
                     $this->objpdf->Text(67, $linha + 39, $this->especie);
                     // especie
                     $this->objpdf->Text(93, $linha + 39, $this->quantidade);
                     // quantidade
                     $this->objpdf->Text(123, $linha + 39, $this->valor);
                     // valor
                     $this->objpdf->Text(151, $linha + 39, $this->valor_documento);
                     // valor do documento
                     $this->objpdf->Text(20, $linha + 54, $this->instrucoes1);
                     // instrucoes 1
                     $this->objpdf->Text(20, $linha + 58, $this->instrucoes2);
                     // instrucoes 2
                     $this->objpdf->Text(20, $linha + 62, $this->instrucoes3);
                     // instrucoes 3
                     $this->objpdf->Text(15, $linha + 70, $this->instrucoes4);
                     // instrucoes 4
                     $this->objpdf->Text(20, $linha + 74, $this->instrucoes5);
                     // instrucoes 5
                     $this->objpdf->Text(151, $linha + 47, $this->desconto_abatimento);
                     // desconto/abatimento
                     $this->objpdf->Text(151, $linha + 55, $this->outras_deducoes);
                     // outras deducoes
                     $this->objpdf->Text(151, $linha + 63, $this->mora_multa);
                     // multa
                     $this->objpdf->Text(151, $linha + 71, $this->outros_acrecimos);
                     // outros acrescimos
                     $this->objpdf->Text(151, $linha + 79, $this->valor_cobrado);
                     // valor cobrado
                     $this->objpdf->Text(29, $linha + 85, $this->sacado1);
                     // sacado 1
                     $this->objpdf->Text(29, $linha + 88, $this->sacado2);
                     // sacado 2
                     $this->objpdf->Text(29, $linha + 91, $this->sacado3);
                     // sacado 3
                 } else {
                     if ($this->modelo == 2) {
                         //// RECIBO
                         $this->objpdf->AliasNbPages();
                         $this->objpdf->AddPage();
                         $this->objpdf->settopmargin(1);
                         $this->objpdf->line(2, 148.5, 208, 148.5);
                         $xlin = 20;
                         $xcol = 4;
                         for ($i = 0; $i < 2; $i++) {
                             $this->objpdf->setfillcolor(245);
                             $this->objpdf->roundedrect($xcol - 2, $xlin - 18, 206, 144.5, 2, 'DF', '1234');
                             $this->objpdf->setfillcolor(255, 255, 255);
                             //		$this->objpdf->roundedrect(10,07,190,183,2,'DF','1234');
                             $this->objpdf->Setfont('Arial', 'B', 11);
                             $this->objpdf->text(150, $xlin - 13, 'RECIBO VÁLIDO ATÉ: ');
                             $this->objpdf->text(159, $xlin - 8, $this->datacalc);
                             $this->objpdf->Image('imagens/files/' . $this->logo, 15, $xlin - 17, 12);
                             $this->objpdf->Setfont('Arial', 'B', 9);
                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                             $this->objpdf->Setfont('Arial', '', 9);
                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                             //		$this->objpdf->setfillcolor(245);
                             $this->objpdf->Roundedrect($xcol, $xlin + 2, $xcol + 119, 20, 2, 'DF', '1234');
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->text($xcol + 2, $xlin + 4, 'Identificação:');
                             $this->objpdf->Setfont('Arial', '', 8);
                             $this->objpdf->text($xcol + 2, $xlin + 7, $this->tipoinscr);
                             $this->objpdf->text($xcol + 17, $xlin + 7, $this->nrinscr);
                             $this->objpdf->text($xcol + 30, $xlin + 7, 'Nome :');
                             $this->objpdf->text($xcol + 40, $xlin + 7, $this->nome);
                             $this->objpdf->text($xcol + 2, $xlin + 11, 'Endereço :');
                             $this->objpdf->text($xcol + 17, $xlin + 11, $this->ender);
                             $this->objpdf->text($xcol + 2, $xlin + 15, 'Município :');
                             $this->objpdf->text($xcol + 17, $xlin + 15, $this->munic);
                             $this->objpdf->text($xcol + 75, $xlin + 15, 'CEP :');
                             $this->objpdf->text($xcol + 82, $xlin + 15, $this->cep);
                             $this->objpdf->text($xcol + 2, $xlin + 19, 'Data :');
                             $this->objpdf->text($xcol + 17, $xlin + 19, date("d-m-Y", db_getsession("DB_datausu")));
                             $this->objpdf->text($xcol + 40, $xlin + 19, 'Hora: ' . date("H:i:s"));
                             $this->objpdf->text($xcol + 75, $xlin + 19, 'IP :');
                             $this->objpdf->text($xcol + 82, $xlin + 19, $this->ip);
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->Roundedrect($xcol + 126, $xlin + 2, 76, 20, 2, 'DF', '1234');
                             $this->objpdf->text($xcol + 128, $xlin + 7, $this->tipoinscr1);
                             $this->objpdf->text($xcol + 145, $xlin + 7, $this->nrinscr1);
                             $this->objpdf->text($xcol + 128, $xlin + 11, $this->tipolograd);
                             $this->objpdf->text($xcol + 145, $xlin + 11, $this->nomepri);
                             $this->objpdf->text($xcol + 128, $xlin + 15, $this->tipocompl);
                             $this->objpdf->text($xcol + 145, $xlin + 15, $this->nrpri . "      " . $this->complpri);
                             $this->objpdf->text($xcol + 128, $xlin + 19, $this->tipobairro);
                             $this->objpdf->text($xcol + 145, $xlin + 19, $this->bairropri);
                             //		$this->objpdf->setfillcolor(245);
                             $this->objpdf->Roundedrect($xcol, $xlin + 24, 202, 45, 2, 'DF', '1234');
                             $this->objpdf->sety($xlin + 24);
                             $maiscol = 0;
                             $yy = $this->objpdf->gety();
                             for ($ii = 0; $ii < $this->linhasdadospagto; $ii++) {
                                 if ($ii == 14) {
                                     $maiscol = 100;
                                     $this->objpdf->sety($yy);
                                 }
                                 if ($ii == 0 || $ii == 14) {
                                     $this->objpdf->setx($xcol + 3 + $maiscol);
                                     $this->objpdf->cell(5, 3, "Rec", 0, 0, "L", 0);
                                     $this->objpdf->cell(7, 3, "Reduz", 0, 0, "L", 0);
                                     $this->objpdf->cell(63, 3, "Descrição", 0, 0, "L", 0);
                                     $this->objpdf->cell(15, 3, "Valor", 0, 1, "R", 0);
                                 }
                                 $this->objpdf->setx($xcol + 3 + $maiscol);
                                 $this->objpdf->cell(5, 3, trim(pg_result($this->recorddadospagto, $ii, $this->receita)), 0, 0, "R", 0);
                                 $this->objpdf->cell(7, 3, "(" . trim(pg_result($this->recorddadospagto, $ii, $this->receitared)) . ")", 0, 0, "R", 0);
                                 if (trim(pg_result($this->recorddadospagto, $ii, $this->ddreceita)) == '') {
                                     $this->objpdf->cell(63, 3, trim(pg_result($this->recorddadospagto, $ii, $this->dreceita)), 0, 0, "L", 0);
                                 } else {
                                     $this->objpdf->cell(63, 3, trim(pg_result($this->recorddadospagto, $ii, $this->ddreceita)), 0, 0, "L", 0);
                                 }
                                 $this->objpdf->cell(15, 3, db_formatar(pg_result($this->recorddadospagto, $ii, $this->valor), 'f'), 0, 1, "R", 0);
                             }
                             $this->objpdf->Roundedrect($xcol, $xlin + 71, 202, 30, 2, 'DF', '1234');
                             $this->objpdf->SetY($xlin + 72);
                             $this->objpdf->SetX($xcol + 3);
                             $this->objpdf->multicell(0, 4, 'HISTÓRICO :   ' . $this->historico);
                             $this->objpdf->SetX($xcol + 3);
                             $this->objpdf->multicell(0, 4, $this->histparcel);
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->setx(15);
                             $this->objpdf->Roundedrect(128, $xlin + 103, 38, 10, 2, 'DF', '1234');
                             $this->objpdf->Roundedrect(168, $xlin + 103, 38, 10, 2, 'DF', '1234');
                             $this->objpdf->Roundedrect(146, $xlin + 115, 40, 10, 2, 'DF', '1234');
                             $this->objpdf->text(130, $xlin + 105, 'Vencimento');
                             $this->objpdf->text(170, $xlin + 105, 'Código de Arrecadação');
                             $this->objpdf->text(148, $xlin + 118, 'Valor a Pagar');
                             $this->objpdf->setfont('Arial', '', 10);
                             $this->objpdf->text(135, $xlin + 110, $this->dtvenc);
                             $this->objpdf->text(170, $xlin + 110, $this->numpre);
                             $this->objpdf->text(155, $xlin + 123, $this->valtotal);
                             $this->objpdf->setfillcolor(0, 0, 0);
                             $this->objpdf->SetFont('Arial', '', 4);
                             //	        $this->objpdf->TextWithDirection(1.5,$xlin+60,$this->texto,'U'); // texto no canhoto do carne
                             $this->objpdf->TextWithDirection(1.5, $xlin + 60, $this->texto . ' - ' . ($i == 1 ? '2ª VIA' : '1ª VIA'), 'U');
                             // texto no canhoto do carne
                             $this->objpdf->setfont('Arial', '', 11);
                             $this->objpdf->text(10, $xlin + 108, $this->linhadigitavel);
                             $this->objpdf->int25(10, $xlin + 110, $this->codigobarras, 15, 0.341);
                             $xlin = 169;
                         }
                     } else {
                         if ($this->modelo == 5) {
                             ////////// MODELO 5  -  AUTORIZACAO DE EMPENHO
                             if (strtoupper(trim($this->municpref)) == 'GUAIBA') {
                                 $this->objpdf->AliasNbPages();
                                 $this->objpdf->AddPage();
                                 $this->objpdf->settopmargin(1);
                                 $pagina = 1;
                                 $xlin = 20;
                                 $xcol = 4;
                                 $this->objpdf->setfillcolor(245);
                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                 $this->objpdf->setfillcolor(255, 255, 255);
                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                 $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                                 $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                 $this->objpdf->text(137.5, $xlin - 8, 'PROCESSO DE COMPRA N' . CHR(176));
                                 $this->objpdf->text(185, $xlin - 8, db_formatar(pg_result($this->recorddositens, 0, $this->Snumeroproc), 's', '0', 6, 'e'));
                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                 //.$this->logo
                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                 $this->objpdf->Setfont('Arial', '', 7);
                                 $this->objpdf->text(40, $xlin - 12, $this->enderpref);
                                 $this->objpdf->text(40, $xlin - 9, $this->municpref);
                                 $this->objpdf->text(40, $xlin - 6, $this->telefpref);
                                 $this->objpdf->text(40, $xlin - 3, $this->emailpref);
                                 $this->objpdf->text(40, $xlin, db_formatar($this->cgcpref, 'cnpj'));
                                 $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 28, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 2, $xlin + 4, 'Dados da Compra');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 2, $xlin + 8, 'Licitação');
                                 $this->objpdf->text($xcol + 2, $xlin + 12, 'Tipo de Compra');
                                 $this->objpdf->text($xcol + 2, $xlin + 16, 'Prazo de Entrega');
                                 $this->objpdf->text($xcol + 2, $xlin + 20, 'Observações');
                                 $this->objpdf->text($xcol + 2, $xlin + 24, 'Cond.de Pagto');
                                 $this->objpdf->text($xcol + 2, $xlin + 28, 'Outras Condições');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 27, $xlin + 8, ':  ' . $this->num_licitacao . '  -  ' . $this->descr_licitacao);
                                 $this->objpdf->text($xcol + 27, $xlin + 12, ':  ' . $this->descr_tipocompra);
                                 $this->objpdf->text($xcol + 27, $xlin + 16, ':  ' . $this->prazo_ent);
                                 $this->objpdf->text($xcol + 27, $xlin + 20, ':  ' . $this->obs);
                                 $this->objpdf->text($xcol + 27, $xlin + 24, ':  ' . $this->cond_pag);
                                 $this->objpdf->text($xcol + 27, $xlin + 28, ':  ' . $this->out_cond);
                                 $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 28, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 110, $xlin + 4, 'Dados da Dotação');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 108, $xlin + 8, 'Dotação');
                                 $this->objpdf->text($xcol + 108, $xlin + 11.5, 'Órgão');
                                 $this->objpdf->text($xcol + 108, $xlin + 15, 'Unidade');
                                 $this->objpdf->text($xcol + 108, $xlin + 18.5, 'Proj/Ativ');
                                 $this->objpdf->text($xcol + 108, $xlin + 22, 'Elemento');
                                 $this->objpdf->text($xcol + 108, $xlin + 25.5, 'Recurso');
                                 $this->objpdf->text($xcol + 178, $xlin + 25.5, 'Reduz');
                                 $this->objpdf->text($xcol + 108, $xlin + 29, 'Destino');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 122, $xlin + 8, ':  ' . $this->dotacao);
                                 $this->objpdf->text($xcol + 122, $xlin + 11.5, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                 $this->objpdf->text($xcol + 122, $xlin + 15, ':  ' . db_formatar($this->orgao, 'orgao') . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                 $this->objpdf->text($xcol + 122, $xlin + 18.5, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                 $this->objpdf->text($xcol + 122, $xlin + 22, ':  ' . $this->descrdotacao);
                                 $this->objpdf->text($xcol + 122, $xlin + 25.5, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                 $this->objpdf->text($xcol + 188, $xlin + 25.5, ':  ' . $this->coddot . '-' . db_CalculaDV($this->coddot));
                                 $this->objpdf->text($xcol + 122, $xlin + 29, ':  ' . $this->destino);
                                 $this->objpdf->rect($xcol, $xlin + 32, $xcol + 198, 20, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 2, $xlin + 34, 'Dados do Credor');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 109, $xlin + 38, 'Numcgm');
                                 $this->objpdf->text($xcol + 150, $xlin + 38, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                 $this->objpdf->text($xcol + 2, $xlin + 38, 'Nome');
                                 $this->objpdf->text($xcol + 2, $xlin + 42, 'Endereço');
                                 $this->objpdf->text($xcol + 102, $xlin + 42, 'Complemento');
                                 $this->objpdf->text($xcol + 2, $xlin + 46, 'Município');
                                 $this->objpdf->text($xcol + 115, $xlin + 46, 'CEP');
                                 $this->objpdf->text($xcol + 2, $xlin + 50, 'Contato');
                                 $this->objpdf->text($xcol + 110, $xlin + 50, 'Telefone');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 159, $xlin + 38, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')));
                                 $this->objpdf->text($xcol + 122, $xlin + 38, ':  ' . $this->numcgm);
                                 $this->objpdf->text($xcol + 18, $xlin + 38, ':  ' . $this->nome);
                                 $this->objpdf->text($xcol + 18, $xlin + 42, ':  ' . $this->ender);
                                 $this->objpdf->text($xcol + 122, $xlin + 42, ':  ' . $this->compl);
                                 $this->objpdf->text($xcol + 18, $xlin + 46, ':  ' . $this->munic . '-' . $this->uf);
                                 $this->objpdf->text($xcol + 122, $xlin + 46, ':  ' . $this->cep);
                                 $this->objpdf->text($xcol + 18, $xlin + 50, ':  ' . $this->contato);
                                 $this->objpdf->text($xcol + 122, $xlin + 50, ':  ' . $this->telefone);
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 //	$this->objpdf->Roundedrect($xcol,$xlin+54,202,80,2,'DF','1234');
                                 $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol, $xlin + 60, 15, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 155, 2, 'DF', '');
                                 $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 155, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol, $xlin + 205, 142, 10, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 142, $xlin + 205, 30, 10, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 172, $xlin + 205, 30, 10, 2, 'DF', '34');
                                 $this->objpdf->text($xcol + 120, $xlin + 211, 'T O T A L');
                                 $this->objpdf->SetXY(172, $xlin + 205);
                                 $this->objpdf->cell(30, 10, db_formatar($this->valtotal, 'f'), 0, 0, "R");
                                 $this->objpdf->rect($xcol, $xlin + 182, 142, 23, 2, 'DF', '');
                                 $this->objpdf->sety($xlin + 28);
                                 $alt = 4;
                                 $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                 $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                 $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                 $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                 $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                 $maiscol = 0;
                                 $this->objpdf->SetWidths(array(10, 22, 105, 30, 30));
                                 $this->objpdf->SetAligns(array('C', 'C', 'L', 'R', 'R'));
                                 $this->objpdf->setleftmargin(8);
                                 $this->objpdf->sety($xlin + 61);
                                 $ele = 0;
                                 $xtotal = 0;
                                 for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                     db_fieldsmemory($this->recorddositens, $ii);
                                     if ($this->usa_sub == 'f') {
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         if ($ele != pg_result($this->recorddositens, $ii, $this->analitico)) {
                                             $this->objpdf->cell(32, 4, '', 0, 0, "C", 0);
                                             $this->objpdf->cell(137, 4, db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), 0, 1, "L", 0);
                                             $ele = pg_result($this->recorddositens, $ii, $this->analitico);
                                         }
                                     }
                                     $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem);
                                     if (pg_result($this->recorddositens, $ii, $this->Snumero) != "") {
                                         $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem) . "\n" . 'SOLICITAÇÃO: ' . pg_result($this->recorddositens, $ii, $this->Snumero);
                                     }
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->item), pg_result($this->recorddositens, $ii, $this->quantitem), $descricaoitem . "\n" . pg_result($this->recorddositens, $ii, $this->observacaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                     $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     /////// troca de pagina
                                     if ($this->objpdf->gety() > $this->objpdf->h - 100 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 30 && $pagina != 1) {
                                         if ($this->objpdf->PageNo() == 1) {
                                             $this->objpdf->text(110, $xlin + 214, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                             $this->objpdf->rect($xcol, $xlin + 217, 202, 55, 2, 'DF', '1234');
                                             $y = 260;
                                             //// ASSINATURAS DA AUTORIZACAO
                                             $cont = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                             $ord = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                             $visto = "VISTO";
                                             //	       $ass_cont   = $this->assinatura(1006,$cont);
                                             //	       $ass_ord    = $this->assinatura(1002,$ord);
                                             if (strtoupper(trim($this->municpref)) != 'SAPIRANGA') {
                                                 $ass_cont = $this->assinatura(1006, $cont);
                                                 $ass_ord = $this->assinatura(1002, $ord);
                                                 $ass_visto = $this->assinatura(5000, $visto);
                                             } else {
                                                 $ass_cont = $this->assinatura(51006, $cont);
                                                 $ass_ord = $this->assinatura(51002, $ord);
                                                 $ass_visto = $this->assinatura(5000, $visto);
                                             }
                                             $this->objpdf->SetXY(2, $y);
                                             $this->objpdf->MultiCell(70, 4, $ass_cont, 0, "C", 0);
                                             $this->objpdf->SetXY(72, $y);
                                             $this->objpdf->MultiCell(70, 4, $ass_ord, 0, "C", 0);
                                             $this->objpdf->SetXY(137, $y);
                                             $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                             //////
                                             $this->objpdf->setfillcolor(0, 0, 0);
                                             $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                             $this->objpdf->SetFont('Arial', '', 4);
                                             $this->objpdf->TextWithDirection(1.5, $xlin + 60, $this->texto, 'U');
                                             // texto no canhoto do carne
                                             $this->objpdf->setfont('Arial', '', 11);
                                             if ($pagina == 1) {
                                                 $this->objpdf->setxy($xcol + 1, $xlin + 187);
                                                 $this->objpdf->text($xcol + 2, $xlin + 186, 'RESUMO : ', 0, 1, 'L', 0);
                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                 $this->objpdf->multicell(140, 3.5, $this->resumo);
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                             }
                                         } else {
                                             $this->objpdf->text(110, $xlin + 320, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                         }
                                         $this->objpdf->addpage();
                                         $pagina += 1;
                                         $this->objpdf->settopmargin(1);
                                         $xlin = 20;
                                         $xcol = 4;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                                         $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                         $this->objpdf->text(137.5, $xlin - 8, 'PROCESSO DE COMPRA N' . CHR(176));
                                         $this->objpdf->text(185, $xlin - 8, db_formatar(pg_result($this->recorddositens, 0, $this->Snumeroproc), 's', '0', 6, 'e'));
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 9);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         $xlin = -30;
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 262, 2, 'DF', '34');
                                         $this->objpdf->sety($xlin + 66);
                                         $alt = 4;
                                         $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                         $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                         $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                         $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                         $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                         $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                         $maiscol = 0;
                                     }
                                 }
                                 if ($pagina == 1) {
                                     $this->objpdf->setxy($xcol + 1, $xlin + 187);
                                     $this->objpdf->text($xcol + 2, $xlin + 186, 'RESUMO : ', 0, 1, 'L', 0);
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->multicell(140, 3.5, $this->resumo);
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                 }
                                 //	$this->objpdf->SetXY(172,$xlin+205);
                                 //	$this->objpdf->cell(30 ,10,db_formatar($xtotal,'f'),0,0,"R");
                                 //	echo $this->numaut."<br>";
                                 //	echo $pagina;exit;
                                 if ($pagina == 1) {
                                     $this->objpdf->rect($xcol, $xlin + 217, 100, 55, 2, 'DF', '1234');
                                     $this->objpdf->rect($xcol + 102, $xlin + 217, 100, 55, 2, 'DF', '1234');
                                     //		$this->objpdf->rect($xcol+136,$xlin+217,66,55,2,'DF','1234');
                                     $this->objpdf->setfillcolor(0, 0, 0);
                                     $y = 260;
                                     $this->objpdf->Setfont('Arial', '', 6);
                                     //// ASSINATURAS DA AUTORIZACAO
                                     $cont = "__________________________________";
                                     $ord = "ORDENADOR DA DESPESA";
                                     $visto = "";
                                     if (strtoupper(trim($this->municpref)) != 'SAPIRANGA') {
                                         $ass_cont = $this->assinatura(1006, $cont);
                                         $ass_ord = $this->assinatura(51002, $ord);
                                         $ass_visto = $this->assinatura(5000, $visto);
                                     } else {
                                         $ass_cont = $this->assinatura(51006, $cont);
                                         $ass_ord = $this->assinatura(51002, $ord);
                                         $ass_visto = $this->assinatura(5000, $visto);
                                     }
                                     $this->objpdf->SetXY(20, $y);
                                     $this->objpdf->MultiCell(70, 2, "\n\n\n\n\n\n" . $ass_cont, 0, "C", 0);
                                     $this->objpdf->SetXY(122, $y);
                                     $this->objpdf->MultiCell(70, 2, "\n\n\n\n\n\n" . $ass_ord, 0, "C", 0);
                                     $this->objpdf->SetXY(137, $y);
                                     //               $this->objpdf->MultiCell(70,2,$ass_visto,0,"C",0);
                                     //////
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     $this->objpdf->setfillcolor(0, 0, 0);
                                     $this->objpdf->text($xcol + 10, $xlin + 223, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                     //	   $this->objpdf->SetFont('Arial','',4);
                                     //         $this->objpdf->TextWithDirection(1.5,$xlin+60,$this->texto,'U'); // texto no canhoto do carne
                                     //	   $this->objpdf->setfont('Arial','',11);
                                     //         $xlin = 169;
                                 }
                             } else {
                                 $this->objpdf->AliasNbPages();
                                 $this->objpdf->AddPage();
                                 $this->objpdf->settopmargin(1);
                                 $pagina = 1;
                                 $xlin = 20;
                                 $xcol = 4;
                                 $this->objpdf->setfillcolor(245);
                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                 $this->objpdf->setfillcolor(255, 255, 255);
                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                 $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                                 $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                 $this->objpdf->text(137.5, $xlin - 8, 'PROCESSO DE COMPRA N' . CHR(176));
                                 $this->objpdf->text(185, $xlin - 8, db_formatar(pg_result($this->recorddositens, 0, $this->Snumeroproc), 's', '0', 6, 'e'));
                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                 //.$this->logo
                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                 $this->objpdf->Setfont('Arial', '', 7);
                                 $this->objpdf->text(40, $xlin - 12, $this->enderpref);
                                 $this->objpdf->text(40, $xlin - 9, $this->municpref);
                                 $this->objpdf->text(40, $xlin - 6, $this->telefpref);
                                 $this->objpdf->text(40, $xlin - 3, $this->emailpref);
                                 $this->objpdf->text(40, $xlin, db_formatar($this->cgcpref, 'cnpj'));
                                 $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 28, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 2, $xlin + 4, 'Dados da Compra');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 2, $xlin + 8, 'Licitação');
                                 $this->objpdf->text($xcol + 2, $xlin + 12, 'Tipo de Compra');
                                 $this->objpdf->text($xcol + 2, $xlin + 16, 'Prazo de Entrega');
                                 $this->objpdf->text($xcol + 2, $xlin + 20, 'Observações');
                                 $this->objpdf->text($xcol + 2, $xlin + 24, 'Cond.de Pagto');
                                 $this->objpdf->text($xcol + 2, $xlin + 28, 'Outras Condições');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 27, $xlin + 8, ':  ' . $this->num_licitacao . '  -  ' . $this->descr_licitacao);
                                 $this->objpdf->text($xcol + 27, $xlin + 12, ':  ' . $this->descr_tipocompra);
                                 $this->objpdf->text($xcol + 27, $xlin + 16, ':  ' . $this->prazo_ent);
                                 $this->objpdf->text($xcol + 27, $xlin + 20, ':  ' . $this->obs);
                                 $this->objpdf->text($xcol + 27, $xlin + 24, ':  ' . $this->cond_pag);
                                 $this->objpdf->text($xcol + 27, $xlin + 28, ':  ' . $this->out_cond);
                                 $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 28, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 110, $xlin + 4, 'Dados da Dotação');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 108, $xlin + 8, 'Dotação');
                                 $this->objpdf->text($xcol + 108, $xlin + 11.5, 'Órgão');
                                 $this->objpdf->text($xcol + 108, $xlin + 15, 'Unidade');
                                 $this->objpdf->text($xcol + 108, $xlin + 18.5, 'Proj/Ativ');
                                 $this->objpdf->text($xcol + 108, $xlin + 22, 'Elemento');
                                 $this->objpdf->text($xcol + 108, $xlin + 25.5, 'Recurso');
                                 $this->objpdf->text($xcol + 178, $xlin + 25.5, 'Reduz');
                                 $this->objpdf->text($xcol + 108, $xlin + 29, 'Destino');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 122, $xlin + 8, ':  ' . $this->dotacao);
                                 $this->objpdf->text($xcol + 122, $xlin + 11.5, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                 $this->objpdf->text($xcol + 122, $xlin + 15, ':  ' . db_formatar($this->orgao, 'orgao') . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                 $this->objpdf->text($xcol + 122, $xlin + 18.5, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                 $this->objpdf->text($xcol + 122, $xlin + 22, ':  ' . $this->descrdotacao);
                                 $this->objpdf->text($xcol + 122, $xlin + 25.5, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                 $this->objpdf->text($xcol + 188, $xlin + 25.5, ':  ' . $this->coddot . '-' . db_CalculaDV($this->coddot));
                                 $this->objpdf->text($xcol + 122, $xlin + 29, ':  ' . $this->destino);
                                 $this->objpdf->rect($xcol, $xlin + 32, $xcol + 198, 20, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 2, $xlin + 34, 'Dados do Credor');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 109, $xlin + 38, 'Numcgm');
                                 $this->objpdf->text($xcol + 150, $xlin + 38, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                 $this->objpdf->text($xcol + 2, $xlin + 38, 'Nome');
                                 $this->objpdf->text($xcol + 2, $xlin + 42, 'Endereço');
                                 $this->objpdf->text($xcol + 102, $xlin + 42, 'Complemento');
                                 $this->objpdf->text($xcol + 2, $xlin + 46, 'Município');
                                 $this->objpdf->text($xcol + 115, $xlin + 46, 'CEP');
                                 $this->objpdf->text($xcol + 2, $xlin + 50, 'Contato');
                                 $this->objpdf->text($xcol + 110, $xlin + 50, 'Telefone');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 159, $xlin + 38, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')));
                                 $this->objpdf->text($xcol + 122, $xlin + 38, ':  ' . $this->numcgm);
                                 $this->objpdf->text($xcol + 18, $xlin + 38, ':  ' . $this->nome);
                                 $this->objpdf->text($xcol + 18, $xlin + 42, ':  ' . $this->ender);
                                 $this->objpdf->text($xcol + 122, $xlin + 42, ':  ' . $this->compl);
                                 $this->objpdf->text($xcol + 18, $xlin + 46, ':  ' . $this->munic . '-' . $this->uf);
                                 $this->objpdf->text($xcol + 122, $xlin + 46, ':  ' . $this->cep);
                                 $this->objpdf->text($xcol + 18, $xlin + 50, ':  ' . $this->contato);
                                 $this->objpdf->text($xcol + 122, $xlin + 50, ':  ' . $this->telefone);
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 //	$this->objpdf->Roundedrect($xcol,$xlin+54,202,80,2,'DF','1234');
                                 $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol, $xlin + 60, 15, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 122, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 155, 2, 'DF', '');
                                 $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 155, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol, $xlin + 205, 142, 10, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 142, $xlin + 205, 30, 10, 2, 'DF', '34');
                                 $this->objpdf->rect($xcol + 172, $xlin + 205, 30, 10, 2, 'DF', '34');
                                 $this->objpdf->text($xcol + 120, $xlin + 211, 'T O T A L');
                                 $this->objpdf->rect($xcol, $xlin + 182, 142, 23, 2, 'DF', '');
                                 $this->objpdf->sety($xlin + 28);
                                 $alt = 4;
                                 $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                 $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                 $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                 $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                 $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                 $maiscol = 0;
                                 $this->objpdf->SetWidths(array(10, 22, 105, 30, 30));
                                 $this->objpdf->SetAligns(array('C', 'C', 'L', 'R', 'R'));
                                 $this->objpdf->setleftmargin(8);
                                 $this->objpdf->sety($xlin + 61);
                                 $ele = 0;
                                 $xtotal = 0;
                                 for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                     db_fieldsmemory($this->recorddositens, $ii);
                                     if ($this->usa_sub == 'f') {
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         if ($ele != pg_result($this->recorddositens, $ii, $this->analitico)) {
                                             $this->objpdf->cell(32, 4, '', 0, 0, "C", 0);
                                             $this->objpdf->cell(137, 4, db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), 0, 1, "L", 0);
                                             $ele = pg_result($this->recorddositens, $ii, $this->analitico);
                                         }
                                     }
                                     $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem);
                                     if (pg_result($this->recorddositens, $ii, $this->Snumero) != "") {
                                         $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem) . "\n" . 'SOLICITAÇÃO: ' . pg_result($this->recorddositens, $ii, $this->Snumero);
                                     }
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->item), pg_result($this->recorddositens, $ii, $this->quantitem), $descricaoitem . "\n" . pg_result($this->recorddositens, $ii, $this->observacaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                     $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     /////// troca de pagina
                                     if ($this->objpdf->gety() > $this->objpdf->h - 100 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 30 && $pagina != 1) {
                                         if ($this->objpdf->PageNo() == 1) {
                                             $this->objpdf->text(110, $xlin + 214, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                             $this->objpdf->rect($xcol, $xlin + 217, 202, 55, 2, 'DF', '1234');
                                             $this->objpdf->SetXY(172, $xlin + 205);
                                             $this->objpdf->cell(30, 10, db_formatar($this->valtotal, 'f'), 0, 0, "R");
                                             $y = 260;
                                             //// ASSINATURAS DA AUTORIZACAO
                                             $cont = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                             $ord = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                             $visto = "VISTO";
                                             //	       $ass_cont   = $this->assinatura(1006,$cont);
                                             //	       $ass_ord    = $this->assinatura(1002,$ord);
                                             if (strtoupper(trim($this->municpref)) == 'SAPIRANGA') {
                                                 $cont = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                                 $ord = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                                 $visto = "VISTO";
                                                 $ass_cont = $this->assinatura(51006, $cont);
                                                 $ass_ord = $this->assinatura(51002, $ord);
                                                 $ass_visto = $this->assinatura(5000, $visto);
                                                 $ass_usu = $this->assinatura_usuario();
                                                 /// primeiro quadro
                                                 $this->objpdf->SetXY(2, $y - 20);
                                                 $this->objpdf->MultiCell(70, 4, $ass_usu, 0, "C", 0);
                                                 $this->objpdf->SetXY(2, $y + 5);
                                                 $this->objpdf->MultiCell(70, 4, $ass_cont, 0, "C", 0);
                                                 $this->objpdf->SetXY(72, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_ord, 0, "C", 0);
                                                 $this->objpdf->SetXY(137, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                                 $this->objpdf->setfillcolor(0, 0, 0);
                                                 $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                             } elseif (strtoupper(trim($this->municpref)) == 'ALEGRETE') {
                                                 $ass_cont = $this->assinatura(1006, $cont);
                                                 $ass_ord = $this->assinatura(1002, $ord);
                                                 $ass_visto = $this->assinatura(5000, $visto);
                                                 $this->objpdf->SetXY(2, $y);
                                                 $this->objpdf->MultiCell(70, 2, "AUTORIZO" . "\n\n\n\n\n\nDIRETOR DE COMPRAS", 0, "C", 0);
                                                 $this->objpdf->SetXY(72, $y);
                                                 $this->objpdf->MultiCell(70, 2, "AUTORIZO" . "\n\n\n\n\n\nSECRETÁRIO DE FINANÇAS", 0, "C", 0);
                                                 $this->objpdf->SetXY(137, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                                 $this->objpdf->setfillcolor(0, 0, 0);
                                                 $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                             } else {
                                                 $ass_cont = $this->assinatura(1006, $cont);
                                                 $ass_ord = $this->assinatura(1002, $ord);
                                                 $ass_visto = $this->assinatura(5000, $visto);
                                                 $this->objpdf->SetXY(2, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_cont, 0, "C", 0);
                                                 $this->objpdf->SetXY(72, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_ord, 0, "C", 0);
                                                 $this->objpdf->SetXY(137, $y);
                                                 $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                                 $this->objpdf->setfillcolor(0, 0, 0);
                                                 $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                             }
                                             /* 
                                             		 if(strtoupper(trim($this->municpref)) != 'SAPIRANGA'){
                                             		    $ass_cont   = $this->assinatura(1006,$cont);
                                             		    $ass_ord    = $this->assinatura(1002,$ord);
                                             		    $ass_visto  = $this->assinatura(5000,$visto);
                                             		 }else{
                                             		    $ass_cont   = $this->assinatura(51006,$cont);
                                             		    $ass_ord    = $this->assinatura(51002,$ord);
                                             		    $ass_visto  = $this->assinatura(5000,$visto);
                                             		 }
                                             																			       
                                             		 $this->objpdf->SetXY(2,$y);
                                             
                                             		 if(strtoupper(trim($this->municpref)) == 'ALEGRETE'){
                                               		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\nDIRETOR DE COMPRAS",0,"C",0);
                                             		 } else {
                                             		   $this->objpdf->MultiCell(70,4,$ass_cont,0,"C",0);
                                             		 }
                                             		 
                                             		 
                                             		 $this->objpdf->SetXY(72,$y);
                                             		 if(strtoupper(trim($this->municpref)) == 'ALEGRETE'){
                                               		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\nSECRETÁRIO DE FINANÇAS",0,"C",0);
                                             		 } else {
                                             		   $this->objpdf->MultiCell(70,4,$ass_ord,0,"C",0);
                                             		 }
                                             		 
                                             		 $this->objpdf->SetXY(137,$y);
                                             		 $this->objpdf->MultiCell(70,4,$ass_visto,0,"C",0);
                                             		 /////
                                             		 
                                             		 $this->objpdf->setfillcolor(0,0,0);
                                             		 $this->objpdf->text($xcol+10,$xlin+223,$this->municpref.', '.date('d').' DE '.strtoupper(db_mes(date('m'))).' DE '.db_getsession("DB_anousu").'.');
                                             */
                                             $this->objpdf->SetFont('Arial', '', 4);
                                             $this->objpdf->TextWithDirection(1.5, $xlin + 60, $this->texto, 'U');
                                             // texto no canhoto do carne
                                             $this->objpdf->setfont('Arial', '', 11);
                                             if ($pagina == 1) {
                                                 $this->objpdf->setxy($xcol + 1, $xlin + 187);
                                                 $this->objpdf->text($xcol + 2, $xlin + 186, 'RESUMO : ', 0, 1, 'L', 0);
                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                 $this->objpdf->multicell(140, 3.5, $this->resumo);
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                             }
                                         } else {
                                             $this->objpdf->text(110, $xlin + 320, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                         }
                                         $this->objpdf->addpage();
                                         $pagina += 1;
                                         $this->objpdf->settopmargin(1);
                                         $xlin = 20;
                                         $xcol = 4;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                                         $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                         $this->objpdf->text(137.5, $xlin - 8, 'PROCESSO DE COMPRA N' . CHR(176));
                                         $this->objpdf->text(185, $xlin - 8, db_formatar(pg_result($this->recorddositens, 0, $this->Snumeroproc), 's', '0', 6, 'e'));
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 9);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         $xlin = -30;
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 262, 2, 'DF', '34');
                                         $this->objpdf->sety($xlin + 66);
                                         $alt = 4;
                                         $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                         $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                         $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                         $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                         $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                         $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                         $maiscol = 0;
                                     }
                                 }
                                 if ($pagina == 1) {
                                     $this->objpdf->setxy($xcol + 1, $xlin + 187);
                                     $this->objpdf->text($xcol + 2, $xlin + 186, 'RESUMO : ', 0, 1, 'L', 0);
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->multicell(140, 3.5, $this->resumo);
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                 }
                                 //	  $this->objpdf->SetXY(172,$xlin+205);
                                 //	  $this->objpdf->cell(30 ,10,db_formatar($xtotal,'f'),0,0,"R");
                                 //	echo $this->numaut."<br>";
                                 //	echo $pagina;exit;
                                 if ($pagina == 1) {
                                     $this->objpdf->SetXY(172, $xlin + 205);
                                     $this->objpdf->cell(30, 10, db_formatar($this->valtotal, 'f'), 0, 0, "R");
                                     $this->objpdf->rect($xcol, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                     $this->objpdf->rect($xcol + 68, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                     $this->objpdf->rect($xcol + 136, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                     $this->objpdf->setfillcolor(0, 0, 0);
                                     $y = 260;
                                     $this->objpdf->Setfont('Arial', '', 6);
                                     //// ASSINATURAS DA AUTORIZACAO
                                     //		 $cont =  "__________________________________";
                                     //		 $ord =   "__________________________________";
                                     //		 $visto =  "VISTO";
                                     //// ASSINATURAS DA AUTORIZACAO
                                     $cont = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                     $ord = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                     $visto = "VISTO";
                                     //	       $ass_cont   = $this->assinatura(1006,$cont);
                                     //	       $ass_ord    = $this->assinatura(1002,$ord);
                                     if (strtoupper(trim($this->municpref)) == 'SAPIRANGA') {
                                         $cont = "__________________________________" . "\n" . "CONTABILIDADE";
                                         $pref = "__________________________________" . "\n" . "PREFEITO MUNICIPAL";
                                         $ord = "AUTORIZO" . "\n\n\n" . "__________________________________";
                                         $visto = "VISTO";
                                         $ch_compras = "__________________________________" . "\n" . "CHEFE COMPRAS";
                                         $ass_pref = $this->assinatura(1000, $pref);
                                         $ass_secfaz = $this->assinatura(1002, $ord);
                                         $ass_visto = $this->assinatura(5000, $visto);
                                         $ass_usu = $this->assinatura_usuario();
                                         /// primeiro quadro
                                         $this->objpdf->SetXY(2, $y - 15);
                                         $this->objpdf->MultiCell(70, 3, "__________________________________" . "\n" . $ass_usu, 0, "C", 0);
                                         $this->objpdf->SetXY(2, $y + 8);
                                         $this->objpdf->MultiCell(70, 3, $ch_compras, 0, "C", 0);
                                         $this->objpdf->setfillcolor(0, 0, 0);
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 10, $xlin + 270, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                         /// segundo quadro
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->SetXY(72, $y - 15);
                                         $this->objpdf->MultiCell(65, 3, $cont, 0, "C", 0);
                                         $this->objpdf->SetXY(72, $y);
                                         $this->objpdf->MultiCell(65, 3, "HÁ RECURSOS FINANCEIROS:", 0, "C", 0);
                                         $this->objpdf->SetXY(72, $y + 8);
                                         $this->objpdf->MultiCell(65, 3, $ass_secfaz, 0, "C", 0);
                                         $this->objpdf->setfillcolor(0, 0, 0);
                                         //	            $this->objpdf->Setfont('Arial','B',8);
                                         $this->objpdf->text($xcol + 95, $xlin + 263, 'CONFERIDO');
                                         $this->objpdf->text($xcol + 91, $xlin + 270, '______/______/______');
                                         /// terceiro quadro
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->SetXY(137, $y);
                                         $this->objpdf->MultiCell(70, 3, $ass_pref, 0, "C", 0);
                                         $this->objpdf->text($xcol + 165, $xlin + 263, 'AUTORIZA');
                                         $this->objpdf->text($xcol + 161, $xlin + 270, '______/______/______');
                                     } elseif (strtoupper(trim($this->municpref)) == 'ALEGRETE') {
                                         $ass_cont = $this->assinatura(1006, $cont);
                                         $ass_ord = $this->assinatura(1002, $ord);
                                         $ass_visto = $this->assinatura(5000, $visto);
                                         $this->objpdf->SetXY(2, $y);
                                         $this->objpdf->MultiCell(70, 2, "AUTORIZO" . "\n\n\n\n\n\nDIRETOR DE COMPRAS", 0, "C", 0);
                                         $this->objpdf->SetXY(72, $y);
                                         $this->objpdf->MultiCell(70, 2, "AUTORIZO" . "\n\n\n\n\n\nSECRETÁRIO DE FINANÇAS", 0, "C", 0);
                                         $this->objpdf->SetXY(137, $y);
                                         $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                         $this->objpdf->setfillcolor(0, 0, 0);
                                         $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                     } else {
                                         $ass_cont = $this->assinatura(1006, $cont);
                                         $ass_ord = $this->assinatura(1002, $ord);
                                         $ass_visto = $this->assinatura(5000, $visto);
                                         $this->objpdf->SetXY(2, $y);
                                         $this->objpdf->MultiCell(70, 4, $ass_cont, 0, "C", 0);
                                         $this->objpdf->SetXY(72, $y);
                                         $this->objpdf->MultiCell(70, 4, $ass_ord, 0, "C", 0);
                                         $this->objpdf->SetXY(137, $y);
                                         $this->objpdf->MultiCell(70, 4, $ass_visto, 0, "C", 0);
                                         $this->objpdf->setfillcolor(0, 0, 0);
                                         $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                     }
                                     /*
                                     		 if(strtoupper(trim($this->municpref)) != 'SAPIRANGA'){
                                     		    $ass_cont   = $this->assinatura(1006,$cont);
                                     		    $ass_ord    = $this->assinatura(1002,$ord);
                                     		    $ass_visto  = $this->assinatura(5000,$visto);
                                     		 }else{
                                     		    $ass_cont   = $this->assinatura(51006,$cont);
                                     		    $ass_ord    = $this->assinatura(51002,$ord);
                                     		    $ass_visto  = $this->assinatura(5000,$visto);
                                     		 }
                                     
                                     		 $this->objpdf->SetXY(2,$y);
                                     		 
                                     		 if(strtoupper(trim($this->municpref)) == 'ALEGRETE'){
                                       		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\nDIRETOR DE COMPRAS",0,"C",0);
                                     		 } else {
                                       		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\n".$ass_cont,0,"C",0);
                                     		 }
                                     		 
                                     		 $this->objpdf->SetXY(72,$y);
                                     		 if(strtoupper(trim($this->municpref)) == 'ALEGRETE'){
                                       		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\nSECRETÁRIO DE FINANÇAS",0,"C",0);
                                     		 } else {
                                       		   $this->objpdf->MultiCell(70,2,"AUTORIZO"."\n\n\n\n\n\n".$ass_ord,0,"C",0);
                                     		 }
                                     		 
                                     		 $this->objpdf->SetXY(137,$y);
                                     		 $this->objpdf->MultiCell(70,2,$ass_visto,0,"C",0);
                                     		 //////
                                     		  
                                     		 
                                     	     $this->objpdf->Setfont('Arial','B',8);
                                     	     $this->objpdf->setfillcolor(0,0,0);
                                     	     $this->objpdf->text($xcol+10,$xlin+223,strtoupper($this->municpref).', '.substr($this->emissao,8,2).' DE '.strtoupper(db_mes(substr($this->emissao,5,2))).' DE '.substr($this->emissao,0,4).'.');
                                     */
                                     //	   $this->objpdf->SetFont('Arial','',4);
                                     //         $this->objpdf->TextWithDirection(1.5,$xlin+60,$this->texto,'U'); // texto no canhoto do carne
                                     //	   $this->objpdf->setfont('Arial','',11);
                                     //         $xlin = 169;
                                 }
                             }
                         } else {
                             if ($this->modelo == 6) {
                                 ////////// MODELO 6  -  NOTA DE EMPENHO
                                 if (strtoupper(trim($this->municpref)) == 'GUAIBA') {
                                     $assinatura2 = 'CONTADORA';
                                     $assinatura3 = 'JORGE ANTONIO POKORSKI';
                                     $assinaturaprefeito = 'MANOEL STRINGHINI';
                                     for ($xxx = 0; $xxx < $this->nvias; $xxx++) {
                                         $this->objpdf->AliasNbPages();
                                         $this->objpdf->AddPage();
                                         $this->objpdf->settopmargin(1);
                                         $pagina = 1;
                                         $xlin = 20;
                                         $xcol = 4;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 10);
                                         $this->objpdf->text(128, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                         $this->objpdf->text(175, $xlin - 13, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                         $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                         $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         $this->objpdf->text(40, $xlin, db_formatar($this->cgcpref, 'cnpj'));
                                         /// retangulo dos dados da dotação
                                         $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 50, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                         $this->objpdf->text($xcol + 2, $xlin + 10.5, 'Unidade');
                                         $this->objpdf->text($xcol + 2, $xlin + 14, 'Função');
                                         $this->objpdf->text($xcol + 2, $xlin + 20.5, 'Proj/Ativ');
                                         $this->objpdf->text($xcol + 2, $xlin + 27, 'Rubrica');
                                         $this->objpdf->text($xcol + 2, $xlin + 35, 'Recurso');
                                         if ($this->banco != "") {
                                             $this->objpdf->text($xcol + 2, $xlin + 38.5, 'Banco');
                                             $this->objpdf->text($xcol + 30, $xlin + 38.5, 'Agencia:');
                                             $this->objpdf->text($xcol + 60, $xlin + 38.5, 'Conta:');
                                         }
                                         $this->objpdf->text($xcol + 2, $xlin + 42.5, 'Reduzido');
                                         $this->objpdf->text($xcol + 2, $xlin + 48, 'Licitação');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                         $this->objpdf->text($xcol + 17, $xlin + 10.5, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                         $this->objpdf->text($xcol + 17, $xlin + 14, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                         $this->objpdf->text($xcol + 17, $xlin + 20.5, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                         $this->objpdf->text($xcol + 17, $xlin + 27, ':  ' . db_formatar($this->sintetico, 'elemento'));
                                         $this->objpdf->setxy($xcol + 18, $xlin + 28);
                                         $this->objpdf->multicell(90, 3, $this->descr_sintetico, 0, "L");
                                         $this->objpdf->text($xcol + 17, $xlin + 35, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                         if ($this->banco != "") {
                                             $this->objpdf->text($xcol + 17, $xlin + 38.5, ':  ' . $this->banco);
                                             $this->objpdf->text($xcol + 47, $xlin + 38.5, $this->agencia);
                                             $this->objpdf->text($xcol + 77, $xlin + 38.5, $this->conta);
                                         }
                                         $this->objpdf->text($xcol + 17, $xlin + 42.5, ':  ' . $this->coddot);
                                         $this->objpdf->text($xcol + 17, $xlin + 48, ':  ' . $this->descr_licitacao);
                                         //// retangulo dos dados do credor
                                         $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 18, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 107, $xlin + 7, 'Numcgm');
                                         $this->objpdf->text($xcol + 140, $xlin + 7, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                         $this->objpdf->text($xcol + 107, $xlin + 11, 'Nome');
                                         $this->objpdf->text($xcol + 107, $xlin + 15, 'Endereço');
                                         $this->objpdf->text($xcol + 107, $xlin + 19, 'Município');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 124, $xlin + 7, ': ' . $this->numcgm);
                                         $this->objpdf->text($xcol + 149, $xlin + 7, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')) . '   Fone: ' . $this->telefone);
                                         $this->objpdf->text($xcol + 124, $xlin + 11, ': ' . $this->nome);
                                         $this->objpdf->text($xcol + 124, $xlin + 15, ': ' . $this->ender . '  ' . $this->compl);
                                         $this->objpdf->text($xcol + 124, $xlin + 19, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                         ///// retangulo dos valores
                                         $this->objpdf->rect($xcol + 106, $xlin + 21.5, 96, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 106, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 155, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 106, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 155, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 34.0, 'Valor Orçado');
                                         $this->objpdf->text($xcol + 157, $xlin + 34.0, 'Saldo Anterior');
                                         $this->objpdf->text($xcol + 108, $xlin + 44.5, 'Valor Empenhado');
                                         $this->objpdf->text($xcol + 157, $xlin + 44.5, 'Saldo Atual');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 108, $xlin + 27, 'AUTORIZAÇÃO N' . chr(176) . ' ' . db_formatar($this->numaut, 's', '0', 5, 'e'));
                                         $this->objpdf->text($xcol + 150, $xlin + 27, 'SEQ. DO EMPENHO N' . chr(176) . ' ' . db_formatar($this->numemp, 's', '0', 6, 'e'));
                                         //	$this->objpdf->text($xcol+108,$xlin+26.5,$this->texto);
                                         $this->objpdf->text($xcol + 130, $xlin + 38.0, db_formatar($this->orcado, 'f'));
                                         $this->objpdf->text($xcol + 180, $xlin + 38.0, db_formatar($this->saldo_ant, 'f'));
                                         $this->objpdf->text($xcol + 130, $xlin + 47.5, db_formatar($this->empenhado, 'f'));
                                         $this->objpdf->text($xcol + 180, $xlin + 47.5, db_formatar($this->saldo_ant - $this->empenhado, 'f'));
                                         /// retangulo do corpo do empenho
                                         $this->objpdf->rect($xcol, $xlin + 60, 15, 100, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 15, $xlin + 60, 137, 100, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 152, $xlin + 60, 25, 123, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 123, 2, 'DF', '');
                                         $this->objpdf->rect($xcol, $xlin + 160, 152, 23, 2, 'DF', '');
                                         // resumo
                                         //// retangulos do titulo do corpo do empenho
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 15, $xlin + 54, 137, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 152, $xlin + 54, 25, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                         //// título do corpo do empenho
                                         $this->objpdf->text($xcol + 2, $xlin + 58, 'QUANT');
                                         $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                         $this->objpdf->text($xcol + 154, $xlin + 58, 'VALOR UNITÁRIO');
                                         $this->objpdf->text($xcol + 181, $xlin + 58, 'VALOR TOTAL');
                                         $maiscol = 0;
                                         /// monta os dados para itens do empenho
                                         $this->objpdf->SetWidths(array(15, 137, 25, 25));
                                         $this->objpdf->SetAligns(array('C', 'L', 'R', 'R'));
                                         $this->objpdf->setleftmargin(4);
                                         $this->objpdf->sety($xlin + 62);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $ele = 0;
                                         $xtotal = 0;
                                         for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                             db_fieldsmemory($this->recorddositens, $ii);
                                             $this->objpdf->Setfont('Arial', 'B', 7);
                                             if ($ele != pg_result($this->recorddositens, $ii, $this->analitico)) {
                                                 $this->objpdf->cell(15, 4, '', 0, 0, "C", 0);
                                                 $this->objpdf->cell(137, 4, db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), 0, 1, "L", 0);
                                                 $ele = pg_result($this->recorddositens, $ii, $this->analitico);
                                             }
                                             $this->objpdf->Setfont('Arial', '', 7);
                                             $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->quantitem), pg_result($this->recorddositens, $ii, $this->descricaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                             $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                             /////// troca de pagina
                                             if ($this->objpdf->gety() > $this->objpdf->h - 125 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 22 && $pagina != 1) {
                                                 $proxima_pagina = $pagina + 1;
                                                 $this->objpdf->Row(array('', "Continua na página {$proxima_pagina}", '', ''), 3, false, 4);
                                                 if ($pagina == 1) {
                                                     $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                                     //	   $this->objpdf->setfillcolor(0,0,0);
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                                     $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                                     $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                                     $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                                     $this->objpdf->multicell(147, 3.5, $this->resumo);
                                                     $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                                     $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                                     $this->objpdf->cell(30, 10, db_formatar($this->empenhado, 'f'), 0, 0, 'f');
                                                     $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                                     $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                                     $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                                     $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                                     if ($this->assinatura1 != "") {
                                                         //               $this->objpdf->line($xcol+5,$xlin+211,$xcol+54,$xlin+211);
                                                     }
                                                     if ($assinatura2 != "") {
                                                         $this->objpdf->line($xcol + 5, $xlin + 215, $xcol + 54, $xlin + 225);
                                                     }
                                                     if ($assinatura3 != "") {
                                                         $this->objpdf->line($xcol + 5, $xlin + 235, $xcol + 54, $xlin + 238);
                                                     }
                                                     $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                                     $this->objpdf->SetFont('Arial', '', 6);
                                                     //         $this->objpdf->text($xcol+12,$xlin+199,'EMPENHADO E CONFERIDO');
                                                     $this->objpdf->text($xcol + 27 - strlen($this->assinatura1) / 2, $xlin + 218, $this->assinatura1);
                                                     $this->objpdf->text($xcol + 27 - strlen($assinatura2) / 2, $xlin + 238, $assinatura2);
                                                     $this->objpdf->text($xcol + 27 - strlen($assinatura3) / 2, $xlin + 241, $assinatura3);
                                                     //           $this->objpdf->text($xcol+66,$xlin+212,'DATA  ____________/____________/____________');
                                                     $this->objpdf->text($xcol + 88 - strlen($assinaturaprefeito) / 2, $xlin + 228, $assinaturaprefeito);
                                                     $this->objpdf->text($xcol + 88 - strlen("PREFEITO MUNICIPAL") / 2, $xlin + 231, "PREFEITO MUNICIPAL");
                                                     //	   $this->objpdf->text($xcol+66,$xlin+212,'DATA  ____________/____________/____________');
                                                     //  $this->objpdf->text($xcol+76,$xlin+227,'PREFEITO MUNICIPAL');
                                                     $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                                     $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                                     $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                                     $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                                     $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                                     $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                                     $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                                     $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                                     $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                                     $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                                     $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                                     $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                                     $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                                     $this->objpdf->SetFont('Arial', '', 6);
                                                     $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                                     $this->objpdf->SetFont('Arial', '', 4);
                                                     $this->objpdf->Text(2, 296, $this->texto);
                                                     // texto no canhoto do carne
                                                     $this->objpdf->setfont('Arial', '', 11);
                                                     $xlin = 169;
                                                 }
                                                 $this->objpdf->addpage();
                                                 $pagina += 1;
                                                 $this->objpdf->settopmargin(1);
                                                 $xlin = 20;
                                                 $xcol = 4;
                                                 $this->objpdf->setfillcolor(245);
                                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                 $this->objpdf->setfillcolor(255, 255, 255);
                                                 $this->objpdf->Setfont('Arial', 'B', 11);
                                                 $this->objpdf->text(128, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                                 $this->objpdf->text(175, $xlin - 13, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                                 $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                                 $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                 //.$this->logo
                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                 $this->objpdf->Setfont('Arial', '', 9);
                                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                 $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                 $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                 $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                 $xlin = -30;
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                 //  	    $this->objpdf->Roundedrect($xcol,$xlin+54,15,6,2,'DF','12');
                                                 $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 15, $xlin + 54, 127, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 54, 35, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                                 //  	    $this->objpdf->Roundedrect($xcol,$xlin+60,15,262,2,'DF','34');
                                                 $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 15, $xlin + 60, 127, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 60, 35, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 262, 2, 'DF', '34');
                                                 $this->objpdf->sety($xlin + 66);
                                                 $alt = 4;
                                                 //	    $this->objpdf->text($xcol+4,$xlin+58,'ITEM');
                                                 $this->objpdf->text($xcol + 0.5, $xlin + 58, 'QUANT');
                                                 $this->objpdf->text($xcol + 65, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                                 $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                                 $this->objpdf->text($xcol + 179, $xlin + 58, 'VALOR TOTAL');
                                                 $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                                 $maiscol = 0;
                                             }
                                         }
                                         if ($pagina == 1) {
                                             $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             //	   $this->objpdf->setfillcolor(0,0,0);
                                             $this->objpdf->SetFont('Arial', '', 7);
                                             $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                             $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                             $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                             $this->objpdf->multicell(147, 3.5, $this->resumo);
                                             $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                             $this->objpdf->cell(30, 10, db_formatar($this->empenhado, 'f'), 0, 0, 'f');
                                             //	   $this->rodape($mod_rodape);
                                             $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                             $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                             $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                             $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                             $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                             if ($this->assinatura1 != "") {
                                                 //////////               $this->objpdf->line($xcol+5,$xlin+211,$xcol+54,$xlin+211);
                                             }
                                             if ($assinatura2 != "") {
                                                 $this->objpdf->line($xcol + 5, $xlin + 215, $xcol + 54, $xlin + 215);
                                             }
                                             if ($assinatura3 != "") {
                                                 $this->objpdf->line($xcol + 5, $xlin + 235, $xcol + 54, $xlin + 235);
                                                 //////////
                                             }
                                             $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             //         $this->objpdf->text($xcol+12,$xlin+199,'EMPENHADO E CONFERIDO');
                                             //////////           $this->objpdf->text($xcol+27-(strlen($this->assinatura1)/2),$xlin+213,$this->assinatura1);
                                             $this->objpdf->text($xcol + 27 - strlen($assinatura2) / 2, $xlin + 218, $assinatura2);
                                             $this->objpdf->text($xcol + 27 - strlen($assinatura3) / 2, $xlin + 238, $assinatura3);
                                             //////////
                                             $this->objpdf->text($xcol + 27 - strlen($this->assinatura4) / 2, $xlin + 241, $this->assinatura4);
                                             //////////
                                             ////           $this->objpdf->text($xcol+66,$xlin+212,'DATA  ____________/____________/____________');
                                             $this->objpdf->text($xcol + 88 - strlen($assinaturaprefeito) / 2, $xlin + 228, $assinaturaprefeito);
                                             $this->objpdf->text($xcol + 88 - strlen("PREFEITO MUNICIPAL") / 2, $xlin + 231, "PREFEITO MUNICIPAL");
                                             $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                             $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                             $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                             $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                             $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                             $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                             $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                             //////	   $this->objpdf->text($xcol+2,$xlin+250,'RESUMO: ',0,1,'L',0);
                                             //////	   $this->objpdf->setxy($xcol+1,$xlin+252);
                                             ////// 	   $this->objpdf->multicell(147,3.5,$this->resumo);
                                             /*
                                             	     
                                             	     $this->objpdf->SetFont('Arial','',7);
                                             
                                             	     $this->objpdf->text($xcol+90,$xlin+249,'R E C I B O');
                                             	     $this->objpdf->text($xcol+45,$xlin+253,'RECEBI(EMOS) DO MUNICÍPIO DE '.$this->municpref.', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                             	     $this->objpdf->text($xcol+2,$xlin+257,'(     ) PARTE DO VALOR EMPENHADO');
                                             	     $this->objpdf->text($xcol+102,$xlin+257,'(     ) SALDO/TOTAL EMPENHADO');
                                             	     $this->objpdf->text($xcol+2,$xlin+261,'R$');
                                             	     $this->objpdf->text($xcol+102,$xlin+261,'R$');
                                             	     $this->objpdf->text($xcol+2,$xlin+265,'EM ________/________/________',0,0,'C',0);
                                             	     $this->objpdf->text($xcol+42,$xlin+265,'_________________________________________',0,0,'C',0);
                                             	     $this->objpdf->text($xcol+102,$xlin+265,'EM ________/________/________',0,0,'C',0);
                                             	     $this->objpdf->text($xcol+142,$xlin+265,'_________________________________________',0,1,'C',0);
                                             	     $this->objpdf->SetFont('Arial','',6);
                                             	     $this->objpdf->text($xcol+62,$xlin+269,'CREDOR',0,0,'C',0);
                                             	     $this->objpdf->text($xcol+162,$xlin+269,'CREDOR',0,1,'C',0);
                                             	     
                                             	     $this->objpdf->SetFont('Arial','',4);
                                             	     $this->objpdf->Text(2,296,$this->texto); // texto no canhoto do carne
                                             	     $this->objpdf->SetFont('Arial','',6);
                                             	     $this->objpdf->Text(200,296,($xxx+1).' via'); // texto no canhoto do carne
                                             	     $this->objpdf->setfont('Arial','',11);
                                             */
                                             $xlin = 169;
                                         }
                                     }
                                 } else {
                                     for ($xxx = 0; $xxx < $this->nvias; $xxx++) {
                                         $this->objpdf->AliasNbPages();
                                         $this->objpdf->AddPage();
                                         $this->objpdf->settopmargin(1);
                                         $pagina = 1;
                                         $xlin = 20;
                                         $xcol = 4;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 10);
                                         $this->objpdf->text(128, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                         $this->objpdf->text(175, $xlin - 13, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                         $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                         $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                         $this->objpdf->text(159, $xlin - 3, 'TIPO : ');
                                         $this->objpdf->text(175, $xlin - 3, $this->emptipo);
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                         /// retangulo dos dados da dotação
                                         $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 50, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                         $this->objpdf->text($xcol + 2, $xlin + 10.5, 'Unidade');
                                         $this->objpdf->text($xcol + 2, $xlin + 14, 'Função');
                                         $this->objpdf->text($xcol + 2, $xlin + 20.5, 'Proj/Ativ');
                                         $this->objpdf->text($xcol + 2, $xlin + 27, 'Rubrica');
                                         $this->objpdf->text($xcol + 2, $xlin + 35, 'Recurso');
                                         if ($this->banco != "") {
                                             $this->objpdf->text($xcol + 2, $xlin + 38.5, 'Banco');
                                             $this->objpdf->text($xcol + 30, $xlin + 38.5, 'Agencia:');
                                             $this->objpdf->text($xcol + 60, $xlin + 38.5, 'Conta:');
                                         }
                                         $this->objpdf->text($xcol + 2, $xlin + 42.5, 'Reduzido');
                                         $this->objpdf->text($xcol + 2, $xlin + 48, 'Licitação');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                         $this->objpdf->text($xcol + 17, $xlin + 10.5, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                         $this->objpdf->text($xcol + 17, $xlin + 14, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                         $this->objpdf->text($xcol + 17, $xlin + 20.5, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                         $this->objpdf->text($xcol + 17, $xlin + 27, ':  ' . db_formatar($this->sintetico, 'elemento'));
                                         $this->objpdf->setxy($xcol + 18, $xlin + 28);
                                         $this->objpdf->multicell(90, 3, $this->descr_sintetico, 0, "L");
                                         $this->objpdf->text($xcol + 17, $xlin + 35, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                         if ($this->banco != "") {
                                             $this->objpdf->text($xcol + 17, $xlin + 38.5, ':  ' . $this->banco);
                                             $this->objpdf->text($xcol + 47, $xlin + 38.5, $this->agencia);
                                             $this->objpdf->text($xcol + 77, $xlin + 38.5, $this->conta);
                                         }
                                         $this->objpdf->text($xcol + 17, $xlin + 42.5, ':  ' . $this->coddot);
                                         $this->objpdf->text($xcol + 17, $xlin + 48, ':  ' . ($this->num_licitacao != null ? $this->num_licitacao . ' - ' : '') . $this->descr_licitacao);
                                         //// retangulo dos dados do credor
                                         $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 18, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 107, $xlin + 7, 'Numcgm');
                                         $this->objpdf->text($xcol + 135, $xlin + 7, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                         $this->objpdf->text($xcol + 107, $xlin + 11, 'Nome');
                                         $this->objpdf->text($xcol + 107, $xlin + 15, 'Endereço');
                                         $this->objpdf->text($xcol + 107, $xlin + 19, 'Município');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 124, $xlin + 7, ': ' . $this->numcgm);
                                         $this->objpdf->text($xcol + 143, $xlin + 7, ': ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')) . ' - Fone: ' . $this->telefone);
                                         $this->objpdf->text($xcol + 124, $xlin + 11, ': ' . $this->nome);
                                         $this->objpdf->text($xcol + 124, $xlin + 15, ': ' . $this->ender . '  ' . $this->compl);
                                         $this->objpdf->text($xcol + 124, $xlin + 19, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                         ///// retangulo dos valores
                                         $this->objpdf->rect($xcol + 106, $xlin + 21.5, 96, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 106, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 155, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 106, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 155, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 34.0, 'Valor Orçado');
                                         $this->objpdf->text($xcol + 157, $xlin + 34.0, 'Saldo Anterior');
                                         $this->objpdf->text($xcol + 108, $xlin + 44.5, 'Valor Empenhado');
                                         $this->objpdf->text($xcol + 157, $xlin + 44.5, 'Saldo Atual');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 108, $xlin + 27, 'AUTORIZAÇÃO N' . chr(176) . ' ' . db_formatar($this->numaut, 's', '0', 5, 'e'));
                                         $this->objpdf->text($xcol + 150, $xlin + 27, 'SEQ. DO EMPENHO N' . chr(176) . ' ' . db_formatar($this->numemp, 's', '0', 6, 'e'));
                                         //	$this->objpdf->text($xcol+108,$xlin+26.5,$this->texto);
                                         $this->objpdf->text($xcol + 130, $xlin + 38.0, db_formatar($this->orcado, 'f'));
                                         $this->objpdf->text($xcol + 180, $xlin + 38.0, db_formatar($this->saldo_ant, 'f'));
                                         $this->objpdf->text($xcol + 130, $xlin + 47.5, db_formatar($this->empenhado, 'f'));
                                         $this->objpdf->text($xcol + 180, $xlin + 47.5, db_formatar($this->saldo_ant - $this->empenhado, 'f'));
                                         /// retangulo do corpo do empenho
                                         $this->objpdf->rect($xcol, $xlin + 60, 15, 100, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 15, $xlin + 60, 137, 100, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 152, $xlin + 60, 25, 123, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 123, 2, 'DF', '');
                                         $this->objpdf->rect($xcol, $xlin + 160, 152, 23, 2, 'DF', '');
                                         //// retangulos do titulo do corpo do empenho
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 15, $xlin + 54, 137, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 152, $xlin + 54, 25, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                         //// título do corpo do empenho
                                         $this->objpdf->text($xcol + 2, $xlin + 58, 'QUANT');
                                         $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                         $this->objpdf->text($xcol + 154, $xlin + 58, 'VALOR UNITÁRIO');
                                         $this->objpdf->text($xcol + 181, $xlin + 58, 'VALOR TOTAL');
                                         $maiscol = 0;
                                         /// monta os dados para itens do empenho
                                         $this->objpdf->SetWidths(array(15, 137, 25, 25));
                                         $this->objpdf->SetAligns(array('C', 'L', 'R', 'R'));
                                         $this->objpdf->setleftmargin(4);
                                         $this->objpdf->sety($xlin + 62);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $ele = 0;
                                         $xtotal = 0;
                                         for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                             db_fieldsmemory($this->recorddositens, $ii);
                                             $this->objpdf->Setfont('Arial', 'B', 7);
                                             if ($ele != pg_result($this->recorddositens, $ii, $this->analitico)) {
                                                 $this->objpdf->cell(15, 4, '', 0, 0, "C", 0);
                                                 $this->objpdf->cell(137, 4, db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), 0, 1, "L", 0);
                                                 $ele = pg_result($this->recorddositens, $ii, $this->analitico);
                                             }
                                             $this->objpdf->Setfont('Arial', '', 7);
                                             $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->quantitem), pg_result($this->recorddositens, $ii, $this->descricaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                             $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                             /////// troca de pagina
                                             if ($this->objpdf->gety() > $this->objpdf->h - 125 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 22 && $pagina != 1) {
                                                 $proxima_pagina = $pagina + 1;
                                                 $this->objpdf->Row(array('', "Continua na página {$proxima_pagina}", '', ''), 3, false, 4);
                                                 if ($pagina == 1) {
                                                     $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                                     //	   $this->objpdf->setfillcolor(0,0,0);
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                                     $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                                     $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                                     $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                                     $this->objpdf->multicell(147, 3.5, $this->resumo);
                                                     $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                                     $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                                     $this->objpdf->cell(30, 10, db_formatar($this->empenhado, 'f'), 0, 0, 'f');
                                                     $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                                     $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                                     $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                                     $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                                     if ($this->assinatura1 != "") {
                                                         $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                                     }
                                                     if ($this->assinatura2 != "") {
                                                         $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                                     }
                                                     if ($this->assinatura3 != "") {
                                                         $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                                     }
                                                     $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                                     $this->objpdf->SetFont('Arial', '', 6);
                                                     //         $this->objpdf->text($xcol+12,$xlin+199,'EMPENHADO E CONFERIDO');
                                                     $this->objpdf->text($xcol + 27 - strlen($this->assinatura1) / 2, $xlin + 213, $this->assinatura1);
                                                     $this->objpdf->text($xcol + 27 - strlen($this->assinatura2) / 2, $xlin + 227, $this->assinatura2);
                                                     $this->objpdf->text($xcol + 27 - strlen($this->assinatura3) / 2, $xlin + 240, $this->assinatura3);
                                                     $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                                     $this->objpdf->text($xcol + 88 - strlen($this->assinaturaprefeito) / 2, $xlin + 227, $this->assinaturaprefeito);
                                                     $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                                     //  $this->objpdf->text($xcol+76,$xlin+227,'PREFEITO MUNICIPAL');
                                                     $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                                     $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                                     $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                                     $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                                     $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                                     $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                                     $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                                     $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                                     $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                                     $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                                     $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                                     $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                                     $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                                     $this->objpdf->SetFont('Arial', '', 6);
                                                     $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                                     $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                                     $this->objpdf->SetFont('Arial', '', 4);
                                                     $this->objpdf->Text(2, 296, $this->texto);
                                                     // texto no canhoto do carne
                                                     $this->objpdf->setfont('Arial', '', 11);
                                                     $xlin = 169;
                                                 }
                                                 $this->objpdf->addpage();
                                                 $pagina += 1;
                                                 $this->objpdf->settopmargin(1);
                                                 $xlin = 20;
                                                 $xcol = 4;
                                                 $this->objpdf->setfillcolor(245);
                                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                 $this->objpdf->setfillcolor(255, 255, 255);
                                                 $this->objpdf->Setfont('Arial', 'B', 11);
                                                 $this->objpdf->text(128, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                                 $this->objpdf->text(175, $xlin - 13, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                                 $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                                 $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                 //.$this->logo
                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                 $this->objpdf->Setfont('Arial', '', 9);
                                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                 $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                 $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                 $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                 $xlin = -30;
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                 //  	    $this->objpdf->Roundedrect($xcol,$xlin+54,15,6,2,'DF','12');
                                                 $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 15, $xlin + 54, 127, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 54, 35, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                                 //  	    $this->objpdf->Roundedrect($xcol,$xlin+60,15,262,2,'DF','34');
                                                 $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 15, $xlin + 60, 127, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 60, 35, 262, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 262, 2, 'DF', '34');
                                                 $this->objpdf->sety($xlin + 66);
                                                 $alt = 4;
                                                 //	    $this->objpdf->text($xcol+4,$xlin+58,'ITEM');
                                                 $this->objpdf->text($xcol + 0.5, $xlin + 58, 'QUANT');
                                                 $this->objpdf->text($xcol + 65, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                                 $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                                 $this->objpdf->text($xcol + 179, $xlin + 58, 'VALOR TOTAL');
                                                 $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                                 $maiscol = 0;
                                             }
                                         }
                                         if ($pagina == 1) {
                                             $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             //	   $this->objpdf->setfillcolor(0,0,0);
                                             $this->objpdf->SetFont('Arial', '', 7);
                                             $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                             $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                             $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                             $this->objpdf->multicell(147, 3.5, $this->resumo);
                                             $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                             $this->objpdf->cell(30, 10, db_formatar($this->empenhado, 'f'), 0, 0, 'f');
                                             //	   $this->rodape($mod_rodape);
                                             $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                             $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                             $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                             $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                             $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                             if ($this->assinatura1 != "") {
                                                 $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                             }
                                             if ($this->assinatura2 != "") {
                                                 $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                             }
                                             if ($this->assinatura3 != "") {
                                                 $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                             }
                                             $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             //         $this->objpdf->text($xcol+12,$xlin+199,'EMPENHADO E CONFERIDO');
                                             $this->objpdf->text($xcol + 27 - strlen($this->assinatura1) / 2, $xlin + 213, $this->assinatura1);
                                             $this->objpdf->text($xcol + 27 - strlen($this->assinatura2) / 2, $xlin + 227, $this->assinatura2);
                                             $this->objpdf->text($xcol + 27 - strlen($this->assinatura3) / 2, $xlin + 240, $this->assinatura3);
                                             $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                             $this->objpdf->text($xcol + 88 - strlen($this->assinaturaprefeito) / 2, $xlin + 227, $this->assinaturaprefeito);
                                             $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                             $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                             $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                             $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                             $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                             $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                             $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                             $this->objpdf->SetFont('Arial', '', 7);
                                             $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                             $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                             $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                             $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                             $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                             $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                             $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                             $this->objpdf->SetFont('Arial', '', 4);
                                             $this->objpdf->Text(2, 296, $this->texto);
                                             // texto no canhoto do carne
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->Text(200, 296, $xxx + 1 . ' via');
                                             // texto no canhoto do carne
                                             $this->objpdf->setfont('Arial', '', 11);
                                             $xlin = 169;
                                         }
                                     }
                                 }
                             } else {
                                 if ($this->modelo == 7) {
                                     ////////// MODELO 7  -  ORDEM DE PAGAMENTO
                                     for ($xxx = 0; $xxx < $this->nvias; $xxx++) {
                                         $this->objpdf->AliasNbPages();
                                         $this->objpdf->AddPage();
                                         $this->objpdf->settopmargin(1);
                                         $pagina = 1;
                                         $xlin = 20;
                                         $xcol = 4;
                                         $ano = $this->ano;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 10);
                                         $this->objpdf->text(128, $xlin - 13, 'ORDEM DE PAGAMENTO N' . CHR(176) . ': ');
                                         $this->objpdf->text(177, $xlin - 13, db_formatar($this->ordpag, 's', '0', 6, 'e'));
                                         $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                         $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 9);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         /// retangulo dos dados da dotação
                                         $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 39, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         //if($ano < 2005){
                                         //  $this->objpdf->text($xcol+2,$xlin+19,'RESTOS A PAGAR ');
                                         //}else{
                                         $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                         $this->objpdf->text($xcol + 2, $xlin + 11, 'Unidade');
                                         $this->objpdf->text($xcol + 2, $xlin + 15, 'Função');
                                         $this->objpdf->text($xcol + 2, $xlin + 19, 'Proj/Ativ');
                                         $this->objpdf->text($xcol + 2, $xlin + 23, 'Dotação');
                                         $this->objpdf->text($xcol + 2, $xlin + 27, 'Elemento');
                                         $this->objpdf->text($xcol + 2, $xlin + 34, 'Recurso');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                         $this->objpdf->text($xcol + 17, $xlin + 11, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                         $this->objpdf->text($xcol + 17, $xlin + 15, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                         $this->objpdf->text($xcol + 17, $xlin + 19, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                         $this->objpdf->text($xcol + 17, $xlin + 23, ':  ' . $this->dotacao);
                                         $this->objpdf->text($xcol + 17, $xlin + 27, ':  ' . db_formatar($this->elemento, 'elemento'));
                                         $this->objpdf->text($xcol + 17, $xlin + 30, '   ' . $this->descr_elemento);
                                         $this->objpdf->text($xcol + 17, $xlin + 34, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                         //}
                                         if ($ano < db_getsession("DB_anousu")) {
                                             $this->objpdf->text($xcol + 2, $xlin + 38, 'RESTOS A PAGAR ');
                                         }
                                         //// retangulo dos dados do credor
                                         $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 27, 2, 'DF', '1234');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         $this->objpdf->text($xcol + 107, $xlin + 9, 'Numcgm');
                                         $this->objpdf->text($xcol + 150, $xlin + 9, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                         $this->objpdf->text($xcol + 107, $xlin + 13, 'Nome');
                                         $this->objpdf->text($xcol + 107, $xlin + 17, 'Endereço');
                                         $this->objpdf->text($xcol + 107, $xlin + 21, 'Município');
                                         $this->objpdf->text($xcol + 107, $xlin + 25, 'Banco/Ag./Conta');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 124, $xlin + 9, ': ' . $this->numcgm);
                                         $this->objpdf->text($xcol + 157, $xlin + 9, ' :  ' . $this->cnpj);
                                         $this->objpdf->text($xcol + 124, $xlin + 13, ': ' . $this->nome);
                                         $this->objpdf->text($xcol + 124, $xlin + 17, ': ' . $this->ender . '  ' . $this->compl);
                                         $this->objpdf->text($xcol + 124, $xlin + 21, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                         if ($this->banco != null) {
                                             $this->objpdf->text($xcol + 131, $xlin + 25, ': ' . $this->banco . ' / ' . $this->agencia . ' / ' . $this->conta);
                                         }
                                         ///// retangulo do empenho
                                         $this->objpdf->rect($xcol + 106, $xlin + 32, 47, 9, 2, 'DF', '1234');
                                         $this->objpdf->rect($xcol + 155, $xlin + 32, 47, 9, 2, 'DF', '1234');
                                         ///// retangulo dos itens
                                         $this->objpdf->rect($xcol + 102, $xlin + 98, 25, 7, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 127, $xlin + 98, 25, 7, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 152, $xlin + 98, 25, 7, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 177, $xlin + 98, 25, 7, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 00, $xlin + 98, 102, 24, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 00, $xlin + 48, 102, 50, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 102, $xlin + 48, 25, 50, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 127, $xlin + 48, 25, 50, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 152, $xlin + 48, 25, 50, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 177, $xlin + 48, 25, 50, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 102, $xlin + 105, 75, 17, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 177, $xlin + 105, 25, 17, 2, 'DF', '34');
                                         ///// retangulo das retenções
                                         $this->objpdf->rect($xcol + 177, $xlin + 179, 25, 8, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 177, $xlin + 171, 25, 8, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 00, $xlin + 133, 75, 46, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 00, $xlin + 179, 75, 8, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 75, $xlin + 133, 25, 46, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 75, $xlin + 179, 25, 8, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 102, $xlin + 133, 75, 38, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 102, $xlin + 171, 75, 8, 2, 'DF', '');
                                         $this->objpdf->rect($xcol + 102, $xlin + 179, 75, 8, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 177, $xlin + 133, 25, 38, 2, 'DF', '12');
                                         //        $this->objpdf->Roundedrect($xcol+177,$xlin+179, 25,5,2,'DF','34');
                                         $this->objpdf->Setfont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 108, $xlin + 34, 'Empenho N' . chr(176));
                                         $this->objpdf->text($xcol + 157, $xlin + 34, 'Valor do Empenho');
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 130, $xlin + 38, db_formatar($this->numemp, 's', '0', 6, 'e'));
                                         $this->objpdf->text($xcol + 180, $xlin + 38, db_formatar($this->empenhado, 'f'));
                                         //// retangulos do titulo do corpo do empenho
                                         //	$this->objpdf->line($xcol,$xlin+42,$xcol+202,$xlin+42);
                                         $this->objpdf->Setfont('Arial', 'B', 10);
                                         $this->objpdf->text($xcol + 2, $xlin + 46, 'Dados da Ordem de Pagto.');
                                         $this->objpdf->Setfont('Arial', 'B', 6);
                                         //// título do corpo do empenho
                                         $maiscol = 0;
                                         /// monta os dados dos elementos da ordem de compra
                                         $this->objpdf->SetWidths(array(20, 80, 25, 25, 25, 25));
                                         $this->objpdf->SetAligns(array('L', 'L', 'R', 'R', 'R', 'R'));
                                         $this->objpdf->setleftmargin(4);
                                         $this->objpdf->sety($xlin + 48);
                                         $this->objpdf->cell(20, 4, 'ELEMENTO', 0, 0, "L");
                                         $this->objpdf->cell(80, 4, 'DESCRIÇÃO', 0, 0, "L");
                                         $this->objpdf->cell(25, 4, 'VALOR', 0, 0, "R");
                                         $this->objpdf->cell(25, 4, 'ANULADO', 0, 0, "R");
                                         $this->objpdf->cell(25, 4, 'PAGO', 0, 0, "R");
                                         $this->objpdf->cell(25, 4, 'SALDO', 0, 1, "R");
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $total_pag = 0;
                                         $total_emp = 0;
                                         $total_anu = 0;
                                         $total_sal = 0;
                                         for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                             db_fieldsmemory($this->recorddositens, $ii);
                                             $this->objpdf->Setfont('Arial', '', 7);
                                             $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->elementoitem), pg_result($this->recorddositens, $ii, $this->descr_elementoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->vlremp), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlranu), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlrpag), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlrsaldo), 'f')), 3, false, 3);
                                             $total_emp += pg_result($this->recorddositens, $ii, $this->vlremp);
                                             $total_anu += pg_result($this->recorddositens, $ii, $this->vlranu);
                                             $total_pag += pg_result($this->recorddositens, $ii, $this->vlrpag);
                                             $total_sal += pg_result($this->recorddositens, $ii, $this->vlrsaldo);
                                         }
                                         /// monta os dados das retenções da ordem de compra
                                         $this->objpdf->SetWidths(array(10, 62, 25));
                                         $this->objpdf->SetAligns(array('C', 'L', 'R'));
                                         $this->objpdf->setleftmargin(4);
                                         $this->objpdf->setxy($xcol + 102, $xlin + 134);
                                         $this->objpdf->Setfont('Arial', 'B', 10);
                                         $this->objpdf->text($xcol + 104, $xlin + 131, 'Dados das Retenções');
                                         $this->objpdf->text($xcol + 2, $xlin + 131, 'Repasses');
                                         $this->objpdf->Setfont('Arial', 'b', 7);
                                         $this->objpdf->cell(10, 4, 'REC.', 0, 0, "L");
                                         $this->objpdf->cell(62, 4, 'DESCRIÇÃO', 0, 0, "L");
                                         $this->objpdf->cell(25, 4, 'VALOR', 0, 1, "R");
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $total_ret = 0;
                                         for ($ii = 0; $ii < $this->linhasretencoes; $ii++) {
                                             $this->objpdf->setx($xcol + 102);
                                             db_fieldsmemory($this->recordretencoes, $ii);
                                             $this->objpdf->Setfont('Arial', '', 7);
                                             $this->objpdf->Row(array(pg_result($this->recordretencoes, $ii, $this->receita), pg_result($this->recordretencoes, $ii, $this->dreceita), db_formatar(pg_result($this->recordretencoes, $ii, $this->vlrrec), 'f')), 3, false, 3);
                                             $total_ret += pg_result($this->recordretencoes, $ii, $this->vlrrec);
                                         }
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->setxy($xcol + 100, $xlin + 100);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->cell(25, 4, db_formatar($total_emp, 'f'), 0, 0, "R");
                                         $this->objpdf->cell(25, 4, db_formatar($total_anu, 'f'), 0, 0, "R");
                                         $this->objpdf->cell(25, 4, db_formatar($total_pag, 'f'), 0, 0, "R");
                                         $this->objpdf->cell(25, 4, db_formatar($total_sal, 'f'), 0, 1, "R");
                                         $this->objpdf->setxy($xcol + 127, $xlin + 107);
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->cell(50, 5, 'TOTAL DA ORDEM', 0, 0, "R");
                                         $this->objpdf->cell(23, 5, db_formatar($total_emp - $total_anu, 'f'), 0, 1, "R");
                                         $this->objpdf->setx($xcol + 127);
                                         $this->objpdf->cell(50, 5, 'OUTRAS ORDENS', 0, 0, "R");
                                         $this->objpdf->cell(23, 4, db_formatar($this->outrasordens, 'f'), 0, 1, "R");
                                         $this->objpdf->setx($xcol + 127);
                                         $this->objpdf->cell(50, 5, 'VALOR RESTANTE', 0, 0, "R");
                                         $this->objpdf->cell(23, 4, db_formatar($this->empenhado - $this->outrasordens - $total_emp - $total_anu, 'f'), 0, 1, "R");
                                         $this->objpdf->Setfont('Arial', 'b', 8);
                                         $this->objpdf->text($xcol + 2, $xlin + 102, 'OBSERVAÇÕES :');
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->setxy($xcol, $xlin + 103);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->multicell(102, 4, $this->obs);
                                         /// total das retenções
                                         $this->objpdf->setxy($xcol + 127, $xlin + 172);
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->cell(50, 5, 'TOTAL ', 0, 0, "R");
                                         $this->objpdf->cell(23, 5, db_formatar($total_ret, 'f'), 0, 1, "R");
                                         /// total dos repasses
                                         $this->objpdf->setxy($xcol, $xlin + 181);
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->cell(75, 5, 'TOTAL ', 0, 0, "R");
                                         $this->objpdf->cell(23, 5, db_formatar(0, 'f'), 0, 1, "R");
                                         /// liquido da ordem de compra
                                         $this->objpdf->setxy($xcol + 127, $xlin + 181);
                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                         $this->objpdf->cell(50, 5, 'LÍQUIDO DA ORDEM DE PAGTO. ', 0, 0, "R");
                                         $this->objpdf->cell(23, 5, db_formatar($total_sal - $total_ret, 'f'), 0, 1, "R");
                                         $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '');
                                         $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                         $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                         $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                         $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                         if ($this->municpref == "GUAIBA") {
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->line($xcol + 12, $xlin + 221, $xcol + 43, $xlin + 221);
                                             $this->objpdf->line($xcol + 74, $xlin + 221, $xcol + 100, $xlin + 221);
                                             $this->objpdf->text($xcol + 13, $xlin + 224, 'JORGE ANTONIO POKORSKI');
                                             $this->objpdf->text($xcol + 76, $xlin + 224, 'MANOEL STRINGHINI');
                                             $this->objpdf->text($xcol + 76, $xlin + 227, 'PREFEITO MUNICIPAL');
                                             $this->objpdf->text($xcol + 13, $xlin + 227, 'SECRETÁRIO DA FAZENDA');
                                         } else {
                                             $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                             $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                             $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->text($xcol + 12, $xlin + 199, 'EMPENHADO E CONFERIDO');
                                             $this->objpdf->text($xcol + 26, $xlin + 213, 'VISTO');
                                             if (strtoupper(trim($this->municpref)) != 'SAPIRANGA') {
                                                 $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                                 $this->objpdf->text($xcol + 19, $xlin + 227, 'TÉCNICO CONTÁBIL');
                                                 $this->objpdf->text($xcol + 13, $xlin + 240, 'SECRETÁRIO(A) DA FAZENDA');
                                             }
                                             $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                             $this->objpdf->text($xcol + 76, $xlin + 227, 'PREFEITO MUNICIPAL');
                                         }
                                         $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                         $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                         $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                         $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                         $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                         $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                         $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                         $this->objpdf->SetFont('Arial', '', 7);
                                         $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                         $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                         $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                         $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                         $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                         $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                         $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                         $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                         $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                         $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                         $this->objpdf->SetFont('Arial', '', 6);
                                         $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                         $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                         $this->objpdf->SetFont('Arial', '', 4);
                                         $this->objpdf->Text(2, 296, $this->texto);
                                         // texto no canhoto do carne
                                         $this->objpdf->SetFont('Arial', '', 6);
                                         $this->objpdf->Text(200, 296, $xxx + 1 . ' via');
                                         // texto no canhoto do carne
                                         $this->objpdf->setfont('Arial', '', 11);
                                         $xlin = 169;
                                     }
                                 } else {
                                     if ($this->modelo == 8) {
                                         //// Ficha de transferencia de bens
                                         $this->objpdf->AliasNbPages();
                                         //	$this->objpdf->AddPage();
                                         $this->objpdf->settopmargin(1);
                                         $this->objpdf->line(2, 148.5, 208, 148.5);
                                         $xlin = 20;
                                         $xcol = 4;
                                         $comeco = 0;
                                         $passada = 0;
                                         if ($this->linhasbens < 40) {
                                             $vias = 2;
                                         } elseif ($this->linhasbens < 80) {
                                             $vias = 4;
                                         } elseif ($this->linhasbens < 120) {
                                             $vias = 6;
                                         } elseif ($this->linhasbens < 160) {
                                             $vias = 8;
                                         } elseif ($this->linhasbens < 200) {
                                             $vias = 10;
                                         }
                                         for ($i = 0; $i < $vias; $i++) {
                                             if ($i % 2 == 0) {
                                                 $this->objpdf->AddPage();
                                             }
                                             $this->objpdf->setfillcolor(245);
                                             $this->objpdf->roundedrect($xcol - 2, $xlin - 18, 206, 144.5, 2, 'DF', '1234');
                                             $this->objpdf->setfillcolor(255, 255, 255);
                                             //		$this->objpdf->roundedrect(10,07,190,183,2,'DF','1234');
                                             $this->objpdf->Setfont('Arial', 'B', 11);
                                             $this->objpdf->text(150, $xlin - 13, 'TRANSFERÊNCIA N' . chr(176) . '  ' . $this->codtransf);
                                             $this->objpdf->text(159, $xlin - 8, $this->datacalc);
                                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                             $this->objpdf->Setfont('Arial', '', 9);
                                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                             //		$this->objpdf->setfillcolor(245);
                                             $this->objpdf->Roundedrect($xcol, $xlin + 2, $xcol + 98, 20, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 5, 'Origem:');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 9, 'Departamento ');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 22, $xlin + 9, ':  ' . $this->origem);
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 16, 'Usuario');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 22, $xlin + 16, ':  ' . $this->usuario);
                                             $this->objpdf->Setfont('Arial', '', 6);
                                             $this->objpdf->Roundedrect($xcol + 104, $xlin + 2, 98, 20, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 106, $xlin + 5, 'Destino:');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 106, $xlin + 9, 'Departamento');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 128, $xlin + 9, ':  ' . $this->destino);
                                             //		$this->objpdf->setfillcolor(245);
                                             $this->objpdf->Roundedrect($xcol, $xlin + 24, 202, 70, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 27, 'Itens a Transmitir :');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 30, 'BEM');
                                             $this->objpdf->text($xcol + 25, $xlin + 30, 'DESCRIÇÃO');
                                             $this->objpdf->text($xcol + 75, $xlin + 30, 'CLASSIFICAÇÃO');
                                             $this->objpdf->text($xcol + 102, $xlin + 30, 'BEM');
                                             $this->objpdf->text($xcol + 125, $xlin + 30, 'DESCRIÇÃO');
                                             $this->objpdf->text($xcol + 175, $xlin + 30, 'CLASSIFICAÇÃO');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->sety($xlin + 31);
                                             $maiscol = 0;
                                             $yy = $this->objpdf->gety();
                                             for ($ii = $comeco; $ii < $this->linhasbens; $ii++) {
                                                 if ($ii % 40 == 0 && $ii > 0 && $passada == 0) {
                                                     $maiscol = 0;
                                                     $passada++;
                                                     $comeco = $ii;
                                                     break;
                                                 } elseif ($ii % 20 == 0 && $ii > 0 && $ii % 40 != 0) {
                                                     $maiscol = 100;
                                                     $this->objpdf->sety($yy);
                                                 }
                                                 $this->objpdf->setx($xcol + 3 + $maiscol);
                                                 $this->objpdf->cell(5, 3, trim(pg_result($this->recordbens, $ii, $this->bem)), 0, 0, "R", 0);
                                                 $this->objpdf->cell(70, 3, trim(pg_result($this->recordbens, $ii, $this->descr_bem)), 0, 0, "L", 0);
                                                 $this->objpdf->cell(15, 3, pg_result($this->recordbens, $ii, $this->class_bem), 0, 1, "R", 0);
                                                 if ($ii + 1 == $this->linhasbens) {
                                                     $comeco = 0;
                                                     $passada = 0;
                                                     break;
                                                 }
                                             }
                                             $this->objpdf->line($xcol + 10, $xlin + 116, $xcol + 70, $xlin + 116);
                                             $this->objpdf->text($xcol + 30, $xlin + 120, 'TRANSMITENTE');
                                             $this->objpdf->line($xcol + 135, $xlin + 116, $xcol + 195, $xlin + 116);
                                             $this->objpdf->text($xcol + 155, $xlin + 120, 'RECEBEDOR');
                                             if ($i % 2 == 0) {
                                                 $xlin = 169;
                                             } else {
                                                 $xlin = 20;
                                             }
                                         }
                                     } else {
                                         if ($this->modelo == 9) {
                                             $this->objpdf->SetTextColor(0, 0, 0);
                                             $this->objpdf->SetFont('Arial', 'B', 12);
                                             $coluna = 44;
                                             $linha = 20;
                                             $this->objpdf->SetLineWidth(1);
                                             $this->objpdf->RoundedRect(37, 0.2, 137, 195, 2, '1234');
                                             $this->objpdf->SetLineWidth(0.5);
                                             $this->objpdf->roundedrect(39, 2, 133, 191, 2, '1234');
                                             $this->objpdf->SetLineWidth(0.2);
                                             $this->objpdf->Image('imagens/files/Brasao.png', 43, 5, 20);
                                             $this->objpdf->Image('imagens/files/Brasao.jpg', 60, 30, 100);
                                             //	$this->objpdf->roundedrect(42,$linha+30,127,35,2,'1234');
                                             //	$this->objpdf->roundedrect(42,$linha+72,127,15,2,'1234'); // obs da atividade principal
                                             //  	$this->objpdf->roundedrect(42,$linha+88,127,5,2,'1234'); // descricao da atividade secundaria
                                             //	$this->objpdf->roundedrect(42,$linha+94,127,15,2,'1234'); // obs da atividade secundaria
                                             //	$this->objpdf->setdrawcolor(235);
                                             $this->objpdf->setxy(65, 8);
                                             $this->objpdf->setfont('Arial', 'B', 13);
                                             $this->objpdf->Multicell(0, 8, $this->prefeitura, "C");
                                             // prefeitura
                                             $this->objpdf->setxy(65, 15);
                                             $this->objpdf->setfont('Arial', 'B', 13);
                                             $this->objpdf->setleftmargin(50);
                                             $this->objpdf->setrightmargin(50);
                                             $this->objpdf->Multicell(0, 8, $this->tipoalvara, 0, "C", 0);
                                             // tipo de alvara
                                             $this->objpdf->Ln(6);
                                             $this->objpdf->sety(28);
                                             $this->objpdf->SetFont('Arial', '', 11);
                                             $this->objpdf->multicell(0, 5, db_geratexto($this->texto), 0, "J", 0, 20);
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 35, 'INSCRIÇÃO:');
                                             // inscricao
                                             if ($this->processo > 0) {
                                                 $this->objpdf->Text($coluna + 70, $linha + 35, 'PROCESSO:');
                                                 // inscricao
                                             }
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 35, $this->nrinscr);
                                             // inscricao
                                             if ($this->processo > 0) {
                                                 $this->objpdf->Text($coluna + 90, $linha + 35, $this->processo);
                                                 // processo
                                             }
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 39, "NOME/RAZAO SOCIAL: ");
                                             // nome
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 39, $this->nome);
                                             // nome
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 43, "CNPJ/CPF: ");
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 43, $this->cnpjcpf);
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 47, "ENDEREÇO: ");
                                             // endereco
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 47, $this->ender);
                                             // endereco
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 51, "NÚMERO: ");
                                             // endereco
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 51, $this->numero == "" ? "" : $this->numero);
                                             if ($this->compl != "") {
                                                 $this->objpdf->SetFont('Arial', 'B', 9);
                                                 $this->objpdf->Text($coluna + 60, $linha + 51, "COMPLEMENTO: ");
                                                 // endereco
                                                 $this->objpdf->SetFont('Arial', '', 9);
                                                 $this->objpdf->Text($coluna + 90, $linha + 51, $this->compl == "" ? "" : $this->compl);
                                             }
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 55, "DATA DE INCLUSAO: ");
                                             if ($this->datafim != "") {
                                                 $this->objpdf->Text($coluna + 60, $linha + 55, "VALIDADE ATÉ: ");
                                             }
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 55, db_formatar($this->datainc, 'd'));
                                             if ($this->datafim != "") {
                                                 $this->objpdf->Text($coluna + 85, $linha + 55, db_formatar($this->datafim, 'd'));
                                             }
                                             $this->objpdf->setx(40);
                                             if ($this->q02_memo != '') {
                                                 $this->objpdf->SetFont('Arial', 'B', 9);
                                                 $this->objpdf->Text($coluna, $linha + 59, "OBSERVAÇÃO: ");
                                                 // observação
                                                 $this->objpdf->SetFont('Arial', '', 9);
                                                 $this->objpdf->sety($linha + 60);
                                                 $this->objpdf->Multicell(0, 3, $this->q02_memo);
                                                 // texto
                                                 $this->objpdf->SetFont('Arial', 'B', 10);
                                                 $this->objpdf->roundedrect(42, $linha + 30, 127, 38, 2, '1234');
                                                 $linha = 90;
                                             } else {
                                                 $this->objpdf->roundedrect(42, $linha + 30, 127, 27, 2, '1234');
                                                 $linha = 79;
                                             }
                                             $this->objpdf->sety($linha);
                                             $this->objpdf->roundedrect(42, $linha - 1, 127, 5, 2, '1234');
                                             $this->objpdf->SetFont('Arial', 'B', 8);
                                             $this->objpdf->Ln(0.5);
                                             $this->objpdf->setx(45);
                                             $this->objpdf->Multicell(0, 3, "ATIVIDADE PRINCIPAL: " . $this->descrativ);
                                             // descrição da atividade principal
                                             $linha += 6;
                                             $yyy = $this->objpdf->gety();
                                             $obs = '';
                                             if (isset($this->q03_atmemo[$this->ativ])) {
                                                 if ($this->q03_atmemo[$this->ativ] != '') {
                                                     $obs = $this->q03_atmemo[$this->ativ];
                                                     $this->objpdf->Ln(3);
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->Multicell(0, 3, $this->q03_atmemo[$this->ativ]);
                                                     // texto
                                                     //		 $linha += 16;
                                                     $yyyatual = $this->objpdf->gety();
                                                     $this->objpdf->roundedrect(42, $linha - 1, 127, $yyyatual - $yyy, 2, '1234');
                                                     // obs da atividade principal
                                                 }
                                             }
                                             $yyy = $this->objpdf->gety();
                                             $linha = $this->objpdf->gety() + 2;
                                             $this->objpdf->sety($linha);
                                             //        $this->objpdf->sety($linha);
                                             $num_outras = count($this->outrasativs);
                                             $x = 105;
                                             $y = $linha + 1;
                                             if ($num_outras > 0) {
                                                 $x = $x + 4;
                                                 reset($this->outrasativs);
                                                 $this->objpdf->Ln(2);
                                                 $this->objpdf->setx(45);
                                                 $yyy = $this->objpdf->gety() + 7;
                                                 $this->objpdf->SetFont('Arial', 'B', 8);
                                                 //           $this->objpdf->roundedrect(42,$yyy-1,127,5,2,'1234'); // descricao da atividade secundaria
                                                 $this->objpdf->Multicell(0, 3, "ATIVIDADE" . ($num_outras > 1 ? "S" : "") . " SECUNDÁRIA" . ($num_outras > 1 ? "S" : "") . ":");
                                                 $linha += 6;
                                                 $this->objpdf->Ln(2);
                                                 $this->objpdf->roundedrect(42, $y, 127, 5, 2, '1234');
                                                 // descricao da atividade secundaria
                                                 for ($i = 0; $i < $num_outras; $i++) {
                                                     $yyy = $this->objpdf->gety();
                                                     $chave = key($this->outrasativs);
                                                     $obs = '';
                                                     if (isset($this->q03_atmemo[$chave])) {
                                                         $obs = $this->q03_atmemo[$chave];
                                                     }
                                                     $this->objpdf->SetFont('Arial', '', 8);
                                                     //             $this->objpdf->roundedrect(42,$yyy-1,127,5,2,'1234'); // descricao da atividade secundaria
                                                     $this->objpdf->Ln(0.5);
                                                     $this->objpdf->setx(45);
                                                     // 	     $this->objpdf->Multicell(0,3,"ATIVIDADE SECUNDÁRIA: " . $this->outrasativs[$chave]); // texto
                                                     $this->objpdf->Multicell(0, 3, $this->outrasativs[$chave]);
                                                     // texto
                                                     $linha += 4;
                                                     if ($obs != "") {
                                                         $yyyant = $this->objpdf->gety();
                                                         //               $this->objpdf->Ln(1);
                                                         $this->objpdf->SetFont('Arial', 'B', 7);
                                                         $this->objpdf->Multicell(0, 3, $obs);
                                                         // texto
                                                         $yyyatual = $this->objpdf->gety();
                                                         //               $this->objpdf->roundedrect(42,$linha-1,127,$yyyatual-$yyyant+1,2,'1234'); // obs da atividade secundaria
                                                         $linha += $yyyatual - $yyyant;
                                                     }
                                                     $x = $x + 4;
                                                     next($this->outrasativs);
                                                     //             $this->objpdf->ln(2.5);
                                                     $this->objpdf->sety($linha);
                                                     $yyyatual = $this->objpdf->gety();
                                                     //	     if  ($i >= 5) break;
                                                     if ($yyyatual >= 130) {
                                                         break;
                                                     }
                                                 }
                                                 $this->objpdf->roundedrect(42, $y, 127, $linha - $y, 2, '1234');
                                                 // descricao da atividade secundaria
                                             }
                                             $x = 64;
                                             //	$this->objpdf->sety(135);
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Multicell(0, 4, $this->obs);
                                             // observação
                                             //        if($this->q02_obs!=''){
                                             //	  $this->objpdf->Text($coluna,$linha+$x,"OBSERVAÇÃO: "); // descrição da atividade principal
                                             //	  $this->objpdf->Text($coluna + 45,$linha+$x,$this->q02_obs); // descrição da atividade principal
                                             //	  $x=$x+4;
                                             //	}
                                             $this->objpdf->ln(10);
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->cell($coluna, 5, '', 0, 0, "L", 0);
                                             $this->objpdf->cell(60, 5, "DATA DE EMISSÃO DESTE DOCUMENTO.", 0, 1, "L", 0);
                                             $this->objpdf->cell($coluna, 5, '', 0, 0, "L", 0);
                                             $this->objpdf->cell(60, 5, $this->municpref . ", " . date('d') . " DE " . strtoupper(db_mes(date('m'))) . " DE " . date('Y') . ".", 0, 1, "L", 0);
                                             // data
                                             global $db02_texto;
                                             $sqlparag = "select db02_texto \n\t\t     from db_documento \n\t\t     inner join db_docparag on db03_docum = db04_docum \n\t\t     inner join db_paragrafo on db04_idparag = db02_idparag \n\t\t     where db03_docum = 26 and db02_descr ilike '%Assinatura Secretario%' and db03_instit = " . db_getsession("DB_instit");
                                             $resparag = pg_query($sqlparag);
                                             if (pg_numrows($resparag) == 0) {
                                                 db_redireciona('db_erros.php?fechar=true&db_erro=Configure o documento 26 com os paragrafos do alvara!');
                                                 exit;
                                             }
                                             db_fieldsmemory($resparag, 0);
                                             $this->objpdf->setfont('arial', '', 6);
                                             $this->objpdf->SetXY($coluna - 18, 170);
                                             $this->objpdf->MultiCell(90, 4, '..........................................................................................' . "\n" . $db02_texto, 0, "C", 0);
                                             $this->objpdf->SetXY($coluna + 50, 170);
                                             $this->objpdf->MultiCell(90, 4, '..........................................................................................', 0, "C", 0);
                                             //        $this->objpdf->SetXY($coluna-35,160);
                                             //        $this->objpdf->MultiCell(90,4,'..........................................................................................'."\n".'SECRETÁRIO DA IND. COM. E TURISMO',0,"C",0);
                                             //        $this->objpdf->SetXY($coluna+35,160);
                                             //        $this->objpdf->MultiCell(90,4,'..........................................................................................',0,"C",0);
                                             $this->objpdf->sety(185);
                                             $this->objpdf->setfont('arial', 'B', 12);
                                             $this->objpdf->multicell(0, 6, 'FIXAR EM LUGAR VISÍVEL', 1, "C");
                                             $this->objpdf->SetFont('Arial', 'B', 10);
                                         } else {
                                             if ($this->modelo == 10) {
                                                 ////////// MODELO 10  -  ORDEM DE COMPRA
                                                 $this->objpdf->AliasNbPages();
                                                 $this->objpdf->AddPage();
                                                 $this->objpdf->settopmargin(1);
                                                 $this->objpdf->setleftmargin(4);
                                                 $pagina = 1;
                                                 $xlin = 20;
                                                 $xcol = 4;
                                                 $this->objpdf->setfillcolor(245);
                                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                 $this->objpdf->setfillcolor(255, 255, 255);
                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                 $this->objpdf->text(130, $xlin - 13, 'ORDEM DE COMPRA N' . CHR(176));
                                                 $this->objpdf->text(185, $xlin - 13, db_formatar($this->numordem, 's', '0', 6, 'e'));
                                                 $this->objpdf->text(130, $xlin - 10, 'DATA :');
                                                 $this->objpdf->text(185, $xlin - 10, db_formatar($this->dataordem, 'd'));
                                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                 //.$this->logo
                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                 $this->objpdf->Setfont('Arial', '', 9);
                                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                 //	$this->objpdf->text(40,$xlin- 7,$this->municpref);
                                                 $this->objpdf->text(40, $xlin - 7, "FONE: " . $this->telefpref);
                                                 $this->objpdf->text(40, $xlin - 3, $this->emailpref);
                                                 $this->objpdf->text(40, $xlin + 1, $this->url . " - CNPJ:" . db_formatar($this->cgc, 'cnpj'));
                                                 $this->objpdf->rect($xcol, $xlin + 2, $xcol + 198, 20, 2, 'DF', '1234');
                                                 $this->objpdf->Setfont('Arial', '', 6);
                                                 $this->objpdf->text($xcol + 2, $xlin + 4.5, 'Dados do Fornecedor');
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                 $this->objpdf->text($xcol + 109, $xlin + 8, 'Numcgm');
                                                 $this->objpdf->text($xcol + 150, $xlin + 8, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                                 $this->objpdf->text($xcol + 2, $xlin + 8, 'Nome');
                                                 $this->objpdf->text($xcol + 2, $xlin + 12, 'Endereço');
                                                 $this->objpdf->text($xcol + 102, $xlin + 12, 'Complemento');
                                                 $this->objpdf->text($xcol + 2, $xlin + 16, 'Município');
                                                 $this->objpdf->text($xcol + 115, $xlin + 16, 'CEP');
                                                 $this->objpdf->text($xcol + 2, $xlin + 20, 'Contato');
                                                 $this->objpdf->text($xcol + 110, $xlin + 20, 'Telefone');
                                                 $this->objpdf->text($xcol + 155, $xlin + 20, 'FAX');
                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                 $this->objpdf->text($xcol + 157, $xlin + 8, ' :  ' . $this->cnpj);
                                                 $this->objpdf->text($xcol + 122, $xlin + 8, ':  ' . $this->numcgm);
                                                 $this->objpdf->text($xcol + 18, $xlin + 8, ':  ' . $this->nome);
                                                 $this->objpdf->text($xcol + 18, $xlin + 12, ':  ' . $this->ender);
                                                 $this->objpdf->text($xcol + 122, $xlin + 12, ':  ' . $this->compl);
                                                 $this->objpdf->text($xcol + 18, $xlin + 16, ':  ' . $this->munic . '-' . $this->uf);
                                                 $this->objpdf->text($xcol + 122, $xlin + 16, ':  ' . $this->cep);
                                                 $this->objpdf->text($xcol + 18, $xlin + 20, ':  ' . $this->contato);
                                                 $this->objpdf->text($xcol + 122, $xlin + 20, ':  ' . $this->telef_cont);
                                                 $this->objpdf->text($xcol + 162, $xlin + 20, ':  ' . $this->telef_fax);
                                                 global $ordemdecompra1;
                                                 global $ordemdecompra2;
                                                 global $descrtexto;
                                                 global $conteudotexto;
                                                 $sqltexto = "select * from db_config where codigo = " . db_getsession("DB_instit");
                                                 $resulttexto = pg_exec($sqltexto);
                                                 db_fieldsmemory($resulttexto, 0, true);
                                                 $sqltexto = "select * from db_usuarios where id_usuario = " . db_getsession("DB_id_usuario");
                                                 $resulttexto = pg_exec($sqltexto);
                                                 db_fieldsmemory($resulttexto, 0, true);
                                                 $sqltexto = "select * from db_textos where id_instit = " . db_getsession("DB_instit") . " and ( descrtexto like 'ordemdecompra%')";
                                                 $resulttexto = pg_exec($sqltexto);
                                                 for ($xx = 0; $xx < pg_numrows($resulttexto); $xx++) {
                                                     db_fieldsmemory($resulttexto, $xx, true);
                                                     $text = $descrtexto;
                                                     ${$text} = db_geratexto($conteudotexto);
                                                 }
                                                 $texto1 = @$ordemdecompra1;
                                                 $texto2 = @$ordemdecompra2;
                                                 $result_endent = pg_exec("select * from db_departender inner join ruas on j14_codigo = codlograd inner join bairro on j13_codi = codbairro where coddepto = " . $this->depto);
                                                 if (pg_numrows($result_endent) > 0) {
                                                     db_fieldsmemory($result_endent, 0, true);
                                                     global $j14_nome;
                                                     global $numero;
                                                     global $compl;
                                                     global $j13_descr;
                                                     $this->objpdf->sety($xlin + 24);
                                                     $posicao_atual = $this->objpdf->gety();
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     $this->objpdf->multicell(202, 4, "{$texto1}", 1);
                                                     $this->objpdf->multicell(202, 4, "ENDERECO DE ENTREGA: {$j14_nome}, {$numero} - {$compl}\nBAIRRO: {$j13_descr}", 1);
                                                     $posicao_depois = $this->objpdf->gety();
                                                     $xlin += $posicao_depois - $posicao_atual + 2;
                                                 }
                                                 $this->objpdf->sety($xlin + 24);
                                                 $posicao_atual = $this->objpdf->gety();
                                                 $this->objpdf->multicell(202, 4, "PRAZO DE ENTREGA: " . $this->prazoent . " DIAS A CONTAR DA DATA DO RECEBIMENTO DESTA ORDEM DE COMPRA", 1);
                                                 $this->objpdf->multicell(202, 4, "CONDICOES DE PAGAMENTO: " . pg_result($this->recorddositens, 0, $this->condpag), 1);
                                                 $this->objpdf->multicell(202, 4, "DESTINO: " . pg_result($this->recorddositens, 0, $this->destino), 1);
                                                 $posicao_depois = $this->objpdf->gety();
                                                 $xlin += $posicao_depois - $posicao_atual + 2;
                                                 if ($this->obs != "") {
                                                     $this->objpdf->sety($xlin + 24);
                                                     $posicao_atual = $this->objpdf->gety();
                                                     $this->objpdf->multicell(202, 4, "OBSERVAÇÕES:  " . $this->obs, 1);
                                                     $posicao_depois = $this->objpdf->gety();
                                                     $xlin += $posicao_depois - $posicao_atual + 2;
                                                 }
                                                 $this->objpdf->sety($xlin + 24);
                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                 $this->objpdf->rect($xcol, $xlin + 24, 12, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 12, $xlin + 24, 15, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 27, $xlin + 24, 11, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 38, $xlin + 24, 104, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 24, 30, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol + 172, $xlin + 24, 30, 6, 2, 'DF', '12');
                                                 $this->objpdf->rect($xcol, $xlin + 30, 12, 205 - $xlin, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 12, $xlin + 30, 15, 205 - $xlin, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 27, $xlin + 30, 11, 205 - $xlin, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 38, $xlin + 30, 104, 205 - $xlin, 2, 'DF', '34');
                                                 $this->objpdf->rect($xcol + 142, $xlin + 30, 30, 205 - $xlin, 2, 'DF', '');
                                                 $this->objpdf->rect($xcol + 172, $xlin + 30, 30, 205 - $xlin, 2, 'DF', '34');
                                                 //	$this->objpdf->rect($xcol,$xlin+182,142,23,2,'DF','');
                                                 $this->objpdf->sety($xlin + 28);
                                                 $alt = 4;
                                                 $this->objpdf->text($xcol + 2, $xlin + 28, 'ITEM');
                                                 $this->objpdf->text($xcol + 12.5, $xlin + 28, 'EMPENHO');
                                                 $this->objpdf->text($xcol + 27.5, $xlin + 28, 'QUANT');
                                                 $this->objpdf->text($xcol + 70, $xlin + 28, 'MATERIAL OU SERVIÇO');
                                                 $this->objpdf->text($xcol + 145, $xlin + 28, 'VALOR UNITÁRIO');
                                                 $this->objpdf->text($xcol + 176, $xlin + 28, 'VALOR TOTAL');
                                                 $maiscol = 0;
                                                 $this->objpdf->setfillcolor(0, 0, 0);
                                                 $this->objpdf->text($xcol + 10, 290, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                                 $this->objpdf->text($xcol + 120, 290, '___________________________________________');
                                                 $this->objpdf->SetWidths(array(12, 16, 10, 104, 30, 30));
                                                 $this->objpdf->SetAligns(array('C', 'C', 'C', 'L', 'R', 'R'));
                                                 $this->objpdf->setleftmargin(4);
                                                 $this->objpdf->sety($xlin + 32);
                                                 $xtotal = 0;
                                                 $item = 1;
                                                 for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                     db_fieldsmemory($this->recorddositens, $ii);
                                                     $this->objpdf->Setfont('Arial', '', 8);
                                                     $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->codmater), pg_result($this->recorddositens, $ii, $this->empempenho) . "/" . pg_result($this->recorddositens, $ii, $this->anousuemp), pg_result($this->recorddositens, $ii, $this->quantitem), pg_result($this->recorddositens, $ii, $this->descricaoitem) . "\n" . pg_result($this->recorddositens, $ii, $this->observacaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                                     $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                                     $item++;
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     /////// troca de pagina
                                                     if ($this->objpdf->gety() > $this->objpdf->h - 85 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 40 && $pagina != 1) {
                                                         if ($this->objpdf->PageNo() == 1) {
                                                             if ($this->obs != "") {
                                                                 $this->objpdf->text(110, 268 - $xlin, 'Continua na Página ' . ($pagina + 1));
                                                                 //$this->objpdf->rect($xcol,$xlin+217,202,55,2,'DF','1234');
                                                             } else {
                                                                 $this->objpdf->text(110, $xlin + 243, 'Continua na Página ' . ($pagina + 1));
                                                             }
                                                         } else {
                                                             $this->objpdf->text(110, $xlin + 320, 'Continua na Página ' . ($pagina + 1));
                                                         }
                                                         if ($pagina == 1) {
                                                             $xlin = 20;
                                                             $xcol = 4;
                                                             $this->objpdf->rect($xcol, $xlin + 205, 142, 10, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 142, $xlin + 205, 30, 10, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 172, $xlin + 205, 30, 10, 2, 'DF', '34');
                                                             $this->objpdf->text($xcol + 100, $xlin + 211, 'T O T A L   D A   P Á G I N A');
                                                             $this->objpdf->SetXY(172, $xlin + 205);
                                                             $this->objpdf->cell(30, 10, db_formatar($xtotal, 'f'), 0, 0, "R");
                                                             $this->objpdf->SetXY(4, $xlin + 217);
                                                             $this->objpdf->multicell(202, 4, $texto2, 1);
                                                         }
                                                         $this->objpdf->addpage();
                                                         $pagina += 1;
                                                         $this->objpdf->settopmargin(1);
                                                         $xlin = 20;
                                                         $xcol = 4;
                                                         $this->objpdf->setfillcolor(245);
                                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                         $this->objpdf->setfillcolor(255, 255, 255);
                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                         $this->objpdf->text(130, $xlin - 13, 'ORDEM DE COMPRA N' . CHR(176));
                                                         $this->objpdf->text(185, $xlin - 13, db_formatar($this->numordem, 's', '0', 6, 'e'));
                                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                         //.$this->logo
                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                         $this->objpdf->Setfont('Arial', '', 9);
                                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                         $xlin = -30;
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         $this->objpdf->rect($xcol, $xlin + 54, 12, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 12, $xlin + 54, 15, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 27, $xlin + 54, 11, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 38, $xlin + 54, 104, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol, $xlin + 60, 12, 252, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 12, $xlin + 60, 15, 252, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 27, $xlin + 60, 11, 252, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 38, $xlin + 60, 104, 252, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 252, 2, 'DF', '');
                                                         $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 252, 2, 'DF', '34');
                                                         $this->objpdf->sety($xlin + 66);
                                                         $alt = 4;
                                                         $this->objpdf->text($xcol + 2, $xlin + 59, 'ITEM');
                                                         $this->objpdf->text($xcol + 12.5, $xlin + 59, 'EMPENHO');
                                                         $this->objpdf->text($xcol + 27.5, $xlin + 59, 'QUANT');
                                                         $this->objpdf->text($xcol + 70, $xlin + 59, 'MATERIAL OU SERVIÇO');
                                                         $this->objpdf->text($xcol + 145, $xlin + 59, 'VALOR UNITÁRIO');
                                                         $this->objpdf->text($xcol + 176, $xlin + 59, 'VALOR TOTAL');
                                                         $this->objpdf->text($xcol + 40, $xlin + 63, 'Continuação da Página ' . ($pagina - 1));
                                                         $maiscol = 0;
                                                     }
                                                 }
                                                 if ($pagina == 1) {
                                                     $xlin = 20;
                                                     $xcol = 4;
                                                     $this->objpdf->rect($xcol, $xlin + 205, 142, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 142, $xlin + 205, 30, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 172, $xlin + 205, 30, 10, 2, 'DF', '34');
                                                     $this->objpdf->text($xcol + 100, $xlin + 211, 'T O T A L   G E R A L');
                                                     $this->objpdf->SetXY(172, $xlin + 205);
                                                     $this->objpdf->cell(30, 10, db_formatar($xtotal, 'f'), 0, 0, "R");
                                                     $this->objpdf->SetXY(4, $xlin + 217);
                                                     $this->objpdf->multicell(202, 4, $texto2, 1);
                                                 } else {
                                                     $this->objpdf->rect($xcol, $xlin + 312, 12, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 12, $xlin + 312, 15, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 27, $xlin + 312, 11, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 38, $xlin + 312, 104, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 142, $xlin + 312, 30, 10, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 172, $xlin + 312, 30, 10, 2, 'DF', '34');
                                                     /*
                                                     	  $this->objpdf->rect($xcol,    $xlin+295,142, 10,2,'DF','34');
                                                     	  $this->objpdf->rect($xcol+142,$xlin+295,30, 10,2,'DF','34');
                                                     	  $this->objpdf->rect($xcol+172,$xlin+295,30, 10,2,'DF','34');
                                                     */
                                                     $this->objpdf->text($xcol + 100, $xlin + 319, 'T O T A L   G E R A L');
                                                     $this->objpdf->text($xcol + 172, $xlin + 319, db_formatar($xtotal, 'f'));
                                                 }
                                                 //	$this->objpdf->multicell(202,4,"A) PARA INFORMAÇÕES SOBRE O PRESENTE ORDEM, FAVOR ENTRAR EM CONTATO COM MARA, PELO TELEFONE (055) 3961 1616, OU EM NOSSA SEDE: MAJOR JOÃO CEZIMBRA JACQUES, 200\n",1);
                                                 //	$this->objpdf->multicell(202,4,"B) AS NOTAS FISCAIS DEVEM SER ENCAMMINHADAS AO SETOR DE ALMOXARIFADO CENTRAL - CAM, EM 2 VIAS COM NUMERO DE EMPENHO E CONTA BANCARIA.",1);
                                                 //	$this->objpdf->multicell(202,4,"NAO SERAO ACEITAS NOTAS FISCAIS CONTENDO ITENS DE MAIS DE UMA ORDEM DE COMPRA",1);
                                                 //	$this->objpdf->multicell(202,4,"OS PRODUTOS DEVERAO SER ENTREGUES NO ALMOXARIFADO CENTRAL - CAM - CENTRO ADM MUNICIPAL NO PRAZO MAXIMO DE " . $this->prazoent. " DIAS A CONTAR DA DATA DO RECEBIMENTO DESTA ORDEM DE COMPRA",1);
                                                 $posicao_depois = $this->objpdf->gety();
                                                 $xlin += $posicao_depois - $posicao_atual + 2;
                                             } else {
                                                 if ($this->modelo == 11) {
                                                     global $contapagina;
                                                     $contapagina = 1;
                                                     if (!in_array("cl_orcreservasol", get_declared_classes())) {
                                                         include "classes/db_orcreservasol_classe.php";
                                                     }
                                                     $clorcreservasol = new cl_orcreservasol();
                                                     ////////// MODELO 11  -  SOLICITAÇÃO DE COMPRA
                                                     $this->objpdf->AliasNbPages();
                                                     $this->objpdf->AddPage();
                                                     $this->objpdf->settopmargin(1);
                                                     $pagina = 1;
                                                     $xlin = 20;
                                                     $xcol = 4;
                                                     // Imprime caixa externa
                                                     $this->objpdf->setfillcolor(245);
                                                     $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                     // Imprime o cabeçalho com dados sobre a prefeitura
                                                     $this->objpdf->setfillcolor(255, 255, 255);
                                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                                     $this->objpdf->text(130, $xlin - 13, 'SOLICITAÇÃO DE COMPRA N' . CHR(176));
                                                     $this->objpdf->text(185, $xlin - 13, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                                     $this->objpdf->text(130, $xlin - 9, 'ORGÃO');
                                                     $this->objpdf->text(142, $xlin - 9, ': ' . substr($this->Sorgao, 0, 35));
                                                     $this->objpdf->text(130, $xlin - 5, 'UNIDADE');
                                                     $this->objpdf->text(142, $xlin - 5, ': ' . substr($this->Sunidade, 0, 35));
                                                     $this->objpdf->text(130, $xlin - 1, 'USUÁRIO');
                                                     $this->objpdf->text(142, $xlin - 1, ': ' . substr($this->Susuarioger, 0, 35));
                                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                                     $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                                     $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                     $this->objpdf->Setfont('Arial', '', 9);
                                                     $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                     $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                     $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                     $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                     $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     // caixa para frases
                                                     $this->objpdf->rect($xcol, $xlin + 3, $xcol + 198, 9, 2, 'DF', '1234');
                                                     $this->objpdf->SetXY(4, $xlin + 4);
                                                     $this->objpdf->MultiCell(202, 4, 'QUANDO NECESSÁRIO FRETE, O MESMO CORRERÁ POR CONTA DO FORNECEDOR', 0, "C", 0);
                                                     $this->objpdf->SetXY(4, $xlin + 8);
                                                     $this->objpdf->MultiCell(202, 4, 'TODO FRETE DEVERÁ SER PAGO PELA EMPRESA REMETENTE - O MATERIAL DEVERÁ SER DE PRIMEIRA QUALIDADE', 0, "C", 0);
                                                     $this->objpdf->Setfont('Arial', '', 8);
                                                     // Caixa com dados da solicitação
                                                     $this->objpdf->rect($xcol, $xlin + 13, $xcol + 198, 10, 2, 'DF', '1234');
                                                     $this->objpdf->Setfont('Arial', '', 6);
                                                     $this->objpdf->text($xcol + 2, $xlin + 15, 'Dados do Solicitação');
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     $this->objpdf->text($xcol + 2, $xlin + 18, 'Departamento');
                                                     $this->objpdf->text($xcol + 109, $xlin + 18, 'Tipo');
                                                     $this->objpdf->text($xcol + 2, $xlin + 22, 'Data');
                                                     $this->objpdf->text($xcol + 109, $xlin + 22, 'Val. Aprox.');
                                                     // Imprime dados da solicitação
                                                     $this->objpdf->text($xcol + 23, $xlin + 18, ':  ' . $this->Sdepart);
                                                     if (isset($this->Sdata) && trim($this->Sdata) != "") {
                                                         $this->Sdata = db_formatar($this->Sdata, 'd');
                                                     }
                                                     if (isset($this->Svalor) && trim($this->Svalor) != "") {
                                                         $this->Svalor = db_formatar($this->Svalor, 'f');
                                                     }
                                                     $this->objpdf->text($xcol + 125, $xlin + 18, ':  ' . $this->Stipcom);
                                                     $this->objpdf->text($xcol + 23, $xlin + 22, ':  ' . $this->Sdata);
                                                     $this->objpdf->text($xcol + 125, $xlin + 22, ':  R$ ' . $this->Svalor);
                                                     $this->objpdf->text($xcol + 2, $xlin + 27, 'Resumo');
                                                     $this->objpdf->setxy($xcol + 22, $xlin + 24);
                                                     $this->objpdf->cell(3, 4, ':  ', 0, 0, "L", 0);
                                                     $this->objpdf->setxy($xcol + 24.5, $xlin + 24);
                                                     $posini = $this->objpdf->gety();
                                                     $this->objpdf->multicell(175, 4, trim(AddSlashes($this->Sresumo)), 0, "j");
                                                     $setaut = $this->objpdf->gety();
                                                     $oldsetaut = $setaut;
                                                     $setaut += 8;
                                                     $newsetaut = $setaut;
                                                     if ($setaut > 64) {
                                                         $newsetaut = $setaut - 8;
                                                         $tiramenos = $setaut - 64;
                                                         $setaut = $setaut - $posini;
                                                     } else {
                                                         if ($setaut == 64) {
                                                             $newsetaut = $setaut - 8;
                                                             $setaut -= 8;
                                                         } else {
                                                             if ($setaut == 60) {
                                                                 $newsetaut = $setaut - 4;
                                                                 $setaut -= 4;
                                                             }
                                                         }
                                                     }
                                                     //	db_msgbox($setaut.' -- '.$posini);
                                                     $this->objpdf->rect($xcol, $xlin + 24, $xcol + 198, $newsetaut - $posini, 2, 'DF', '1234');
                                                     $getdoy = 32;
                                                     $contafornec = 0;
                                                     if ($this->linhasdosfornec > 0) {
                                                         $x = $this->muda_pag($pagina, $xlin, $xcol, "true", $contapagina);
                                                         for ($i = 0; $i < $this->linhasdosfornec; $i++) {
                                                             $contafornec += 4;
                                                         }
                                                         $onze = 11;
                                                         if ($oldsetaut + 8 > 64) {
                                                             $setaut += 36;
                                                         }
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         // Caixa de texto para labels
                                                         $this->objpdf->rect($xcol, $setaut + 0.8, 202, 6, 2, 'DF', '12');
                                                         $this->objpdf->text($xcol + 4, $setaut + 4.2, 'FORNECEDORES SUGERIDOS ');
                                                         $this->objpdf->rect($xcol, $setaut + 6.8, 15, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 15, $setaut + 6.8, 64, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 79, $setaut + 6.8, 63, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 142, $setaut + 6.8, 40, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 182, $setaut + 6.8, 20, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol, $setaut + 12.8, 15, $contafornec + 1, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 15, $setaut + 12.8, 64, $contafornec + 1, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 79, $setaut + 12.8, 63, $contafornec + 1, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 142, $setaut + 12.8, 40, $contafornec + 1, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 182, $setaut + 12.8, 20, $contafornec + 1, 2, 'DF', '34');
                                                         $this->objpdf->sety($xlin + 66);
                                                         // Label das colunas
                                                         $this->objpdf->text($xcol + 4, $setaut + 11, 'CGM');
                                                         $this->objpdf->text($xcol + 30.5, $setaut + 11, 'NOME/RAZÃO SOCIAL');
                                                         $this->objpdf->text($xcol + 103, $setaut + 11, 'ENDEREÇO');
                                                         $this->objpdf->text($xcol + 155, $setaut + 11, 'MUNICÍPIO');
                                                         $this->objpdf->text($xcol + 184.5, $setaut + 11, 'TELEFONE');
                                                         // Seta altura nova para impressão dos dados
                                                         $this->objpdf->sety($setaut + 13.8);
                                                         $this->objpdf->setx($xcol);
                                                         $this->objpdf->setleftmargin(4);
                                                         $this->objpdf->Setfont('Arial', '', 7);
                                                         $this->objpdf->SetAligns(array('C', 'L', 'L', 'L', 'C'));
                                                         $this->objpdf->SetWidths(array(15, 64, 63, 40, 20));
                                                         for ($i = 0; $i < $this->linhasdosfornec; $i++) {
                                                             db_fieldsmemory($this->recorddosfornec, $i);
                                                             $cgmforn = trim(pg_result($this->recorddosfornec, $i, $this->cgmforn));
                                                             $nomeforn = trim(pg_result($this->recorddosfornec, $i, $this->nomeforn));
                                                             $enderforn = trim(pg_result($this->recorddosfornec, $i, $this->enderforn));
                                                             $numforn = trim(pg_result($this->recorddosfornec, $i, $this->numforn));
                                                             $municforn = trim(pg_result($this->recorddosfornec, $i, $this->municforn));
                                                             $foneforn = trim(pg_result($this->recorddosfornec, $i, $this->foneforn));
                                                             $this->objpdf->Row(array($cgmforn, $nomeforn, $enderforn . ", " . $numforn, $municforn, $foneforn), 4, false, 4);
                                                         }
                                                         $getdoy = $this->objpdf->gety();
                                                         $getdoy += 0.8;
                                                         $getdoy = $getdoy - $xlin;
                                                         $contafornec += 8;
                                                     } else {
                                                         $getdoy += 4.8;
                                                         if ($oldsetaut + 8 > 64) {
                                                             $getdoy += 8;
                                                         }
                                                     }
                                                     // Caixas dos label's
                                                     $this->objpdf->rect($xcol, $xlin + $getdoy, 10, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 10, $xlin + $getdoy, 12, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 22, $xlin + $getdoy, 22, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 44, $xlin + $getdoy, 98, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 142, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                     $this->objpdf->rect($xcol + 172, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                     $menos = 16.9;
                                                     if ($this->linhasdosfornec == 0) {
                                                         $menos = 11;
                                                     }
                                                     if (isset($tiramenos)) {
                                                         $menos = $menos + $tiramenos;
                                                         if ($menos < 0) {
                                                             $menos = -$menos;
                                                         }
                                                     }
                                                     // Caixa dos itens
                                                     $this->objpdf->rect($xcol, $xlin + $getdoy + 6, 10, 193 - $contafornec - $menos, 2, 'DF', '34');
                                                     // Caixa da quantidade
                                                     $this->objpdf->rect($xcol + 10, $xlin + $getdoy + 6, 12, 193 - $contafornec - $menos, 2, 'DF', '34');
                                                     $this->objpdf->rect($xcol + 22, $xlin + $getdoy + 6, 22, 193 - $contafornec - $menos, 2, 'DF', '34');
                                                     // Caixa dos materiais ou serviços
                                                     $this->objpdf->rect($xcol + 44, $xlin + $getdoy + 6, 98, 193 - $contafornec - $menos, 2, 'DF', '34');
                                                     // Caixa dos valores unitários
                                                     $this->objpdf->rect($xcol + 142, $xlin + $getdoy + 6, 30, 193 - $contafornec - $menos, 2, 'DF', '');
                                                     // Caixa dos valores totais dos itens
                                                     $this->objpdf->rect($xcol + 172, $xlin + $getdoy + 6, 30, 193 - $contafornec - $menos, 2, 'DF', '34');
                                                     $this->objpdf->sety($xlin + 28);
                                                     // Label das colunas
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     $this->objpdf->text($xcol + 2, $xlin + $getdoy + 4, 'ITEM');
                                                     $this->objpdf->text($xcol + 11, $xlin + $getdoy + 4, 'QUANT');
                                                     $this->objpdf->text($xcol + 30, $xlin + $getdoy + 4, 'REF');
                                                     $this->objpdf->text($xcol + 70, $xlin + $getdoy + 4, 'MATERIAL OU SERVIÇO');
                                                     $this->objpdf->text($xcol + 145, $xlin + $getdoy + 4, 'VALOR UNITÁRIO');
                                                     $this->objpdf->text($xcol + 176, $xlin + $getdoy + 4, 'VALOR TOTAL');
                                                     $maiscol = 0;
                                                     $this->objpdf->setleftmargin(3);
                                                     $this->objpdf->sety($xlin + $getdoy + 7);
                                                     $xtotal = 0;
                                                     $muda_pag = false;
                                                     $index = 0;
                                                     for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                         $itemant = "";
                                                         $pass = false;
                                                         $this->objpdf->SetWidths(array(10, 12, 24, 95, 30, 30));
                                                         $this->objpdf->SetAligns(array('C', 'C', 'C', 'J', 'R', 'R'));
                                                         $pagina = $this->objpdf->PageNo();
                                                         db_fieldsmemory($this->recorddositens, $ii);
                                                         if ($ii != 0 && $muda_pag == false) {
                                                             $muda_pag = false;
                                                             $this->objpdf->ln(0.3);
                                                             $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                             $this->objpdf->ln(1.3);
                                                         }
                                                         $codigo = pg_result($this->recorddositens, $ii, "pc11_codigo");
                                                         $item = pg_result($this->recorddositens, $ii, $this->item);
                                                         $quantitem = pg_result($this->recorddositens, $ii, $this->quantitem);
                                                         $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem);
                                                         $valoritem = db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), "f");
                                                         $valtot = pg_result($this->recorddositens, $ii, $this->svalortot);
                                                         $valimp = db_formatar($valtot, 'f');
                                                         $prazo = pg_result($this->recorddositens, $ii, $this->sprazo);
                                                         $pgto = pg_result($this->recorddositens, $ii, $this->spgto);
                                                         $resum = pg_result($this->recorddositens, $ii, $this->sresum);
                                                         $just = pg_result($this->recorddositens, $ii, $this->sjust);
                                                         $unid = pg_result($this->recorddositens, $ii, $this->sunidade);
                                                         $abrevunid = pg_result($this->recorddositens, $ii, $this->sabrevunidade);
                                                         $servico = pg_result($this->recorddositens, $ii, $this->sservico);
                                                         $quantunid = pg_result($this->recorddositens, $ii, $this->squantunid);
                                                         $susaquant = pg_result($this->recorddositens, $ii, $this->susaquant);
                                                         $scodpcmater = pg_result($this->recorddositens, $ii, $this->scodpcmater);
                                                         $selemento = pg_result($this->recorddositens, $ii, $this->selemento);
                                                         $sdelemento = pg_result($this->recorddositens, $ii, $this->sdelemento);
                                                         $xtotal += $valtot;
                                                         if (isset($descricaoitem) && (trim($descricaoitem) == "" || $descricaoitem == null) || !isset($descricaoitem)) {
                                                             $descricaoitem = $resum;
                                                             unset($resum);
                                                         }
                                                         if (isset($scodpcmater) && trim($scodpcmater) != "") {
                                                             $scodpcmater = trim($scodpcmater) . " - ";
                                                         }
                                                         if (isset($prazo) && trim($prazo) != "") {
                                                             $prazo = "\nPRAZO: " . trim($prazo);
                                                         }
                                                         if (isset($pgto) && trim($pgto) != "") {
                                                             $pgto = "\nCONDIÇÃO: " . trim($pgto);
                                                         }
                                                         if (isset($resum) && trim($resum) != "") {
                                                             $resum = "\nRESUMO: " . trim($resum);
                                                         }
                                                         if (isset($just) && trim($just) != "") {
                                                             $just = "\nJUSTIFICATIVA: " . trim($just);
                                                         }
                                                         if (isset($servico) && (trim($servico) == "f" || trim($servico) == "") || !isset($servico)) {
                                                             $unid = trim(substr($unid, 0, 10));
                                                             if ($susaquant == "t") {
                                                                 $unid .= " \n{$quantunid} UNIDADES\n";
                                                             }
                                                         } else {
                                                             $unid = "SERVIÇO";
                                                         }
                                                         //	  $descricaoitem .= " - ".$unid;
                                                         $distanciar = 0;
                                                         if (isset($prazo) && trim($prazo) == "" && (isset($pgto) && trim($pgto) == "") && (isset($resum) && trim($resum) == "") && (isset($just) && trim($just) == "")) {
                                                             $distanciar = 4;
                                                         } else {
                                                         }
                                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                                         if (isset($selemento) && trim($selemento) != "") {
                                                             $this->objpdf->Row(array('', '', '', db_formatar($selemento, 'elemento') . " - " . $sdelemento, '', ''), 3, false, 4);
                                                         }
                                                         $this->objpdf->Row(array($item, $quantitem, $unid, $scodpcmater . $descricaoitem, $valoritem, $valimp), 3, false, $distanciar);
                                                         $dist = 2.7;
                                                         $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                         //	  if(isset($unid) && $unid!=""){
                                                         //	    $this->objpdf->Row(array('','',$unid,'',''),3,false,$dist);
                                                         //	    $x = $this->muda_pag($pagina,$xlin,$xcol,"false",$contapagina);
                                                         //	  }
                                                         $this->objpdf->Setfont('Arial', '', 7);
                                                         $mostraunid = false;
                                                         if (isset($prazo) && $prazo != "") {
                                                             $this->objpdf->Row(array('', '', $unid, $prazo, '', ''), 3, false, $dist);
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                         }
                                                         if (isset($pgto) && $pgto != "") {
                                                             $this->objpdf->Row(array('', '', '', $pgto, '', ''), 3, false, $dist);
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                         }
                                                         if (isset($resum) && $resum != "" && (isset($scodpcmater) && trim($scodpcmater) != "")) {
                                                             $this->objpdf->Row(array('', '', '', $resum, '', ''), 3, false, $dist);
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                         }
                                                         if (isset($just) && $just != "") {
                                                             $this->objpdf->Row(array('', '', '', $just, '', ''), 3, false, $dist);
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                         }
                                                         $this->objpdf->SetWidths(array(10, 12, 24, 95, 30, 30));
                                                         $this->objpdf->SetWidths(array(10, 12, 24, 23.7, 23.7, 23.7, 23.7, 0.2, 30, 30));
                                                         $arr_dotac = array();
                                                         for ($i = 0; $i < $this->linhasdasdotac; $i++) {
                                                             db_fieldsmemory($this->recorddasdotac, $i);
                                                             if (pg_result($this->recorddasdotac, $i, $this->dcodigo) == $codigo && !in_array(pg_result($this->recorddasdotac, $i, $this->dcoddot), $arr_dotac)) {
                                                                 if ($item != $itemant) {
                                                                     $pass = true;
                                                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                                                     $distc = 3.5;
                                                                     $distb = 3;
                                                                     $this->objpdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'R', 'R'));
                                                                     $this->objpdf->Row(array('', '', "\n", '', ''), 3, false, $dist);
                                                                     $this->objpdf->Row(array('', '', '', "DOTAÇÃO", "ANO", "ELEMENTO", "RESERVADO", '', ''), 3, false, $dist);
                                                                     $itemant = $item;
                                                                 }
                                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                                 $this->objpdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'R', 'R'));
                                                                 $dquant = pg_result($this->recorddasdotac, $i, $this->dquant);
                                                                 $danousu = pg_result($this->recorddasdotac, $i, $this->danousu);
                                                                 $dcoddot = pg_result($this->recorddasdotac, $i, $this->dcoddot);
                                                                 $dvalor = pg_result($this->recorddasdotac, $i, $this->dvalor);
                                                                 $delemento = pg_result($this->recorddasdotac, $i, $this->delemento);
                                                                 //	      $dreserva = pg_result($this->recorddasdotac,$i,$this->dreserva);
                                                                 array_push($arr_dotac, $dcoddot);
                                                                 if (isset($dcoddot) && trim($dcoddot) != "") {
                                                                     $result_orcreservasol = $clorcreservasol->sql_record($clorcreservasol->sql_query_orcreserva(null, null, "o82_codres as codigodareserva,o80_valor as valorreserva", "", "o82_solicitem={$codigo} and o80_coddot={$dcoddot}"));
                                                                     $ddvalor = "NÃO";
                                                                     if ($clorcreservasol->numrows > 0) {
                                                                         db_fieldsmemory($result_orcreservasol, 0);
                                                                         global $valorreserva;
                                                                         $valorreserva = db_formatar($valorreserva, "f");
                                                                         if ($valorreserva == $valimp) {
                                                                             $ddvalor = "TOTAL";
                                                                         } else {
                                                                             $ddvalor = $valorreserva;
                                                                         }
                                                                     }
                                                                     $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                                     $this->objpdf->Row(array('', $dquant, '', $dcoddot, $danousu, $delemento, $ddvalor, '', db_formatar($dvalor / $dquant, "f"), db_formatar($dvalor, "f")), $distc, false, $distb);
                                                                 }
                                                             } else {
                                                                 $pass = false;
                                                             }
                                                         }
                                                     }
                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                     $maislin = 248;
                                                     if ($contapagina == 1) {
                                                         $maislin = 211;
                                                     }
                                                     $this->objpdf->text(180, $xlin + $maislin + 20, db_formatar($xtotal, 'f'));
                                                     if ($contapagina == 1) {
                                                         $this->objpdf->rect($xcol, $xlin + 224.7, 142, 10.8, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 142, $xlin + 224.7, 30, 10.8, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 172, $xlin + 224.7, 30, 10.8, 2, 'DF', '34');
                                                         $this->objpdf->text($xcol + 120, $xlin + 230.7, 'T O T A L');
                                                         if (strtoupper(trim($this->municpref)) != 'SAPIRANGA') {
                                                             $this->objpdf->rect($xcol, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 68, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 136, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 5, $xlin + 244, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                                             $this->objpdf->text($xcol + 20, $xlin + 256, "AUTORIZO", 0, 4);
                                                             $this->objpdf->text($xcol + 5, $xlin + 268, substr($this->Sorgao, 0, 35));
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 93, $xlin + 256, "AUTORIZO", 0, 4);
                                                             if (strtoupper(trim($this->municpref)) != 'GUAIBA') {
                                                                 $this->objpdf->text($xcol + 83, $xlin + 268, 'DIV. DE ABASTECIMENTO', 0, 40);
                                                             }
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 150, $xlin + 256, "ORDENADOR DA DESPESA", 0, 4);
                                                         } else {
                                                             $this->objpdf->Setfont('Arial', 'B', 7);
                                                             $this->objpdf->rect($xcol, $xlin + 227, 66, 45, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 68, $xlin + 227, 66, 45, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 136, $xlin + 227, 66, 45, 2, 'DF', '1234');
                                                             $this->objpdf->SetXY($xcol + 00, $xlin + 238);
                                                             $this->objpdf->multicell(66, 4, "SOLICITANTE", 0, "C");
                                                             $this->objpdf->SetXY($xcol + 00, $xlin + 243.5);
                                                             $this->objpdf->multicell(66, 0.5, "_________________________________", 0, "C");
                                                             $this->objpdf->SetXY($xcol + 00, $xlin + 249.5);
                                                             //   SECRETÁRIO(A) DA SECRETARIA QUE SOLICITOU   //
                                                             $this->objpdf->multicell(66, 4, "SECRETÁRIO", 0, "C");
                                                             $this->objpdf->text($xcol + 10, $xlin + 254.5, substr($this->Sorgao, 0, 30), 0, 4);
                                                             ///////////////////////////////////////////////////
                                                             $this->objpdf->text($xcol + 10, $xlin + 260, "_________________________________", 0, 4);
                                                             //	    $this->objpdf->multicell(66,0.5,"_________________________________",0,"C");
                                                             $this->objpdf->text($xcol + 10, $xlin + 270, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                                             //	    $this->objpdf->SetXY($xcol+68,$xlin+243.5);
                                                             //	    $this->objpdf->multicell(66,0.5,"_________________________________",0,"C");
                                                             $this->objpdf->SetXY($xcol + 68, $xlin + 238);
                                                             $this->objpdf->multicell(66, 4, "CONTABILIDADE", 0, "C");
                                                             $this->objpdf->SetXY($xcol + 68, $xlin + 249);
                                                             $this->objpdf->multicell(66, 4, "HÁ RECURSOS FINANCEIROS", 0, "C");
                                                             $tamanho = strlen($this->secfaz);
                                                             $posicao = strpos($this->secfaz, "\n");
                                                             $secretaria = $this->secfaz;
                                                             $deque = "";
                                                             if ($posicao != "" && $posicao != 0) {
                                                                 $secretaria = substr($this->secfaz, 0, $posicao);
                                                                 $deque = substr($this->secfaz, $posicao, $tamanho);
                                                             }
                                                             $this->objpdf->text($xcol + 85, $xlin + 257, $secretaria, 0, 4);
                                                             $this->objpdf->text($xcol + 84.5, $xlin + 259.5, $deque, 0, 4);
                                                             $this->objpdf->text($xcol + 92, $xlin + 264, "CONFERIDO", 0, 4);
                                                             $this->objpdf->text($xcol + 83.5, $xlin + 270, "________/________/________", 0, 4);
                                                             $this->objpdf->SetXY($xcol + 136, $xlin + 240);
                                                             $this->objpdf->multicell(66, 4, $this->nompre, 0, "C");
                                                             $this->objpdf->SetXY($xcol + 136, $xlin + 252);
                                                             $this->objpdf->multicell(66, 4, "AUTORIZO", 0, "C");
                                                             $this->objpdf->text($xcol + 150.5, $xlin + 270, "________/________/________", 0, 4);
                                                             //	    $this->objpdf->text($xcol+14,$xlin+247,"________/________/________",0,4);
                                                             /*
                                                             $this->objpdf->text($xcol+20,$xlin+241,strtoupper($this->municpref).', '.substr($this->emissao,8,2).' DE '.strtoupper(db_mes(substr($this->emissao,5,2))).' DE '.substr($this->emissao,0,4).'.');
                                                             $this->objpdf->rect($xcol,$xlin+237,100,35,2,'DF','1234');
                                                             $this->objpdf->rect($xcol+102,$xlin+237,100,35,2,'DF','1234');
                                                             
                                                             $this->objpdf->text($xcol+40,$xlin+256,"AUTORIZO",0,4);
                                                             $this->objpdf->text($xcol+20,$xlin+264,substr($this->Srespdepart,0,35));
                                                             $this->objpdf->text($xcol+20,$xlin+268,substr($this->Sdepart,0,35));
                                                             $this->objpdf->text($xcol+145,$xlin+256,"VISTO",0,4);
                                                             */
                                                         }
                                                     } else {
                                                         $this->objpdf->rect($xcol, $xlin + 262, 142, 10, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 142, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                         $this->objpdf->rect($xcol + 172, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                         $this->objpdf->text($xcol + 120, $xlin + 268, 'T O T A L');
                                                     }
                                                 } else {
                                                     if ($this->modelo == 111) {
                                                         global $contapagina;
                                                         $contapagina = 1;
                                                         if (!in_array("cl_orcreservasol", get_declared_classes())) {
                                                             include "classes/db_orcreservasol_classe.php";
                                                         }
                                                         $clorcreservasol = new cl_orcreservasol();
                                                         ////////// MODELO 111  -  SOLICITAÇÃO DE COMPRA
                                                         $this->objpdf->AliasNbPages();
                                                         $this->objpdf->AddPage();
                                                         $this->objpdf->settopmargin(1);
                                                         $pagina = 1;
                                                         $xlin = 20;
                                                         $xcol = 4;
                                                         // Imprime caixa externa
                                                         $this->objpdf->setfillcolor(245);
                                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                         // Imprime o cabeçalho com dados sobre a prefeitura
                                                         $this->objpdf->setfillcolor(255, 255, 255);
                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                         $this->objpdf->text(130, $xlin - 13, 'SOLICITAÇÃO DE COMPRA N' . CHR(176));
                                                         $this->objpdf->text(185, $xlin - 13, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                                         $this->objpdf->text(130, $xlin - 9, 'ORGAO');
                                                         $this->objpdf->text(142, $xlin - 9, ': ' . substr($this->Sorgao, 0, 35));
                                                         $this->objpdf->text(130, $xlin - 5, 'UNIDADE');
                                                         $this->objpdf->text(142, $xlin - 5, ': ' . substr($this->Sunidade, 0, 35));
                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                         $this->objpdf->Setfont('Arial', '', 9);
                                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         // caixa para frases
                                                         $this->objpdf->rect($xcol, $xlin + 3, $xcol + 198, 9, 2, 'DF', '1234');
                                                         $this->objpdf->SetXY(4, $xlin + 4);
                                                         $this->objpdf->MultiCell(202, 4, 'QUANDO NECESSÁRIO FRETE, O MESMO CORRERÁ POR CONTA DO FORNECEDOR', 0, "C", 0);
                                                         $this->objpdf->SetXY(4, $xlin + 8);
                                                         $this->objpdf->MultiCell(202, 4, 'TODO FRETE DEVERÁ SER PAGO PELA EMPRESA REMETENTE - O MATERIAL DEVERÁ SER DE PRIMEIRA QUALIDADE', 0, "C", 0);
                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                         // Caixa com dados da solicitação
                                                         $this->objpdf->rect($xcol, $xlin + 13, $xcol + 198, 10, 2, 'DF', '1234');
                                                         $this->objpdf->Setfont('Arial', '', 6);
                                                         $this->objpdf->text($xcol + 2, $xlin + 15, 'Dados do Solicitação');
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         $this->objpdf->text($xcol + 2, $xlin + 18, 'Departamento');
                                                         $this->objpdf->text($xcol + 109, $xlin + 18, 'Tipo');
                                                         $this->objpdf->text($xcol + 2, $xlin + 22, 'Data');
                                                         $this->objpdf->text($xcol + 109, $xlin + 22, 'Val. Aprox.');
                                                         // Imprime dados da solicitação
                                                         $this->objpdf->text($xcol + 23, $xlin + 18, ':  ' . $this->Sdepart);
                                                         if (isset($this->Sdata) && trim($this->Sdata) != "") {
                                                             $this->Sdata = db_formatar($this->Sdata, 'd');
                                                         }
                                                         if (isset($this->Svalor) && trim($this->Svalor) != "") {
                                                             $this->Svalor = db_formatar($this->Svalor, 'f');
                                                         }
                                                         $this->objpdf->text($xcol + 125, $xlin + 18, ':  ' . $this->Stipcom);
                                                         $this->objpdf->text($xcol + 23, $xlin + 22, ':  ' . $this->Sdata);
                                                         $this->objpdf->text($xcol + 125, $xlin + 22, ':  R$ ' . $this->Svalor);
                                                         $this->objpdf->text($xcol + 2, $xlin + 27, 'Resumo');
                                                         $this->objpdf->setxy($xcol + 22, $xlin + 24);
                                                         $this->objpdf->cell(3, 4, ':  ', 0, 0, "L", 0);
                                                         $this->objpdf->setxy($xcol + 24.5, $xlin + 24);
                                                         $posini = $this->objpdf->gety();
                                                         $this->objpdf->multicell(175, 4, trim(AddSlashes($this->Sresumo)), 0, "j");
                                                         $setaut = $this->objpdf->gety();
                                                         $this->objpdf->rect($xcol, $xlin + 24, $xcol + 198, $setaut - $posini, 2, 'DF', '1234');
                                                         $getdoy = 32;
                                                         $contafornec = 0;
                                                         if ($this->linhasdosfornec > 0) {
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "true", $contapagina);
                                                             for ($i = 0; $i < $this->linhasdosfornec; $i++) {
                                                                 $contafornec += 4;
                                                             }
                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                             // Caixa de texto para labels
                                                             $this->objpdf->rect($xcol, $setaut + 0.8, 202, 6, 2, 'DF', '12');
                                                             $this->objpdf->text($xcol + 4, $setaut + 4.2, 'FORNECEDORES SUGERIDOS ');
                                                             $this->objpdf->rect($xcol, $setaut + 6.8, 15, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 15, $setaut + 6.8, 64, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 79, $setaut + 6.8, 63, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 142, $setaut + 6.8, 40, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 182, $setaut + 6.8, 20, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol, $setaut + 12.8, 15, $contafornec + 1, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 15, $setaut + 12.8, 64, $contafornec + 1, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 79, $setaut + 12.8, 63, $contafornec + 1, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 142, $setaut + 12.8, 40, $contafornec + 1, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 182, $setaut + 12.8, 20, $contafornec + 1, 2, 'DF', '34');
                                                             $this->objpdf->sety($xlin + 66);
                                                             // Label das colunas
                                                             $this->objpdf->text($xcol + 4, $setaut + 11, 'CGM');
                                                             $this->objpdf->text($xcol + 30.5, $setaut + 11, 'NOME/RAZÃO SOCIAL');
                                                             $this->objpdf->text($xcol + 103, $setaut + 11, 'ENDEREÇO');
                                                             $this->objpdf->text($xcol + 155, $setaut + 11, 'MUNICÍPIO');
                                                             $this->objpdf->text($xcol + 184.5, $setaut + 11, 'TELEFONE');
                                                             // Seta altura nova para impressão dos dados
                                                             $this->objpdf->sety($setaut + 13.8);
                                                             $this->objpdf->setx($xcol);
                                                             $this->objpdf->setleftmargin(4);
                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                             $this->objpdf->SetAligns(array('C', 'L', 'L', 'L', 'C'));
                                                             $this->objpdf->SetWidths(array(15, 64, 63, 40, 20));
                                                             for ($i = 0; $i < $this->linhasdosfornec; $i++) {
                                                                 db_fieldsmemory($this->recorddosfornec, $i);
                                                                 $cgmforn = trim(pg_result($this->recorddosfornec, $i, $this->cgmforn));
                                                                 $nomeforn = trim(pg_result($this->recorddosfornec, $i, $this->nomeforn));
                                                                 $enderforn = trim(pg_result($this->recorddosfornec, $i, $this->enderforn));
                                                                 $numforn = trim(pg_result($this->recorddosfornec, $i, $this->numforn));
                                                                 $municforn = trim(pg_result($this->recorddosfornec, $i, $this->municforn));
                                                                 $foneforn = trim(pg_result($this->recorddosfornec, $i, $this->foneforn));
                                                                 $this->objpdf->Row(array($cgmforn, $nomeforn, $enderforn . ", " . $numforn, $municforn, $foneforn), 4, false, 4);
                                                             }
                                                             $getdoy = $this->objpdf->gety();
                                                             $getdoy += 0.8;
                                                             $getdoy = $getdoy - $xlin;
                                                             $contafornec += 8;
                                                         } else {
                                                             $getdoy += 4.8;
                                                         }
                                                         // Caixas dos label's
                                                         $this->objpdf->rect($xcol, $xlin + $getdoy, 15, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 15, $xlin + $getdoy, 20, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 35, $xlin + $getdoy, 107, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 142, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                         $this->objpdf->rect($xcol + 172, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                         // Caixa dos itens
                                                         $this->objpdf->rect($xcol, $xlin + $getdoy + 6, 15, 193 - $contafornec, 2, 'DF', '34');
                                                         // Caixa da quantidade
                                                         $this->objpdf->rect($xcol + 15, $xlin + $getdoy + 6, 20, 193 - $contafornec, 2, 'DF', '34');
                                                         // Caixa dos materiais ou serviços
                                                         $this->objpdf->rect($xcol + 35, $xlin + $getdoy + 6, 107, 193 - $contafornec, 2, 'DF', '34');
                                                         // Caixa dos valores unitários
                                                         $this->objpdf->rect($xcol + 142, $xlin + $getdoy + 6, 30, 193 - $contafornec, 2, 'DF', '');
                                                         // Caixa dos valores totais dos itens
                                                         $this->objpdf->rect($xcol + 172, $xlin + $getdoy + 6, 30, 193 - $contafornec, 2, 'DF', '34');
                                                         $this->objpdf->sety($xlin + 28);
                                                         // Label das colunas
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         $this->objpdf->text($xcol + 4, $xlin + $getdoy + 4, 'ITEM');
                                                         $this->objpdf->text($xcol + 15.5, $xlin + $getdoy + 4, 'QUANTIDADE');
                                                         $this->objpdf->text($xcol + 70, $xlin + $getdoy + 4, 'MATERIAL OU SERVIÇO');
                                                         $this->objpdf->text($xcol + 145, $xlin + $getdoy + 4, 'VALOR UNITÁRIO');
                                                         $this->objpdf->text($xcol + 176, $xlin + $getdoy + 4, 'VALOR TOTAL');
                                                         $maiscol = 0;
                                                         $this->objpdf->setleftmargin(8);
                                                         $this->objpdf->sety($xlin + $getdoy + 7);
                                                         $xtotal = 0;
                                                         $muda_pag = false;
                                                         $index = 0;
                                                         for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                             $this->objpdf->SetWidths(array(10, 22, 22, 95, 30, 30));
                                                             $this->objpdf->SetAligns(array('C', 'C', 'C', 'J', 'R', 'R'));
                                                             $pagina = $this->objpdf->PageNo();
                                                             db_fieldsmemory($this->recorddositens, $ii);
                                                             if ($ii != 0 && $muda_pag == false) {
                                                                 $muda_pag = false;
                                                                 $this->objpdf->ln(0.3);
                                                                 $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                                 $this->objpdf->ln(1.3);
                                                             }
                                                             $codigo = pg_result($this->recorddositens, $ii, "pc11_codigo");
                                                             $item = pg_result($this->recorddositens, $ii, $this->item);
                                                             $quantitem = pg_result($this->recorddositens, $ii, $this->quantitem);
                                                             $descricaoitem = pg_result($this->recorddositens, $ii, $this->descricaoitem);
                                                             $valoritem = db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), "f");
                                                             $valtot = pg_result($this->recorddositens, $ii, $this->svalortot);
                                                             $valimp = db_formatar($valtot, 'f');
                                                             $prazo = pg_result($this->recorddositens, $ii, $this->sprazo);
                                                             $pgto = pg_result($this->recorddositens, $ii, $this->spgto);
                                                             $resum = pg_result($this->recorddositens, $ii, $this->sresum);
                                                             $just = pg_result($this->recorddositens, $ii, $this->sjust);
                                                             $unid = pg_result($this->recorddositens, $ii, $this->sunidade);
                                                             $servico = pg_result($this->recorddositens, $ii, $this->sservico);
                                                             $quantunid = pg_result($this->recorddositens, $ii, $this->squantunid);
                                                             $susaquant = pg_result($this->recorddositens, $ii, $this->susaquant);
                                                             $scodpcmater = pg_result($this->recorddositens, $ii, $this->scodpcmater);
                                                             $xtotal += $valtot;
                                                             if (isset($descricaoitem) && (trim($descricaoitem) == "" || $descricaoitem == null) || !isset($descricaoitem)) {
                                                                 $descricaoitem = $resum;
                                                             }
                                                             if (isset($scodpcmater) && trim($scodpcmater) != "") {
                                                                 $scodpcmater = trim($scodpcmater) . " - ";
                                                             }
                                                             if (isset($prazo) && trim($prazo) != "") {
                                                                 $prazo = "\nPRAZO: " . trim($prazo);
                                                             }
                                                             if (isset($pgto) && trim($pgto) != "") {
                                                                 $pgto = "\nCONDIÇÃO: " . trim($pgto);
                                                             }
                                                             if (isset($resum) && trim($resum) != "") {
                                                                 $resum = "\nRESUMO: " . trim($resum);
                                                             }
                                                             if (isset($just) && trim($just) != "") {
                                                                 $just = "\nJUSTIFICATIVA: " . trim($just);
                                                             }
                                                             $barran = "";
                                                             if (strlen($scodpcmater . $descricaoitem) > 53) {
                                                                 $barran = "\n";
                                                             }
                                                             if (isset($servico) && (trim($servico) == "f" || trim($servico) == "") || !isset($servico)) {
                                                                 $unid = $barran . "\n" . trim($unid);
                                                                 if ($susaquant == "t") {
                                                                     $unid .= " ({$quantunid} UNIDADES)\n";
                                                                 }
                                                             } else {
                                                                 $unid = $barran . "\nSERVIÇO";
                                                             }
                                                             $descricaoitem .= " - " . $unid;
                                                             $distanciar = 0;
                                                             if (isset($prazo) && trim($prazo) == "" && (isset($pgto) && trim($pgto) == "") && (isset($resum) && trim($resum) == "") && (isset($just) && trim($just) == "")) {
                                                                 $distanciar = 4;
                                                             }
                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                             $this->objpdf->Row(array($item, $quantitem, $scodpcmater . $descricaoitem, $valoritem, $valimp), 3, false, $distanciar);
                                                             $dist = 2.7;
                                                             $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             if (isset($unid) && $unid != "") {
                                                                 $this->objpdf->Row(array('', '', $unid, '', ''), 3, false, $dist);
                                                                 $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             }
                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                             if (isset($prazo) && $prazo != "") {
                                                                 $this->objpdf->Row(array('', '', $prazo, '', ''), 3, false, $dist);
                                                                 $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             }
                                                             if (isset($pgto) && $pgto != "") {
                                                                 $this->objpdf->Row(array('', '', $pgto, '', ''), 3, false, $dist);
                                                                 $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             }
                                                             if (isset($resum) && $resum != "") {
                                                                 $this->objpdf->Row(array('', '', $resum, '', ''), 3, false, $dist);
                                                                 $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             }
                                                             if (isset($just) && $just != "") {
                                                                 $this->objpdf->Row(array('', '', $just, '', ''), 3, false, $dist);
                                                                 $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                             }
                                                             $this->objpdf->SetWidths(array(10, 22, 26, 26, 26, 26, '1', 30, 30));
                                                             $pass = false;
                                                             $arr_dotac = array();
                                                             for ($i = 0; $i < $this->linhasdasdotac; $i++) {
                                                                 db_fieldsmemory($this->recorddasdotac, $i);
                                                                 if (pg_result($this->recorddasdotac, $i, $this->dcodigo) == $codigo && !in_array(pg_result($this->recorddasdotac, $i, $this->dcoddot), $arr_dotac)) {
                                                                     if ($pass == false) {
                                                                         $pass = true;
                                                                         $this->objpdf->Setfont('Arial', 'B', 7);
                                                                         $distc = 3.5;
                                                                         $distb = 3;
                                                                         $this->objpdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'R', 'R'));
                                                                         $this->objpdf->Row(array('', '', "\n", '', ''), 3, false, $dist);
                                                                         $this->objpdf->Row(array('', '', "DOTAÇÃO", "ANO", "ELEMENTO", "RESERVADO", '', ''), 3, false, $dist);
                                                                     }
                                                                     $this->objpdf->Setfont('Arial', '', 7);
                                                                     $this->objpdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'R', 'R'));
                                                                     $dquant = pg_result($this->recorddasdotac, $i, $this->dquant);
                                                                     $danousu = pg_result($this->recorddasdotac, $i, $this->danousu);
                                                                     $dcoddot = pg_result($this->recorddasdotac, $i, $this->dcoddot);
                                                                     $dvalor = pg_result($this->recorddasdotac, $i, $this->dvalor);
                                                                     $delemento = pg_result($this->recorddasdotac, $i, $this->delemento);
                                                                     //	      $dreserva = pg_result($this->recorddasdotac,$i,$this->dreserva);
                                                                     array_push($arr_dotac, $dcoddot);
                                                                     if (isset($dcoddot) && trim($dcoddot) != "") {
                                                                         $result_orcreservasol = $clorcreservasol->sql_record($clorcreservasol->sql_query_orcreserva(null, null, "o82_codres as codigodareserva", "", "o82_solicitem={$codigo} and o80_coddot={$dcoddot}"));
                                                                         $ddvalor = "NÃO";
                                                                         if ($clorcreservasol->numrows > 0) {
                                                                             $ddvalor = "SIM";
                                                                         }
                                                                         $x = $this->muda_pag($pagina, $xlin, $xcol, "false", $contapagina);
                                                                         $this->objpdf->Row(array('', $dquant, $dcoddot, $danousu, $delemento, $ddvalor, '', db_formatar($dvalor / $dquant, "f"), db_formatar($dvalor, "f")), $distc, false, $distb);
                                                                     }
                                                                 } else {
                                                                     $pass = false;
                                                                 }
                                                             }
                                                         }
                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                         $maislin = 248;
                                                         if ($contapagina == 1) {
                                                             $maislin = 211;
                                                         }
                                                         $this->objpdf->text(180, $xlin + $maislin + 20, db_formatar($xtotal, 'f'));
                                                         if ($contapagina == 1) {
                                                             $this->objpdf->rect($xcol, $xlin + 224.7, 142, 10.8, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 142, $xlin + 224.7, 30, 10.8, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 172, $xlin + 224.7, 30, 10.8, 2, 'DF', '34');
                                                             $this->objpdf->text($xcol + 120, $xlin + 230.7, 'T O T A L');
                                                             $this->objpdf->rect($xcol, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 68, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 136, $xlin + 237, 66, 35, 2, 'DF', '1234');
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 5, $xlin + 244, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                                             $this->objpdf->text($xcol + 20, $xlin + 256, "AUTORIZO", 0, 4);
                                                             $this->objpdf->text($xcol + 5, $xlin + 268, substr($this->Sorgao, 0, 35));
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 93, $xlin + 256, "AUTORIZO", 0, 4);
                                                             if (strtoupper(trim($this->municpref)) != 'GUAIBA') {
                                                                 $this->objpdf->text($xcol + 83, $xlin + 268, 'DIV. DE ABASTECIMENTO', 0, 40);
                                                             }
                                                             $this->objpdf->setfillcolor(0, 0, 0);
                                                             $this->objpdf->text($xcol + 150, $xlin + 256, "ORDENADOR DA DESPESA", 0, 4);
                                                         } else {
                                                             $this->objpdf->rect($xcol, $xlin + 262, 142, 10, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 142, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                             $this->objpdf->rect($xcol + 172, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                             $this->objpdf->text($xcol + 120, $xlin + 268, 'T O T A L');
                                                         }
                                                     } else {
                                                         if ($this->modelo == 12) {
                                                             ////////// MODELO 12  -  ANULAÇÃO DE EMPENHO
                                                             $this->objpdf->AliasNbPages();
                                                             $this->objpdf->AddPage();
                                                             $this->objpdf->settopmargin(1);
                                                             $pagina = 1;
                                                             $xlin = 20;
                                                             $xcol = 4;
                                                             $this->objpdf->setfillcolor(245);
                                                             $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                             $this->objpdf->setfillcolor(255, 255, 255);
                                                             $this->objpdf->Setfont('Arial', 'B', 10);
                                                             $this->objpdf->text(126, $xlin - 13, 'NOTA DE ANULAÇÃO N' . CHR(176) . ': ');
                                                             $this->objpdf->text(175, $xlin - 13, db_formatar($this->notaanulacao, 's', '0', 6, 'e'));
                                                             $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                                             $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                                             $this->objpdf->text(134, $xlin - 3, '        EMPENHO : ');
                                                             $this->objpdf->text(175, $xlin - 3, trim($this->codemp) . "/" . $this->anousu);
                                                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                             //.$this->logo
                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                             $this->objpdf->Setfont('Arial', '', 9);
                                                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                             /// retangulo dos dados da dotação
                                                             $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 50, 2, 'DF', '1234');
                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                             $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                                             $this->objpdf->text($xcol + 2, $xlin + 11, 'Unidade');
                                                             $this->objpdf->text($xcol + 2, $xlin + 15, 'Função');
                                                             $this->objpdf->text($xcol + 2, $xlin + 22, 'Proj/Ativ');
                                                             $this->objpdf->text($xcol + 2, $xlin + 30, 'Rubrica');
                                                             $this->objpdf->text($xcol + 2, $xlin + 42, 'Recurso');
                                                             $this->objpdf->text($xcol + 2, $xlin + 48, 'Licitação');
                                                             $this->objpdf->Setfont('Arial', '', 8);
                                                             $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                                             $this->objpdf->text($xcol + 17, $xlin + 11, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                                             $this->objpdf->text($xcol + 17, $xlin + 15, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                                             $this->objpdf->text($xcol + 17, $xlin + 22, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                                             $this->objpdf->text($xcol + 17, $xlin + 30, ':  ' . db_formatar($this->sintetico, 'elemento'));
                                                             $this->objpdf->setxy($xcol + 18, $xlin + 31);
                                                             $this->objpdf->multicell(90, 3, $this->descr_sintetico, 0, "L");
                                                             $this->objpdf->text($xcol + 17, $xlin + 42, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                                             $this->objpdf->text($xcol + 17, $xlin + 48, ':  ' . $this->descr_licitacao);
                                                             //// retangulo dos dados do credor
                                                             $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 18, 2, 'DF', '1234');
                                                             $this->objpdf->Setfont('Arial', '', 6);
                                                             $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                             $this->objpdf->text($xcol + 107, $xlin + 7, 'Numcgm');
                                                             $this->objpdf->text($xcol + 107, $xlin + 11, 'Nome');
                                                             $this->objpdf->text($xcol + 107, $xlin + 15, 'Endereço');
                                                             $this->objpdf->text($xcol + 107, $xlin + 19, 'Município');
                                                             $this->objpdf->Setfont('Arial', '', 8);
                                                             $this->objpdf->text($xcol + 124, $xlin + 7, ': ' . $this->numcgm);
                                                             $this->objpdf->text($xcol + 124, $xlin + 11, ': ' . $this->nome);
                                                             $this->objpdf->text($xcol + 124, $xlin + 15, ': ' . $this->ender . '  ' . $this->compl);
                                                             $this->objpdf->text($xcol + 124, $xlin + 19, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                                             ///// retangulo dos valores
                                                             $this->objpdf->rect($xcol + 106, $xlin + 21.5, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 155, $xlin + 21.5, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 106, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 155, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 106, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->rect($xcol + 155, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                                             $this->objpdf->Setfont('Arial', '', 6);
                                                             $this->objpdf->text($xcol + 157, $xlin + 23.5, 'Valor Empenhado');
                                                             $this->objpdf->text($xcol + 108, $xlin + 34.0, 'Valor Orçado');
                                                             $this->objpdf->text($xcol + 157, $xlin + 34.0, 'Saldo Anterior');
                                                             $this->objpdf->text($xcol + 108, $xlin + 44.5, 'Valor Anulado');
                                                             $this->objpdf->text($xcol + 157, $xlin + 44.5, 'Saldo Atual');
                                                             $this->objpdf->Setfont('Arial', '', 8);
                                                             $this->objpdf->text($xcol + 108, $xlin + 27, 'SEQ. EMP. N' . chr(176) . ' ' . db_formatar($this->numemp, 's', '0', 6, 'e'));
                                                             //	$this->objpdf->text($xcol+108,$xlin+26.5,$this->texto);
                                                             $this->objpdf->text($xcol + 180, $xlin + 27.5, db_formatar($this->empenhado, 'f'));
                                                             $this->objpdf->text($xcol + 130, $xlin + 38.0, db_formatar($this->orcado, 'f'));
                                                             $this->objpdf->text($xcol + 180, $xlin + 38.0, db_formatar($this->saldo_ant, 'f'));
                                                             $this->objpdf->text($xcol + 130, $xlin + 47.5, db_formatar($this->anulado, 'f'));
                                                             $this->objpdf->text($xcol + 180, $xlin + 47.5, db_formatar($this->saldo_ant + $this->anulado, 'f'));
                                                             /// retangulo do corpo do empenho
                                                             $this->objpdf->rect($xcol, $xlin + 60, 15, 130, 2, 'DF', '');
                                                             $this->objpdf->rect($xcol + 15, $xlin + 60, 137, 130, 2, 'DF', '');
                                                             $this->objpdf->rect($xcol + 152, $xlin + 60, 25, 163, 2, 'DF', '');
                                                             $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 163, 2, 'DF', '');
                                                             $this->objpdf->rect($xcol, $xlin + 190, 152, 33, 2, 'DF', '');
                                                             //// retangulos do titulo do corpo do empenho
                                                             $this->objpdf->Setfont('Arial', 'B', 7);
                                                             $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 15, $xlin + 54, 137, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 152, $xlin + 54, 25, 6, 2, 'DF', '12');
                                                             $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                                             //// título do corpo do empenho
                                                             $this->objpdf->text($xcol + 2, $xlin + 58, 'QUANT');
                                                             $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                                             $this->objpdf->text($xcol + 154, $xlin + 58, 'VALOR UNITÁRIO');
                                                             $this->objpdf->text($xcol + 181, $xlin + 58, 'VALOR TOTAL');
                                                             $maiscol = 0;
                                                             /// monta os dados para itens do empenho
                                                             $this->objpdf->SetWidths(array(15, 137, 25, 25));
                                                             $this->objpdf->SetAligns(array('C', 'L', 'R', 'R'));
                                                             $this->objpdf->setleftmargin(4);
                                                             $this->objpdf->sety($xlin + 62);
                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                             $ele = 0;
                                                             $xtotal = 0;
                                                             for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                                 db_fieldsmemory($this->recorddositens, $ii);
                                                                 $this->objpdf->Setfont('Arial', 'B', 7);
                                                                 $this->objpdf->Row(array('', db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), '', db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                                                 $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                                                 /////// troca de pagina
                                                             }
                                                             if ($pagina == 1) {
                                                                 $this->objpdf->rect($xcol, $xlin + 223, 152, 6, 2, 'DF', '34');
                                                                 $this->objpdf->rect($xcol + 152, $xlin + 223, 25, 6, 2, 'DF', '34');
                                                                 $this->objpdf->rect($xcol + 177, $xlin + 223, 25, 6, 2, 'DF', '34');
                                                                 //           $this->objpdf->rect($xcol,$xlin+197,60,47,2,'DF','34');
                                                                 //           $this->objpdf->rect($xcol+60,$xlin+197,60,47,2,'DF','34');
                                                                 //           $this->objpdf->rect($xcol+120,$xlin+197,82,47,2,'DF','34');
                                                                 //           $this->objpdf->rect($xcol+120,$xlin+216,32,28,2,'DF','4');
                                                                 //	   $this->objpdf->setfillcolor(0,0,0);
                                                                 $this->objpdf->SetFont('Arial', '', 7);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 227, 'DESTINO : ', 0, 1, 'L', 0);
                                                                 $this->objpdf->text($xcol + 30, $xlin + 227, $this->destino, 0, 1, 'L', 0);
                                                                 $this->objpdf->setxy($xcol + 1, $xlin + 195);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 194, 'MOTIVO : ', 0, 1, 'L', 0);
                                                                 $this->objpdf->multicell(147, 3.5, $this->resumo);
                                                                 $this->objpdf->text($xcol + 159, $xlin + 227, 'T O T A L', 0, 1, 'L', 0);
                                                                 $this->objpdf->setxy($xcol + 185, $xlin + 222);
                                                                 $this->objpdf->cell(30, 10, db_formatar($this->empenhado - $xtotal, 'f'), 0, 0, 'f');
                                                                 /*
                                                                            $this->objpdf->rect($xcol,$xlin+191,60,6,2,'DF','12');
                                                                            $this->objpdf->rect($xcol+60,$xlin+191,60,6,2,'DF','12');
                                                                            $this->objpdf->rect($xcol+120,$xlin+191,82,6,2,'DF','12');
                                                                 	   $this->objpdf->text($xcol+15,$xlin+195,'CONTADORIA GERAL');
                                                                 	   $this->objpdf->text($xcol+82,$xlin+195,'PAGUE-SE');
                                                                 	   $this->objpdf->text($xcol+150,$xlin+195,'TESOURARIA');
                                                                 	   
                                                                 	   $this->objpdf->line($xcol+5,$xlin+211,$xcol+54,$xlin+211);
                                                                 	   $this->objpdf->line($xcol+5,$xlin+225,$xcol+54,$xlin+225);
                                                                 	   $this->objpdf->line($xcol+5,$xlin+238,$xcol+54,$xlin+238);
                                                                 	   
                                                                 	   $this->objpdf->line($xcol+65,$xlin+225,$xcol+114,$xlin+225);
                                                                 	   
                                                                 	   $this->objpdf->SetFont('Arial','',6);
                                                                 	   $this->objpdf->text($xcol+12,$xlin+199,'EMPENHADO E CONFERIDO');
                                                                 	   $this->objpdf->text($xcol+26,$xlin+213,'VISTO');
                                                                 	   $this->objpdf->text($xcol+19,$xlin+227,'TÉCNICO CONTÁBIL');
                                                                 	   $this->objpdf->text($xcol+13,$xlin+240,'SECRETÁRIO(A) DA FAZENDA');
                                                                 	   
                                                                 	   $this->objpdf->text($xcol+66,$xlin+212,'DATA  ____________/____________/____________');
                                                                 	   $this->objpdf->text($xcol+76,$xlin+227,'PREFEITO MUNICIPAL');
                                                                 	  
                                                                 	   $this->objpdf->text($xcol+122,$xlin+207,'CHEQUE N'.chr(176));
                                                                 	   $this->objpdf->text($xcol+170,$xlin+207,'DATA');
                                                                 	   $this->objpdf->text($xcol+122,$xlin+215,'BANCO N'.chr(176));
                                                                 	   $this->objpdf->text($xcol+127,$xlin+218,'DOCUMENTO N'.chr(176));
                                                                 	   $this->objpdf->line($xcol+155,$xlin+240,$xcol+200,$xlin+240);
                                                                 	   $this->objpdf->text($xcol+170,$xlin+242,'TESOUREIRO');
                                                                 	  
                                                                            $this->objpdf->rect($xcol,$xlin+246,202,26,2,'DF','1234');
                                                                 	   
                                                                 	   $this->objpdf->SetFont('Arial','',7);
                                                                 	   $this->objpdf->text($xcol+90,$xlin+249,'R E C I B O');
                                                                 	   $this->objpdf->text($xcol+45,$xlin+253,'RECEBI(EMOS) DO MUNICÍPIO DE '.$this->municpref.', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                                                 	   $this->objpdf->text($xcol+2,$xlin+257,'(     ) PARTE DO VALOR EMPENHADO');
                                                                 	   $this->objpdf->text($xcol+102,$xlin+257,'(     ) SALDO/TOTAL EMPENHADO');
                                                                 	   $this->objpdf->text($xcol+2,$xlin+261,'R$');
                                                                 	   $this->objpdf->text($xcol+102,$xlin+261,'R$');
                                                                 	   $this->objpdf->text($xcol+2,$xlin+265,'EM ________/________/________',0,0,'C',0);
                                                                 	   $this->objpdf->text($xcol+42,$xlin+265,'_________________________________________',0,0,'C',0);
                                                                 	   $this->objpdf->text($xcol+102,$xlin+265,'EM ________/________/________',0,0,'C',0);
                                                                 	   $this->objpdf->text($xcol+142,$xlin+265,'_________________________________________',0,1,'C',0);
                                                                 	   $this->objpdf->SetFont('Arial','',6);
                                                                 	   $this->objpdf->text($xcol+62,$xlin+269,'CREDOR',0,0,'C',0);
                                                                 	   $this->objpdf->text($xcol+162,$xlin+269,'CREDOR',0,1,'C',0);
                                                                 	   
                                                                 	   $this->objpdf->SetFont('Arial','',4);
                                                                            $this->objpdf->Text(2,296,$this->texto); // texto no canhoto do carne
                                                                 	   $this->objpdf->setfont('Arial','',11);
                                                                 */
                                                                 $xlin = 169;
                                                             }
                                                         } else {
                                                             if ($this->modelo == 13) {
                                                                 ////////// MODELO 13  -  SOLICITAÇÃO DE ORÇAMENTO
                                                                 $this->objpdf->AliasNbPages();
                                                                 $this->objpdf->AddPage();
                                                                 $this->objpdf->settopmargin(1);
                                                                 $pagina = 1;
                                                                 $xlin = 20;
                                                                 $xcol = 4;
                                                                 $this->objpdf->setfillcolor(245);
                                                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                                 $this->objpdf->setfillcolor(255, 255, 255);
                                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                 //.$this->logo
                                                                 $this->objpdf->text(130, $xlin - 13, "ORÇAMENTO N" . CHR(176));
                                                                 $this->objpdf->text(185, $xlin - 13, db_formatar($this->orccodigo, 's', '0', 6, 'e'));
                                                                 $this->objpdf->text(130, $xlin - 9, $this->labdados . CHR(176));
                                                                 $this->objpdf->text(185, $xlin - 9, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                 $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                 $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                 $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                 $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                                                 // Caixa com dados do orçamento e solicitação
                                                                 $this->objpdf->rect($xcol, $xlin + 3, $xcol + 198, 27, 2, 'DF', '1234');
                                                                 $this->objpdf->Setfont('Arial', '', 6);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 5, 'Dados do Orçamento/' . $this->labtitulo);
                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 8, 'Orçamento');
                                                                 $this->objpdf->text($xcol + 109, $xlin + 8, 'Data Limite');
                                                                 $this->objpdf->text($xcol + 150, $xlin + 8, 'Hora Limite');
                                                                 $this->objpdf->text($xcol + 2, $xlin + 13, $this->labtitulo);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 21, 'Departamento');
                                                                 $this->objpdf->text($xcol + 109, $xlin + 17, $this->labtipo);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 17, 'Data');
                                                                 $this->objpdf->text($xcol + 2, $xlin + 25, 'Resumo');
                                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                                 // Imprime dados do orçamento e solicitação
                                                                 $this->objpdf->text($xcol + 23, $xlin + 8, ':  ' . $this->orccodigo);
                                                                 $this->objpdf->text($xcol + 125, $xlin + 8, ':  ' . $this->orcdtlim);
                                                                 $this->objpdf->text($xcol + 166, $xlin + 8, ':  ' . $this->orchrlim);
                                                                 $this->objpdf->text($xcol + 23, $xlin + 13, ':  ' . $this->Snumero);
                                                                 $this->objpdf->text($xcol + 23, $xlin + 21, ':  ' . $this->Sdepart);
                                                                 if (isset($this->Sdata) && trim($this->Sdata) != "") {
                                                                     $this->Sdata = db_formatar($this->Sdata, 'd');
                                                                 }
                                                                 if (trim($this->labtipo) != "") {
                                                                     $this->objpdf->text($xcol + 125, $xlin + 17, ':  ' . $this->Stipcom);
                                                                 }
                                                                 $this->objpdf->text($xcol + 23, $xlin + 17, ':  ' . $this->Sdata);
                                                                 $this->objpdf->setxy($xcol + 22, $xlin + 22);
                                                                 $this->objpdf->cell(3, 4, ':  ', 0, 0, "L", 0);
                                                                 $this->objpdf->setxy($xcol + 24.5, $xlin + 22);
                                                                 $Sresumo = $this->Sresumo;
                                                                 $Sresumo = str_replace("\n", ". ", $Sresumo);
                                                                 $Sresumo = str_replace("\r", "", $Sresumo);
                                                                 $this->objpdf->multicell(175, 4, $Sresumo, 0, "J");
                                                                 // Caixa com dados dos fornecedores
                                                                 $this->objpdf->rect($xcol, $xlin + 32, $xcol + 198, 16, 2, 'DF', '1234');
                                                                 $this->objpdf->Setfont('Arial', '', 6);
                                                                 $this->objpdf->text($xcol + 2, $xlin + 34, 'Dados do Fornecedor');
                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                 $this->objpdf->text($xcol + 109, $xlin + 38, 'Numcgm');
                                                                 $this->objpdf->text($xcol + 150, $xlin + 38, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                                                 $this->objpdf->text($xcol + 2, $xlin + 38, 'Nome');
                                                                 $this->objpdf->text($xcol + 2, $xlin + 42, 'Endereço');
                                                                 $this->objpdf->text($xcol + 102, $xlin + 42, 'Complemento');
                                                                 $this->objpdf->text($xcol + 2, $xlin + 46, 'Município');
                                                                 $this->objpdf->text($xcol + 115, $xlin + 46, 'CEP');
                                                                 $this->objpdf->text($xcol + 150, $xlin + 46, 'Telefone');
                                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                                 // Imprime dados dos fornecedores
                                                                 $this->objpdf->text($xcol + 18, $xlin + 38, ':  ' . $this->nome);
                                                                 $this->objpdf->text($xcol + 122, $xlin + 38, ':  ' . $this->numcgm);
                                                                 $this->objpdf->text($xcol + 163, $xlin + 38, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')));
                                                                 $this->objpdf->text($xcol + 18, $xlin + 42, ':  ' . $this->ender);
                                                                 $this->objpdf->text($xcol + 122, $xlin + 42, ':  ' . $this->compl);
                                                                 $this->objpdf->text($xcol + 18, $xlin + 46, ':  ' . $this->munic . '-' . $this->uf);
                                                                 $this->objpdf->text($xcol + 122, $xlin + 46, ':  ' . $this->cep);
                                                                 $this->objpdf->text($xcol + 163, $xlin + 46, ':  ' . $this->telefone);
                                                                 $getdoy = 50;
                                                                 $contadepart = 0;
                                                                 $alturaini = 216;
                                                                 if ($this->linhasdosdepart > 0) {
                                                                     for ($i = 0; $i < $this->linhasdosdepart; $i++) {
                                                                         $contadepart += 4;
                                                                     }
                                                                     $setaut = $xlin + $getdoy;
                                                                     $alturaini -= $contadepart + 15;
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     // Caixa de texto para labels
                                                                     $this->objpdf->rect($xcol, $setaut, 202, 6, 2, 'DF', '12');
                                                                     $this->objpdf->text($xcol + 4, $setaut + 4, 'DEPARTAMENTOS DAS SOLICITAÇÕES');
                                                                     $this->objpdf->rect($xcol, $setaut + 6, 30, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 30, $setaut + 6, 30, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 60, $setaut + 6, 142, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol, $setaut + 12, 30, $contadepart + 1, 2, 'DF', '34');
                                                                     $this->objpdf->rect($xcol + 30, $setaut + 12, 30, $contadepart + 1, 2, 'DF', '34');
                                                                     $this->objpdf->rect($xcol + 60, $setaut + 12, 142, $contadepart + 1, 2, 'DF', '34');
                                                                     $this->objpdf->sety($xlin + 66);
                                                                     // Label das colunas
                                                                     $this->objpdf->text($xcol + 6, $setaut + 11, 'SOLICITAÇÃO');
                                                                     $this->objpdf->text($xcol + 39, $setaut + 11, 'CÓDIGO');
                                                                     $this->objpdf->text($xcol + 125, $setaut + 11, 'DESCRIÇÃO');
                                                                     // Seta altura nova para impressão dos dados
                                                                     $this->objpdf->sety($setaut + 13);
                                                                     $this->objpdf->setx($xcol);
                                                                     $this->objpdf->setleftmargin(4);
                                                                     $this->objpdf->Setfont('Arial', '', 7);
                                                                     $this->objpdf->SetAligns(array('C', 'C', 'L'));
                                                                     $this->objpdf->SetWidths(array(30, 30, 142));
                                                                     for ($i = 0; $i < $this->linhasdosdepart; $i++) {
                                                                         db_fieldsmemory($this->recorddosdepart, $i);
                                                                         $solicita = trim(pg_result($this->recorddosdepart, $i, $this->Snumdepart));
                                                                         $codigodep = trim(pg_result($this->recorddosdepart, $i, $this->Scoddepto));
                                                                         $descrdep = trim(pg_result($this->recorddosdepart, $i, $this->Sdescrdepto));
                                                                         $this->objpdf->Row(array($solicita, $codigodep, $descrdep), 4, false, 4);
                                                                     }
                                                                     $getdoy = $this->objpdf->gety() + 2 - $xlin;
                                                                 }
                                                                 // Caixa com Labels item, quantidade, descrição, valor
                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                 $this->objpdf->rect($xcol, $xlin + $getdoy, 14, 6, 2, 'DF', '12');
                                                                 $this->objpdf->rect($xcol + 14, $xlin + $getdoy, 12, 6, 2, 'DF', '12');
                                                                 $this->objpdf->rect($xcol + 26, $xlin + $getdoy, 22, 6, 2, 'DF', '12');
                                                                 $this->objpdf->rect($xcol + 48, $xlin + $getdoy, 98, 6, 2, 'DF', '12');
                                                                 $this->objpdf->rect($xcol + 146, $xlin + $getdoy, 28, 6, 2, 'DF', '12');
                                                                 $this->objpdf->rect($xcol + 174, $xlin + $getdoy, 28, 6, 2, 'DF', '12');
                                                                 $menos = 16.9;
                                                                 if ($this->linhasdosfornec == 0) {
                                                                     $menos = 11;
                                                                 }
                                                                 if (isset($tiramenos)) {
                                                                     $menos = $menos + $tiramenos;
                                                                     if ($menos < 0) {
                                                                         $menos = -$menos;
                                                                     }
                                                                 }
                                                                 // Caixa dos itens
                                                                 $this->objpdf->rect($xcol, $xlin + $getdoy + 6, 14, $alturaini, 2, 'DF', '34');
                                                                 // Caixa da quantidade
                                                                 $this->objpdf->rect($xcol + 14, $xlin + $getdoy + 6, 12, $alturaini, 2, 'DF', '34');
                                                                 $this->objpdf->rect($xcol + 26, $xlin + $getdoy + 6, 22, $alturaini, 2, 'DF', '34');
                                                                 // Caixa dos materiais ou serviços
                                                                 $this->objpdf->rect($xcol + 48, $xlin + $getdoy + 6, 98, $alturaini, 2, 'DF', '34');
                                                                 // Caixa dos valores unitários
                                                                 $this->objpdf->rect($xcol + 146, $xlin + $getdoy + 6, 28, $alturaini, 2, 'DF', '');
                                                                 // Caixa dos valores totais dos itens
                                                                 $this->objpdf->rect($xcol + 174, $xlin + $getdoy + 6, 28, $alturaini, 2, 'DF', '34');
                                                                 $this->objpdf->sety($xlin + 48);
                                                                 $alt = 4;
                                                                 // Label das colunas
                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                 $this->objpdf->text($xcol + 4, $xlin + $getdoy + 4, 'ITEM');
                                                                 $this->objpdf->text($xcol + 15, $xlin + $getdoy + 4, 'QUANT');
                                                                 $this->objpdf->text($xcol + 34, $xlin + $getdoy + 4, 'REF');
                                                                 $this->objpdf->text($xcol + 74, $xlin + $getdoy + 4, 'MATERIAL OU SERVIÇO');
                                                                 $this->objpdf->text($xcol + 148, $xlin + $getdoy + 4, 'VALOR UNITÁRIO');
                                                                 $this->objpdf->text($xcol + 179, $xlin + $getdoy + 4, 'VALOR TOTAL');
                                                                 $maiscol = 0;
                                                                 $this->objpdf->SetWidths(array(14, 12, 22, 95, 28, 28));
                                                                 $this->objpdf->SetAligns(array('C', 'C', 'C', 'J', 'R', 'R'));
                                                                 $this->objpdf->setleftmargin(4);
                                                                 $this->objpdf->sety($xlin + $getdoy + 7);
                                                                 $this->objpdf->setfillcolor(235);
                                                                 $xtotal = 0;
                                                                 $muda_pagina = false;
                                                                 $pag = 1;
                                                                 for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                                     if ($ii != 0 && $muda_pagina != true) {
                                                                         $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                                     }
                                                                     $this->objpdf->ln(2);
                                                                     db_fieldsmemory($this->recorddositens, $ii);
                                                                     $prazo = "";
                                                                     $pgto = "";
                                                                     $resumo = "";
                                                                     $descricaoitem = trim(pg_result($this->recorddositens, $ii, $this->descricaoitem));
                                                                     if (trim(pg_result($this->recorddositens, $ii, $this->sprazo)) != "") {
                                                                         $prazo = pg_result($this->recorddositens, $ii, $this->sprazo);
                                                                         $prazo = "PRAZO: " . trim($prazo);
                                                                     }
                                                                     if (trim(pg_result($this->recorddositens, $ii, $this->spgto)) != "") {
                                                                         $pgto = pg_result($this->recorddositens, $ii, $this->spgto);
                                                                         $pgto = "CONDIÇÃO: " . trim($pgto);
                                                                     }
                                                                     if (trim(pg_result($this->recorddositens, $ii, $this->sresum) != "")) {
                                                                         $resumo = "RESUMO: " . pg_result($this->recorddositens, $ii, $this->sresum);
                                                                         if ($descricaoitem == "" || $descricaoitem == null) {
                                                                             $descricaoitem = trim(pg_result($this->recorddositens, $ii, $this->sresum));
                                                                             $resumo = "";
                                                                         }
                                                                     }
                                                                     if ($muda_pagina == true) {
                                                                         $muda_pagina = false;
                                                                         $this->objpdf->sety($xlin + 12);
                                                                     }
                                                                     $unid = pg_result($this->recorddositens, $ii, $this->sunidade);
                                                                     $codunid = pg_result($this->recorddositens, $ii, $this->scodunid);
                                                                     $servico = pg_result($this->recorddositens, $ii, $this->sservico);
                                                                     $quantunid = pg_result($this->recorddositens, $ii, $this->squantunid);
                                                                     $susaquant = pg_result($this->recorddositens, $ii, $this->susaquant);
                                                                     $dist = 2.7;
                                                                     if (trim($codunid) != "") {
                                                                         $unid = trim(substr($unid, 0, 10));
                                                                         if ($susaquant == "t") {
                                                                             $unid .= " \n{$quantunid} UNIDADES\n";
                                                                             $resumo = str_replace("\n", "", $resumo);
                                                                         }
                                                                     } else {
                                                                         if ($servico == "t") {
                                                                             $unid = "SERVIÇO";
                                                                         }
                                                                     }
                                                                     $this->objpdf->Setfont('Arial', '', 8);
                                                                     $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->item), pg_result($this->recorddositens, $ii, $this->quantitem), $unid, $descricaoitem, '', ''), 3, false, 3);
                                                                     if (isset($resumo) && $resumo != "") {
                                                                         $this->objpdf->Row(array('', '', '', $resumo, '', ''), $dist, false, 2.7);
                                                                     }
                                                                     if (isset($prazo) && $prazo != "") {
                                                                         $this->objpdf->Row(array('', '', '', $prazo, '', ''), $dist, false, 2.7);
                                                                     }
                                                                     if (isset($pgto) && $pgto != "") {
                                                                         $this->objpdf->Row(array('', '', '', $pgto, '', ''), $dist, false, 2.7);
                                                                     }
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     /////// troca de pagina
                                                                     if ($this->objpdf->gety() > $this->objpdf->h - 30) {
                                                                         if ($ii + 1 != $this->linhasdositens) {
                                                                             $pag++;
                                                                             $muda_pagina = true;
                                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                                             if ($pag != 1) {
                                                                                 $this->objpdf->Setfont('Arial', 'B', 7);
                                                                                 $this->objpdf->rect($xcol, $xlin + 262, 146, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 146, $xlin + 262, 28, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 174, $xlin + 262, 28, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->text($xcol + 118, $xlin + 268, 'T O T A L   P Á G I N A');
                                                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                                             }
                                                                             $this->objpdf->addpage();
                                                                             $pagina += 1;
                                                                             $this->objpdf->settopmargin(1);
                                                                             $xlin = 20;
                                                                             $xcol = 4;
                                                                             $this->objpdf->setfillcolor(245);
                                                                             $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                                             $this->objpdf->setfillcolor(255, 255, 255);
                                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                             //.$this->logo
                                                                             $this->objpdf->text(130, $xlin - 13, "ORÇAMENTO N" . CHR(176));
                                                                             $this->objpdf->text(185, $xlin - 13, db_formatar($this->orccodigo, 's', '0', 6, 'e'));
                                                                             $this->objpdf->text(130, $xlin - 9, $this->labdados . CHR(176));
                                                                             $this->objpdf->text(185, $xlin - 9, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                             $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                                                             $xlin = -30;
                                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                                             // Caixas dos label's
                                                                             $this->objpdf->rect($xcol, $xlin + 54, 14, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 14, $xlin + 54, 12, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 26, $xlin + 54, 22, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 48, $xlin + 54, 98, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 146, $xlin + 54, 28, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 174, $xlin + 54, 28, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol, $xlin + 54, 14, 268, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 14, $xlin + 54, 12, 268, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 26, $xlin + 54, 22, 268, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 48, $xlin + 54, 98, 268, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 146, $xlin + 54, 28, 268, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 174, $xlin + 54, 28, 268, 2, 'DF', '34');
                                                                             $this->objpdf->sety($xlin + 66);
                                                                             $alt = 4;
                                                                             // Label das colunas
                                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                                             $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                                                             $this->objpdf->text($xcol + 15, $xlin + 58, 'QUANT');
                                                                             $this->objpdf->text($xcol + 34, $xlin + 58, 'REF');
                                                                             $this->objpdf->text($xcol + 74, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                                                             $this->objpdf->text($xcol + 148, $xlin + 58, 'VALOR UNITÁRIO');
                                                                             $this->objpdf->text($xcol + 179, $xlin + 58, 'VALOR TOTAL');
                                                                             /*
                                                                             	      $this->objpdf->text($xcol+   4,$xlin+58,'ITEM');
                                                                             	      $this->objpdf->text($xcol+15.5,$xlin+58,'QUANTIDADE');
                                                                             	      $this->objpdf->text($xcol+  70,$xlin+58,'MATERIAL OU SERVIÇO');
                                                                             	      $this->objpdf->text($xcol+ 145,$xlin+58,'VALOR UNITÁRIO');
                                                                             	      $this->objpdf->text($xcol+ 176,$xlin+58,'VALOR TOTAL');
                                                                             */
                                                                             $maiscol = 0;
                                                                             $xlin = 20;
                                                                         }
                                                                         $this->objpdf->ln(2);
                                                                         if ($ii + 1 == $this->linhasdositens) {
                                                                             $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                                         }
                                                                     }
                                                                 }
                                                                 // caixas para total
                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                 $this->objpdf->rect($xcol, $xlin + 262, 146, 10, 2, 'DF', '34');
                                                                 $this->objpdf->rect($xcol + 146, $xlin + 262, 28, 10, 2, 'DF', '34');
                                                                 $this->objpdf->rect($xcol + 174, $xlin + 262, 28, 10, 2, 'DF', '34');
                                                                 $this->objpdf->text($xcol + 113, $xlin + 268, 'T O T A L   G E R A L');
                                                                 //	echo $this->numaut."<br>";
                                                                 //	echo $pagina;exit;
                                                             } else {
                                                                 if ($this->modelo == 133) {
                                                                     ////////// MODELO 13  -  SOLICITAÇÃO DE ORÇAMENTO
                                                                     $this->objpdf->AliasNbPages();
                                                                     $this->objpdf->AddPage();
                                                                     $this->objpdf->settopmargin(1);
                                                                     $pagina = 1;
                                                                     $xlin = 20;
                                                                     $xcol = 4;
                                                                     $this->objpdf->setfillcolor(245);
                                                                     $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                                     $this->objpdf->setfillcolor(255, 255, 255);
                                                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                                                     $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                     //.$this->logo
                                                                     $this->objpdf->text(130, $xlin - 13, "ORÇAMENTO N" . CHR(176));
                                                                     $this->objpdf->text(185, $xlin - 13, db_formatar($this->orccodigo, 's', '0', 6, 'e'));
                                                                     $this->objpdf->text(130, $xlin - 9, $this->labdados . CHR(176));
                                                                     $this->objpdf->text(185, $xlin - 9, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                                                     $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                     $this->objpdf->Setfont('Arial', '', 7);
                                                                     $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                     $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                     $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                     $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                     $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                                                     // Caixa com dados do orçamento e solicitação
                                                                     $this->objpdf->rect($xcol, $xlin + 3, $xcol + 198, 27, 2, 'DF', '1234');
                                                                     $this->objpdf->Setfont('Arial', '', 6);
                                                                     $this->objpdf->text($xcol + 2, $xlin + 5, 'Dados do Orçamento/' . $this->labtitulo);
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     $this->objpdf->text($xcol + 2, $xlin + 8, 'Orçamento');
                                                                     $this->objpdf->text($xcol + 109, $xlin + 8, 'Data Limite');
                                                                     $this->objpdf->text($xcol + 150, $xlin + 8, 'Hora Limite');
                                                                     $this->objpdf->text($xcol + 2, $xlin + 13, $this->labtitulo);
                                                                     $this->objpdf->text($xcol + 2, $xlin + 21, 'Departamento');
                                                                     $this->objpdf->text($xcol + 109, $xlin + 17, $this->labtipo);
                                                                     $this->objpdf->text($xcol + 2, $xlin + 17, 'Data');
                                                                     $this->objpdf->text($xcol + 2, $xlin + 25, 'Resumo');
                                                                     $this->objpdf->Setfont('Arial', '', 8);
                                                                     // Imprime dados do orçamento e solicitação
                                                                     $this->objpdf->text($xcol + 23, $xlin + 8, ':  ' . $this->orccodigo);
                                                                     $this->objpdf->text($xcol + 125, $xlin + 8, ':  ' . $this->orcdtlim);
                                                                     $this->objpdf->text($xcol + 166, $xlin + 8, ':  ' . $this->orchrlim);
                                                                     $this->objpdf->text($xcol + 23, $xlin + 13, ':  ' . $this->Snumero);
                                                                     $this->objpdf->text($xcol + 23, $xlin + 21, ':  ' . $this->Sdepart);
                                                                     if (isset($this->Sdata) && trim($this->Sdata) != "") {
                                                                         $this->Sdata = db_formatar($this->Sdata, 'd');
                                                                     }
                                                                     if (trim($this->labtipo) != "") {
                                                                         $this->objpdf->text($xcol + 125, $xlin + 17, ':  ' . $this->Stipcom);
                                                                     }
                                                                     $this->objpdf->text($xcol + 23, $xlin + 17, ':  ' . $this->Sdata);
                                                                     $this->objpdf->setxy($xcol + 22, $xlin + 22);
                                                                     $this->objpdf->cell(3, 4, ':  ', 0, 0, "L", 0);
                                                                     $this->objpdf->setxy($xcol + 24.5, $xlin + 22);
                                                                     $Sresumo = $this->Sresumo;
                                                                     $Sresumo = str_replace("\n", ". ", $Sresumo);
                                                                     $Sresumo = str_replace("\r", "", $Sresumo);
                                                                     $this->objpdf->multicell(175, 4, $Sresumo, 0, "J");
                                                                     // Caixa com dados dos fornecedores
                                                                     $this->objpdf->rect($xcol, $xlin + 32, $xcol + 198, 16, 2, 'DF', '1234');
                                                                     $this->objpdf->Setfont('Arial', '', 6);
                                                                     $this->objpdf->text($xcol + 2, $xlin + 34, 'Dados do Fornecedor');
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     $this->objpdf->text($xcol + 109, $xlin + 38, 'Numcgm');
                                                                     $this->objpdf->text($xcol + 150, $xlin + 38, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                                                     $this->objpdf->text($xcol + 2, $xlin + 38, 'Nome');
                                                                     $this->objpdf->text($xcol + 2, $xlin + 42, 'Endereço');
                                                                     $this->objpdf->text($xcol + 102, $xlin + 42, 'Complemento');
                                                                     $this->objpdf->text($xcol + 2, $xlin + 46, 'Município');
                                                                     $this->objpdf->text($xcol + 115, $xlin + 46, 'CEP');
                                                                     $this->objpdf->text($xcol + 150, $xlin + 46, 'Telefone');
                                                                     $this->objpdf->Setfont('Arial', '', 8);
                                                                     // Imprime dados dos fornecedores
                                                                     $this->objpdf->text($xcol + 18, $xlin + 38, ':  ' . $this->nome);
                                                                     $this->objpdf->text($xcol + 122, $xlin + 38, ':  ' . $this->numcgm);
                                                                     $this->objpdf->text($xcol + 163, $xlin + 38, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')));
                                                                     $this->objpdf->text($xcol + 18, $xlin + 42, ':  ' . $this->ender);
                                                                     $this->objpdf->text($xcol + 122, $xlin + 42, ':  ' . $this->compl);
                                                                     $this->objpdf->text($xcol + 18, $xlin + 46, ':  ' . $this->munic . '-' . $this->uf);
                                                                     $this->objpdf->text($xcol + 122, $xlin + 46, ':  ' . $this->cep);
                                                                     $this->objpdf->text($xcol + 163, $xlin + 46, ':  ' . $this->telefone);
                                                                     $getdoy = 50;
                                                                     $contadepart = 0;
                                                                     $alturaini = 216;
                                                                     if ($this->linhasdosdepart > 0) {
                                                                         for ($i = 0; $i < $this->linhasdosdepart; $i++) {
                                                                             $contadepart += 4;
                                                                         }
                                                                         $setaut = $xlin + $getdoy;
                                                                         $alturaini -= $contadepart + 15;
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         // Caixa de texto para labels
                                                                         $this->objpdf->rect($xcol, $setaut, 202, 6, 2, 'DF', '12');
                                                                         $this->objpdf->text($xcol + 4, $setaut + 4, 'DEPARTAMENTOS DAS SOLICITAÇÕES');
                                                                         $this->objpdf->rect($xcol, $setaut + 6, 30, 6, 2, 'DF', '12');
                                                                         $this->objpdf->rect($xcol + 30, $setaut + 6, 30, 6, 2, 'DF', '12');
                                                                         $this->objpdf->rect($xcol + 60, $setaut + 6, 142, 6, 2, 'DF', '12');
                                                                         $this->objpdf->rect($xcol, $setaut + 12, 30, $contadepart + 1, 2, 'DF', '34');
                                                                         $this->objpdf->rect($xcol + 30, $setaut + 12, 30, $contadepart + 1, 2, 'DF', '34');
                                                                         $this->objpdf->rect($xcol + 60, $setaut + 12, 142, $contadepart + 1, 2, 'DF', '34');
                                                                         $this->objpdf->sety($xlin + 66);
                                                                         // Label das colunas
                                                                         $this->objpdf->text($xcol + 6, $setaut + 11, 'SOLICITAÇÃO');
                                                                         $this->objpdf->text($xcol + 39, $setaut + 11, 'CÓDIGO');
                                                                         $this->objpdf->text($xcol + 125, $setaut + 11, 'DESCRIÇÃO');
                                                                         // Seta altura nova para impressão dos dados
                                                                         $this->objpdf->sety($setaut + 13);
                                                                         $this->objpdf->setx($xcol);
                                                                         $this->objpdf->setleftmargin(4);
                                                                         $this->objpdf->Setfont('Arial', '', 7);
                                                                         $this->objpdf->SetAligns(array('C', 'C', 'L'));
                                                                         $this->objpdf->SetWidths(array(30, 30, 142));
                                                                         for ($i = 0; $i < $this->linhasdosdepart; $i++) {
                                                                             db_fieldsmemory($this->recorddosdepart, $i);
                                                                             $solicita = trim(pg_result($this->recorddosdepart, $i, $this->Snumdepart));
                                                                             $codigodep = trim(pg_result($this->recorddosdepart, $i, $this->Scoddepto));
                                                                             $descrdep = trim(pg_result($this->recorddosdepart, $i, $this->Sdescrdepto));
                                                                             $this->objpdf->Row(array($solicita, $codigodep, $descrdep), 4, false, 4);
                                                                         }
                                                                         $getdoy = $this->objpdf->gety() + 2 - $xlin;
                                                                     }
                                                                     // Caixa com Labels item, quantidade, descrição, valor
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     // Caixas dos label's
                                                                     $this->objpdf->rect($xcol, $xlin + $getdoy, 10, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 10, $xlin + $getdoy, 12, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 22, $xlin + $getdoy, 22, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 44, $xlin + $getdoy, 98, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 142, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                                     $this->objpdf->rect($xcol + 172, $xlin + $getdoy, 30, 6, 2, 'DF', '12');
                                                                     $menos = 16.9;
                                                                     if ($this->linhasdosfornec == 0) {
                                                                         $menos = 11;
                                                                     }
                                                                     if (isset($tiramenos)) {
                                                                         $menos = $menos + $tiramenos;
                                                                         if ($menos < 0) {
                                                                             $menos = -$menos;
                                                                         }
                                                                     }
                                                                     // Caixa dos itens
                                                                     $this->objpdf->rect($xcol, $xlin + $getdoy + 6, 10, $alturaini, 2, 'DF', '34');
                                                                     // Caixa da quantidade
                                                                     $this->objpdf->rect($xcol + 10, $xlin + $getdoy + 6, 12, $alturaini, 2, 'DF', '34');
                                                                     $this->objpdf->rect($xcol + 22, $xlin + $getdoy + 6, 22, $alturaini, 2, 'DF', '34');
                                                                     // Caixa dos materiais ou serviços
                                                                     $this->objpdf->rect($xcol + 44, $xlin + $getdoy + 6, 98, $alturaini, 2, 'DF', '34');
                                                                     // Caixa dos valores unitários
                                                                     $this->objpdf->rect($xcol + 142, $xlin + $getdoy + 6, 30, $alturaini, 2, 'DF', '');
                                                                     // Caixa dos valores totais dos itens
                                                                     $this->objpdf->rect($xcol + 172, $xlin + $getdoy + 6, 30, $alturaini, 2, 'DF', '34');
                                                                     $this->objpdf->sety($xlin + 48);
                                                                     $alt = 4;
                                                                     // Label das colunas
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     $this->objpdf->text($xcol + 2, $xlin + $getdoy + 4, 'ITEM');
                                                                     $this->objpdf->text($xcol + 11, $xlin + $getdoy + 4, 'QUANT');
                                                                     $this->objpdf->text($xcol + 30, $xlin + $getdoy + 4, 'REF');
                                                                     $this->objpdf->text($xcol + 70, $xlin + $getdoy + 4, 'MATERIAL OU SERVIÇO');
                                                                     $this->objpdf->text($xcol + 145, $xlin + $getdoy + 4, 'VALOR UNITÁRIO');
                                                                     $this->objpdf->text($xcol + 176, $xlin + $getdoy + 4, 'VALOR TOTAL');
                                                                     $maiscol = 0;
                                                                     $this->objpdf->SetWidths(array(10, 12, 22, 95, 30, 30));
                                                                     $this->objpdf->SetAligns(array('C', 'C', 'C', 'J', 'R', 'R'));
                                                                     $this->objpdf->setleftmargin(4);
                                                                     $this->objpdf->sety($xlin + $getdoy + 7);
                                                                     $this->objpdf->setfillcolor(235);
                                                                     $xtotal = 0;
                                                                     $muda_pagina = false;
                                                                     $pag = 1;
                                                                     for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                                                         if ($ii != 0 && $muda_pagina != true) {
                                                                             $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                                         }
                                                                         $this->objpdf->ln(2);
                                                                         db_fieldsmemory($this->recorddositens, $ii);
                                                                         $prazo = "";
                                                                         $pgto = "";
                                                                         $resumo = "";
                                                                         $descricaoitem = trim(pg_result($this->recorddositens, $ii, $this->descricaoitem));
                                                                         if (trim(pg_result($this->recorddositens, $ii, $this->sprazo)) != "") {
                                                                             $prazo = pg_result($this->recorddositens, $ii, $this->sprazo);
                                                                             $prazo = "PRAZO: " . trim($prazo);
                                                                         }
                                                                         if (trim(pg_result($this->recorddositens, $ii, $this->spgto)) != "") {
                                                                             $pgto = pg_result($this->recorddositens, $ii, $this->spgto);
                                                                             $pgto = "CONDIÇÃO: " . trim($pgto);
                                                                         }
                                                                         if (trim(pg_result($this->recorddositens, $ii, $this->sresum) != "")) {
                                                                             $resumo = "RESUMO: " . pg_result($this->recorddositens, $ii, $this->sresum);
                                                                             if ($descricaoitem == "" || $descricaoitem == null) {
                                                                                 $descricaoitem = trim(pg_result($this->recorddositens, $ii, $this->sresum));
                                                                                 $resumo = "";
                                                                             }
                                                                         }
                                                                         if ($muda_pagina == true) {
                                                                             $muda_pagina = false;
                                                                             $this->objpdf->sety($xlin + 12);
                                                                         }
                                                                         $unid = pg_result($this->recorddositens, $ii, $this->sunidade);
                                                                         $codunid = pg_result($this->recorddositens, $ii, $this->scodunid);
                                                                         $servico = pg_result($this->recorddositens, $ii, $this->sservico);
                                                                         $quantunid = pg_result($this->recorddositens, $ii, $this->squantunid);
                                                                         $susaquant = pg_result($this->recorddositens, $ii, $this->susaquant);
                                                                         $dist = 2.7;
                                                                         if (trim($codunid) != "") {
                                                                             $unid = trim(substr($unid, 0, 10));
                                                                             if ($susaquant == "t") {
                                                                                 $unid .= " \n{$quantunid} UNIDADES\n";
                                                                                 $resumo = str_replace("\n", "", $resumo);
                                                                             }
                                                                         } else {
                                                                             if ($servico == "t") {
                                                                                 $unid = "SERVIÇO";
                                                                             }
                                                                         }
                                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                                         $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->item), pg_result($this->recorddositens, $ii, $this->quantitem), $unid, $descricaoitem, '', ''), 3, false, 3);
                                                                         if (isset($resumo) && $resumo != "") {
                                                                             $this->objpdf->Row(array('', '', '', $resumo, '', ''), $dist, false, 2.7);
                                                                         }
                                                                         if (isset($prazo) && $prazo != "") {
                                                                             $this->objpdf->Row(array('', '', '', $prazo, '', ''), $dist, false, 2.7);
                                                                         }
                                                                         if (isset($pgto) && $pgto != "") {
                                                                             $this->objpdf->Row(array('', '', '', $pgto, '', ''), $dist, false, 2.7);
                                                                         }
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         /////// troca de pagina
                                                                         if ($this->objpdf->gety() > $this->objpdf->h - 30) {
                                                                             $pag++;
                                                                             $muda_pagina = true;
                                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                                             if ($pag != 1) {
                                                                                 $this->objpdf->Setfont('Arial', 'B', 7);
                                                                                 $this->objpdf->rect($xcol, $xlin + 262, 142, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 142, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 172, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                                                 $this->objpdf->text($xcol + 114, $xlin + 268, 'T O T A L   P Á G I N A');
                                                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                                             }
                                                                             $this->objpdf->addpage();
                                                                             $pagina += 1;
                                                                             $this->objpdf->settopmargin(1);
                                                                             $xlin = 20;
                                                                             $xcol = 4;
                                                                             $this->objpdf->setfillcolor(245);
                                                                             $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                                             $this->objpdf->setfillcolor(255, 255, 255);
                                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                             //.$this->logo
                                                                             $this->objpdf->text(130, $xlin - 13, "ORÇAMENTO N" . CHR(176));
                                                                             $this->objpdf->text(185, $xlin - 13, db_formatar($this->orccodigo, 's', '0', 6, 'e'));
                                                                             $this->objpdf->text(130, $xlin - 9, $this->labdados . CHR(176));
                                                                             $this->objpdf->text(185, $xlin - 9, db_formatar($this->Snumero, 's', '0', 6, 'e'));
                                                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                                                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                             $this->objpdf->Setfont('Arial', '', 7);
                                                                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                             $this->objpdf->text(40, $xlin + 1, db_formatar($this->cgcpref, 'cnpj'));
                                                                             $xlin = -30;
                                                                             $this->objpdf->Setfont('Arial', 'B', 8);
                                                                             $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                                                             $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 262, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 262, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 262, 2, 'DF', '34');
                                                                             $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 262, 2, 'DF', '34');
                                                                             $this->objpdf->sety($xlin + 66);
                                                                             $alt = 4;
                                                                             $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                                                             $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                                                             $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                                                             $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                                                             $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                                                             $maiscol = 0;
                                                                             $xlin = 20;
                                                                         }
                                                                         $this->objpdf->ln(2);
                                                                         if ($ii + 1 == $this->linhasdositens) {
                                                                             $this->objpdf->rect(4, $this->objpdf->gety(), 202, 0, 1, 'DF', '1234');
                                                                         }
                                                                     }
                                                                     // caixas para total
                                                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                                                     $this->objpdf->rect($xcol, $xlin + 262, 142, 10, 2, 'DF', '34');
                                                                     $this->objpdf->rect($xcol + 142, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                                     $this->objpdf->rect($xcol + 172, $xlin + 262, 30, 10, 2, 'DF', '34');
                                                                     $this->objpdf->text($xcol + 113, $xlin + 268, 'T O T A L   G E R A L');
                                                                     //	echo $this->numaut."<br>";
                                                                     //	echo $pagina;exit;
                                                                 } else {
                                                                     if ($this->modelo == 14) {
                                                                         ////////// MODELO 14  -  AIDOF
                                                                         $this->objpdf->AliasNbPages();
                                                                         $this->objpdf->AddPage();
                                                                         $this->objpdf->settopmargin(1);
                                                                         $this->objpdf->setleftmargin(4);
                                                                         $pagina = 1;
                                                                         $xlin = 30;
                                                                         $xcol = 4;
                                                                         $this->objpdf->setfillcolor(245);
                                                                         $this->objpdf->rect($xcol - 2, $xlin - 28, 206, 292, 2, 'DF', '1234');
                                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                                         $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO  N' . CHR(176));
                                                                         $this->objpdf->text(165, $xlin - 13, db_formatar($this->codaidof, 's', '0', 6, 'e'));
                                                                         $this->objpdf->text(180, $xlin - 13, "/" . $this->ano);
                                                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                         //.$this->logo
                                                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                         $this->objpdf->Setfont('Arial', '', 9);
                                                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                         $this->objpdf->Setfont('Arial', 'b', 12);
                                                                         $this->objpdf->text($xcol + 50, $xlin + 6, "AUTORIZAÇÃO DE IMPRESSÃO DE DOCUMENTOS");
                                                                         $this->objpdf->text($xcol + 60, $xlin + 12, "FISCAIS DO IMPOSTO SOBRE SERVIÇOS");
                                                                         $this->objpdf->Setfont('Arial', 'b', 8);
                                                                         $this->objpdf->text($xcol + 80, $xlin + 19, "ESTABELECIMENTO GRÁFICO");
                                                                         $this->objpdf->rect($xcol, $xlin + 20, $xcol + 198, 30, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 20, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 30, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 40, $xcol + 96, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 100, $xlin + 40, $xcol + 98, 10, 2, '', '1234');
                                                                         $this->objpdf->Setfont('Arial', 'b', 8);
                                                                         $this->objpdf->text($xcol + 2, $xlin + 28, "NOME:");
                                                                         $this->objpdf->text($xcol + 2, $xlin + 38, "ENDEREÇO:");
                                                                         $this->objpdf->text($xcol + 2, $xlin + 48, "INSCRIÇÃO MUNICIPAL:");
                                                                         $this->objpdf->text($xcol + 102, $xlin + 48, "INSCRIÇÃO DO CNPJ:");
                                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                                         $this->objpdf->text($xcol + 12, $xlin + 28, $this->nome_graf);
                                                                         $this->objpdf->text($xcol + 22, $xlin + 38, $this->ender_graf);
                                                                         $this->objpdf->text($xcol + 38, $xlin + 48, $this->inscr_graf);
                                                                         $this->objpdf->text($xcol + 138, $xlin + 48, $this->cnpj_graf);
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         $this->objpdf->text($xcol + 81, $xlin + 54, "ESTABELECIMENTO USUÁRIO");
                                                                         $this->objpdf->rect($xcol, $xlin + 55, $xcol + 198, 30, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 55, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 65, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 100, $xlin + 75, $xcol + 98, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 75, $xcol + 96, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 100, $xlin + 75, $xcol + 98, 10, 2, '', '1234');
                                                                         $this->objpdf->text($xcol + 2, $xlin + 63, "NOME:");
                                                                         $this->objpdf->text($xcol + 2, $xlin + 73, "ENDEREÇO:");
                                                                         $this->objpdf->text($xcol + 2, $xlin + 83, "INSCRIÇÃO MUNICIPAL:");
                                                                         $this->objpdf->text($xcol + 102, $xlin + 83, "INSCRIÇÃO DO CNPJ:");
                                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                                         $this->objpdf->text($xcol + 12, $xlin + 63, $this->nome_usu);
                                                                         $this->objpdf->text($xcol + 22, $xlin + 73, $this->ender_usu);
                                                                         $this->objpdf->text($xcol + 38, $xlin + 83, $this->inscr_usu);
                                                                         $this->objpdf->text($xcol + 138, $xlin + 83, $this->cnpj_usu);
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         $this->objpdf->text($xcol + 80, $xlin + 89, "DOCUMENTO A SER IMPRESSO");
                                                                         $this->objpdf->rect($xcol, $xlin + 90, $xcol + 198, 50, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 90, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 100, $xcol + 198, 10, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 90, $xcol + 65, 20, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 110, $xlin + 90, $xcol + 88, 20, 2, '', '1234');
                                                                         $this->objpdf->text($xcol + 25, $xlin + 96, "NUMERAÇÃO");
                                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                                         $this->objpdf->text($xcol + 20, $xlin + 108, $this->notaini . "   A   " . $this->notafin);
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         $this->objpdf->text($xcol + 78, $xlin + 96, "QUANTIDADE");
                                                                         $this->objpdf->text($xcol + 150, $xlin + 96, "ESPÉCIE");
                                                                         $this->objpdf->text($xcol + 2, $xlin + 115, "OBSERVAÇÕES:");
                                                                         $this->objpdf->Setfont('Arial', '', 8);
                                                                         $this->objpdf->text($xcol + 85, $xlin + 108, $this->quant);
                                                                         $this->objpdf->text($xcol + 115, $xlin + 108, $this->especie);
                                                                         $this->objpdf->SetXY($xcol + 2, $xlin + 117);
                                                                         $this->objpdf->Setfont('Arial', '', 7);
                                                                         $this->objpdf->multicell(198, 4, $this->obs, 0, "L");
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         $this->objpdf->text($xcol + 40, $xlin + 144, "PEDIDO");
                                                                         $this->objpdf->rect($xcol, $xlin + 145, $xcol + 95, 80, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 145, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 153, $xcol + 95, 16, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 169, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol, $xlin + 177, $xcol + 95, 24, 2, '', '1234');
                                                                         $this->objpdf->text($xcol + 140, $xlin + 144, "ENTREGA");
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 145, $xcol + 95, 48, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 145, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 153, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 153, $xcol + 47, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 161, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 169, $xcol + 95, 8, 2, '', '1234');
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 177, $xcol + 95, 16, 2, '', '1234');
                                                                         $this->objpdf->text($xcol + 137, $xlin + 197, "REPARTIÇÃO FISCAL");
                                                                         $this->objpdf->text($xcol + 141, $xlin + 203, "AUTORIZAMOS");
                                                                         $this->objpdf->rect($xcol + 103, $xlin + 198, $xcol + 95, 27, 2, '', '1234');
                                                                         $this->objpdf->Setfont('Arial', '', 7);
                                                                         $this->objpdf->text($xcol + 2, $xlin + 151, "DATA:________________DE______________________________DE_____________");
                                                                         $this->objpdf->text($xcol + 1, $xlin + 156, "NOME DO RESPONSÁVEL PELO ESTABELECIMENTO USUÁRIO");
                                                                         $this->objpdf->text($xcol + 3, $xlin + 165, "___________________________________________________________________");
                                                                         $this->objpdf->text($xcol + 1, $xlin + 172, "DOCUMENTO DE IDENTIDADE");
                                                                         $this->objpdf->text($xcol + 1, $xlin + 200, "ASSINATURA DO RESPONSÁVEL PELO ESTABELECIMENTO USUÁRIO");
                                                                         $this->objpdf->text($xcol + 1, $xlin + 224, "ASSINATURA DO RESPONSÁVEL PELO ESTABELECIMENTO GRÁFICO");
                                                                         $this->objpdf->text($xcol + 105, $xlin + 151, "DATA:________________DE______________________________DE_____________");
                                                                         $this->objpdf->text($xcol + 104, $xlin + 156, "DOC. FISCAL N°.:");
                                                                         $this->objpdf->text($xcol + 155, $xlin + 156, "SÉRIE:");
                                                                         $this->objpdf->text($xcol + 104, $xlin + 164, "RECEBIDO POR");
                                                                         $this->objpdf->text($xcol + 104, $xlin + 172, "DOCUMENTO DE IDENTIDADE");
                                                                         $this->objpdf->text($xcol + 116, $xlin + 192, "ASSINATURA DO RESPONSÁVEL PELO RECEBIMENTO");
                                                                         $this->objpdf->text($xcol + 105, $xlin + 211, "EM________________DE______________________________DE_____________");
                                                                         $this->objpdf->text($xcol + 115, $xlin + 224, "ASSINATURA E CARIMBO DA AUTORIDADE COMPETENTE");
                                                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                                                         $this->objpdf->text($xcol + 90, $xlin + 229, "IMPORTANTE");
                                                                         $this->objpdf->rect($xcol, $xlin + 230, $xcol + 198, 30, 2, '', '1234');
                                                                         $this->objpdf->Setfont('Arial', 'b', 7);
                                                                         $this->objpdf->text($xcol + 10, $xlin + 236, "NO RODAPÉ DAS NOTAS FISCAIS DEVERÁ CONSTAR OBRIGATORIAMENTE:");
                                                                         $this->objpdf->text($xcol + 10, $xlin + 242, "- A QUANTIDADE DE TALÕES IMPRESSOS:");
                                                                         $this->objpdf->text($xcol + 10, $xlin + 246, "- A NUMERAÇÃO:");
                                                                         $this->objpdf->text($xcol + 10, $xlin + 250, "- O NUMERO DA AUTORIZAÇÃO PARA IMPRESSÃO:");
                                                                         $this->objpdf->text($xcol + 10, $xlin + 254, "- O CNPJ E O NÚMERO DE INSCRIÇÃO MUNICIPAL DA GRÁFICA:");
                                                                     } else {
                                                                         if ($this->modelo == 15) {
                                                                             ////////// MODELO 15  -  ESTORNO DE EMPENHO
                                                                             for ($xxx = 0; $xxx < $this->nvias; $xxx++) {
                                                                                 $this->objpdf->AliasNbPages();
                                                                                 $this->objpdf->AddPage();
                                                                                 $this->objpdf->settopmargin(1);
                                                                                 $pagina = 1;
                                                                                 $xlin = 20;
                                                                                 $xcol = 4;
                                                                                 $this->objpdf->setfillcolor(245);
                                                                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                                                                 $this->objpdf->setfillcolor(255, 255, 255);
                                                                                 $this->objpdf->Setfont('Arial', 'B', 10);
                                                                                 $this->objpdf->text(117, $xlin - 13, 'ESTORNO DE PAGAMENTO N' . CHR(176) . ': ');
                                                                                 $this->objpdf->text(175, $xlin - 13, db_formatar($this->anulado, 's', '0', 6, 'e'));
                                                                                 $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                                                                 $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                                                                 $this->objpdf->text(128, $xlin - 3, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                                                                 $this->objpdf->text(175, $xlin - 3, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                                                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                                                                 //.$this->logo
                                                                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                                                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                                                                 $this->objpdf->Setfont('Arial', '', 7);
                                                                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                                                                 $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                                                                 $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                                                                 $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                                                                 $this->objpdf->text(40, $xlin, db_formatar($this->cgcpref, 'cnpj'));
                                                                                 /// retangulo dos dados da dotação
                                                                                 $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 50, 2, 'DF', '1234');
                                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 10.5, 'Unidade');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 14, 'Função');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 20.5, 'Proj/Ativ');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 27, 'Rubrica');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 35, 'Recurso');
                                                                                 if ($this->banco != "") {
                                                                                     $this->objpdf->text($xcol + 2, $xlin + 38.5, 'Banco');
                                                                                     $this->objpdf->text($xcol + 30, $xlin + 38.5, 'Agencia:');
                                                                                     $this->objpdf->text($xcol + 60, $xlin + 38.5, 'Conta:');
                                                                                 }
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 42.5, 'Reduzido');
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 48, 'Licitação');
                                                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 10.5, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 14, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 20.5, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 27, ':  ' . db_formatar($this->sintetico, 'elemento'));
                                                                                 $this->objpdf->setxy($xcol + 18, $xlin + 28);
                                                                                 $this->objpdf->multicell(90, 3, $this->descr_sintetico, 0, "L");
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 35, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                                                                 if ($this->banco != "") {
                                                                                     $this->objpdf->text($xcol + 17, $xlin + 38.5, ':  ' . $this->banco);
                                                                                     $this->objpdf->text($xcol + 47, $xlin + 38.5, $this->agencia);
                                                                                     $this->objpdf->text($xcol + 77, $xlin + 38.5, $this->conta);
                                                                                 }
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 42.5, ':  ' . $this->coddot);
                                                                                 $this->objpdf->text($xcol + 17, $xlin + 48, ':  ' . $this->descr_licitacao);
                                                                                 //// retangulo dos dados do credor
                                                                                 $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 18, 2, 'DF', '1234');
                                                                                 $this->objpdf->Setfont('Arial', '', 6);
                                                                                 $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                                                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                                                                 $this->objpdf->text($xcol + 107, $xlin + 7, 'Numcgm');
                                                                                 $this->objpdf->text($xcol + 140, $xlin + 7, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                                                                                 $this->objpdf->text($xcol + 107, $xlin + 11, 'Nome');
                                                                                 $this->objpdf->text($xcol + 107, $xlin + 15, 'Endereço');
                                                                                 $this->objpdf->text($xcol + 107, $xlin + 19, 'Município');
                                                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                                                 $this->objpdf->text($xcol + 124, $xlin + 7, ': ' . $this->numcgm);
                                                                                 $this->objpdf->text($xcol + 149, $xlin + 7, ':  ' . (strlen($this->cnpj) == 11 ? db_formatar($this->cnpj, 'cpf') : db_formatar($this->cnpj, 'cnpj')) . '   Fone: ' . $this->telefone);
                                                                                 $this->objpdf->text($xcol + 124, $xlin + 11, ': ' . $this->nome);
                                                                                 $this->objpdf->text($xcol + 124, $xlin + 15, ': ' . $this->ender . '  ' . $this->compl);
                                                                                 $this->objpdf->text($xcol + 124, $xlin + 19, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                                                                 ///// retangulo dos valores
                                                                                 $this->objpdf->rect($xcol + 106, $xlin + 21.5, 96, 9, 2, 'DF', '1234');
                                                                                 $this->objpdf->rect($xcol + 106, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                                                                 $this->objpdf->rect($xcol + 155, $xlin + 32.0, 47, 9, 2, 'DF', '1234');
                                                                                 $this->objpdf->rect($xcol + 106, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                                                                 $this->objpdf->rect($xcol + 155, $xlin + 42.5, 47, 9, 2, 'DF', '1234');
                                                                                 $this->objpdf->Setfont('Arial', '', 6);
                                                                                 $this->objpdf->text($xcol + 108, $xlin + 34.0, 'Valor Empenhado');
                                                                                 $this->objpdf->text($xcol + 157, $xlin + 34.0, 'Data do Empenho');
                                                                                 $this->objpdf->text($xcol + 108, $xlin + 44.5, 'Valor Estorno');
                                                                                 $this->objpdf->text($xcol + 157, $xlin + 44.5, 'Data do Estorno');
                                                                                 $this->objpdf->Setfont('Arial', '', 8);
                                                                                 $this->objpdf->text($xcol + 108, $xlin + 27, 'AUTORIZAÇÃO N' . chr(176) . ' ' . db_formatar($this->numaut, 's', '0', 5, 'e'));
                                                                                 $this->objpdf->text($xcol + 150, $xlin + 27, 'SEQ. DO EMPENHO N' . chr(176) . ' ' . db_formatar($this->numemp, 's', '0', 6, 'e'));
                                                                                 //	$this->objpdf->text($xcol+108,$xlin+26.5,$this->texto);
                                                                                 $this->objpdf->text($xcol + 130, $xlin + 38.0, db_formatar($this->empenhado, 'f'));
                                                                                 $this->objpdf->text($xcol + 180, $xlin + 38.0, $this->emissao, 'd');
                                                                                 $this->objpdf->text($xcol + 130, $xlin + 47.5, db_formatar($this->vlr_anul, 'f'));
                                                                                 $this->objpdf->text($xcol + 180, $xlin + 47.5, db_formatar($this->data_est, 'd'));
                                                                                 /// retangulo do corpo do empenho
                                                                                 $this->objpdf->rect($xcol, $xlin + 60, 202, 55, 2, 'DF', '');
                                                                                 $this->objpdf->rect($xcol, $xlin + 117, 202, 55, 2, 'DF', '');
                                                                                 $maiscol = 0;
                                                                                 $this->objpdf->rect($xcol, $xlin + 178, 202, 6, 2, 'DF', '34');
                                                                                 $this->objpdf->SetFont('Arial', '', 7);
                                                                                 $this->objpdf->setxy($xcol + 1, $xlin + 68);
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 64, 'Histórico do Estorno : ', 0, 1, 'L', 0);
                                                                                 $this->objpdf->multicell(195, 3.5, $this->descr_anu);
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 120, 'Histórico do Empenho : ', 0, 1, 'L', 0);
                                                                                 $this->objpdf->setxy($xcol + 1, $xlin + 124);
                                                                                 $this->objpdf->multicell(147, 3.5, $this->resumo);
                                                                                 $this->objpdf->text($xcol + 2, $xlin + 182, 'DESTINO : ', 0, 1, 'L', 0);
                                                                                 $this->objpdf->text($xcol + 30, $xlin + 182, $this->destino, 0, 1, 'L', 0);
                                                                                 $this->objpdf->rect($xcol, $xlin + 197, 67, 47, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 67, $xlin + 197, 67, 47, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol + 134, $xlin + 197, 68, 47, 2, 'DF', '34');
                                                                                 $this->objpdf->rect($xcol, $xlin + 191, 67, 6, 2, 'DF', '12');
                                                                                 $this->objpdf->rect($xcol + 67, $xlin + 191, 67, 6, 2, 'DF', '12');
                                                                                 $this->objpdf->rect($xcol + 134, $xlin + 191, 68, 6, 2, 'DF', '12');
                                                                                 $this->objpdf->text($xcol + 19, $xlin + 195, 'CONTADORIA GERAL');
                                                                                 $this->objpdf->text($xcol + 84, $xlin + 195, 'GABINETE DO PREFEITO');
                                                                                 $this->objpdf->text($xcol + 158, $xlin + 195, 'TESOURARIA');
                                                                                 if ($this->assinatura3 != "") {
                                                                                     $this->objpdf->line($xcol + 8, $xlin + 225, $xcol + 58, $xlin + 225);
                                                                                 }
                                                                                 if (strtoupper(trim($this->municpref)) == 'SAPIRANGA') {
                                                                                     $this->objpdf->line($xcol + 10, $xlin + 210, $xcol + 55, $xlin + 210);
                                                                                     $this->objpdf->SetFont('Arial', '', 6);
                                                                                     $this->objpdf->text($xcol + 29 - strlen($this->assinatura2) / 2, $xlin + 212, $this->assinatura2);
                                                                                 }
                                                                                 $this->objpdf->line($xcol + 73, $xlin + 225, $xcol + 125, $xlin + 225);
                                                                                 $this->objpdf->SetFont('Arial', '', 6);
                                                                                 $this->objpdf->text($xcol + 29 - strlen($this->assinatura3) / 2, $xlin + 227, $this->assinatura3);
                                                                                 $this->objpdf->text($xcol + 99 - strlen($this->assinaturaprefeito) / 2, $xlin + 227, $this->assinaturaprefeito);
                                                                                 $this->objpdf->line($xcol + 141, $xlin + 225, $xcol + 195, $xlin + 225);
                                                                                 $this->objpdf->text($xcol + 160, $xlin + 227, 'TESOUREIRO');
                                                                                 //           $this->objpdf->rect($xcol,$xlin+246,202,26,2,'DF','1234');
                                                                                 $this->objpdf->SetFont('Arial', '', 4);
                                                                                 $this->objpdf->Text(2, 296, $this->texto);
                                                                                 // texto no canhoto do carne
                                                                                 $this->objpdf->SetFont('Arial', '', 6);
                                                                                 $this->objpdf->Text(200, 296, $xxx + 1 . ' via');
                                                                                 // texto no canhoto do carne
                                                                                 $this->objpdf->setfont('Arial', '', 11);
                                                                                 $xlin = 169;
                                                                             }
                                                                         } else {
                                                                             echo "<script>alert('Modelo No. {$this->modelo} não definido no sistema. Contate suporte.')</script>";
                                                                             exit;
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
                    if (isset($sEmailServ) && $sEmailServ != '') {
                        $oMail = new Smtp();
                        $oMail->Send($mailpref, $w13_emailadmin, 'Prefeitura On-Line - Esqueci Minha Senha', $mensagemDestinatario);
                        msgbox("Uma mensagem foi encaminhada para o e-mail: {$sEmailServ}");
                    }
                    db_logs("", "", 0, "Esqueci minha senha: cgc ou cpf - {$sCgcCpf}");
                }
            } else {
                $sMsg = "Dados informados NÃO encontrados no cadastro da Prefeitura!\\n\n                   Procure o balcão da Prefeitura para realizar seu cadastro.";
                msgbox($sMsg);
                db_redireciona("centro_pref.php");
            }
        } else {
            $sMsg = "Dados informados NÃO encontrados no cadastro da Prefeitura!\\n\n                 Procure o balcão da Prefeitura para realizar seu cadastro.";
            msgbox($sMsg);
            db_redireciona("centro_pref.php");
        }
    }
}
function formataDataNascBanco($sData)
{
    $data = str_replace("/", "", $sData);
    $datanasc_dia = substr($data, -8, 2);
    $datanasc_mes = substr($data, -6, 2);
    $datanasc_ano = substr($data, -4);
    $datanasc = $datanasc_ano . "-" . $datanasc_mes . "-" . $datanasc_dia;
    return $datanasc;
}
function formataCpfBanco($sCpf)
{
    $cpf = str_replace(".", "", $sCpf);
     $script = true;
 } elseif (pg_numrows($result) == 1) {
     db_fieldsmemory($result, 0);
     //$sql2 = "select * from iptubase where j01_numcgm = $z01_numcgm";
     //$result2 = @db_query($sql2);
     //if(pg_numrows($result2)==0){
     //  db_redireciona("certidao.php");
     //}else{
     // db_redireciona("digitamatricula.php");
     //}
     //exit;
 } else {
     if (pg_numrows($result) > 1) {
         msgbox("Inconsistencia de dados, procure a Prefeitura.");
         setcookie("cookie_codigo_cgm");
         db_redireciona("certidaonome003.php?outro");
         $script = false;
     }
 }
 //	if (! isset ( $DB_LOGADO ) && $m_publico != 't') {
 //		$sql = "select fc_permissaodbpref(" . db_getsession ( "DB_login" ) . ",1,$codigo_cgm)";
 //		$result = db_query ( $sql );
 //		if (pg_numrows ( $result ) == 0) {
 //			db_redireciona ( "digitacontribuinte.php?" . base64_encode ( 'erroscripts=Acesso não Permitido. Contate a Prefeitura.' ) );
 //			exit ();
 //		}
 //		$result = pg_result ( $result, 0, 0 );
 //		if ($result == "0") {
 //			db_redireciona ( "digitacontribuinte.php?" . base64_encode ( 'erroscripts=Acesso não Permitido. Contate a Prefeitura.' ) );
 //			exit ();
 //		}
    $oBanco = db_utils::fieldsMemory($rsConsultaBanco, 0);
    $pdf1->numbanco = $oBanco->db90_codban . "-" . $oBanco->db90_digban;
    $pdf1->banco = $oBanco->db90_abrev;
    try {
        $pdf1->imagemlogo = $oConvenio->getImagemBanco();
    } catch (Exception $eExeption) {
        db_redireciona("db_erros.php?fechar=true&db_erro=" . $eExeption->getMessage());
    }
}
//#############################################################
/**
 * Verifica se é um objeto db_impcarne
 */
if (!is_a($pdf1, "db_impcarne")) {
    $sMensagemErro = "Erro ao gerar recibo. Contate suporte! Não possui modelo do documento para emissão do boleto selecionado.";
    db_redireciona("db_erros.php?fechar=true&db_erro=" . $sMensagemErro);
}
$pdf1->imprime();
$pdf1->objpdf->output();
function recibodesconto($numpre, $numpar, $tipo, $tipo_debito, $whereloteador, $totalregistrospassados, $totregistros)
{
    // desconto
    global $k00_dtvenc, $k40_codigo, $k40_todasmarc, $cadtipoparc;
    $cadtipoparc = 0;
    $sqlvenc = "select k00_dtvenc\n                from arrecad\n               where k00_numpre = {$numpre}\n                 and k00_numpar = {$numpar}";
    $resultvenc = db_query($sqlvenc) or die($sqlvenc);
    if (pg_numrows($resultvenc) == 0) {
        return 0;
    }
    db_fieldsmemory($resultvenc, 0);
    $sqltipoparc = "select k40_codigo,\n                         k40_todasmarc,\n                         cadtipoparc\n                    from tipoparc\n                   inner join cadtipoparc    on cadtipoparc = k40_codigo\n                   inner join cadtipoparcdeb on k41_cadtipoparc = cadtipoparc\n                   where maxparc = 1\n                     and '" . date("Y-m-d", db_getsession("DB_datausu")) . "' >= k40_dtini\n                     and '" . date("Y-m-d", db_getsession("DB_datausu")) . "' <= k40_dtfim\n                     and k41_arretipo = {$tipo} {$whereloteador}\n                     and '{$k00_dtvenc}' >= k41_vencini\n                     and '{$k00_dtvenc}' <= k41_vencfim ";
$this->objpdf->cell(6, 3, "Rec", 0, 0, "L", 0);
$this->objpdf->cell(7, 3, "Reduz", 0, 0, "L", 0);
$this->objpdf->cell(64, 3, "Descrição", 0, 0, "L", 0);
$this->objpdf->cell(18, 3, "Valor", 0, 1, "R", 0);
$reccol = $xcol + 5;
$reccol2 = $xcol + 5;
$bklin = $xlin + 30;
//17
$bklin2 = $xlin + 30;
$this->totalrec = 0;
$this->totaldesc = 0;
$this->totalacres = 0;
for ($x = 0; $x < $intnumrows; $x++) {
    $this->obsdescr = null;
    if ($x == 50) {
        db_redireciona('db_erros.php?fechar=true&db_erro=O numero de receitas ultrapassou o espaço limite do carne.  Contate o suporte!');
        break;
    }
    $this->objpdf->Text($reccol, $bklin, $this->arraycodreceitas[$x]);
    $this->objpdf->Text($reccol + 6, $bklin, "(" . $this->arrayreduzreceitas[$x] . ")");
    if (@$this->arraycodhist[$x] == 918) {
        $this->obsdescr = " (desconto)";
    }
    $this->objpdf->Text($reccol + 12, $bklin, $this->arraydescrreceitas[$x] . $this->obsdescr);
    //$this->objpdf->Text($reccol+82, $bklin,db_formatar($this->arrayvalreceitas[$x],'f'));
    $this->objpdf->cell($reccol + 85, 3, db_formatar($this->arrayvalreceitas[$x], 'f'), 0, 1, "R", 0);
    $iFormaCorrecao = pg_result(db_query("select k03_separajurmulparc\n                                           from numpref\n                                          where k03_instit = " . db_getsession("DB_instit") . "\n                                            and k03_anousu = " . db_getsession("DB_anousu")), 0, 0);
    if ($iFormaCorrecao == 1) {
        /*
         * Controle da composição 
         * utilizado em Canela
$result_pcorcamforne = $clpcorcamforne->sql_record($clpcorcamforne->sql_query_fornec(null, $sCampos, "", "pc21_codorc = {$pc20_codorc} {$fornecedores}"));
$numrows_pcorcamforne = $clpcorcamforne->numrows;
if ($numrows_pcorcamforne == 0) {
    if (isset($gera_branco) && $gera_branco == true) {
        $numrows_pcorcamforne = 1;
        $branco = true;
    } else {
        db_redireciona("db_erros.php?fechar=true&db_erro=Nenhum registro encontrado ou orçamento sem fornecedores!");
    }
}
$sCampos2 = "distinct\n             pc11_codigo,\n             pc11_quant,\n             pc01_descrmater,\n             pc11_resum,\n             pc11_pgto,\n             pc11_prazo,\n             pc81_codprocitem,\n             pc10_numero,\n             pc81_codproc as pc80_codproc,\n             m61_usaquant,\n             m61_descr,\n             pc17_codigo,\n             pc17_quant,\n             pc01_servico,\n             pc23_valor,\n             pc23_obs,\n             pc23_vlrun,\n             pc23_validmin";
$sWhere = "    pc22_codorc={$pc20_codorc} \n           and pc23_orcamforne in ( select pc21_orcamforne \n                                      from pcorcamforne \n                                     where pc21_numcgm in ({$fornecedor_cgm}) )";
$result_itens = $clpcorcamitemproc->sql_record($clpcorcamitemproc->sql_query_solicitem(null, null, $sCampos2, "pc81_codprocitem", $sWhere));
$numrows_itens = $clpcorcamitemproc->numrows;
if ($numrows_itens == 0) {
    db_redireciona("db_erros.php?fechar=true&db_erro=Nenhum item encontrado neste orçamento!");
}
$result_departs = $clpcorcam->sql_record($clpcorcam->sql_query_soldepto($pc20_codorc, "distinct pc10_numero as numdepart,coddepto,descrdepto"));
$numrows_departs = $clpcorcam->numrows;
$pdf = new scpdf();
$pdf->Open();
$pdf1 = new db_impcarne($pdf, '13');
$pdf1->objpdf->SetTextColor(0, 0, 0);
$numcgm_ant = "";
for ($i = 0; $i < $numrows_pcorcamforne; $i++) {
    if (isset($branco) && $branco == true) {
    } else {
        db_fieldsmemory($result_pcorcamforne, $i);
    }
    db_fieldsmemory($result_itens, 0);
    $result_pcproc = $clpcproc->sql_record($clpcproc->sql_query($pc80_codproc, "distinct pc80_codproc,descrdepto,pc80_data,pc80_resumo,fonedepto,emaildepto,faxdepto,ramaldepto"));
    //busca dados do issbase
    for ($x = 0; $x < $iptubase; $x++) {
        if ($x == 0) {
            ?>
<tr height="20" bgcolor="<?php 
            echo $w01_corfundomenu;
            ?>
"><td colspan="3"><b>Minhas Matrículas</b></td></tr><?php 
        }
        db_fieldsmemory($result2, $x);
        if ($imobil == 0 && $iptubase == 1) {
            $redireciona = "opcoesdebitospendentes.php?" . base64_encode("matricula1={$j01_matric}&cgc={$z01_cgccpf}&opcao=m&id_usuario=" . @$id_usuario);
            if (!isset($DB_LOGADO)) {
                @(include $redireciona);
            } else {
                db_redireciona($redireciona);
            }
        }
        echo "<tr height=\"20\"><td><img src=\"imagens/seta.gif\" border=\"0\"></td><td align=\"right\"><a class=\"links\" href=\"opcoesdebitospendentes.php?" . base64_encode("matricula1={$j01_matric}&cgc={$z01_cgccpf}&opcao=m&id_usuario=" . @$id_usuario) . "\"><b>" . $j01_matric . "</b></a></td><td><a class='links' href=\"opcoesdebitospendentes.php?" . base64_encode("matricula1={$j01_matric}&cgc={$z01_cgccpf}&cpf={$z01_cgccpf}&opcao=m&id_usuario=" . @$id_usuario) . "\"> " . $z01_nome . " - " . $proprietario . "</a></td></tr>";
        echo "<tr height=\"1\" bgcolor=\"{$w01_corfundomenu}\"><td colspan=\"3\"></td></tr>";
    }
    ?>
</table><?php 
}
db_logs("", "", 0, "Digita Codigo da Matrícula.");
if (isset($erroscripts)) {
    echo "<script>alert('" . $erroscripts . "');</script>";
}
?>

<iframe src='captcha/pesquisa_captcha.php?code=<?php 
                    msgbox("Inconsistencia de dados, procure a Prefeitura.");
                    setcookie("cookie_codigo_cgm");
                    db_redireciona("digitacontribuinte.php?outro");
                    $script = false;
                }
            }
            if (!isset($DB_LOGADO) && $m_publico != 't') {
                $sql = "select fc_permissaodbpref(" . db_getsession("DB_login") . ",1,{$codigo_cgm})";
                $result = db_query($sql);
                if (pg_numrows($result) == 0) {
                    db_redireciona("digitacontribuinte.php?" . base64_encode('erroscripts=Acesso não Permitido. Contate a Prefeitura.'));
                    exit;
                }
                $result = pg_result($result, 0, 0);
                if ($result == "0") {
                    db_redireciona("digitacontribuinte.php?" . base64_encode('erroscripts=Acesso não Permitido. Contate a Prefeitura.'));
                    exit;
                }
            }
        }
    }
}
if (pg_num_rows($result) > 0) {
    //db_fieldsmemory ( $result, 0 );//lmachado-tiago-email:Acerto E-cidadão Online data: 27/05/15 16:53
    if (@$codigo_cgm == "") {
        @($codigo_cgm = $z01_numcgm);
    }
}
?>
<html>
<head>
$sSqlRendimento .= "                 inner join rhdirfgeracaodadospessoal      on rhdirfgeracaodadospessoal.rh96_rhdirfgeracao                  = rhdirfgeracao.rh95_sequencial             \n";
$sSqlRendimento .= "                 inner join rhdirfgeracaodadospessoalvalor on rhdirfgeracaodadospessoalvalor.rh98_rhdirfgeracaodadospessoal = rhdirfgeracaodadospessoal.rh96_sequencial \n";
$sSqlRendimento .= "                 inner join cgm                            on cgm.z01_numcgm                                                = rhdirfgeracaodadospessoal.rh96_numcgm     \n";
$sSqlRendimento .= "                 inner join rhdirfgeracaopessoalregist     on rhdirfgeracaodadospessoalvalor.rh98_sequencial                = rh99_rhdirfgeracaodadospessoalvalor       \n";
$sSqlRendimento .= "                 inner join rhpessoalmov                   on rh02_anousu                                                   = {$anofolha}                               \n";
$sSqlRendimento .= "                                                          and rh02_mesusu                                                   = {$mesfolha}                               \n";
$sSqlRendimento .= "                                                          and rh02_regist                                                   = rh99_regist                               \n";
$sSqlRendimento .= "                                                          and rh02_instit                                                   = " . db_getsession("DB_instit") . "            \n";
$sSqlRendimento .= "                 inner join rhlota                         on rhlota.r70_codigo                                             = rhpessoalmov.rh02_lota                    \n";
$sSqlRendimento .= "                                                          and rhlota.r70_instit                                             = rhpessoalmov.rh02_instit                  \n";
$sSqlRendimento .= "         {$sWhere}                                                                                                                                                      \n";
$sSqlRendimento .= "        ) as x                                                                                                                                                          \n";
$rsSqlRendimento = db_query($sSqlRendimento);
$iNumRows = pg_num_rows($rsSqlRendimento);
if ($iNumRows == 0) {
    db_redireciona('db_erros.php?fechar=true&db_erro=Registros não Processados para o Ano Calendário, entre em contato com o setor responsável.');
    exit;
}
$pdf = new scpdf();
$pdf->Open();
$pdf1 = new db_impcarne($pdf, $iTipoRelatorio);
for ($iInd = 0; $iInd < $iNumRows; $iInd++) {
    $oRendimento = db_utils::fieldsMemory($rsSqlRendimento, $iInd);
    $nome_pens = '';
    if ($oRendimento->pensao > 0) {
        $sSqlPensao = " select z01_nome as pensionista                    ";
        $sSqlPensao .= "   from pensao                                     ";
        $sSqlPensao .= "        inner join cgm on r52_numcgm = z01_numcgm  ";
        $sSqlPensao .= "  where r52_anousu = {$anofolha}            ";
        $sSqlPensao .= "    and r52_mesusu = {$mesfolha}            ";
        $sSqlPensao .= "    and r52_regist in(" . str_replace('}', '', str_replace('{', '', $oRendimento->regist)) . ") ";
        	$ins= $inscricaow;
        	$cnpj ="$z01_cgccpf";
        	$nros = $ano . $mes . $dia . $codigo . $ins . $cnpj ;
        	$t1 = strrev($nros);
        	$cod= md5($t1);
        */
        $cl_aidofweb->y07_aidof = $claidof->y08_codigo;
        $cl_aidofweb->y07_ip = $ip;
        $cl_aidofweb->y07_data = $dataat;
        $cl_aidofweb->y07_hora = $hora;
        //$cl_aidofweb->y07_codautenticidade = $cod;
        $cl_aidofweb->incluir(null);
        db_fim_transacao();
        //echo "<script>jan = window.open('aidof.php?".base64_encode('codigo='.$codigo.'&inscricao='.$inscricaow.'&grafica='.$numgrafica.'&nota='.$nomenota)."','','height=500,width=650,scrollbars=1');</script>";
        echo "<script>jan = window.open('aidof.php?codigo={$codigo}&inscricao={$inscricaow}&grafica={$numgrafica}&nota={$nomenota}','','height=500,width=650,scrollbars=1');</script>";
        db_redireciona("digitaaidof.php");
    }
}
// acaba o gravar
//verifica se contribuinte possui pedido aberto
?>
<html>
<head>
<title><?php 
echo $w01_titulo;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="scripts/db_script.js"></script>
<script>
js_verificapagina("digitaaidof.php,pesquisagrafica.php,opcoesaidof.php");
    $script = false;
} else {
    if ($z01_cgccpf == "00000000000000" || $z01_cgccpf == "              ") {
        $script = true;
    }
}
if (!isset($DB_LOGADO) && $m_publico != 't') {
    $sql = "select fc_permissaodbpref(" . db_getsession("DB_login") . ",2,{$inscricao})";
    $result = pg_exec($sql);
    if (pg_numrows($result) == 0) {
        db_redireciona("digitaissqn.php?" . base64_encode("erroscripts=Acesso não Permitido. Contate a Prefeitura."));
        exit;
    }
    $result = pg_result($result, 0, 0);
    if ($result == "0") {
        db_redireciona("digitaissqn.php?" . base64_encode("erroscripts=Acesso não Permitido. Contate a Prefeitura."));
        exit;
    }
}
db_logs("{$matricula}", "", 0, "Matricula Pesquisada. Numero : {$matricula}");
?>
<html>
<head>
<title><?php 
echo $w01_titulo;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="scripts/db_script.js"></script>
<script>
js_verificapagina("digitaitbi.php,listabicimovel.php,listaitbisolicitacao.php,listaitbiverifica.php");
    $item = 0;
    for ($i = 0; $i < $tamanho; $i++) {
        $valores = "valores" . ($i + 1);
        $input = ${$valores};
        if ($input != "") {
            $matriz = split("#", $input);
            $mes = $matriz[0];
            $valor = $matriz[1];
            $aliquota = $matriz[2];
            $imposto = $matriz[3];
            $data = $matriz[4];
            $result = pg_exec("insert into db_daevalores values({$codigo},{$item},'{$mes}',{$valor},{$aliquota},{$imposto},'{$data}')");
            $item += 1;
        }
    }
    db_redireciona("valoresdae.php?" . base64_encode('inscricaow=$inscricaow&primeira=1'));
}
?>
<html>
<head>
<title><?php 
echo $w01_titulo;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="scripts/db_script.js">
</script>
<script>
js_verificapagina("digitadae.php,opcoesdae.php,enderecodae.php,sociosdae.php,valoresdae.php,enviadae.php");
function js_trocaframe(div,obj){
  var id1 = new Array('endereco','socios','valores','enviadae');
Exemplo n.º 15
0
require "libs/db_stdlib.php";
parse_str(base64_decode($HTTP_SERVER_VARS["QUERY_STRING"]));
$result = pg_exec("SELECT distinct m_publico,m_arquivo,m_descricao\n                       FROM db_menupref \n                       WHERE m_arquivo = 'digitainscricao.php'\n                       ORDER BY m_descricao\n                       ");
db_fieldsmemory($result, 0);
if ($m_publico != 't') {
    if (!session_is_registered("DB_acesso")) {
        echo "<script>location.href='index.php?" . base64_encode('erroscripts=3') . "'</script>";
    }
}
include "classes/db_db_certidaoweb_classe.php";
$clcertidao = new cl_db_certidaoweb();
$result = $clcertidao->sql_record($clcertidao->sql_query("", "*", "", "ceracesso = '" . $cod . "'"));
if ($clcertidao->numrows == 0) {
    echo "<script>window.opener.alert('CNPJ ou CPF inválidos')</script>";
    echo "<script>window.close()</script>";
    db_redireciona("certidaoautentica.php");
}
db_fieldsmemory($result, 0);
$dtvenc = str_replace("-", "", $cerdtvenc);
$data = getdate();
$dia = $data['mday'];
$mes = $data['mon'];
$ano = $data['year'];
if (strlen($mes) == "1") {
    $mes = "0" . $mes;
}
if (strlen($dia) == "1") {
    $dia = "0" . $dia;
}
$dtat = $ano . $mes . $dia;
if (strcmp($dtat, $dtvenc) < "0") {
function db_buscaImagemBanco($cadban, $conn)
{
    /*
     * $cadban = codigo k15_codigo da cadban
     * $conn   =  conexão
     */
    $sqlcodban = "select k15_codbco from cadban where k15_codigo = {$cadban}";
    $resultcadban = db_query($sqlcodban);
    $linhascadban = pg_num_rows($resultcadban);
    if ($linhascadban > 0) {
        //db_fieldsmemory($resultcadban,0);
        $k15_codbco = pg_result($resultcadban, 0, "k15_codbco");
        $banco = str_pad($k15_codbco, 3, "0", STR_PAD_LEFT);
        // busca os dados do banco..logo etc
        $sqlBanco = "select  * from db_bancos where db90_codban = '" . $banco . "'";
        $resultBanco = db_query($sqlBanco);
        $linhasBanco = pg_num_rows($resultBanco);
        if ($linhasBanco > 0) {
            //db_fieldsmemory($resultBanco,0);
            $db90_digban = pg_result($resultBanco, 0, "db90_digban");
            $db90_abrev = pg_result($resultBanco, 0, "db90_abrev");
            $db90_logo = pg_result($resultBanco, 0, "db90_logo");
            // se não tiver os dados do banco na db_bancos não deve emitir o recibo.
            if ($db90_digban == "" || $db90_abrev == "" || $db90_logo == "") {
                return false;
                //	  	db_redireciona('db_erros.php?fechar=true&db_erro=Configure os dados(Digito verificador, Nome abreviado do banco e o Arquivo do logo) do Banco: '.$banco.'-'.$db90_descr.', no Cadastro de Bancos');
            }
            // seta os dados para o boleto passando as informações do logo
            db_query($conn, "begin");
            $caminho = "tmp/" . $banco . ".jpg";
            pg_lo_export("{$db90_logo}", $caminho, $conn);
            db_query($conn, "commit");
            $arr = array("numbanco" => $banco . "-" . $db90_digban, "banco" => $db90_abrev, "imagemlogo" => $caminho);
            return $arr;
        } else {
            // se não tiver o banco na db_bancos
            db_redireciona('db_erros.php?fechar=true&db_erro=Não existe Banco cadastrado para o código' . $banco . ' no Cadastro de Bancos' . $sqlBanco);
        }
    }
}
$rsRetornoConfig = db_query("select * from configdbpref where w13_instit = {$instit}");
$sConfig = pg_fetch_assoc($rsRetornoConfig);
$sqlinst = "select codigo as instituicao, db21_regracgmiptu from db_config where prefeitura='t'";
$resultinst = db_query($sqlinst);
db_fieldsmemory($resultinst, 0);
// valida se o número da matrícula fornecida é válida
if (isset($matric)) {
    $sql = "select q02_numcgm, j01_matric \n            from iptubase \n           inner join cgm       on z01_numcgm = j01_numcgm \n           left  join issbase   on q02_numcgm = j01_numcgm \n\t\t   where j01_matric = {$matric}";
    //Se o parâmetro "Exige CPF/CNPJ na consulta de imóveis" do mód. Prefeitura On-line estiver como "Sim" verifica o CPF/CNPJ
    if ($sConfig["w13_exigecpfcnpjmatricula"] == "t") {
        $sql .= " and trim(z01_cgccpf) = '{$cgccpf}' ";
    }
    $rsValidaMatricula = db_query($sql);
    $sResultadoValMat = pg_num_rows($rsValidaMatricula);
    if ($sResultadoValMat == 0) {
        db_redireciona("digitamatricula.php?" . base64_encode("erroscripts=Aviso: Os dados informados não conferem. Verifique o número da matrícula ou o CPF/CNPJ indicado!"));
    }
}
$matricula = $matric;
echo "\n<script type=\"text/javascript\"> \nfunction js_voltar(){\n  location.href = 'opcoesdebitospendentes.php?matricula=" . @$matric . "&inscricao=" . @$inscr . "&opcao=m&id_usuario=" . @$id_usuario . "&opcao=" . @$opcao . "&cgccpf=" . @$cgccpf . "';\n}\n</script>\n";
?>
<html>
<head>
<title><?php 
echo $w01_titulo;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="include/estilodai.css">
<script language="JavaScript" src="scripts/db_script.js"></script>
<script>
 $iMod1 = db_CalculaDV($iMatricula);
 $iMod2 = db_CalculaDV($iMatricula . $iMod1 . $iMes . $ano . $iSequencial);
 $iCodAutent = $iMatricula . $iMod1 . $iMes . $iMod2 . $ano . $iSequencial;
 $clrhemitecontracheque->rh85_sequencial = $iSequencial;
 $clrhemitecontracheque->rh85_regist = $regist;
 $clrhemitecontracheque->rh85_anousu = $ano;
 $clrhemitecontracheque->rh85_mesusu = $mes;
 $clrhemitecontracheque->rh85_sigla = substr($sigla, 0, 3);
 $clrhemitecontracheque->rh85_codautent = $iCodAutent;
 $clrhemitecontracheque->rh85_dataemissao = date('Y-m-d', db_getsession('DB_datausu'));
 $clrhemitecontracheque->rh85_horaemissao = db_hora();
 $clrhemitecontracheque->rh85_ip = $sIp;
 $clrhemitecontracheque->rh85_externo = 'true';
 $clrhemitecontracheque->incluir($iSequencial);
 if ($clrhemitecontracheque->erro_status == 0) {
     db_redireciona('db_erros.php?fechar=true&db_erro=' . $clrhemitecontracheque->erro_msg);
 }
 if ($lin == 1) {
     $lin = 0;
     $pdf1->seq = 0;
 } else {
     $lin = 1;
     $pdf1->seq = 1;
 }
 $sql = "\n  select " . $sigla . "rubric as rubrica,\n       round(" . $sigla . "valor,2) as valor,\n       round(" . $sigla . "quant,2) as quant, \n       rh27_descr, \n       " . $xtipo . " as tipo , \n       case when " . $sigla . "pd = 3 then 'B' \n            else case when " . $sigla . "pd = 1 then 'P' \n\t         else 'D' \n\t    end \n       end as provdesc\n \n  from " . $arquivo . " \n     inner join rhrubricas on rh27_rubric = " . $sigla . "rubric \n                          and rh27_instit = {$institservidor}\n  where " . $sigla . "regist = {$regist}\n    and " . $sigla . "anousu = {$ano} \n    and " . $sigla . "mesusu = {$mes}\n    and " . $sigla . "instit = {$institservidor}\n    {$wheresemest}\n  order by " . $sigla . "rubric  ";
 if (cl_cfpess::verificarUtilizacaoEstruturaSuplementar() && ($opcao == 'salario' || $opcao == 'suplementar' || $opcao == 'complementar')) {
     $sql = "select rh143_rubrica              as rubrica,                             ";
     $sql .= "       round(sum(rh143_valor), 2) as valor,                               ";
     $sql .= "       round(rh143_quantidade, 2) as quant,                               ";
     $sql .= "       rh27_descr                 ,                                       ";
     $sql .= "       {$xtipo}                   as tipo ,                               ";
 function imprime()
 {
     if ($this->modelo == 1) {
         if ($this->qtdcarne % 4 == 0) {
             $this->objpdf->AddPage();
         }
         $this->objpdf->SetLineWidth(0.05);
         $this->qtdcarne += 1;
         $top = $this->objpdf->GetY() - 5;
         $this->objpdf->SetFont('Arial', 'B', 8);
         $this->objpdf->SetTextColor(0, 0, 0);
         $this->objpdf->SetFillColor(250, 250, 250);
         $this->objpdf->SetX(17);
         $this->objpdf->Text(17, $top, $this->prefeitura, 0, 0, "L", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Text(105, $top, $this->prefeitura, 0, 1, "L", 0);
         $this->objpdf->SetX(170);
         $this->objpdf->SetX(17);
         $this->objpdf->SetFont('Arial', '', 7);
         $this->objpdf->Text(17, $top + 3, $this->secretaria, 0, 0, "L", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Text(105, $top + 3, $this->secretaria, 0, 1, "L", 0);
         $this->objpdf->Ln(2);
         $this->objpdf->SetFont('Arial', 'B', 8);
         $this->objpdf->SetX(10);
         $this->objpdf->Cell(90, 4, $this->tipodebito, 0, 0, "C", 0);
         $this->objpdf->SetX(105);
         $this->objpdf->Cell(90, 4, $this->tipodebito, 0, 1, "C", 0);
         $y = $this->objpdf->GetY() - 1;
         $this->objpdf->Image('imagens/files/' . $this->logo, 8, $y - 14, 8);
         $this->objpdf->Image('imagens/files/' . $this->logo, 95, $y - 14, 8);
         $this->objpdf->SetFont('Times', '', 5);
         $this->objpdf->RoundedRect(10, $y + 1, 32, 6, 2, 'DF', '1234');
         // matricula/ inscrição
         $this->objpdf->RoundedRect(43, $y + 1, 27, 6, 2, 'DF', '1234');
         // cod. de arrecadação
         $this->objpdf->RoundedRect(71, $y + 1, 20, 6, 2, 'DF', '1234');
         // parcela
         $this->objpdf->RoundedRect(10, $y + 8, 81, 12, 2, 'DF', '1234');
         // nome / endereço
         $this->objpdf->RoundedRect(10, $y + 21, 81, 14, 2, 'DF', '1234');
         // instruçoes
         $this->objpdf->RoundedRect(10, $y + 36, 39, 7, 2, 'DF', '1234');
         // vencimento
         $this->objpdf->RoundedRect(50, $y + 36, 41, 7, 2, 'DF', '1234');
         // valor
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 3, $this->titulo1);
         // matricula/ inscrição
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(13, $y + 6, $this->descr1);
         // numero da matricula ou inscricao
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(45, $y + 3, $this->titulo2);
         // cod. de arrecadação
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(47, $y + 6, $this->descr2);
         // numpre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(73, $y + 3, $this->titulo5);
         // Parcela
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(76, $y + 6, $this->descr5);
         // Parcela inicial e total de parcelas
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 10, $this->titulo3);
         // contribuinte/endereço
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(13, $y + 13, $this->descr3_1);
         // nome do contribuinte
         $this->objpdf->Text(13, $y + 16, $this->descr3_2);
         // endereço
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 23, $this->titulo4);
         // Instruções
         $this->objpdf->SetFont('Arial', 'B', 7);
         $xx = $this->objpdf->getx();
         $yy = $this->objpdf->gety();
         $this->objpdf->setleftmargin(10);
         $this->objpdf->setrightmargin(120);
         $this->objpdf->sety($y + 23);
         $this->objpdf->multicell(0, 3, $this->descr4_1);
         // Instruções 1 - linha 1
         //        $this->objpdf->multicell(0,3,$this->descr4_2); // Instruções 1 - linha 2
         $this->objpdf->setxy($xx, $yy);
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(13, $y + 38, $this->titulo6);
         // Vencimento
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(20, $y + 41, $this->descr6);
         // Data de Vencimento
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(53, $y + 38, $this->titulo7);
         // valor
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(56, $y + 41, $this->descr7);
         // qtd de URM ou valor
         $this->objpdf->RoundedRect(95, $y + 1, 33, 6, 2, 'DF', '1234');
         // matricula / inscricao
         $this->objpdf->RoundedRect(129, $y + 1, 27, 6, 2, 'DF', '1234');
         // cod. arrecadacao
         $this->objpdf->RoundedRect(157, $y + 1, 20, 6, 2, 'DF', '1234');
         // parcela
         $this->objpdf->RoundedRect(178, $y + 1, 31, 6, 2, 'DF', '1234');
         // livre
         $this->objpdf->RoundedRect(95, $y + 8, 82, 13, 2, 'DF', '1234');
         // nome / endereco
         $this->objpdf->RoundedRect(95, $y + 22, 114, 13, 2, 'DF', '1234');
         // instrucoes
         $this->objpdf->RoundedRect(178, $y + 8, 31, 6, 2, 'DF', '1234');
         // vencimento
         $this->objpdf->RoundedRect(178, $y + 15, 31, 6, 2, 'DF', '1234');
         // valor
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 3, $this->titulo8);
         // matricula / inscricao
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(97, $y + 6, $this->descr8);
         // numero da matricula ou inscricao
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(131, $y + 3, $this->titulo9);
         // cod. de arrecadação
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(133, $y + 6, $this->descr9);
         // numpre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(159, $y + 3, $this->titulo10);
         // parcela
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(162, $y + 6, $this->descr10);
         // parcela e total das parcelas
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 3, $this->titulo13);
         // livre
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(183, $y + 6, $this->descr13);
         // livre
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 10, $this->titulo11);
         // contribuinte / endereço
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(97, $y + 13, $this->descr11_1);
         // nome do contribuinte
         $this->objpdf->Text(97, $y + 16, $this->descr11_2);
         // endereço
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(97, $y + 24, $this->titulo12);
         // instruções
         $this->objpdf->SetFont('Arial', 'B', 7);
         $xx = $this->objpdf->getx();
         $yy = $this->objpdf->gety();
         $this->objpdf->setleftmargin(97);
         $this->objpdf->setrightmargin(2);
         $this->objpdf->sety($y + 24);
         $this->objpdf->multicell(0, 3, $this->descr12_1);
         // Instruções 2 - linha 1
         $this->objpdf->multicell(0, 3, $this->descr12_2);
         // Instruções 2 - linha 2
         $this->objpdf->setxy($xx, $yy);
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 10, $this->titulo14);
         // vencimento
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(180, $y + 13, $this->descr14);
         // data de vencimento
         $this->objpdf->SetFont('Arial', '', 5);
         $this->objpdf->Text(180, $y + 17, $this->titulo15);
         // valor
         $this->objpdf->SetFont('Arial', 'B', 7);
         $this->objpdf->Text(180, $y + 20, $this->descr15);
         // total de URM ou valor
         $this->objpdf->SetLineWidth(0.05);
         $this->objpdf->SetDash(1, 1);
         //        $this->objpdf->Line(5,$y+58,205,$y+58); // linha tracejada horizontal
         $this->objpdf->Line(93, $y - 30, 93, $y + 60);
         // linha tracejada vertical
         $this->objpdf->SetDash();
         $this->objpdf->Ln(70);
         $this->objpdf->SetFillColor(0, 0, 0);
         $this->objpdf->SetFont('Arial', '', 10);
         $this->objpdf->SetFont('Arial', '', 4);
         $this->objpdf->TextWithDirection(2, $y + 30, $this->texto, 'U');
         // texto no canhoto do carne
         $this->objpdf->SetFont('Arial', '', 9);
         $this->objpdf->Text(10, $y + 46, $this->descr16_1);
         //
         $this->objpdf->Text(10, $y + 50, $this->descr16_2);
         //
         $this->objpdf->Text(10, $y + 54, $this->descr16_3);
         //
         $this->objpdf->Text(105, $y + 38, $this->linha_digitavel);
         $this->objpdf->int25(95, $y + 39, $this->codigo_barras, 15, 0.341);
         /*
                 $y = $this->objpdf->gety();
                 $this->objpdf->setleftmargin(10);
                 $this->objpdf->setrightmargin(120);
                 $this->objpdf->sety($y+28);
                 $this->objpdf->multicell(0,3,$this->descr4_1); // Instruções 1 - linha 1
                 $this->objpdf->ln(39.5);
         */
     } else {
         if ($this->modelo == 22) {
             $this->objpdf->AliasNbPages();
             $this->objpdf->AddPage();
             $this->objpdf->Setfont('Arial', 'B', 12);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->roundedrect(05, 05, 200, 288, 2, 'DF', '1234');
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->roundedrect(10, 07, 190, 183, 2, 'DF', '1234');
             $this->objpdf->Image('imagens/files/' . $this->logo, 45, 9, 20);
             $this->objpdf->text(70, 15, $this->prefeitura);
             $this->objpdf->Setfont('Arial', '', 12);
             $this->objpdf->text(70, 20, $this->enderpref);
             $this->objpdf->text(70, 25, $this->municpref);
             $this->objpdf->text(70, 30, $this->telefpref);
             $this->objpdf->text(70, 35, $this->emailpref);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(15, 45, 110, 35, 2, 'DF', '1234');
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(16, 47, 'Identificação:');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(16, 51, 'Nome :');
             $this->objpdf->text(32, 51, $this->nome);
             $this->objpdf->text(16, 56, 'Endereço :');
             $this->objpdf->text(32, 56, $this->ender);
             $this->objpdf->text(16, 60, 'Município :');
             $this->objpdf->text(32, 60, $this->munic);
             $this->objpdf->text(16, 64, 'CEP :');
             $this->objpdf->text(32, 64, $this->cep);
             $this->objpdf->text(16, 68, 'Data :');
             $this->objpdf->text(32, 68, date('d/m/Y'));
             $this->objpdf->text(50, 68, 'Hora: ' . date("H:i:s"));
             $this->objpdf->text(16, 72, $this->tipoinscr);
             $this->objpdf->text(32, 72, $this->nrinscr);
             $this->objpdf->text(16, 76, 'IP :');
             $this->objpdf->text(32, 76, $this->ip);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->Roundedrect(130, 45, 65, 35, 2, 'DF', '1234');
             $this->objpdf->text(132, 47, $this->tipoinscr);
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 50, $this->nrinscr);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 55, 'Logradouro :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 58, $this->nomepri);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 63, 'Número/Complemento :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 66, $this->nrpri . "      " . $this->complpri);
             $this->objpdf->Setfont('Arial', '', 6);
             $this->objpdf->text(132, 71, 'Bairro :');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->text(132, 74, $this->bairropri);
             $this->objpdf->Setfont('Arial', 'B', 11);
             $this->objpdf->text(70, 87, 'RECIBO VÁLIDO ATÉ: ' . $this->datacalc);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(15, 90, 180, 65, 2, 'DF', '1234');
             $this->objpdf->Setfont('Arial', '', 8);
             $this->objpdf->SetXY(17, 96);
             if ($this->taxabanc != 0) {
                 $this->objpdf->Cell(20, 4, 'Taxa Bancária', 0, 0, "L", 0);
                 $this->objpdf->Cell(20, 4, db_formatar($this->taxabanc, 'f'), 0, 1, "R", 0);
             }
             for ($i = 0; $i < $this->linhasdadospagto; $i++) {
                 $this->objpdf->setx(17);
                 $this->objpdf->cell(5, 4, trim(pg_result($this->recorddadospagto, $i, $this->receita)), 0, 0, "C", 0);
                 if (trim(pg_result($this->recorddadospagto, $i, $this->ddreceita)) == '') {
                     $this->objpdf->cell(70, 4, trim(pg_result($this->recorddadospagto, $i, $this->dreceita)), 0, 0, "L", 0);
                 } else {
                     $this->objpdf->cell(70, 4, trim(pg_result($this->recorddadospagto, $i, $this->ddreceita)), 0, 0, "L", 0);
                 }
                 $this->objpdf->cell(15, 4, db_formatar(pg_result($this->recorddadospagto, $i, $this->valor), 'f'), 0, 1, "R", 0);
             }
             $this->objpdf->SetXY(15, 158);
             $this->objpdf->multicell(0, 4, 'HISTÓRICO :   ' . $this->historico);
             $this->objpdf->setx(15);
             $this->objpdf->multicell(0, 4, $this->histparcel);
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->Roundedrect(10, 195, 190, 46, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 6);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(40, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(93, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(146, 200, 48, 10, 2, 'DF', '1234');
             $this->objpdf->text(42, 202, 'Vencimento');
             $this->objpdf->text(95, 202, 'Código de Arrecadação');
             $this->objpdf->text(148, 202, 'Valor a Pagar');
             $this->objpdf->setfont('Arial', '', 10);
             $this->objpdf->text(48, 207, $this->dtvenc);
             $this->objpdf->text(101, 207, $this->numpre);
             $this->objpdf->text(153, 207, $this->valtotal);
             $this->objpdf->SetDash(0.8, 0.8);
             $this->objpdf->line(5, 242.5, 205, 242.5);
             $this->objpdf->SetDash();
             $this->objpdf->setfillcolor(255, 255, 255);
             $this->objpdf->Roundedrect(10, 244, 190, 46, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 12);
             $this->objpdf->setfillcolor(0, 0, 0);
             $this->objpdf->Image('imagens/files/' . $this->logo, 12, 200, 25);
             $this->objpdf->text(60, 218, $this->linhadigitavel);
             $this->objpdf->int25(60, 220, $this->codigobarras, 15, 0.341);
             $this->objpdf->setfillcolor(245);
             $this->objpdf->Roundedrect(40, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(93, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->Roundedrect(146, 250, 48, 10, 2, 'DF', '1234');
             $this->objpdf->setfont('Arial', '', 6);
             $this->objpdf->text(42, 252, 'Vencimento');
             $this->objpdf->text(95, 252, 'Código de Arrecadação');
             $this->objpdf->text(148, 252, 'Valor a Pagar');
             $this->objpdf->setfont('Arial', '', 10);
             $this->objpdf->text(48, 257, $this->dtvenc);
             $this->objpdf->text(101, 257, $this->numpre);
             $this->objpdf->text(153, 257, $this->valtotal);
             $this->objpdf->Image('imagens/files/' . $this->logo, 12, 250, 25);
             $this->objpdf->SetFont('Arial', '', 5);
             $this->objpdf->text(10, $this->objpdf->h - 2, 'Base: ' . @$GLOBALS["DB_NBASE"]);
             $this->objpdf->setfillcolor(0, 0, 0);
             $this->objpdf->setfont('Arial', '', 12);
             $this->objpdf->text(60, 268, $this->linhadigitavel);
             $this->objpdf->int25(60, 270, $this->codigobarras, 15, 0.341);
         } else {
             if ($this->modelo == 3) {
                 $this->objpdf->SetTextColor(0, 0, 0);
                 $this->objpdf->SetFont('Arial', 'B', 12);
                 $coluna = 44;
                 $linha = 35;
                 $this->objpdf->SetLineWidth(1);
                 $this->objpdf->RoundedRect(37, 0.2, 137, 195, 2, '1234');
                 $this->objpdf->SetLineWidth(0.5);
                 $this->objpdf->roundedrect(39, 2, 133, 191, 2, '1234');
                 $this->objpdf->SetLineWidth(0.2);
                 $this->objpdf->Image('imagens/files/Brasao.png', 43, 5, 20);
                 $this->objpdf->Image('imagens/files/Brasao.jpg', 60, 30, 100);
                 //	$this->objpdf->roundedrect(42,$linha+30,127,35,2,'1234');
                 //	$this->objpdf->roundedrect(42,$linha+72,127,15,2,'1234'); // obs da atividade principal
                 //  	$this->objpdf->roundedrect(42,$linha+88,127,5,2,'1234'); // descricao da atividade secundaria
                 //	$this->objpdf->roundedrect(42,$linha+94,127,15,2,'1234'); // obs da atividade secundaria
                 //	$this->objpdf->setdrawcolor(235);
                 $this->objpdf->setxy(65, 5);
                 $this->objpdf->setfont('Arial', 'B', 13);
                 $this->objpdf->Multicell(0, 8, $this->prefeitura, "C");
                 // prefeitura
                 $this->objpdf->setxy(65, 10);
                 $this->objpdf->setfont('Arial', 'B', 13);
                 $this->objpdf->setleftmargin(50);
                 $this->objpdf->setrightmargin(50);
                 $this->objpdf->Multicell(0, 8, $this->tipoalvara, 0, "C", 0);
                 // tipo de alvara
                 $this->objpdf->settextcolor(150);
                 $this->objpdf->setxy(85, 25);
                 $this->objpdf->setfont('Arial', 'B', 60);
                 $this->objpdf->Multicell(0, 8, date('Y'), "C");
                 // exercicio
                 $this->objpdf->settextcolor(0, 0, 0);
                 $this->objpdf->setxy(84, 24);
                 $this->objpdf->setfont('Arial', 'B', 60);
                 $this->objpdf->Multicell(0, 8, date('Y'), "C");
                 // exercicio
                 $this->objpdf->Ln(6);
                 //	$this->objpdf->sety(38);
                 $this->objpdf->SetFont('Arial', '', 11);
                 $this->objpdf->Multicell(0, 6, $this->texto);
                 // texto
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 35, 'CCM:');
                 // atividade / inscricao
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 35, $this->ativ . ' / ' . $this->nrinscr);
                 // atividade / inscricao
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 39, "NOME/RAZAO SOCIAL: ");
                 // nome
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 39, $this->nome);
                 // nome
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 43, "ENDEREÇO: ");
                 // endereco
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 43, $this->ender);
                 // endereco
                 $this->objpdf->SetFont('Arial', 'B', 9);
                 $this->objpdf->Text($coluna, $linha + 47, "NÚMERO: ");
                 // endereco
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Text($coluna + 40, $linha + 47, $this->numero == "" ? "" : $this->numero);
                 if ($this->compl != "") {
                     $this->objpdf->SetFont('Arial', 'B', 9);
                     $this->objpdf->Text($coluna + 60, $linha + 47, "COMPLEMENTO: ");
                     // endereco
                     $this->objpdf->SetFont('Arial', '', 9);
                     $this->objpdf->Text($coluna + 90, $linha + 47, $this->compl == "" ? "" : $this->compl);
                 }
                 $this->objpdf->setx(40);
                 if ($this->q02_memo != '') {
                     $this->objpdf->SetFont('Arial', 'B', 9);
                     $this->objpdf->Text($coluna, $linha + 51, "OBSERVAÇÃO: ");
                     // observação
                     $this->objpdf->SetFont('Arial', '', 9);
                     $this->objpdf->sety($linha + 52);
                     $this->objpdf->Multicell(0, 3, $this->q02_memo);
                     // texto
                     $this->objpdf->SetFont('Arial', 'B', 10);
                     $this->objpdf->roundedrect(42, $linha + 30, 127, 35, 2, '1234');
                     $linha = 102;
                 } else {
                     $this->objpdf->roundedrect(42, $linha + 30, 127, 20, 2, '1234');
                     $linha = 87;
                 }
                 $this->objpdf->sety($linha);
                 $this->objpdf->roundedrect(42, $linha - 1, 127, 5, 2, '1234');
                 $this->objpdf->SetFont('Arial', 'B', 8);
                 $this->objpdf->Ln(0.5);
                 $this->objpdf->setx(45);
                 $this->objpdf->Multicell(0, 3, "ATIVIDADE PRINCIPAL: " . $this->descrativ);
                 // descrição da atividade principal
                 $linha += 6;
                 $obs = '';
                 if (isset($this->q03_atmemo[$this->ativ])) {
                     if ($this->q03_atmemo[$this->ativ] != '') {
                         $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                         // obs da atividade principal
                         $obs = $this->q03_atmemo[$this->ativ];
                         $this->objpdf->Ln(3);
                         $this->objpdf->SetFont('Arial', '', 7);
                         $this->objpdf->Multicell(0, 3, $this->q03_atmemo[$this->ativ]);
                         // texto
                         $linha += 16;
                     }
                 }
                 $this->objpdf->sety($linha);
                 $num_outras = count($this->outrasativs);
                 $x = 105;
                 if ($num_outras > 0) {
                     $x = $x + 4;
                     reset($this->outrasativs);
                     for ($i = 0; $i < $num_outras; $i++) {
                         $yyy = $this->objpdf->gety();
                         $chave = key($this->outrasativs);
                         $obs = '';
                         if (isset($this->q03_atmemo[$chave])) {
                             $obs = $this->q03_atmemo[$chave];
                         }
                         $this->objpdf->SetFont('Arial', 'B', 8);
                         $this->objpdf->roundedrect(42, $yyy - 1, 127, 5, 2, '1234');
                         // descricao da atividade secundaria
                         $this->objpdf->Ln(0.5);
                         $this->objpdf->setx(45);
                         $this->objpdf->Multicell(0, 3, "ATIVIDADE SECUNDÁRIA: " . $this->outrasativs[$chave]);
                         // texto
                         $linha += 6;
                         if ($obs != "") {
                             $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                             // obs da atividade secundaria
                             $this->objpdf->Ln(3);
                             $this->objpdf->SetFont('Arial', '', 7);
                             $this->objpdf->Multicell(0, 3, $obs);
                             // texto
                             $linha += 16;
                         }
                         $x = $x + 4;
                         next($this->outrasativs);
                         //             $this->objpdf->ln(2.5);
                         $this->objpdf->sety($linha);
                     }
                 }
                 $x = 64;
                 //        if($this->q02_obs!=''){
                 //	  $this->objpdf->Text($coluna,$linha+$x,"OBSERVAÇÃO: "); // descrição da atividade principal
                 //	  $this->objpdf->Text($coluna + 45,$linha+$x,$this->q02_obs); // descrição da atividade principal
                 //	  $x=$x+4;
                 //	}
                 //        $linha = $this->objpdf->gety();
                 $this->objpdf->SetFont('Arial', 'B', 12);
                 $this->objpdf->Text($coluna + 55, $linha + 5, "Sapiranga, " . date('d') . " de " . db_mes(date('m')) . " de " . date('Y') . ".");
                 // data
                 $this->objpdf->sety(125);
                 $this->objpdf->SetFont('Arial', '', 9);
                 $this->objpdf->Multicell(0, 6, $this->obs);
                 // observação
                 $this->objpdf->setfont('arial', '', 6);
                 $this->objpdf->SetXY($coluna - 18, 165);
                 $this->objpdf->MultiCell(90, 4, '..........................................................................................' . "\n" . 'SECRETÁRIO DA IND. COM. E TURISMO', 0, "C", 0);
                 $this->objpdf->SetXY($coluna + 50, 165);
                 $this->objpdf->MultiCell(90, 4, '..........................................................................................', 0, "C", 0);
                 //        $this->objpdf->SetXY($coluna-35,160);
                 //        $this->objpdf->MultiCell(90,4,'..........................................................................................'."\n".'SECRETÁRIO DA IND. COM. E TURISMO',0,"C",0);
                 //        $this->objpdf->SetXY($coluna+35,160);
                 //        $this->objpdf->MultiCell(90,4,'..........................................................................................',0,"C",0);
                 $this->objpdf->sety(180);
                 $this->objpdf->setfont('arial', 'B', 12);
                 $this->objpdf->multicell(0, 8, 'FIXAR EM LUGAR VISÍVEL', 1, "C");
                 $this->objpdf->SetFont('Arial', 'B', 10);
             } else {
                 if ($this->modelo == 4) {
                     // BOLETO BANCÁRIO
                     $linha = 186;
                     $pdf->Line(47, $linha, 47, $linha + 9);
                     $pdf->Line(63, $linha, 63, $linha + 9);
                     $pdf->SetLineWidth(0.6);
                     $pdf->Line(10, $linha + 9, 195, $linha + 9);
                     $pdf->SetLineWidth(0.2);
                     $pdf->Line(10, $linha + 17, 195, $linha + 17);
                     $pdf->Line(10, $linha + 25, 195, $linha + 25);
                     $pdf->Line(10, $linha + 33, 195, $linha + 33);
                     $pdf->Line(10, $linha + 41, 195, $linha + 41);
                     $pdf->Line(149, $linha + 49, 195, $linha + 49);
                     $pdf->Line(149, $linha + 57, 195, $linha + 57);
                     $pdf->Line(149, $linha + 65, 195, $linha + 65);
                     $pdf->Line(149, $linha + 73, 195, $linha + 73);
                     $pdf->Line(10, $linha + 81, 195, $linha + 81);
                     $pdf->Line(149, $linha + 9, 149, $linha + 81);
                     $pdf->Line(169, $linha + 9, 169, $linha + 17);
                     $pdf->Line(40, $linha + 25, 40, $linha + 33);
                     $pdf->Line(86, $linha + 25, 86, $linha + 33);
                     $pdf->Line(112, $linha + 25, 112, $linha + 33);
                     $pdf->Line(125, $linha + 25, 125, $linha + 33);
                     $pdf->Line(45, $linha + 33, 45, $linha + 41);
                     $pdf->Line(65, $linha + 33, 65, $linha + 41);
                     $pdf->Line(91, $linha + 33, 91, $linha + 41);
                     $pdf->Line(121, $linha + 33, 121, $linha + 41);
                     $pdf->Line(10, $linha + 93, 195, $linha + 93);
                     //codigo de barras
                     $this->objpdf->SetFillColor(0, 0, 0);
                     $this->objpdf->int25(10, $linha + 94, $this->codigo_barras, 20, 0.341);
                     // quadrado inferior //
                     $this->objpdf->Image('imagens/files/Brasao.png', 10, 187, 35, 7);
                     $this->objpdf->SetFont('Arial', 'b', 14);
                     $this->objpdf->Text(49, $linha + 7, $this->numbanco);
                     // numero do banco
                     $this->objpdf->SetFont('Arial', 'b', 11);
                     $this->objpdf->Text(70, $linha + 7, $this->linha_digitavel);
                     $this->objpdf->SetFont('Arial', 'b', 5);
                     $this->objpdf->Text(13, $linha + 11, "Local de Pagamento");
                     $this->objpdf->Text(151, $linha + 11, "Parcela");
                     $this->objpdf->Text(171, $linha + 11, "Vencimento");
                     $this->objpdf->Text(13, $linha + 19, "Cedente");
                     $this->objpdf->Text(151, $linha + 19, "Agência/Código Cedente");
                     $this->objpdf->Text(13, $linha + 27, "Data do Documento");
                     $this->objpdf->Text(42, $linha + 27, "Número do Documento");
                     $this->objpdf->Text(88, $linha + 27, "Espécie Doc.");
                     $this->objpdf->Text(114, $linha + 27, "Aceite");
                     $this->objpdf->Text(127, $linha + 27, "Data do Processamento");
                     $this->objpdf->Text(151, $linha + 27, "Nosso Número");
                     $this->objpdf->Text(13, $linha + 35, "Código do Cedente");
                     $this->objpdf->Text(47, $linha + 35, "Carteira");
                     $this->objpdf->Text(67, $linha + 35, "Espécie");
                     $this->objpdf->Text(93, $linha + 35, "Quantidade");
                     $this->objpdf->Text(123, $linha + 35, "Valor");
                     $this->objpdf->Text(151, $linha + 35, "( = ) Valor do Documento");
                     $this->objpdf->Text(13, $linha + 43, "Instruções");
                     $this->objpdf->Text(151, $linha + 43, "( - ) Desconto / Abatimento");
                     $this->objpdf->Text(151, $linha + 51, "( - ) Outras Deduções");
                     $this->objpdf->Text(151, $linha + 59, "( + ) Mora / Multa");
                     $this->objpdf->Text(151, $linha + 67, "( + ) Outros Acrécimos");
                     $this->objpdf->Text(151, $linha + 75, "( = ) Valor Cobrado");
                     $this->objpdf->Text(13, $linha + 83, "Sacado");
                     $this->objpdf->Text(13, $linha + 91, "Sacador/Avalista");
                     $this->objpdf->Text(160, $linha + 99, "Autenticação Mecânica");
                     $this->objpdf->SetFont('Arial', 'b', 8);
                     $this->objpdf->Text(13, $linha + 15, $this->localpagamento);
                     // local de pagamento
                     $this->objpdf->SetFont('Arial', '', 10);
                     $this->objpdf->Text(151, $linha + 15, $this->parcela);
                     // parcela
                     $this->objpdf->Text(171, $linha + 15, $this->dtvenc);
                     // vencimento
                     $this->objpdf->Text(13, $linha + 23, $this->cedente);
                     // cedente
                     $this->objpdf->Text(151, $linha + 23, $this->agencia_cedente);
                     // agencia do cedente
                     $this->objpdf->Text(13, $linha + 31, $this->data_documento);
                     // data do documento
                     $this->objpdf->Text(42, $linha + 31, $this->numero_documento);
                     // numero do documento
                     $this->objpdf->Text(88, $linha + 31, $this->especie_doc);
                     // especie do documento
                     $this->objpdf->Text(114, $linha + 31, $this->aceite);
                     // aceite
                     $this->objpdf->Text(127, $linha + 31, $this->data_processamento);
                     // data do processamento
                     $this->objpdf->Text(151, $linha + 31, $this->nosso_numero);
                     // nosso numero
                     $this->objpdf->Text(13, $linha + 39, $this->codigo_cedente);
                     // codigo do cedente
                     $this->objpdf->Text(47, $linha + 39, $this->carteira);
                     // carteira
                     $this->objpdf->Text(67, $linha + 39, $this->especie);
                     // especie
                     $this->objpdf->Text(93, $linha + 39, $this->quantidade);
                     // quantidade
                     $this->objpdf->Text(123, $linha + 39, $this->valor);
                     // valor
                     $this->objpdf->Text(151, $linha + 39, $this->valor_documento);
                     // valor do documento
                     $this->objpdf->Text(20, $linha + 54, $this->instrucoes1);
                     // instrucoes 1
                     $this->objpdf->Text(20, $linha + 58, $this->instrucoes2);
                     // instrucoes 2
                     $this->objpdf->Text(20, $linha + 62, $this->instrucoes3);
                     // instrucoes 3
                     $this->objpdf->Text(15, $linha + 70, $this->instrucoes4);
                     // instrucoes 4
                     $this->objpdf->Text(20, $linha + 74, $this->instrucoes5);
                     // instrucoes 5
                     $this->objpdf->Text(151, $linha + 47, $this->desconto_abatimento);
                     // desconto/abatimento
                     $this->objpdf->Text(151, $linha + 55, $this->outras_deducoes);
                     // outras deducoes
                     $this->objpdf->Text(151, $linha + 63, $this->mora_multa);
                     // multa
                     $this->objpdf->Text(151, $linha + 71, $this->outros_acrecimos);
                     // outros acrescimos
                     $this->objpdf->Text(151, $linha + 79, $this->valor_cobrado);
                     // valor cobrado
                     $this->objpdf->Text(29, $linha + 85, $this->sacado1);
                     // sacado 1
                     $this->objpdf->Text(29, $linha + 88, $this->sacado2);
                     // sacado 2
                     $this->objpdf->Text(29, $linha + 91, $this->sacado3);
                     // sacado 3
                 } else {
                     if ($this->modelo == 2) {
                         //// RECIBO
                         $this->objpdf->AliasNbPages();
                         $this->objpdf->AddPage();
                         $this->objpdf->settopmargin(1);
                         $this->objpdf->line(2, 148.5, 208, 148.5);
                         $xlin = 20;
                         $xcol = 4;
                         for ($i = 0; $i < 2; $i++) {
                             $this->objpdf->setfillcolor(245);
                             $this->objpdf->roundedrect($xcol - 2, $xlin - 18, 206, 144.5, 2, 'DF', '1234');
                             $this->objpdf->setfillcolor(255, 255, 255);
                             //		$this->objpdf->roundedrect(10,07,190,183,2,'DF','1234');
                             $this->objpdf->Setfont('Arial', 'B', 11);
                             $this->objpdf->text(150, $xlin - 13, 'RECIBO VÁLIDO ATÉ: ');
                             $this->objpdf->text(159, $xlin - 8, $this->datacalc);
                             $this->objpdf->Image('imagens/files/' . $this->logo, 15, $xlin - 17, 12);
                             $this->objpdf->Setfont('Arial', 'B', 9);
                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                             $this->objpdf->Setfont('Arial', '', 9);
                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                             //		$this->objpdf->setfillcolor(245);
                             $this->objpdf->Roundedrect($xcol, $xlin + 2, $xcol + 119, 20, 2, 'DF', '1234');
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->text($xcol + 2, $xlin + 4, 'Identificação:');
                             $this->objpdf->Setfont('Arial', '', 8);
                             $this->objpdf->text($xcol + 2, $xlin + 7, $this->tipoinscr);
                             $this->objpdf->text($xcol + 17, $xlin + 7, $this->nrinscr);
                             $this->objpdf->text($xcol + 30, $xlin + 7, 'Nome :');
                             $this->objpdf->text($xcol + 40, $xlin + 7, $this->nome);
                             $this->objpdf->text($xcol + 2, $xlin + 11, 'Endereço :');
                             $this->objpdf->text($xcol + 17, $xlin + 11, $this->ender);
                             $this->objpdf->text($xcol + 2, $xlin + 15, 'Município :');
                             $this->objpdf->text($xcol + 17, $xlin + 15, $this->munic);
                             $this->objpdf->text($xcol + 75, $xlin + 15, 'CEP :');
                             $this->objpdf->text($xcol + 82, $xlin + 15, $this->cep);
                             $this->objpdf->text($xcol + 2, $xlin + 19, 'Data :');
                             $this->objpdf->text($xcol + 17, $xlin + 19, date('d/m/Y'));
                             $this->objpdf->text($xcol + 40, $xlin + 19, 'Hora: ' . date("H:i:s"));
                             $this->objpdf->text($xcol + 75, $xlin + 19, 'IP :');
                             $this->objpdf->text($xcol + 82, $xlin + 19, $this->ip);
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->Roundedrect($xcol + 126, $xlin + 2, 76, 20, 2, 'DF', '1234');
                             $this->objpdf->text($xcol + 128, $xlin + 7, $this->tipoinscr1);
                             $this->objpdf->text($xcol + 145, $xlin + 7, $this->nrinscr1);
                             $this->objpdf->text($xcol + 128, $xlin + 11, $this->tipolograd);
                             $this->objpdf->text($xcol + 145, $xlin + 11, $this->nomepri);
                             $this->objpdf->text($xcol + 128, $xlin + 15, $this->tipocompl);
                             $this->objpdf->text($xcol + 145, $xlin + 15, $this->nrpri . "      " . $this->complpri);
                             $this->objpdf->text($xcol + 128, $xlin + 19, $this->tipobairro);
                             $this->objpdf->text($xcol + 145, $xlin + 19, $this->bairropri);
                             //		$this->objpdf->setfillcolor(245);
                             $this->objpdf->Roundedrect($xcol, $xlin + 24, 202, 45, 2, 'DF', '1234');
                             $this->objpdf->sety($xlin + 28);
                             $maiscol = 0;
                             $yy = $this->objpdf->gety();
                             for ($ii = 0; $ii < $this->linhasdadospagto; $ii++) {
                                 if ($ii == 10) {
                                     $maiscol = 100;
                                     $this->objpdf->sety($yy);
                                 }
                                 $this->objpdf->setx($xcol + 3 + $maiscol);
                                 $this->objpdf->cell(5, 3, trim(pg_result($this->recorddadospagto, $ii, $this->receita)), 0, 0, "R", 0);
                                 if (trim(pg_result($this->recorddadospagto, $ii, $this->ddreceita)) == '') {
                                     $this->objpdf->cell(70, 3, trim(pg_result($this->recorddadospagto, $ii, $this->dreceita)), 0, 0, "L", 0);
                                 } else {
                                     $this->objpdf->cell(70, 3, trim(pg_result($this->recorddadospagto, $ii, $this->ddreceita)), 0, 0, "L", 0);
                                 }
                                 $this->objpdf->cell(15, 3, db_formatar(pg_result($this->recorddadospagto, $ii, $this->valor), 'f'), 0, 1, "R", 0);
                             }
                             $this->objpdf->Roundedrect($xcol, $xlin + 71, 202, 30, 2, 'DF', '1234');
                             $this->objpdf->SetY($xlin + 72);
                             $this->objpdf->SetX($xcol + 3);
                             $this->objpdf->multicell(0, 4, 'HISTÓRICO :   ' . $this->historico);
                             $this->objpdf->SetX($xcol + 3);
                             $this->objpdf->multicell(0, 4, $this->histparcel);
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->setx(15);
                             $this->objpdf->Roundedrect(128, $xlin + 103, 38, 10, 2, 'DF', '1234');
                             $this->objpdf->Roundedrect(168, $xlin + 103, 38, 10, 2, 'DF', '1234');
                             $this->objpdf->Roundedrect(146, $xlin + 115, 40, 10, 2, 'DF', '1234');
                             $this->objpdf->text(130, $xlin + 105, 'Vencimento');
                             $this->objpdf->text(170, $xlin + 105, 'Código de Arrecadação');
                             $this->objpdf->text(148, $xlin + 118, 'Valor a Pagar');
                             $this->objpdf->setfont('Arial', '', 10);
                             $this->objpdf->text(135, $xlin + 110, $this->dtvenc);
                             $this->objpdf->text(170, $xlin + 110, $this->numpre);
                             $this->objpdf->text(155, $xlin + 123, $this->valtotal);
                             $this->objpdf->setfillcolor(0, 0, 0);
                             $this->objpdf->SetFont('Arial', '', 4);
                             //	        $this->objpdf->TextWithDirection(1.5,$xlin+60,$this->texto,'U'); // texto no canhoto do carne
                             $this->objpdf->TextWithDirection(1.5, $xlin + 60, $this->texto . ' - ' . ($i == 1 ? '2ª VIA' : '1ª VIA'), 'U');
                             // texto no canhoto do carne
                             $this->objpdf->setfont('Arial', '', 11);
                             $this->objpdf->text(10, $xlin + 108, $this->linhadigitavel);
                             $this->objpdf->int25(10, $xlin + 110, $this->codigobarras, 15, 0.341);
                             $xlin = 169;
                         }
                     } else {
                         if ($this->modelo == 5) {
                             ////////// MODELO 5  -  AUTORIZACAO DE EMPENHO
                             $this->objpdf->AliasNbPages();
                             $this->objpdf->AddPage();
                             $this->objpdf->settopmargin(1);
                             $pagina = 1;
                             $xlin = 20;
                             $xcol = 4;
                             $this->objpdf->setfillcolor(245);
                             $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                             $this->objpdf->setfillcolor(255, 255, 255);
                             $this->objpdf->Setfont('Arial', 'B', 9);
                             $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                             $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                             $this->objpdf->text(133.5, $xlin - 8, 'SOLICITAÇÃO DE COMPRA N' . CHR(176));
                             $this->objpdf->text(185, $xlin - 8, db_formatar($this->numsol, 's', '0', 6, 'e'));
                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                             //.$this->logo
                             $this->objpdf->Setfont('Arial', 'B', 9);
                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                             $this->objpdf->Setfont('Arial', '', 9);
                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                             $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 28, 2, 'DF', '1234');
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->text($xcol + 2, $xlin + 4, 'Dados da Ordem de Compra');
                             $this->objpdf->Setfont('Arial', 'B', 8);
                             $this->objpdf->text($xcol + 2, $xlin + 8, 'Licitação');
                             $this->objpdf->text($xcol + 2, $xlin + 12, 'Tipo de Compra');
                             $this->objpdf->text($xcol + 2, $xlin + 16, 'Prazo de Entrega');
                             $this->objpdf->text($xcol + 2, $xlin + 20, 'Observações');
                             $this->objpdf->text($xcol + 2, $xlin + 24, 'Cond.de Pagto');
                             $this->objpdf->text($xcol + 2, $xlin + 28, 'Outras Condições');
                             $this->objpdf->Setfont('Arial', '', 8);
                             $this->objpdf->text($xcol + 27, $xlin + 8, ':  ' . $this->num_licitacao . '  -  ' . $this->descr_licitacao);
                             $this->objpdf->text($xcol + 27, $xlin + 12, ':  ' . $this->descr_tipocompra);
                             $this->objpdf->text($xcol + 27, $xlin + 16, ':  ' . $this->prazo_ent);
                             $this->objpdf->text($xcol + 27, $xlin + 20, ':  ' . $this->obs);
                             $this->objpdf->text($xcol + 27, $xlin + 24, ':  ' . $this->cond_pag);
                             $this->objpdf->text($xcol + 27, $xlin + 28, ':  ' . $this->out_cond);
                             $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 28, 2, 'DF', '1234');
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->text($xcol + 110, $xlin + 4, 'Dados da Dotação');
                             $this->objpdf->Setfont('Arial', 'B', 8);
                             $this->objpdf->text($xcol + 108, $xlin + 8, 'Dotação');
                             $this->objpdf->text($xcol + 108, $xlin + 12, 'Reduzido');
                             $this->objpdf->text($xcol + 108, $xlin + 16, 'Descrição');
                             $this->objpdf->text($xcol + 108, $xlin + 20, 'Órgão');
                             $this->objpdf->text($xcol + 108, $xlin + 24, 'Unidade');
                             $this->objpdf->text($xcol + 108, $xlin + 28, 'Destino');
                             $this->objpdf->Setfont('Arial', '', 8);
                             $this->objpdf->text($xcol + 122, $xlin + 8, ':  ' . $this->dotacao);
                             $this->objpdf->text($xcol + 122, $xlin + 12, ':  ' . $this->coddot . '-' . db_CalculaDV($this->coddot));
                             $this->objpdf->text($xcol + 122, $xlin + 16, ':  ' . $this->descrdotacao);
                             $this->objpdf->text($xcol + 122, $xlin + 20, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                             $this->objpdf->text($xcol + 122, $xlin + 24, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                             $this->objpdf->text($xcol + 122, $xlin + 28, ':  ' . $this->destino);
                             $this->objpdf->rect($xcol, $xlin + 32, $xcol + 198, 20, 2, 'DF', '1234');
                             $this->objpdf->Setfont('Arial', '', 6);
                             $this->objpdf->text($xcol + 2, $xlin + 34, 'Dados do Credor');
                             $this->objpdf->Setfont('Arial', 'B', 8);
                             $this->objpdf->text($xcol + 109, $xlin + 38, 'Numcgm');
                             $this->objpdf->text($xcol + 150, $xlin + 38, strlen($this->cnpj) == 11 ? 'CPF' : 'CNPJ');
                             $this->objpdf->text($xcol + 2, $xlin + 38, 'Nome');
                             $this->objpdf->text($xcol + 2, $xlin + 42, 'Endereço');
                             $this->objpdf->text($xcol + 102, $xlin + 42, 'Complemento');
                             $this->objpdf->text($xcol + 2, $xlin + 46, 'Município');
                             $this->objpdf->text($xcol + 115, $xlin + 46, 'CEP');
                             $this->objpdf->text($xcol + 2, $xlin + 50, 'Contato');
                             $this->objpdf->text($xcol + 110, $xlin + 50, 'Telefone');
                             $this->objpdf->Setfont('Arial', '', 8);
                             $this->objpdf->text($xcol + 157, $xlin + 38, ':  ' . $this->cnpj);
                             $this->objpdf->text($xcol + 122, $xlin + 38, ':  ' . $this->numcgm);
                             $this->objpdf->text($xcol + 18, $xlin + 38, ':  ' . $this->nome);
                             $this->objpdf->text($xcol + 18, $xlin + 42, ':  ' . $this->ender);
                             $this->objpdf->text($xcol + 122, $xlin + 42, ':  ' . $this->compl);
                             $this->objpdf->text($xcol + 18, $xlin + 46, ':  ' . $this->munic . '-' . $this->uf);
                             $this->objpdf->text($xcol + 122, $xlin + 46, ':  ' . $this->cep);
                             $this->objpdf->text($xcol + 18, $xlin + 50, ':  ' . $this->contato);
                             $this->objpdf->text($xcol + 122, $xlin + 50, ':  ' . $this->telef_cont);
                             $this->objpdf->Setfont('Arial', 'B', 8);
                             //	$this->objpdf->Roundedrect($xcol,$xlin+54,202,80,2,'DF','1234');
                             $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                             $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                             $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                             $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                             $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                             $this->objpdf->rect($xcol, $xlin + 60, 15, 122, 2, 'DF', '34');
                             $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 122, 2, 'DF', '34');
                             $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 122, 2, 'DF', '34');
                             $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 155, 2, 'DF', '');
                             $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 155, 2, 'DF', '34');
                             $this->objpdf->rect($xcol, $xlin + 205, 142, 10, 2, 'DF', '34');
                             $this->objpdf->rect($xcol + 142, $xlin + 205, 30, 10, 2, 'DF', '34');
                             $this->objpdf->rect($xcol + 172, $xlin + 205, 30, 10, 2, 'DF', '34');
                             $this->objpdf->text($xcol + 120, $xlin + 211, 'T O T A L');
                             $this->objpdf->rect($xcol, $xlin + 182, 142, 23, 2, 'DF', '');
                             $this->objpdf->sety($xlin + 28);
                             $alt = 4;
                             $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                             $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                             $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                             $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                             $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                             $maiscol = 0;
                             $this->objpdf->SetWidths(array(10, 22, 105, 30, 30));
                             $this->objpdf->SetAligns(array('C', 'C', 'L', 'R', 'R'));
                             $this->objpdf->setleftmargin(8);
                             $this->objpdf->sety($xlin + 62);
                             $xtotal = 0;
                             for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                 db_fieldsmemory($this->recorddositens, $ii);
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->item), pg_result($this->recorddositens, $ii, $this->quantitem), pg_result($this->recorddositens, $ii, $this->descricaoitem) . "\n" . pg_result($this->recorddositens, $ii, $this->observacaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                 $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 /////// troca de pagina
                                 if ($this->objpdf->gety() > $this->objpdf->h - 70 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 22 && $pagina != 1) {
                                     if ($this->objpdf->PageNo() == 1) {
                                         $this->objpdf->text(110, $xlin + 214, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                         $this->objpdf->rect($xcol, $xlin + 217, 202, 55, 2, 'DF', '1234');
                                         $y = 260;
                                         $this->objpdf->SetXY(2, $y);
                                         $this->objpdf->MultiCell(70, 4, 'AUTORIZO' . "\n\n\n" . 'DIRETOR DE COMPRAS', 0, "C", 0);
                                         $this->objpdf->SetXY(72, $y);
                                         $this->objpdf->MultiCell(70, 4, 'AUTORIZO' . "\n\n\n" . 'SECRETARIA MUNICIPAL', 0, "C", 0);
                                         $this->objpdf->SetXY(142, $y);
                                         $this->objpdf->MultiCell(70, 4, 'VISTO' . "\n\n\n" . '', 0, "C", 0);
                                         $this->objpdf->setfillcolor(0, 0, 0);
                                         $this->objpdf->text($xcol + 10, $xlin + 223, $this->municpref . ', ' . date('d') . ' DE ' . strtoupper(db_mes(date('m'))) . ' DE ' . db_getsession("DB_anousu") . '.');
                                         $this->objpdf->SetFont('Arial', '', 4);
                                         $this->objpdf->TextWithDirection(1.5, $xlin + 60, $this->texto, 'U');
                                         // texto no canhoto do carne
                                         $this->objpdf->setfont('Arial', '', 11);
                                     } else {
                                         $this->objpdf->text(110, $xlin + 320, 'Continua na Página ' . ($this->objpdf->PageNo() + 1));
                                     }
                                     $this->objpdf->addpage();
                                     $pagina += 1;
                                     $this->objpdf->settopmargin(1);
                                     $xlin = 20;
                                     $xcol = 4;
                                     $this->objpdf->setfillcolor(245);
                                     $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                     $this->objpdf->setfillcolor(255, 255, 255);
                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                     $this->objpdf->text(130, $xlin - 13, 'AUTORIZAÇÃO DE EMPENHO N' . CHR(176));
                                     $this->objpdf->text(185, $xlin - 13, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                     $this->objpdf->text(133.5, $xlin - 8, 'SOLICITAÇÃO DE COMPRA N' . CHR(176));
                                     $this->objpdf->text(185, $xlin - 8, db_formatar($this->numsol, 's', '0', 6, 'e'));
                                     $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                     //.$this->logo
                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                     $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                     $this->objpdf->Setfont('Arial', '', 9);
                                     $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                     $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                     $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                     $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                     $xlin = -30;
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 15, $xlin + 54, 20, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 35, $xlin + 54, 107, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 142, $xlin + 54, 30, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 172, $xlin + 54, 30, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 15, $xlin + 60, 20, 262, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 35, $xlin + 60, 107, 262, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 142, $xlin + 60, 30, 262, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 172, $xlin + 60, 30, 262, 2, 'DF', '34');
                                     $this->objpdf->sety($xlin + 66);
                                     $alt = 4;
                                     $this->objpdf->text($xcol + 4, $xlin + 58, 'ITEM');
                                     $this->objpdf->text($xcol + 15.5, $xlin + 58, 'QUANTIDADE');
                                     $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                     $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                     $this->objpdf->text($xcol + 176, $xlin + 58, 'VALOR TOTAL');
                                     $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                     $maiscol = 0;
                                 }
                             }
                             $this->objpdf->setxy($xcol + 1, $xlin + 187);
                             $this->objpdf->text($xcol + 2, $xlin + 186, 'RESUMO : ', 0, 1, 'L', 0);
                             $this->objpdf->Setfont('Arial', '', 7);
                             $this->objpdf->multicell(140, 3.5, $this->resumo);
                             $this->objpdf->Setfont('Arial', 'B', 8);
                             $this->objpdf->SetXY(172, $xlin + 205);
                             $this->objpdf->cell(30, 10, db_formatar($xtotal, 'f'), 0, 0, "R");
                             //	echo $this->numaut."<br>";
                             //	echo $pagina;exit;
                             if ($pagina == 1) {
                                 $this->objpdf->rect($xcol, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 68, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 136, $xlin + 217, 66, 55, 2, 'DF', '1234');
                                 $this->objpdf->setfillcolor(0, 0, 0);
                                 $y = 260;
                                 $this->objpdf->SetXY(2, $y);
                                 $this->objpdf->MultiCell(70, 4, 'AUTORIZO' . "\n\n\n" . 'DIRETOR DE COMPRAS', 0, "C", 0);
                                 $this->objpdf->SetXY(72, $y);
                                 $this->objpdf->MultiCell(70, 4, 'AUTORIZO' . "\n\n\n" . 'ORDENADOR DA DESPESA', 0, "C", 0);
                                 $this->objpdf->SetXY(142, $y);
                                 $this->objpdf->MultiCell(70, 4, 'VISTO' . "\n\n\n" . '', 0, "C", 0);
                                 $this->objpdf->setfillcolor(0, 0, 0);
                                 $this->objpdf->text($xcol + 10, $xlin + 223, strtoupper($this->municpref) . ', ' . substr($this->emissao, 8, 2) . ' DE ' . strtoupper(db_mes(substr($this->emissao, 5, 2))) . ' DE ' . substr($this->emissao, 0, 4) . '.');
                                 //	   $this->objpdf->SetFont('Arial','',4);
                                 //         $this->objpdf->TextWithDirection(1.5,$xlin+60,$this->texto,'U'); // texto no canhoto do carne
                                 //	   $this->objpdf->setfont('Arial','',11);
                                 //         $xlin = 169;
                             }
                         } else {
                             if ($this->modelo == 6) {
                                 ////////// MODELO 6  -  NOTA DE EMPENHO
                                 $this->objpdf->AliasNbPages();
                                 $this->objpdf->AddPage();
                                 $this->objpdf->settopmargin(1);
                                 $pagina = 1;
                                 $xlin = 20;
                                 $xcol = 4;
                                 $this->objpdf->setfillcolor(245);
                                 $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                 $this->objpdf->setfillcolor(255, 255, 255);
                                 $this->objpdf->Setfont('Arial', 'B', 10);
                                 $this->objpdf->text(128, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                 $this->objpdf->text(175, $xlin - 13, db_formatar($this->codemp, 's', '0', 6, 'e'));
                                 $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                 $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                 $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                 //.$this->logo
                                 $this->objpdf->Setfont('Arial', 'B', 9);
                                 $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                 $this->objpdf->Setfont('Arial', '', 9);
                                 $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                 $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                 $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                 $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                 /// retangulo dos dados da dotação
                                 $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 50, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                 $this->objpdf->text($xcol + 2, $xlin + 11, 'Unidade');
                                 $this->objpdf->text($xcol + 2, $xlin + 15, 'Função');
                                 $this->objpdf->text($xcol + 2, $xlin + 22, 'Proj/Ativ');
                                 $this->objpdf->text($xcol + 2, $xlin + 30, 'Rubrica');
                                 $this->objpdf->text($xcol + 2, $xlin + 42, 'Recurso');
                                 $this->objpdf->text($xcol + 2, $xlin + 48, 'Licitação');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                 $this->objpdf->text($xcol + 17, $xlin + 11, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                 $this->objpdf->text($xcol + 17, $xlin + 15, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                 $this->objpdf->text($xcol + 17, $xlin + 22, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                 $this->objpdf->text($xcol + 17, $xlin + 30, ':  ' . db_formatar($this->sintetico, 'elemento'));
                                 $this->objpdf->setxy($xcol + 18, $xlin + 31);
                                 $this->objpdf->multicell(90, 3, $this->descr_sintetico, 0, "L");
                                 $this->objpdf->text($xcol + 17, $xlin + 42, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                 $this->objpdf->text($xcol + 17, $xlin + 48, ':  ' . $this->descr_licitacao);
                                 //// retangulo dos dados do credor
                                 $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 17, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                 $this->objpdf->Setfont('Arial', 'B', 8);
                                 $this->objpdf->text($xcol + 107, $xlin + 9, 'Numcgm');
                                 $this->objpdf->text($xcol + 137, $xlin + 9, 'Nome :');
                                 $this->objpdf->text($xcol + 107, $xlin + 13, 'Endereço');
                                 $this->objpdf->text($xcol + 107, $xlin + 17, 'Município');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 124, $xlin + 9, ': ' . $this->numcgm);
                                 $this->objpdf->text($xcol + 147, $xlin + 9, $this->nome);
                                 $this->objpdf->text($xcol + 124, $xlin + 13, ': ' . $this->ender . '  ' . $this->compl);
                                 $this->objpdf->text($xcol + 124, $xlin + 17, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                 ///// retangulo dos valores
                                 $this->objpdf->rect($xcol + 106, $xlin + 21, 96, 9, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 106, $xlin + 32, 47, 9, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 155, $xlin + 32, 47, 9, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 106, $xlin + 43, 47, 9, 2, 'DF', '1234');
                                 $this->objpdf->rect($xcol + 155, $xlin + 43, 47, 9, 2, 'DF', '1234');
                                 $this->objpdf->Setfont('Arial', '', 6);
                                 $this->objpdf->text($xcol + 108, $xlin + 34, 'Valor Orçado');
                                 $this->objpdf->text($xcol + 157, $xlin + 34, 'Saldo Anterior');
                                 $this->objpdf->text($xcol + 108, $xlin + 45, 'Valor Empenhado');
                                 $this->objpdf->text($xcol + 157, $xlin + 45, 'Saldo Atual');
                                 $this->objpdf->Setfont('Arial', '', 8);
                                 $this->objpdf->text($xcol + 108, $xlin + 26.5, 'AUTORIZAÇÃO N' . chr(176) . ' ' . db_formatar($this->numaut, 's', '0', 5, 'e'));
                                 $this->objpdf->text($xcol + 150, $xlin + 26.5, 'SEQ. DO EMPENHO N' . chr(176) . ' ' . db_formatar($this->numemp, 's', '0', 6, 'e'));
                                 //	$this->objpdf->text($xcol+108,$xlin+26.5,$this->texto);
                                 $this->objpdf->text($xcol + 130, $xlin + 38, db_formatar($this->orcado, 'f'));
                                 $this->objpdf->text($xcol + 180, $xlin + 38, db_formatar($this->saldo_ant, 'f'));
                                 $this->objpdf->text($xcol + 130, $xlin + 49, db_formatar($this->empenhado, 'f'));
                                 $this->objpdf->text($xcol + 180, $xlin + 49, db_formatar($this->saldo_ant - $this->empenhado, 'f'));
                                 /// retangulo do corpo do empenho
                                 $this->objpdf->rect($xcol, $xlin + 60, 15, 100, 2, 'DF', '');
                                 $this->objpdf->rect($xcol + 15, $xlin + 60, 137, 100, 2, 'DF', '');
                                 $this->objpdf->rect($xcol + 152, $xlin + 60, 25, 123, 2, 'DF', '');
                                 $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 123, 2, 'DF', '');
                                 $this->objpdf->rect($xcol, $xlin + 160, 152, 23, 2, 'DF', '');
                                 //// retangulos do titulo do corpo do empenho
                                 $this->objpdf->Setfont('Arial', 'B', 7);
                                 $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 15, $xlin + 54, 137, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 152, $xlin + 54, 25, 6, 2, 'DF', '12');
                                 $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                 //// título do corpo do empenho
                                 $this->objpdf->text($xcol + 2, $xlin + 58, 'QUANT');
                                 $this->objpdf->text($xcol + 70, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                 $this->objpdf->text($xcol + 154, $xlin + 58, 'VALOR UNITÁRIO');
                                 $this->objpdf->text($xcol + 181, $xlin + 58, 'VALOR TOTAL');
                                 $maiscol = 0;
                                 /// monta os dados para itens do empenho
                                 $this->objpdf->SetWidths(array(15, 137, 25, 25));
                                 $this->objpdf->SetAligns(array('C', 'L', 'R', 'R'));
                                 $this->objpdf->setleftmargin(4);
                                 $this->objpdf->sety($xlin + 62);
                                 $this->objpdf->Setfont('Arial', '', 7);
                                 $ele = 0;
                                 $xtotal = 0;
                                 for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                     db_fieldsmemory($this->recorddositens, $ii);
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     if ($ele != pg_result($this->recorddositens, $ii, $this->analitico)) {
                                         $this->objpdf->cell(15, 4, '', 0, 0, "C", 0);
                                         $this->objpdf->cell(137, 4, db_formatar(pg_result($this->recorddositens, $ii, $this->analitico), 'elemento') . ' - ' . pg_result($this->recorddositens, $ii, $this->descr_analitico), 0, 1, "L", 0);
                                         $ele = pg_result($this->recorddositens, $ii, $this->analitico);
                                     }
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->Row(array(pg_result($this->recorddositens, $ii, $this->quantitem), pg_result($this->recorddositens, $ii, $this->descricaoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem) / pg_result($this->recorddositens, $ii, $this->quantitem), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->valoritem), 'f')), 3, false, 4);
                                     $xtotal += pg_result($this->recorddositens, $ii, $this->valoritem);
                                     /////// troca de pagina
                                     if ($this->objpdf->gety() > $this->objpdf->h - 125 && $pagina == 1 || $this->objpdf->gety() > $this->objpdf->h - 22 && $pagina != 1) {
                                         $proxima_pagina = $pagina + 1;
                                         $this->objpdf->Row(array('', "Continua na página {$proxima_pagina}", '', ''), 3, false, 4);
                                         if ($pagina == 1) {
                                             $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                             $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                             //	   $this->objpdf->setfillcolor(0,0,0);
                                             $this->objpdf->SetFont('Arial', '', 7);
                                             $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                             $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                             $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                             $this->objpdf->multicell(147, 3.5, $this->resumo);
                                             $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                             $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                             $this->objpdf->cell(30, 10, db_formatar($xtotal, 'f'), 0, 0, 'f');
                                             $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                             $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                             $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                             $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                             $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                             $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                             $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                             $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                             $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->text($xcol + 12, $xlin + 199, 'EMPENHADO E CONFERIDO');
                                             $this->objpdf->text($xcol + 26, $xlin + 213, 'VISTO');
                                             $this->objpdf->text($xcol + 19, $xlin + 227, 'TÉCNICO CONTÁBIL');
                                             $this->objpdf->text($xcol + 13, $xlin + 240, 'SECRETÁRIO(A) DA FAZENDA');
                                             $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                             $this->objpdf->text($xcol + 76, $xlin + 227, 'PREFEITO MUNICIPAL');
                                             $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                             $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                             $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                             $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                             $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                             $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                             $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                             $this->objpdf->SetFont('Arial', '', 7);
                                             $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                             $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                             $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                             $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                             $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                             $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                             $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                             $this->objpdf->SetFont('Arial', '', 6);
                                             $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                             $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                             $this->objpdf->SetFont('Arial', '', 4);
                                             $this->objpdf->Text(2, 296, $this->texto);
                                             // texto no canhoto do carne
                                             $this->objpdf->setfont('Arial', '', 11);
                                             $xlin = 169;
                                         }
                                         $this->objpdf->addpage();
                                         $pagina += 1;
                                         $this->objpdf->settopmargin(1);
                                         $xlin = 20;
                                         $xcol = 4;
                                         $this->objpdf->setfillcolor(245);
                                         $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                         $this->objpdf->setfillcolor(255, 255, 255);
                                         $this->objpdf->Setfont('Arial', 'B', 11);
                                         $this->objpdf->text(150, $xlin - 13, 'NOTA DE EMPENHO N' . CHR(176) . ': ');
                                         $this->objpdf->text(159, $xlin - 8, db_formatar($this->numaut, 's', '0', 6, 'e'));
                                         $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                         //.$this->logo
                                         $this->objpdf->Setfont('Arial', 'B', 9);
                                         $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                         $this->objpdf->Setfont('Arial', '', 9);
                                         $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                         $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                         $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                         $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                         $xlin = -30;
                                         $this->objpdf->Setfont('Arial', 'B', 8);
                                         //  	    $this->objpdf->Roundedrect($xcol,$xlin+54,15,6,2,'DF','12');
                                         $this->objpdf->rect($xcol, $xlin + 54, 15, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 15, $xlin + 54, 127, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 142, $xlin + 54, 35, 6, 2, 'DF', '12');
                                         $this->objpdf->rect($xcol + 177, $xlin + 54, 25, 6, 2, 'DF', '12');
                                         //  	    $this->objpdf->Roundedrect($xcol,$xlin+60,15,262,2,'DF','34');
                                         $this->objpdf->rect($xcol, $xlin + 60, 15, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 15, $xlin + 60, 127, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 142, $xlin + 60, 35, 262, 2, 'DF', '34');
                                         $this->objpdf->rect($xcol + 177, $xlin + 60, 25, 262, 2, 'DF', '34');
                                         $this->objpdf->sety($xlin + 66);
                                         $alt = 4;
                                         //	    $this->objpdf->text($xcol+4,$xlin+58,'ITEM');
                                         $this->objpdf->text($xcol + 0.5, $xlin + 58, 'QUANT');
                                         $this->objpdf->text($xcol + 65, $xlin + 58, 'MATERIAL OU SERVIÇO');
                                         $this->objpdf->text($xcol + 145, $xlin + 58, 'VALOR UNITÁRIO');
                                         $this->objpdf->text($xcol + 179, $xlin + 58, 'VALOR TOTAL');
                                         $this->objpdf->text($xcol + 38, $xlin + 63, 'Continuação da Página ' . ($this->objpdf->PageNo() - 1));
                                         $maiscol = 0;
                                     }
                                 }
                                 if ($pagina == 1) {
                                     $this->objpdf->rect($xcol, $xlin + 183, 152, 6, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 152, $xlin + 183, 25, 6, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 177, $xlin + 183, 25, 6, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '4');
                                     //	   $this->objpdf->setfillcolor(0,0,0);
                                     $this->objpdf->SetFont('Arial', '', 7);
                                     $this->objpdf->text($xcol + 2, $xlin + 187, 'DESTINO : ', 0, 1, 'L', 0);
                                     $this->objpdf->text($xcol + 30, $xlin + 187, $this->destino, 0, 1, 'L', 0);
                                     $this->objpdf->setxy($xcol + 1, $xlin + 165);
                                     $this->objpdf->text($xcol + 2, $xlin + 164, 'RESUMO : ', 0, 1, 'L', 0);
                                     $this->objpdf->multicell(147, 3.5, $this->resumo);
                                     $this->objpdf->text($xcol + 159, $xlin + 187, 'T O T A L', 0, 1, 'L', 0);
                                     $this->objpdf->setxy($xcol + 185, $xlin + 182);
                                     $this->objpdf->cell(30, 10, db_formatar($xtotal, 'f'), 0, 0, 'f');
                                     $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                     $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                     $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                     $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                     $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                     $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                     $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                     $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                     $this->objpdf->SetFont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 12, $xlin + 199, 'EMPENHADO E CONFERIDO');
                                     $this->objpdf->text($xcol + 26, $xlin + 213, 'VISTO');
                                     $this->objpdf->text($xcol + 19, $xlin + 227, 'TÉCNICO CONTÁBIL');
                                     $this->objpdf->text($xcol + 13, $xlin + 240, 'SECRETÁRIO(A) DA FAZENDA');
                                     $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                     $this->objpdf->text($xcol + 76, $xlin + 227, 'PREFEITO MUNICIPAL');
                                     $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                     $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                     $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                     $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                     $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                     $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                     $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                     $this->objpdf->SetFont('Arial', '', 7);
                                     $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                     $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                     $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                     $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                     $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                     $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                     $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                     $this->objpdf->SetFont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                     $this->objpdf->SetFont('Arial', '', 4);
                                     $this->objpdf->Text(2, 296, $this->texto);
                                     // texto no canhoto do carne
                                     $this->objpdf->setfont('Arial', '', 11);
                                     $xlin = 169;
                                 }
                             } else {
                                 if ($this->modelo == 7) {
                                     ////////// MODELO 7  -  ORDEM DE PAGAMENTO
                                     $this->objpdf->AliasNbPages();
                                     $this->objpdf->AddPage();
                                     $this->objpdf->settopmargin(1);
                                     $pagina = 1;
                                     $xlin = 20;
                                     $xcol = 4;
                                     $ano = $this->ano;
                                     $this->objpdf->setfillcolor(245);
                                     $this->objpdf->rect($xcol - 2, $xlin - 18, 206, 292, 2, 'DF', '1234');
                                     $this->objpdf->setfillcolor(255, 255, 255);
                                     $this->objpdf->Setfont('Arial', 'B', 10);
                                     $this->objpdf->text(128, $xlin - 13, 'ORDEM DE PAGAMENTO N' . CHR(176) . ': ');
                                     $this->objpdf->text(177, $xlin - 13, db_formatar($this->ordpag, 's', '0', 6, 'e'));
                                     $this->objpdf->text(134, $xlin - 8, 'DATA DE EMISSÃO : ');
                                     $this->objpdf->text(175, $xlin - 8, $this->emissao);
                                     $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                     //.$this->logo
                                     $this->objpdf->Setfont('Arial', 'B', 9);
                                     $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                     $this->objpdf->Setfont('Arial', '', 9);
                                     $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                     $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                     $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                     $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                     /// retangulo dos dados da dotação
                                     $this->objpdf->rect($xcol, $xlin + 2, $xcol + 100, 35, 2, 'DF', '1234');
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     if ($ano < 2005) {
                                         $this->objpdf->text($xcol + 2, $xlin + 19, 'RESTOS A PAGAR ');
                                     } else {
                                         $this->objpdf->text($xcol + 2, $xlin + 7, 'Órgao');
                                         $this->objpdf->text($xcol + 2, $xlin + 11, 'Unidade');
                                         $this->objpdf->text($xcol + 2, $xlin + 15, 'Função');
                                         $this->objpdf->text($xcol + 2, $xlin + 19, 'Proj/Ativ');
                                         $this->objpdf->text($xcol + 2, $xlin + 23, 'Dotação');
                                         $this->objpdf->text($xcol + 2, $xlin + 27, 'Elemento');
                                     }
                                     $this->objpdf->text($xcol + 2, $xlin + 34, 'Recurso');
                                     if ($ano >= 2005) {
                                         $this->objpdf->Setfont('Arial', '', 8);
                                         $this->objpdf->text($xcol + 17, $xlin + 7, ':  ' . db_formatar($this->orgao, 'orgao') . ' - ' . $this->descr_orgao);
                                         $this->objpdf->text($xcol + 17, $xlin + 11, ':  ' . db_formatar($this->unidade, 'unidade') . ' - ' . $this->descr_unidade);
                                         $this->objpdf->text($xcol + 17, $xlin + 15, ':  ' . db_formatar($this->funcao, 'funcao') . ' - ' . $this->descr_funcao);
                                         $this->objpdf->text($xcol + 17, $xlin + 19, ':  ' . db_formatar($this->projativ, 'projativ') . ' - ' . $this->descr_projativ);
                                         $this->objpdf->text($xcol + 17, $xlin + 23, ':  ' . $this->dotacao);
                                         $this->objpdf->text($xcol + 17, $xlin + 27, ':  ' . db_formatar($this->elemento, 'elemento'));
                                         $this->objpdf->text($xcol + 17, $xlin + 30, '   ' . $this->descr_elemento);
                                     }
                                     $this->objpdf->text($xcol + 17, $xlin + 34, ':  ' . $this->recurso . ' - ' . $this->descr_recurso);
                                     //// retangulo dos dados do credor
                                     $this->objpdf->rect($xcol + 106, $xlin + 2, 96, 23, 2, 'DF', '1234');
                                     $this->objpdf->Setfont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 108, $xlin + 4, 'Dados do Credor:');
                                     $this->objpdf->Setfont('Arial', 'B', 8);
                                     $this->objpdf->text($xcol + 107, $xlin + 9, 'Numcgm');
                                     $this->objpdf->text($xcol + 107, $xlin + 13, 'Nome');
                                     $this->objpdf->text($xcol + 107, $xlin + 17, 'Endereço');
                                     $this->objpdf->text($xcol + 107, $xlin + 21, 'Município');
                                     $this->objpdf->Setfont('Arial', '', 8);
                                     $this->objpdf->text($xcol + 124, $xlin + 9, ': ' . $this->numcgm);
                                     $this->objpdf->text($xcol + 124, $xlin + 13, ': ' . $this->nome);
                                     $this->objpdf->text($xcol + 124, $xlin + 17, ': ' . $this->ender . '  ' . $this->compl);
                                     $this->objpdf->text($xcol + 124, $xlin + 21, ': ' . $this->munic . '-' . $this->uf . '    CEP : ' . $this->cep);
                                     ///// retangulo do empenho
                                     $this->objpdf->rect($xcol + 106, $xlin + 28, 47, 9, 2, 'DF', '1234');
                                     $this->objpdf->rect($xcol + 155, $xlin + 28, 47, 9, 2, 'DF', '1234');
                                     ///// retangulo dos itens
                                     $this->objpdf->rect($xcol + 102, $xlin + 98, 25, 7, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 127, $xlin + 98, 25, 7, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 152, $xlin + 98, 25, 7, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 177, $xlin + 98, 25, 7, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 00, $xlin + 98, 102, 24, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 00, $xlin + 48, 102, 50, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 102, $xlin + 48, 25, 50, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 127, $xlin + 48, 25, 50, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 152, $xlin + 48, 25, 50, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 177, $xlin + 48, 25, 50, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 102, $xlin + 105, 75, 17, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 177, $xlin + 105, 25, 17, 2, 'DF', '34');
                                     ///// retangulo das retenções
                                     $this->objpdf->rect($xcol + 177, $xlin + 179, 25, 8, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 177, $xlin + 171, 25, 8, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 00, $xlin + 133, 75, 46, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 00, $xlin + 179, 75, 8, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 75, $xlin + 133, 25, 46, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 75, $xlin + 179, 25, 8, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 102, $xlin + 133, 75, 38, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 102, $xlin + 171, 75, 8, 2, 'DF', '');
                                     $this->objpdf->rect($xcol + 102, $xlin + 179, 75, 8, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 177, $xlin + 133, 25, 38, 2, 'DF', '12');
                                     //        $this->objpdf->Roundedrect($xcol+177,$xlin+179, 25,5,2,'DF','34');
                                     $this->objpdf->Setfont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 108, $xlin + 30, 'Empenho N' . chr(176));
                                     $this->objpdf->text($xcol + 157, $xlin + 30, 'Valor do Empenho');
                                     $this->objpdf->Setfont('Arial', '', 8);
                                     $this->objpdf->text($xcol + 130, $xlin + 34, db_formatar($this->numemp, 's', '0', 6, 'e'));
                                     $this->objpdf->text($xcol + 180, $xlin + 34, db_formatar($this->empenhado, 'f'));
                                     //// retangulos do titulo do corpo do empenho
                                     //	$this->objpdf->line($xcol,$xlin+42,$xcol+202,$xlin+42);
                                     $this->objpdf->Setfont('Arial', 'B', 10);
                                     $this->objpdf->text($xcol + 2, $xlin + 46, 'Dados da Ordem de Compra');
                                     $this->objpdf->Setfont('Arial', 'B', 6);
                                     //// título do corpo do empenho
                                     $maiscol = 0;
                                     /// monta os dados dos elementos da ordem de compra
                                     $this->objpdf->SetWidths(array(20, 80, 25, 25, 25, 25));
                                     $this->objpdf->SetAligns(array('L', 'L', 'R', 'R', 'R', 'R'));
                                     $this->objpdf->setleftmargin(4);
                                     $this->objpdf->sety($xlin + 48);
                                     $this->objpdf->cell(20, 4, 'ELEMENTO', 0, 0, "L");
                                     $this->objpdf->cell(80, 4, 'DESCRIÇÃO', 0, 0, "L");
                                     $this->objpdf->cell(25, 4, 'VALOR', 0, 0, "R");
                                     $this->objpdf->cell(25, 4, 'ANULADO', 0, 0, "R");
                                     $this->objpdf->cell(25, 4, 'PAGO', 0, 0, "R");
                                     $this->objpdf->cell(25, 4, 'SALDO', 0, 1, "R");
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $total_pag = 0;
                                     $total_emp = 0;
                                     $total_anu = 0;
                                     $total_sal = 0;
                                     for ($ii = 0; $ii < $this->linhasdositens; $ii++) {
                                         db_fieldsmemory($this->recorddositens, $ii);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->Row(array($ano < 2005 ? ' ' : pg_result($this->recorddositens, $ii, $this->elementoitem), $ano < 2005 ? 'RESTOS A PAGAR' : pg_result($this->recorddositens, $ii, $this->descr_elementoitem), db_formatar(pg_result($this->recorddositens, $ii, $this->vlremp), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlranu), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlrpag), 'f'), db_formatar(pg_result($this->recorddositens, $ii, $this->vlrsaldo), 'f')), 3, false, 3);
                                         $total_emp += pg_result($this->recorddositens, $ii, $this->vlremp);
                                         $total_anu += pg_result($this->recorddositens, $ii, $this->vlranu);
                                         $total_pag += pg_result($this->recorddositens, $ii, $this->vlrpag);
                                         $total_sal += pg_result($this->recorddositens, $ii, $this->vlrsaldo);
                                     }
                                     /// monta os dados das retenções da ordem de compra
                                     $this->objpdf->SetWidths(array(10, 62, 25));
                                     $this->objpdf->SetAligns(array('C', 'L', 'R'));
                                     $this->objpdf->setleftmargin(4);
                                     $this->objpdf->setxy($xcol + 102, $xlin + 134);
                                     $this->objpdf->Setfont('Arial', 'B', 10);
                                     $this->objpdf->text($xcol + 104, $xlin + 131, 'Dados das Retenções');
                                     $this->objpdf->text($xcol + 2, $xlin + 131, 'Repasses');
                                     $this->objpdf->Setfont('Arial', 'b', 7);
                                     $this->objpdf->cell(10, 4, 'REC.', 0, 0, "L");
                                     $this->objpdf->cell(62, 4, 'DESCRIÇÃO', 0, 0, "L");
                                     $this->objpdf->cell(25, 4, 'VALOR', 0, 1, "R");
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $total_ret = 0;
                                     for ($ii = 0; $ii < $this->linhasretencoes; $ii++) {
                                         $this->objpdf->setx($xcol + 102);
                                         db_fieldsmemory($this->recordretencoes, $ii);
                                         $this->objpdf->Setfont('Arial', '', 7);
                                         $this->objpdf->Row(array(pg_result($this->recordretencoes, $ii, $this->receita), pg_result($this->recordretencoes, $ii, $this->dreceita), db_formatar(pg_result($this->recordretencoes, $ii, $this->vlrrec), 'f')), 3, false, 3);
                                         $total_ret += pg_result($this->recordretencoes, $ii, $this->vlrrec);
                                     }
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     $this->objpdf->setxy($xcol + 100, $xlin + 100);
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->cell(25, 4, db_formatar($total_emp, 'f'), 0, 0, "R");
                                     $this->objpdf->cell(25, 4, db_formatar($total_anu, 'f'), 0, 0, "R");
                                     $this->objpdf->cell(25, 4, db_formatar($total_pag, 'f'), 0, 0, "R");
                                     $this->objpdf->cell(25, 4, db_formatar($total_sal, 'f'), 0, 1, "R");
                                     $this->objpdf->setxy($xcol + 127, $xlin + 107);
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     $this->objpdf->cell(50, 5, 'TOTAL DA ORDEM', 0, 0, "R");
                                     $this->objpdf->cell(23, 5, db_formatar($total_emp - $total_anu, 'f'), 0, 1, "R");
                                     $this->objpdf->setx($xcol + 127);
                                     $this->objpdf->cell(50, 5, 'OUTRAS ORDENS', 0, 0, "R");
                                     $this->objpdf->cell(23, 4, db_formatar($this->outrasordens, 'f'), 0, 1, "R");
                                     $this->objpdf->setx($xcol + 127);
                                     $this->objpdf->cell(50, 5, 'VALOR RESTANTE', 0, 0, "R");
                                     $this->objpdf->cell(23, 4, db_formatar($this->empenhado - $this->outrasordens - $total_emp - $total_anu, 'f'), 0, 1, "R");
                                     $this->objpdf->Setfont('Arial', 'b', 8);
                                     $this->objpdf->text($xcol + 2, $xlin + 102, 'OBSERVAÇÕES :');
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->setxy($xcol, $xlin + 103);
                                     $this->objpdf->Setfont('Arial', '', 7);
                                     $this->objpdf->multicell(102, 4, $this->obs);
                                     /// total das retenções
                                     $this->objpdf->setxy($xcol + 127, $xlin + 172);
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     $this->objpdf->cell(50, 5, 'TOTAL ', 0, 0, "R");
                                     $this->objpdf->cell(23, 5, db_formatar($total_ret, 'f'), 0, 1, "R");
                                     /// total dos repasses
                                     $this->objpdf->setxy($xcol, $xlin + 181);
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     $this->objpdf->cell(75, 5, 'TOTAL ', 0, 0, "R");
                                     $this->objpdf->cell(23, 5, db_formatar(0, 'f'), 0, 1, "R");
                                     /// liquido da ordem de compra
                                     $this->objpdf->setxy($xcol + 127, $xlin + 181);
                                     $this->objpdf->Setfont('Arial', 'B', 7);
                                     $this->objpdf->cell(50, 5, 'LÍQUIDO DA ORDEM DE COMPRA ', 0, 0, "R");
                                     $this->objpdf->cell(23, 5, db_formatar($total_sal - $total_ret, 'f'), 0, 1, "R");
                                     $this->objpdf->rect($xcol, $xlin + 197, 60, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 60, $xlin + 197, 60, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 120, $xlin + 197, 82, 47, 2, 'DF', '34');
                                     $this->objpdf->rect($xcol + 120, $xlin + 216, 32, 28, 2, 'DF', '');
                                     $this->objpdf->rect($xcol, $xlin + 191, 60, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 60, $xlin + 191, 60, 6, 2, 'DF', '12');
                                     $this->objpdf->rect($xcol + 120, $xlin + 191, 82, 6, 2, 'DF', '12');
                                     $this->objpdf->text($xcol + 15, $xlin + 195, 'CONTADORIA GERAL');
                                     $this->objpdf->text($xcol + 82, $xlin + 195, 'PAGUE-SE');
                                     $this->objpdf->text($xcol + 150, $xlin + 195, 'TESOURARIA');
                                     $this->objpdf->line($xcol + 5, $xlin + 211, $xcol + 54, $xlin + 211);
                                     $this->objpdf->line($xcol + 5, $xlin + 225, $xcol + 54, $xlin + 225);
                                     $this->objpdf->line($xcol + 5, $xlin + 238, $xcol + 54, $xlin + 238);
                                     $this->objpdf->line($xcol + 65, $xlin + 225, $xcol + 114, $xlin + 225);
                                     $this->objpdf->SetFont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 12, $xlin + 199, 'EMPENHADO E CONFERIDO');
                                     $this->objpdf->text($xcol + 26, $xlin + 213, 'VISTO');
                                     $this->objpdf->text($xcol + 19, $xlin + 227, 'TÉCNICO CONTÁBIL');
                                     $this->objpdf->text($xcol + 13, $xlin + 240, 'SECRETÁRIO(A) DA FAZENDA');
                                     $this->objpdf->text($xcol + 66, $xlin + 212, 'DATA  ____________/____________/____________');
                                     $this->objpdf->text($xcol + 76, $xlin + 227, 'PREFEITO MUNICIPAL');
                                     $this->objpdf->text($xcol + 122, $xlin + 207, 'CHEQUE N' . chr(176));
                                     $this->objpdf->text($xcol + 170, $xlin + 207, 'DATA');
                                     $this->objpdf->text($xcol + 122, $xlin + 215, 'BANCO N' . chr(176));
                                     $this->objpdf->text($xcol + 127, $xlin + 218, 'DOCUMENTO N' . chr(176));
                                     $this->objpdf->line($xcol + 155, $xlin + 240, $xcol + 200, $xlin + 240);
                                     $this->objpdf->text($xcol + 170, $xlin + 242, 'TESOUREIRO');
                                     $this->objpdf->rect($xcol, $xlin + 246, 202, 26, 2, 'DF', '1234');
                                     $this->objpdf->SetFont('Arial', '', 7);
                                     $this->objpdf->text($xcol + 90, $xlin + 249, 'R E C I B O');
                                     $this->objpdf->text($xcol + 45, $xlin + 253, 'RECEBI(EMOS) DO MUNICÍPIO DE ' . $this->municpref . ', A IMPORTÂNCIA ABAIXO ESPECIFICADA, REFERENTE À:');
                                     $this->objpdf->text($xcol + 2, $xlin + 257, '(     ) PARTE DO VALOR EMPENHADO');
                                     $this->objpdf->text($xcol + 102, $xlin + 257, '(     ) SALDO/TOTAL EMPENHADO');
                                     $this->objpdf->text($xcol + 2, $xlin + 261, 'R$');
                                     $this->objpdf->text($xcol + 102, $xlin + 261, 'R$');
                                     $this->objpdf->text($xcol + 2, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 42, $xlin + 265, '_________________________________________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 102, $xlin + 265, 'EM ________/________/________', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 142, $xlin + 265, '_________________________________________', 0, 1, 'C', 0);
                                     $this->objpdf->SetFont('Arial', '', 6);
                                     $this->objpdf->text($xcol + 62, $xlin + 269, 'CREDOR', 0, 0, 'C', 0);
                                     $this->objpdf->text($xcol + 162, $xlin + 269, 'CREDOR', 0, 1, 'C', 0);
                                     $this->objpdf->SetFont('Arial', '', 4);
                                     $this->objpdf->Text(2, 296, $this->texto);
                                     // texto no canhoto do carne
                                     $this->objpdf->setfont('Arial', '', 11);
                                     $xlin = 169;
                                 } else {
                                     if ($this->modelo == 8) {
                                         //// Ficha de transferencia de bens
                                         $this->objpdf->AliasNbPages();
                                         //	$this->objpdf->AddPage();
                                         $this->objpdf->settopmargin(1);
                                         $this->objpdf->line(2, 148.5, 208, 148.5);
                                         $xlin = 20;
                                         $xcol = 4;
                                         $comeco = 0;
                                         $passada = 0;
                                         if ($this->linhasbens < 40) {
                                             $vias = 2;
                                         } elseif ($this->linhasbens < 80) {
                                             $vias = 4;
                                         } elseif ($this->linhasbens < 120) {
                                             $vias = 6;
                                         } elseif ($this->linhasbens < 160) {
                                             $vias = 8;
                                         } elseif ($this->linhasbens < 200) {
                                             $vias = 10;
                                         }
                                         for ($i = 0; $i < $vias; $i++) {
                                             if ($i % 2 == 0) {
                                                 $this->objpdf->AddPage();
                                             }
                                             $this->objpdf->setfillcolor(245);
                                             $this->objpdf->roundedrect($xcol - 2, $xlin - 18, 206, 144.5, 2, 'DF', '1234');
                                             $this->objpdf->setfillcolor(255, 255, 255);
                                             //		$this->objpdf->roundedrect(10,07,190,183,2,'DF','1234');
                                             $this->objpdf->Setfont('Arial', 'B', 11);
                                             $this->objpdf->text(150, $xlin - 13, 'TRANSFERÊNCIA N' . chr(176) . '  ' . $this->codtransf);
                                             $this->objpdf->text(159, $xlin - 8, $this->datacalc);
                                             $this->objpdf->Image('imagens/files/logo_boleto.png', 15, $xlin - 17, 12);
                                             $this->objpdf->Setfont('Arial', 'B', 9);
                                             $this->objpdf->text(40, $xlin - 15, $this->prefeitura);
                                             $this->objpdf->Setfont('Arial', '', 9);
                                             $this->objpdf->text(40, $xlin - 11, $this->enderpref);
                                             $this->objpdf->text(40, $xlin - 8, $this->municpref);
                                             $this->objpdf->text(40, $xlin - 5, $this->telefpref);
                                             $this->objpdf->text(40, $xlin - 2, $this->emailpref);
                                             //		$this->objpdf->setfillcolor(245);
                                             $this->objpdf->Roundedrect($xcol, $xlin + 2, $xcol + 98, 20, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 5, 'Origem:');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 9, 'Departamento ');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 22, $xlin + 9, ':  ' . $this->origem);
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 16, 'Usuario');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 22, $xlin + 16, ':  ' . $this->usuario);
                                             $this->objpdf->Setfont('Arial', '', 6);
                                             $this->objpdf->Roundedrect($xcol + 104, $xlin + 2, 98, 20, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 106, $xlin + 5, 'Destino:');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 106, $xlin + 9, 'Departamento');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 128, $xlin + 9, ':  ' . $this->destino);
                                             //		$this->objpdf->setfillcolor(245);
                                             $this->objpdf->Roundedrect($xcol, $xlin + 24, 202, 70, 2, 'DF', '1234');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 27, 'Itens a Transmitir :');
                                             $this->objpdf->Setfont('Arial', 'b', 8);
                                             $this->objpdf->text($xcol + 2, $xlin + 30, 'BEM');
                                             $this->objpdf->text($xcol + 25, $xlin + 30, 'DESCRIÇÃO');
                                             $this->objpdf->text($xcol + 75, $xlin + 30, 'CLASSIFICAÇÃO');
                                             $this->objpdf->text($xcol + 102, $xlin + 30, 'BEM');
                                             $this->objpdf->text($xcol + 125, $xlin + 30, 'DESCRIÇÃO');
                                             $this->objpdf->text($xcol + 175, $xlin + 30, 'CLASSIFICAÇÃO');
                                             $this->objpdf->Setfont('Arial', '', 8);
                                             $this->objpdf->sety($xlin + 31);
                                             $maiscol = 0;
                                             $yy = $this->objpdf->gety();
                                             for ($ii = $comeco; $ii < $this->linhasbens; $ii++) {
                                                 if ($ii % 40 == 0 && $ii > 0 && $passada == 0) {
                                                     $maiscol = 0;
                                                     $passada++;
                                                     $comeco = $ii;
                                                     break;
                                                 } elseif ($ii % 20 == 0 && $ii > 0 && $ii % 40 != 0) {
                                                     $maiscol = 100;
                                                     $this->objpdf->sety($yy);
                                                 }
                                                 $this->objpdf->setx($xcol + 3 + $maiscol);
                                                 $this->objpdf->cell(5, 3, trim(pg_result($this->recordbens, $ii, $this->bem)), 0, 0, "R", 0);
                                                 $this->objpdf->cell(70, 3, trim(pg_result($this->recordbens, $ii, $this->descr_bem)), 0, 0, "L", 0);
                                                 $this->objpdf->cell(15, 3, pg_result($this->recordbens, $ii, $this->class_bem), 0, 1, "R", 0);
                                                 if ($ii + 1 == $this->linhasbens) {
                                                     $comeco = 0;
                                                     $passada = 0;
                                                     break;
                                                 }
                                             }
                                             $this->objpdf->line($xcol + 10, $xlin + 116, $xcol + 70, $xlin + 116);
                                             $this->objpdf->text($xcol + 30, $xlin + 120, 'TRANSMITENTE');
                                             $this->objpdf->line($xcol + 135, $xlin + 116, $xcol + 195, $xlin + 116);
                                             $this->objpdf->text($xcol + 155, $xlin + 120, 'RECEBEDOR');
                                             if ($i % 2 == 0) {
                                                 $xlin = 169;
                                             } else {
                                                 $xlin = 20;
                                             }
                                         }
                                     } else {
                                         if ($this->modelo == 9) {
                                             $this->objpdf->SetTextColor(0, 0, 0);
                                             $this->objpdf->SetFont('Arial', 'B', 12);
                                             $coluna = 44;
                                             $linha = 35;
                                             $this->objpdf->SetLineWidth(1);
                                             $this->objpdf->RoundedRect(37, 0.2, 137, 195, 2, '1234');
                                             $this->objpdf->SetLineWidth(0.5);
                                             $this->objpdf->roundedrect(39, 2, 133, 191, 2, '1234');
                                             $this->objpdf->SetLineWidth(0.2);
                                             $this->objpdf->Image('imagens/files/Brasao.png', 43, 5, 20);
                                             $this->objpdf->Image('imagens/files/Brasao.jpg', 60, 30, 100);
                                             //	$this->objpdf->roundedrect(42,$linha+30,127,35,2,'1234');
                                             //	$this->objpdf->roundedrect(42,$linha+72,127,15,2,'1234'); // obs da atividade principal
                                             //  	$this->objpdf->roundedrect(42,$linha+88,127,5,2,'1234'); // descricao da atividade secundaria
                                             //	$this->objpdf->roundedrect(42,$linha+94,127,15,2,'1234'); // obs da atividade secundaria
                                             //	$this->objpdf->setdrawcolor(235);
                                             $this->objpdf->setxy(65, 15);
                                             $this->objpdf->setfont('Arial', 'B', 13);
                                             $this->objpdf->Multicell(0, 8, $this->prefeitura, "C");
                                             // prefeitura
                                             $this->objpdf->setxy(65, 23);
                                             $this->objpdf->setfont('Arial', 'B', 13);
                                             $this->objpdf->setleftmargin(50);
                                             $this->objpdf->setrightmargin(50);
                                             $this->objpdf->Multicell(0, 8, $this->tipoalvara, 0, "C", 0);
                                             // tipo de alvara
                                             $this->objpdf->Ln(6);
                                             $this->objpdf->sety(38);
                                             $this->objpdf->SetFont('Arial', '', 11);
                                             $this->objpdf->multicell(0, 6, db_geratexto($this->texto), 0, "J", 0, $db02_inicia);
                                             //	$this->objpdf->multicell(0,6,db_geratexto($db02_texto),0,"J",0,$db02_inicia);
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 35, 'INSCRIÇÃO:');
                                             // inscricao
                                             if ($this->processo > 0) {
                                                 $this->objpdf->Text($coluna + 70, $linha + 35, 'PROCESSO:');
                                                 // inscricao
                                             }
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 35, $this->nrinscr);
                                             // inscricao
                                             if ($this->processo > 0) {
                                                 $this->objpdf->Text($coluna + 90, $linha + 35, $this->processo);
                                                 // processo
                                             }
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 39, "NOME/RAZAO SOCIAL: ");
                                             // nome
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 39, $this->nome);
                                             // nome
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 43, "CNPJ/CPF: ");
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 43, $this->cnpjcpf);
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 47, "ENDEREÇO: ");
                                             // endereco
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 47, $this->ender);
                                             // endereco
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 51, "NÚMERO: ");
                                             // endereco
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 51, $this->numero == "" ? "" : $this->numero);
                                             if ($this->compl != "") {
                                                 $this->objpdf->SetFont('Arial', 'B', 9);
                                                 $this->objpdf->Text($coluna + 60, $linha + 51, "COMPLEMENTO: ");
                                                 // endereco
                                                 $this->objpdf->SetFont('Arial', '', 9);
                                                 $this->objpdf->Text($coluna + 90, $linha + 51, $this->compl == "" ? "" : $this->compl);
                                             }
                                             $this->objpdf->SetFont('Arial', 'B', 9);
                                             $this->objpdf->Text($coluna, $linha + 55, "DATA DE INCLUSAO: ");
                                             if ($this->datafim != "") {
                                                 $this->objpdf->Text($coluna + 60, $linha + 55, "VALIDADE ATÉ: ");
                                             }
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Text($coluna + 40, $linha + 55, db_formatar($this->datainc, 'd'));
                                             if ($this->datafim != "") {
                                                 $this->objpdf->Text($coluna + 85, $linha + 55, db_formatar($this->datafim, 'd'));
                                             }
                                             $this->objpdf->setx(40);
                                             if ($this->q02_memo != '') {
                                                 $this->objpdf->SetFont('Arial', 'B', 9);
                                                 $this->objpdf->Text($coluna, $linha + 59, "OBSERVAÇÃO: ");
                                                 // observação
                                                 $this->objpdf->SetFont('Arial', '', 9);
                                                 $this->objpdf->sety($linha + 60);
                                                 $this->objpdf->Multicell(0, 3, $this->q02_memo);
                                                 // texto
                                                 $this->objpdf->SetFont('Arial', 'B', 10);
                                                 $this->objpdf->roundedrect(42, $linha + 30, 127, 38, 2, '1234');
                                                 $linha = 109;
                                             } else {
                                                 $this->objpdf->roundedrect(42, $linha + 30, 127, 27, 2, '1234');
                                                 $linha = 95;
                                             }
                                             $this->objpdf->sety($linha);
                                             $this->objpdf->roundedrect(42, $linha - 1, 127, 5, 2, '1234');
                                             $this->objpdf->SetFont('Arial', 'B', 8);
                                             $this->objpdf->Ln(0.5);
                                             $this->objpdf->setx(45);
                                             $this->objpdf->Multicell(0, 3, "ATIVIDADE PRINCIPAL: " . $this->descrativ);
                                             // descrição da atividade principal
                                             $linha += 6;
                                             $obs = '';
                                             if (isset($this->q03_atmemo[$this->ativ])) {
                                                 if ($this->q03_atmemo[$this->ativ] != '') {
                                                     $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                                                     // obs da atividade principal
                                                     $obs = $this->q03_atmemo[$this->ativ];
                                                     $this->objpdf->Ln(3);
                                                     $this->objpdf->SetFont('Arial', '', 7);
                                                     $this->objpdf->Multicell(0, 3, $this->q03_atmemo[$this->ativ]);
                                                     // texto
                                                     $linha += 16;
                                                 }
                                             }
                                             $this->objpdf->sety($linha);
                                             $num_outras = count($this->outrasativs);
                                             $x = 105;
                                             if ($num_outras > 0) {
                                                 $x = $x + 4;
                                                 reset($this->outrasativs);
                                                 for ($i = 0; $i < $num_outras; $i++) {
                                                     $yyy = $this->objpdf->gety();
                                                     $chave = key($this->outrasativs);
                                                     $obs = '';
                                                     if (isset($this->q03_atmemo[$chave])) {
                                                         $obs = $this->q03_atmemo[$chave];
                                                     }
                                                     $this->objpdf->SetFont('Arial', 'B', 8);
                                                     $this->objpdf->roundedrect(42, $yyy - 1, 127, 5, 2, '1234');
                                                     // descricao da atividade secundaria
                                                     $this->objpdf->Ln(0.5);
                                                     $this->objpdf->setx(45);
                                                     $this->objpdf->Multicell(0, 3, "ATIVIDADE SECUNDÁRIA: " . $this->outrasativs[$chave]);
                                                     // texto
                                                     $linha += 6;
                                                     if ($obs != "") {
                                                         $this->objpdf->roundedrect(42, $linha - 1, 127, 15, 2, '1234');
                                                         // obs da atividade secundaria
                                                         $this->objpdf->Ln(3);
                                                         $this->objpdf->SetFont('Arial', '', 7);
                                                         $this->objpdf->Multicell(0, 3, $obs);
                                                         // texto
                                                         $linha += 16;
                                                     }
                                                     $x = $x + 4;
                                                     next($this->outrasativs);
                                                     //             $this->objpdf->ln(2.5);
                                                     $this->objpdf->sety($linha);
                                                 }
                                             }
                                             $x = 64;
                                             //        if($this->q02_obs!=''){
                                             //	  $this->objpdf->Text($coluna,$linha+$x,"OBSERVAÇÃO: "); // descrição da atividade principal
                                             //	  $this->objpdf->Text($coluna + 45,$linha+$x,$this->q02_obs); // descrição da atividade principal
                                             //	  $x=$x+4;
                                             //	}
                                             //        $linha = $this->objpdf->gety();
                                             $this->objpdf->SetFont('Arial', 'B', 12);
                                             $this->objpdf->Text($coluna + 40, $linha + 5, "DATA DE EMISSÃO DESTE DOCUMENTO.");
                                             // data
                                             $this->objpdf->Text($coluna + 40, $linha + 10, $this->municpref . ", " . date('d') . " DE " . strtoupper(db_mes(date('m'))) . " DE " . date('Y') . ".");
                                             // data
                                             $this->objpdf->sety(125);
                                             $this->objpdf->SetFont('Arial', '', 9);
                                             $this->objpdf->Multicell(0, 6, $this->obs);
                                             // observação
                                             $this->objpdf->setfont('arial', '', 6);
                                             $this->objpdf->SetXY($coluna - 18, 165);
                                             global $db02_texto;
                                             $sqlparag = "select db02_texto \n\t\t     from db_documento \n\t\t     inner join db_docparag on db03_docum = db04_docum \n\t\t     inner join db_paragrafo on db04_idparag = db02_idparag \n\t\t     where db03_docum = 26 and db02_descr like '%Assinatura Secretario%'";
                                             $resparag = pg_query($sqlparag);
                                             if (pg_numrows($resparag) == 0) {
                                                 db_redireciona('db_erros.php?fechar=true&db_erro=Configure o documento 26 com os paragrafos do alvara!');
                                                 exit;
                                             }
                                             db_fieldsmemory($resparag, 0);
                                             $this->objpdf->MultiCell(90, 4, '..........................................................................................' . "\n" . $db02_texto, 0, "C", 0);
                                             $this->objpdf->SetXY($coluna + 50, 165);
                                             $this->objpdf->MultiCell(90, 4, '..........................................................................................', 0, "C", 0);
                                             //        $this->objpdf->SetXY($coluna-35,160);
                                             //        $this->objpdf->MultiCell(90,4,'..........................................................................................'."\n".'SECRETÁRIO DA IND. COM. E TURISMO',0,"C",0);
                                             //        $this->objpdf->SetXY($coluna+35,160);
                                             //        $this->objpdf->MultiCell(90,4,'..........................................................................................',0,"C",0);
                                             $this->objpdf->sety(180);
                                             $this->objpdf->setfont('arial', 'B', 12);
                                             $this->objpdf->multicell(0, 8, 'FIXAR EM LUGAR VISÍVEL', 1, "C");
                                             $this->objpdf->SetFont('Arial', 'B', 10);
                                         } else {
                                             echo "<script>alert('Modelo de carne({$this->modelo}) não definido')</script>";
                                             exit;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        for ($i = 0; $i < pg_numrows($result); $i++) {
            db_fieldsmemory($result, $i);
            if (strlen(trim($w06_cgccpf)) == 14) {
                $w06_cgccpf = db_formatar($w06_cgccpf, 'cnpj');
            } else {
                $w06_cgccpf = db_formatar($w06_cgccpf, 'cpf');
            }
            echo "<tr align=\"center\">\n                               <td width=\"50%\" >\n                                 {$w06_nome}\n                               </td>\n                               <td width=\"20%\">\n                                 {$w06_cgccpf}\n                               </td>\n                               <td width=\"20%\">\n                                 {$w06_percent} %\n                               </td>\n                               <td>\n                                 <input class=\"botao\" name=\"alterar\" type=\"submit\" value=\"Alterar\" onClick=\"document.form1.qual.value='{$w06_socio}'\">\n                                 <input class=\"botao\" name=\"excluir\" type=\"submit\" value=\"Excluir\" onClick=\"document.form1.qual.value='{$w06_socio}'\">\n                               </td>\n                             </tr>\n                             <input type=\"hidden\" name=\"item{$i}\" value=\"{$i}#{$w06_cgccpf}#{$w06_rg}#{$w06_nome}#{$w06_ender}#{$w06_numero}#{$w06_compl}#{$w06_bairro}#{$w06_cep}#{$w06_uf}#{$w06_percent}\">\n                             ";
        }
    }
} elseif (isset($excluir)) {
    //db_postmemory($HTTP_POST_VARS,2);
    pg_exec("delete from db_daesocios where w06_codigo = {$codigo} and w06_socio = {$qual}");
    $result = pg_exec("select * from db_daesocios where w06_codigo = {$codigo}");
    if (pg_numrows($result) == 0) {
        db_redireciona("sociosdae.php?" . base64_encode("inscricaow=" . $inscricaow . "&codigo=" . $codigo));
    } else {
        for ($i = 0; $i < pg_numrows($result); $i++) {
            db_fieldsmemory($result, $i);
            if (strlen(trim($w06_cgccpf)) == 14) {
                $w06_cgccpf = db_formatar($w06_cgccpf, 'cnpj');
            } else {
                $w06_cgccpf = db_formatar($w06_cgccpf, 'cpf');
            }
            echo "<tr align=\"center\">\n                               <td width=\"50%\" >\n                                 {$w06_nome}\n                               </td>\n                               <td width=\"20%\">\n                                 {$w06_cgccpf}\n                               </td>\n                               <td width=\"20%\">\n                                 {$w06_percent} %\n                               </td>\n                               <td>\n                                 <input class=\"botao\" name=\"alterar\" type=\"submit\" value=\"Alterar\" onClick=\"document.form1.qual.value='{$w06_socio}'\">\n                                 <input class=\"botao\" name=\"excluir\" type=\"submit\" value=\"Excluir\" onClick=\"document.form1.qual.value='{$w06_socio}'\">\n                               </td>\n                             </tr>\n                             <input type=\"hidden\" name=\"item{$i}\" value=\"{$i}#{$w06_cgccpf}#{$w06_rg}#{$w06_nome}#{$w06_ender}#{$w06_numero}#{$w06_compl}#{$w06_bairro}#{$w06_cep}#{$w06_uf}#{$w06_percent}\">\n                             ";
        }
    }
}
?>
                  <input type="hidden" name="qual" value="">
                </table>
function db_planocontassaldo_desp_rec($anousu, $dataini, $datafim, $retsql = false, $where = '', $estrut_inicial = '', $encerramento = 'false')
{
    // anousu
    // where[] :   condições adicionais de pesquisa
    // encerramento[false/true] :  considera documentos de encerramento de exercicio
    // retsql  [false/true] : retorna somente sql
    // estrut_inicia []  :  pesquisa por estrutural
    //
    if ($anousu == null) {
        $anousu = db_getsession("DB_anousu");
    }
    if ($dataini == null) {
        $dataini = date('Y-m-d', db_getsession('DB_datausu'));
    }
    if ($datafim == null) {
        $datafim = date('Y-m-d', db_getsession('DB_datausu'));
    }
    if ($where != '') {
        $condicao = " and " . $where;
    } else {
        $condicao = "";
    }
    $pesq_estrut = "";
    if ($estrut_inicial != "") {
        $pesq_estrut = "  and p.c60_estrut like '{$estrut_inicial}%' ";
    }
    $sql = "\n      select   estrut_mae, \n      estrut, \n      c61_reduz,\n      c61_codcon,\n      c61_codigo,\n      c60_descr,\n      c60_finali,\n      c61_instit,\n      round(substr(fc_planosaldonovo,3,13)::float8,2)::float8 as saldo_anterior,\n      round(substr(fc_planosaldonovo,16,13)::float8,2)::float8 as saldo_anterior_debito,\n      round(substr(fc_planosaldonovo,29,13)::float8,2)::float8 as saldo_anterior_credito,\n      round(substr(fc_planosaldonovo,42,13)::float8,2)::float8 as saldo_final,\n      substr(fc_planosaldonovo,55,1)::varchar(1) as sinal_anterior,\n      substr(fc_planosaldonovo,56,1)::varchar(1) as sinal_final\n      from \n      (select p.c60_estrut as estrut_mae,\t             \n      p.c60_estrut as estrut,\n      c61_reduz,\n      c61_codcon,\n      c61_codigo,\n      p.c60_descr,\n      p.c60_finali,\n      r.c61_instit,                      \n      fc_planosaldonovo(" . db_getsession('DB_anousu') . ",c61_reduz,'{$dataini}','{$datafim}',{$encerramento}) \n      from conplanoexe e\n      inner join conplanoreduz r on r.c61_reduz = e.c62_reduz and r.c61_anousu=e.c62_anousu\n      inner join conplano p on r.c61_codcon = p.c60_codcon and r.c61_anousu=p.c60_anousu\n      {$pesq_estrut}  \n      where c62_anousu = {$anousu} {$condicao}\n      and ( substr(p.c60_estrut,1,1)='3'\n      or fc_conplano_grupo(" . db_getsession("DB_anousu") . ", substr(p.c60_estrut,1,1)||'%', 9004) is true\n      or fc_conplano_grupo(" . db_getsession("DB_anousu") . ", substr(p.c60_estrut,1,1)||'%', 9000) is true)) as x  \n      ";
    pg_exec("create temporary table work_plano (\n      estrut_mae varchar(15), \n      estrut varchar(15),\n      c61_reduz integer,\n      c61_codcon integer,\n      c61_codigo integer,\n      c60_descr varchar(50),\n      c60_finali text,\n      c61_instit integer,\n      saldo_anterior float8,\n      saldo_anterior_debito float8,\n      saldo_anterior_credito float8,\n      saldo_final float8,\n      sinal_anterior varchar(1),\n      sinal_final varchar(1)) ");
    pg_exec("create index work_plano_estrut on work_plano(estrut)");
    pg_exec("create index work_plano_estrutmae on work_plano(estrut_mae)");
    $result = pg_query($sql);
    $tot_anterior = 0;
    $tot_anterior_debito = 0;
    $tot_anterior_credito = 0;
    $tot_saldo_final = 0;
    global $seq;
    global $estrut_mae;
    global $estrut;
    global $c61_reduz;
    global $c61_codcon;
    global $c61_codigo;
    global $c60_codcon;
    global $c60_descr;
    global $c60_finali;
    global $c61_instit;
    global $saldo_anterior;
    global $saldo_anterior_debito;
    global $saldo_anterior_credito;
    global $saldo_final;
    global $result_estrut;
    global $sinal_anterior;
    global $sinal_final;
    $work_planomae = array();
    $work_planoestrut = array();
    $work_plano = array();
    $seq = 0;
    for ($i = 0; $i < pg_numrows($result); $i++) {
        db_fieldsmemory($result, $i);
        if ($sinal_anterior == "C") {
            $saldo_anterior *= -1;
        }
        if ($sinal_final == "C") {
            $saldo_final *= -1;
        }
        $tot_anterior = $saldo_anterior;
        $tot_anterior_debito = $saldo_anterior_debito;
        $tot_anterior_credito = $saldo_anterior_credito;
        $tot_saldo_final = $saldo_final;
        $key = array_search("{$estrut_mae}", $work_planomae);
        if ($key === false) {
            // não achou
            $work_planomae[$seq] = $estrut_mae;
            $work_planoestrut[$seq] = $estrut;
            $work_plano[$seq] = array(0 => "{$c61_reduz}", 1 => "{$c61_codcon}", 2 => "{$c61_codigo}", 3 => "{$c60_descr}", 4 => "{$c60_finali}", 5 => "{$c61_instit}", 6 => "{$saldo_anterior}", 7 => "{$saldo_anterior_debito}", 8 => "{$saldo_anterior_credito}", 9 => "{$saldo_final}", 10 => "{$sinal_anterior}", 11 => "{$sinal_final}");
            $seq = $seq + 1;
        } else {
            $work_plano[$key][6] += $tot_anterior;
            $work_plano[$key][7] += $tot_anterior_debito;
            $work_plano[$key][8] += $tot_anterior_credito;
            $work_plano[$key][9] += $tot_saldo_final;
        }
        $estrutural = $estrut;
        for ($ii = 1; $ii < 10; $ii++) {
            $estrutural = db_le_mae_conplano($estrutural);
            $nivel = db_le_mae_conplano($estrutural, true);
            $key = array_search("{$estrutural}", $work_planomae);
            if ($key === false) {
                // não achou
                // busca no banco e inclui
                $res = pg_query("select c60_descr,c60_finali,c60_codcon from conplano where c60_anousu=" . db_getsession("DB_anousu") . " and c60_estrut = '{$estrutural}'");
                if ($res == false || pg_numrows($res) == 0) {
                    db_redireciona("db_erros.php?fechar=true&db_erro=Está faltando cadastrar esse estrutural na contabilidade. Nível : {$nivel}  Estrutural : {$estrutural}");
                    exit;
                }
                db_fieldsmemory($res, 0);
                $work_planomae[$seq] = $estrutural;
                $work_planoestrut[$seq] = '';
                $work_plano[$seq] = array(0 => 0, 1 => 0, 2 => $c60_codcon, 3 => $c60_descr, 4 => $c60_finali, 5 => 0, 6 => $saldo_anterior, 7 => $saldo_anterior_debito, 8 => $saldo_anterior_credito, 9 => $saldo_final, 10 => $sinal_anterior, 11 => $sinal_final);
                $seq++;
            } else {
                $work_plano[$key][6] += $tot_anterior;
                $work_plano[$key][7] += $tot_anterior_debito;
                $work_plano[$key][8] += $tot_anterior_credito;
                $work_plano[$key][9] += $tot_saldo_final;
            }
            if ($nivel == 1) {
                break;
            }
        }
    }
    for ($i = 0; $i < sizeof($work_planomae); $i++) {
        $mae = $work_planomae[$i];
        $estrut = $work_planoestrut[$i];
        $c61_reduz = $work_plano[$i][0];
        $c61_codcon = $work_plano[$i][1];
        $c61_codigo = $work_plano[$i][2];
        $c60_descr = $work_plano[$i][3];
        $c60_finali = $work_plano[$i][4];
        $c61_instit = $work_plano[$i][5];
        $saldo_anterior = $work_plano[$i][6];
        $saldo_anterior_debito = $work_plano[$i][7];
        $saldo_anterior_credito = $work_plano[$i][8];
        $saldo_final = $work_plano[$i][9];
        $sinal_anterior = $work_plano[$i][10];
        $sinal_final = $work_plano[$i][11];
        $sql = "insert into work_plano \n        values ('{$mae}',\n        '{$estrut}',\n        {$c61_reduz}, \n        {$c61_codcon},\n        {$c61_codigo},\n        '{$c60_descr}',\n        '{$c60_finali}',\n        {$c61_instit},\n        {$saldo_anterior},\n        {$saldo_anterior_debito},\n        {$saldo_anterior_credito},\n        {$saldo_final},\n        '{$sinal_anterior}',\n        '{$sinal_final}')\n        \n        ";
        pg_exec($sql);
    }
    $sql = "select case when c61_reduz = 0 then estrut_mae else estrut end as estrutural,\n      c61_reduz,\n      c61_codcon,\n      c61_codigo,\n      c60_descr,\n      c60_finali,\n      c61_instit,\n      abs(saldo_anterior) as saldo_anterior,\n      abs(saldo_anterior_debito) as saldo_anterior_debito,\n      abs(saldo_anterior_credito) as saldo_anterior_credito,\n      abs(saldo_final) as saldo_final,\n      case when saldo_anterior < 0 then 'C'\n      when saldo_anterior > 0 then 'D'\n      else ' ' end as  sinal_anterior,\n      case when saldo_final < 0 then 'C'\n      when saldo_final > 0 then 'D'\n      else ' ' end as  sinal_final\n      from work_plano \n      order by estrut_mae,estrut";
    if ($retsql == false) {
        $result_final = pg_exec($sql);
        // db_criatabela($result_final); exit;
        return $result_final;
    } else {
        return $sql;
    }
}
$sCamposAtendimentoLocal .= "ov01_dataatend as data_atendimento,";
$sCamposAtendimentoLocal .= "ov01_horaatend as hora_atendimento,";
$sCamposAtendimentoLocal .= "ov01_requerente as nome_requerente,";
$sCamposAtendimentoLocal .= "ov25_sequencial ||' - '|| ov25_descricao as local,";
$sCamposAtendimentoLocal .= "ov01_depart ||' - '|| descrdepto as departamento_inicial,";
$sCamposAtendimentoLocal .= "(select procarquiv.p67_dtarq ";
$sCamposAtendimentoLocal .= "   from arqproc ";
$sCamposAtendimentoLocal .= "        inner join procarquiv on p68_codarquiv = p67_codarquiv ";
$sCamposAtendimentoLocal .= " where  p68_codproc = p58_codproc) as data_arquivamento, ";
$sCamposAtendimentoLocal .= "p58_codproc as numero_processo";
$sWhereAtendimentoLocal = "ouvidoriaatendimento.ov01_sequencial = {$oGet->iAtendimento}";
$sSqlOuvAtend = $oDaoOuvidoriaAtend->sql_query_atendimento_processo(null, $sCamposAtendimentoLocal, null, $sWhereAtendimentoLocal);
$rsOuviAtendimento = $oDaoOuvidoriaAtend->sql_record($sSqlOuvAtend);
if ($oDaoOuvidoriaAtend->erro_status == "0") {
    db_msgbox("Não foi possível localizar o atendimento desejado.");
    db_redireciona("digitaconsultaouvidorianovo.php");
    exit;
}
$oAtendimento = db_utils::fieldsMemory($rsOuviAtendimento, 0);
$sDataArquivamento = "";
if ($oAtendimento->data_arquivamento != "") {
    $sDataArquivamento = db_formatar($oAtendimento->data_arquivamento, "d");
}
$oAtendimento->data_arquivamento = $sDataArquivamento;
$sNumeroProcesso = "";
if ($oAtendimento->numero_processo != "") {
    $sNumeroProcesso = $oAtendimento->numero_processo;
}
$oAtendimento->numero_processo = $sNumeroProcesso;
?>
<html>
		</td>
	      </tr>
              <?php 
if (!isset($primeira)) {
    exit;
}
if (isset($inscricaow)) {
    $result = pg_exec("select * from db_dae where w04_inscr = {$inscricaow}");
    if (pg_numrows($result) == 0) {
        db_redireciona("valoresdae.php?inscricaow={$inscricaow}");
        exit;
    } else {
        db_fieldsmemory($result, 0);
        $result = pg_exec("select * from db_daevalores where w07_codigo = {$w04_codigo}");
        if (pg_numrows($result) == 0) {
            db_redireciona("valoresdae.php?inscricaow={$inscricaow}");
            exit;
        } else {
            for ($i = 0; $i < pg_numrows($result); $i++) {
                $data = pg_result($result, $i, 'w07_dtpaga');
                $valor = pg_result($result, $i, 'w07_valor');
                db_fieldsmemory($result, $i, true);
                echo "<tr id=\"" . ($i + 1) . "\" align=\"center\">";
                echo "<td class=\"fonte\">" . db_mes(@$w07_mes) . "</td>";
                echo "<td class=\"fonte\">" . @$valor . "</td>";
                echo "<td class=\"fonte\">" . @$w07_aliquota . " %</td>";
                echo "<td class=\"fonte\">" . @$w07_imposto . "</td>";
                echo "<td class=\"fonte\">" . @$w07_dtpaga . "</td>";
                $ano = substr($w07_dtpaga, 6, 4);
                $mes = substr($w07_dtpaga, 3, 2);
                $dia = substr($w07_dtpaga, 0, 2);
require_once "dbforms/db_funcoes.php";
require_once "classes/db_isssimulacalculo_classe.php";
require_once "classes/db_isssimulacalculoatividade_classe.php";
$oJson = new services_json();
$oIssSimulaCalculo = new cl_isssimulacalculo();
$oIssSimulaCalculoAtividade = new cl_isssimulacalculoatividade();
$oGet = db_utils::postMemory($_GET);
$oPost = db_utils::postMemory($_POST);
$sSqlMunic = "select munic from db_config where codigo = " . db_getsession("DB_instit");
$rsMunic = db_query($sSqlMunic);
$sMunic = db_utils::fieldsMemory($rsMunic, 0)->munic;
$sSqlSimulaCalculo = $oIssSimulaCalculo->sql_query($oGet->iSimulacao);
$rsSimulacaoCalculo = $oIssSimulaCalculo->sql_record($sSqlSimulaCalculo);
$iLinhasConsulta = $oIssSimulaCalculo->numrows;
if ($iLinhasConsulta == 0) {
    db_redireciona("db_erros.php?fechar=true&db_erro=Nenhum registro encontrado.");
}
$sSqlSimulaCalculoAtividade = $oIssSimulaCalculoAtividade->sql_query(null, "*", "q131_seq", "q131_issimulacalculo = {$oGet->iSimulacao}");
$rsSimulacaoCalculoAtividade = $oIssSimulaCalculoAtividade->sql_record($sSqlSimulaCalculoAtividade);
$iLinhasConsultaAtividade = $oIssSimulaCalculoAtividade->numrows;
$head4 = "BIC simulada de Alvara";
$pdf = new PDF();
$pdf->Open();
$pdf->AliasNbPages();
$total = 0;
$alt = 4;
$pri = true;
for ($iInd = 0; $iInd < $iLinhasConsulta; $iInd++) {
    $oDados = db_utils::fieldsmemory($rsSimulacaoCalculo, $iInd);
    if ($pdf->gety() > $pdf->h - 30 || $pri == true) {
        $pdf->addpage("");
    if (@$codigo_cgm != "" || @$_COOKIE["cookie_codigo_cgm"] != "") {
        $usuario = $codigo_cgm == "" ? $_COOKIE["cookie_codigo_cgm"] : $codigo_cgm;
        // die($clcgm->sql_query("","cgm.z01_cgccpf, cgm.z01_nome, cgm.z01_numcgm","","cgm.z01_numcgm = $usuario"));
        $result = $clcgm->sql_record($clcgm->sql_query("", "cgm.z01_cgccpf, cgm.z01_nome, cgm.z01_numcgm", "", "cgm.z01_numcgm = {$usuario}"));
        $linhas = $clcgm->numrows;
        if ($linhas != 0) {
            db_fieldsmemory($result, $x);
            //11 14
            if (strlen($z01_cgccpf) > 11) {
                $cgc = $z01_cgccpf;
                $cpf = "";
            } else {
                $cgc = "";
                $cpf = $z01_cgccpf;
            }
            db_redireciona("digitafornecedor.php?id_usuario={$z01_numcgm}&cpf={$cpf}&cgc={$cgc}");
        }
    } else {
        ?>
 <form name="form1" method="post" action="digitafornecedor.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="texto">
   <tr>
    <td width="50%" height="30" align="right">Nº Fornecedor / CGM:&nbsp;</td>
    <td width="50%" height="30"><input name="codigo_cgm" type="text" class="digitacgccpf" id="codigo_cgm" size="10" maxlength="10"></td>
   </tr>
   <tr>
    <td width="50%" height="30" align="right">CNPJ:&nbsp;</td>
    <td width="50%" height="30"><input name="cgc" type="text" class="digitacgccpf" id="cgc"  onKeyDown="FormataCNPJ(this,event)" size="18" maxlength="18"></td>
   </tr>
   <tr>
    <td width="50%" height="30" align="right">CPF:&nbsp;</td>
//	  $this->objpdf->Text($coluna,$linha+$x,"OBSERVAÇÃO: "); // descrição da atividade principal
//	  $this->objpdf->Text($coluna + 45,$linha+$x,$this->q02_obs); // descrição da atividade principal
//	  $x=$x+4;
//	}
$this->objpdf->ln(10);
$this->objpdf->SetFont('Arial', 'B', 9);
$this->objpdf->cell($coluna, 5, '', 0, 0, "L", 0);
$this->objpdf->cell(60, 5, "DATA DE EMISSÃO DESTE DOCUMENTO.", 0, 1, "L", 0);
$this->objpdf->cell($coluna, 5, '', 0, 0, "L", 0);
$this->objpdf->cell(60, 5, $this->municpref . ", " . date('d') . " DE " . strtoupper(db_mes(date('m'))) . " DE " . date('Y') . ".", 0, 1, "L", 0);
// data
global $db02_texto;
$sqlparag = "select db02_texto \n\t\t     from db_documento \n\t\t     inner join db_docparag on db03_docum = db04_docum \n\t\t     inner join db_paragrafo on db04_idparag = db02_idparag \n\t\t     where db03_docum = 26 and db02_descr ilike '%Assinatura Alvara%' and db03_instit = " . db_getsession("DB_instit");
$resparag = pg_query($sqlparag);
if (pg_numrows($resparag) == 0) {
    db_redireciona('db_erros.php?fechar=true&db_erro=Configure o documento 26 com os paragrafos do alvara!');
    exit;
}
db_fieldsmemory($resparag, 0);
$this->objpdf->setfont('arial', '', 6);
$this->objpdf->SetXY($coluna - 18, 170);
$this->objpdf->MultiCell(90, 4, '..........................................................................................' . "\n" . $db02_texto, 0, "C", 0);
$this->objpdf->SetXY($coluna + 50, 170);
$this->objpdf->MultiCell(90, 4, '..........................................................................................', 0, "C", 0);
//        $this->objpdf->SetXY($coluna-35,160);
//        $this->objpdf->MultiCell(90,4,'..........................................................................................'."\n".'SECRETÁRIO DA IND. COM. E TURISMO',0,"C",0);
//        $this->objpdf->SetXY($coluna+35,160);
//        $this->objpdf->MultiCell(90,4,'..........................................................................................',0,"C",0);
$this->objpdf->sety(185);
$this->objpdf->setfont('arial', 'B', 12);
$this->objpdf->multicell(0, 6, 'FIXAR EM LUGAR VISÍVEL', 1, "C");
    if (pg_numrows($result) == 0) {
        $erroscripts = "1";
    } elseif (Encriptacao::hash($DB_senha) != pg_result($result, 0, "senha")) {
        $erroscripts = "2";
    } elseif (pg_result($result, 0, "usuarioativo") != 1) {
        $erroscripts = "5";
    } else {
        session_register("DB_login");
        db_fieldsmemory($result, 0, true, true);
        $HTTP_SESSION_VARS["DB_login"] = $cgmlogin;
        $DB_LOGADO = "";
        db_logs("", "", "0", "index.php - Usuário fez login.");
        $sql = "select fc_permissaodbpref({$cgmlogin},0,0)";
        $result = db_query($sql);
        if (pg_numrows($result) == 0) {
            db_redireciona("centro_pref.php?" . base64_encode("erroscripts='4'"));
        }
        $HTTP_SESSION_VARS["DB_acesso"] = pg_result($result, 0, 0);
        $HTTP_SESSION_VARS["hora"] = date("H:i:s");
    }
}
?>
<html>
<head>
<title><?php 
echo $w01_titulo;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript" src="scripts/md5.js"></script>
<script language="JavaScript" type="text/javascript" src="scripts/db_script.js"></script>
                </script>
        ";
            db_redireciona("digitadae.php");
            exit;*/
    } else {
        // se DAI não foi enviada
        $codigo = $w04_codigo;
        // codigo da DAI
    }
} else {
    //se tiver dai para este ano
    db_fieldsmemory($result, 0);
    // transforma campos da tabela db_dae
    if ($w04_enviado == 't') {
        echo "\n\t\t<script>var confirma = confirm('DAI já enviada, deseja reemitir o relatório?');\n        if(confirma == true){\n            window.open('daerelatorio.php?codigo={$w04_codigo}','','width='+(screen.availWidth-5)+',height='+(screen.availHeight-40)+',scrollbars=1,location=0 ');\n        }\n        </script>  \n";
        db_redireciona("digitadae.php");
        exit;
    } else {
        $codigo = $w04_codigo;
    }
}
//$result2 = db_query("select * from confsite");
//db_fieldsmemory($result2,0);
?>
<link rel="stylesheet" type="text/css" href="include/estilodai.css" >
<link href="/common/default.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<html>
<head>
<title><?php 
    }
} else {
    session_register("DB_acesso");
}
include "libs/db_conecta.php";
include_once "functions/func_sys.php";
include "libs/db_stdlib.php";
include "libs/db_sql.php";
require_once "libs/db_encriptacao.php";
mens_help();
db_mensagem("corpoprincipal", "mensagemsenha");
db_fieldsmemory($result, 0);
parse_str(base64_decode($HTTP_SERVER_VARS["QUERY_STRING"]));
if (isset($again)) {
    db_logs("", "", "0", "index.php - usuario fez log-off.");
    db_redireciona("index.php");
}
if (isset($login)) {
    $sSql = "select db_usuarios.id_usuario, senha, u.cgmlogin, usuarioativo         ";
    $sSql .= "  from db_usuarios                                                     ";
    $sSql .= "       inner join db_usuacgm u on u.id_usuario = db_usuarios.id_usuario";
    $sSql .= " where login        = '******'                                      ";
    $sSql .= "   and usuext       = 1                                                ";
    $result = db_query($conn, $sSql);
    if (pg_numrows($result) == 0) {
        $erroscripts = "1";
    } elseif (Encriptacao::hash($DB_senha) != pg_result($result, 0, "senha")) {
        $erroscripts = "2";
    } elseif (pg_result($result, 0, "usuarioativo") != 1) {
        $erroscripts = "5";
    } else {
Exemplo n.º 30
0
$pdf1->dtparapag = db_formatar(@$datavencimento, 'd');
$pdf1->descr10 = "1/1";
$pdf1->dtvenc = db_formatar(@$datavencimento, 'd');
$pdf1->quaisbancos = "LOCAIS DE PAGAMENTO ATÉ O VENCIMENTO:\nAgências do BANCO DO BRASIL, BANRISUL, CAIXA ECONÔMICA FEDERAL e Rede Nacional de LOTÉRICAS.\nEM CASO DE PAGAMENTO VIA HOME-BANKING ESCOLHER A OPÇÃO ARRECADAÇÃO";
$pdf1->numpre = @$numpre;
$pdf1->valtotal = db_formatar(@$valor_parm, 'f');
$pdf1->linhadigitavel = @$linhadigitavel;
$pdf1->linha_digitavel = @$linhadigitavel;
$pdf1->codigobarras = @$codigobarras;
$pdf1->codigo_barras = @$codigobarras;
$pdf1->tipo_exerc = @$tipo . "/" . @$exercv;
//$pdf1->nosso_numero          = $iNossoNumero;
$pdf1->descr12_1 = @$k00_descr . "\n\n" . @$histparcela . "\n\nCPF/CNPJ:" . @$z01_cgccpf;
$pdf1->data_processamento = date('d/m/Y', db_getsession('DB_datausu'));
$pdf1->desconto_abatimento = '0,00';
$pdf1->mora_multa = '0,00';
$pdf1->valor_cobrado = db_formatar(@$valor_parm, 'f');
$pdf1->texto = '';
if ($oRegraEmissao->isCobranca()) {
    $rsConsultaBanco = $cldb_bancos->sql_record($cldb_bancos->sql_query_file($oConvenio->getCodBanco()));
    $oBanco = db_utils::fieldsMemory($rsConsultaBanco, 0);
    $pdf1->numbanco = $oBanco->db90_codban . "-" . $oBanco->db90_digban;
    $pdf1->banco = $oBanco->db90_abrev;
    try {
        $pdf1->imagemlogo = $oConvenio->getImagemBanco();
    } catch (Exception $eExeption) {
        db_redireciona("db_erros.php?fechar=true&db_erro=" . $eExeption->getMessage());
    }
}
$pdf1->imprime();
$pdf1->objpdf->output();