require "libs/db_utils.php";
include "classes/db_protprocesso_classe.php";
include "classes/db_procandam_classe.php";
include "classes/db_proctransfer_classe.php";
include "classes/db_proctransferproc_classe.php";
include "classes/db_proctransand_classe.php";
include "classes/db_proctransferintand_classe.php";
include "classes/db_proctransferint_classe.php";
include "classes/db_procandamint_classe.php";
include "classes/db_procandamintand_classe.php";
include "classes/db_arqproc_classe.php";
include "classes/db_arqandam_classe.php";
include "dbforms/db_funcoes.php";
include "classes/db_protparam_classe.php";
//se $db21_usasisagua = 't' utiliza o modulo agua
db_sel_instit(null, "db21_usasisagua");
db_postmemory($HTTP_SERVER_VARS);
db_postmemory($HTTP_POST_VARS);
$utils = new db_utils();
$oPOST = $utils->postMemory($_POST);
$clprotprocesso = new cl_protprocesso();
$clprocandam = new cl_procandam();
$clproctransfer = new cl_proctransfer();
$clproctransferproc = new cl_proctransferproc();
$clproctransand = new cl_proctransand();
$clproctransferintand = new cl_proctransferintand();
$clproctransferint = new cl_proctransferint();
$clprocandamint = new cl_procandamint();
$clprocandamintand = new cl_procandamintand();
$clarqproc = new cl_arqproc();
$clarqandam = new cl_arqandam();
 $sqltermo = "select k40_forma\n                     from termo\n                          inner join cadtipoparc on k40_codigo = v07_desconto\n                    where v07_numpre = {$k00_numpre}";
 $resulttermo = db_query($sqltermo) or die($sqltermo);
 if (pg_numrows($resulttermo) > 0) {
     db_fieldsmemory($resulttermo, 0);
     if ($k40_forma == 2 and $k00_numpar == $k00_numtot) {
         $imprimircodbar = false;
     }
 }
 if ($imprimircodbar == true) {
     $pdf1->linha_digitavel = $linha_digitavel;
     $pdf1->codigo_barras = $codigo_barras;
 } else {
     $pdf1->linha_digitavel = null;
     $pdf1->codigo_barras = null;
 }
 db_sel_instit();
 $pdf1->enderpref = $ender;
 $pdf1->cgcpref = $cgc;
 $pdf1->numeropref = $numero;
 $pdf1->municpref = $munic;
 $pdf1->telefpref = $email;
 $pdf1->emailpref = $telef;
 @($pdf1->especie = @$especie);
 // VERIFICA SE É UM PARCELAMENTO COM DESCONTO, SE FOR MOSTRAR O DESCONTO NO CARNE.
 $sqlVerParcel = "select k00_numpre,k00_numpar,k00_receit,k00_valor,k00_dtvenc,k00_tipo,v07_totpar,k40_aplicacao\n                       from termo\n                       inner join arrecad     on v07_numpre = k00_numpre\n                       inner join cadtipoparc on k40_codigo = v07_desconto\n                       where k00_numpre = {$k00_numpre} and k00_numpar = {$k00_numpar}  ";
 //echo "<br> $sqlVerParcel <br>";
 $resultVerParcel = db_query($sqlVerParcel);
 $linhasVerParcel = pg_num_rows($resultVerParcel);
 if ($linhasVerParcel > 0) {
     db_fieldsmemory($resultVerParcel, 0);
     //calcula o desconto.