function alterarAbatimento()
 {
     $idPagamento = $this->md5_decrypt($_REQUEST['idPagamento']);
     $oPag = new Pagamento();
     $om = new Moeda();
     $oTipoP = new TipoPagamento();
     $oPag->getById($idPagamento);
     $this->getById($_REQUEST['id']);
     $valor = $this->money($_REQUEST['valor'], "bta");
     $oPartic = new Participante();
     $oPartic->getById($_REQUEST['participante']);
     $idMoedaGrupo = $oPag->participante->grupo->moeda->id;
     if ($idMoedaGrupo == $om->DOLLAR()) {
         $valorNovo = $oPag->CALCULA_DOLLAR($valor);
     } else {
         $valorNovo = $oPag->CALCULA_REAL($valor);
     }
     //validacao
     if ($idMoedaGrupo == $om->DOLLAR()) {
         $valorMaximo = $oPag->CALCULA_DOLLAR();
     } else {
         $valorMaximo = $oPag->CALCULA_REAL();
     }
     $total = $this->totalAbatimentos($idPagamento);
     $total = $total - $this->valor;
     if ($oTipoP->CARTAO() == $oPag->tipo->id && $oPag->codAutorizacao != "") {
         $_SESSION['tupi.mensagem'] = 61;
         header("Location:participante.abatimentos.php?idPagamento=" . $_REQUEST['idPagamento']);
         exit;
     }
     if (number_format($total + $valorNovo, 2, ".", "") > number_format($valorMaximo, 2, ".", "")) {
         $_SESSION['tupi.mensagem'] = 40;
         header("Location:participante.abatimentos.php?idPagamento=" . $_REQUEST['idPagamento']);
         exit;
     }
     //configurando o objeto
     $this->valor = $valorNovo;
     $this->pagamento = $oPag;
     $this->participante = $oPartic;
     $idAbatimento = $this->save();
     //FAZ A CONFERENCIA PARA MUDAR O STATUS DO PARTICIPANTE
     $oPartic->atualiza_status();
     $_SESSION['tupi.mensagem'] = 42;
 }
$tpl->ID_PARTICIPANTE_REP = $_REQUEST['idParticipante'];
$tpl->ID_TIPO = $_REQUEST['idTipo'];
$idMoedaEdita = 0;
$idBancoEdita = 0;
$idBandeiraEdita = 0;
$idTipoTransf = 0;
$idCredito = 0;
$tpl->CAMBIO_DOLLAR_REAL = 0;
$tpl->COD_AUTORIZACAO = "";
$tpl->DATA_COMPENSACAO = "";
$tpl->NUMERO_CHEQUE = "";
$tpl->CAMBIO_MOEDA_REAL = 0;

$tpl->NOME_EMISSOR = $oParticipante->cliente->nomeCompleto."-".$oParticipante->cliente->id;
if(isset($_REQUEST['idPagamento']) && strlen($_REQUEST['idPagamento']) > 0){
$oPag->getById($_REQUEST['idPagamento']);
$idMoedaEdita = $oPag->moeda->id;	
$tpl->ID = $_REQUEST['idPagamento'];
}

switch($_REQUEST['idTipo']){
case $oTipoP->DINHEIRO() :
	$rsm = $oMoeda->getRows();

	foreach($rsm as $key => $row){
		$tpl->ID_MOEDA = $row->id;
		$tpl->LABEL_MOEDA = $row->descricao;
		if(	$idMoedaEdita == $row->id)		
			$tpl->SELECTED_MOEDA = 'selected="selected"';
		$tpl->block("BLOCK_MOEDA");
		$tpl->clear("SELECTED_MOEDA");
<?php

include "tupi.inicializar.php";
$codTemplate = "relatorio";
include "tupi.template.inicializar.php";
$codAcesso = 13;
include "tupi.seguranca.php";
$pag = new Pagamento();
$cheque = new Cheque();
$moeda = new Moeda();
$pag->getById($pag->md5_decrypt($_REQUEST['idPagamento']));
$cliente = $pag->participante->cliente;
$grupo = $pag->participante->grupo;
$moeda = $pag->moeda;
$oTipoP = new TipoPagamento();
if ($cliente->sexo == "F") {
    $tpl->ARTIGO = "a";
    $tpl->SENHOR = "Sra.";
} else {
    $tpl->ARTIGO = "o";
    $tpl->SENHOR = "Sr.";
}
$tpl->NUMERO = str_pad($pag->id, 6, "0", STR_PAD_LEFT);
$tpl->NOME_COMPLETO = $cliente->nomeCompleto;
$tpl->VALOR = $pag->money($pag->CALCULA_REAL(), "atb");
//$velhos = array("Reais", "REAIS", "REAL", "Real");
//$novos   = array($moeda->plural, strtoupper($moeda->plural), strtoupper($moeda->descricao),$moeda->descricao);
$extenso = $pag->extenso($pag->money($pag->CALCULA_REAL(), "atb"), true);
$tpl->VALOR_EXTENSO = $extenso;
$tpl->REFERENTE = $pag->obs;
$tpl->FINALIDADE = $pag->finalidade->descricao;
<?php

include "tupi.inicializar.php";
include "tupi.template.inicializar.php";
$codAcesso = 13;
include "tupi.seguranca.php";
$oMoeda = new Moeda();
$oPagamento = new Pagamento();
$oParticipante = new Participante();
$oGrupo = new Grupo();
$idPagamento = $oPagamento->md5_decrypt($_REQUEST['idPagamento']);
$oPagamento->getById($idPagamento);
$nomeGrupo = $oPagamento->participante->grupo->nomePacote;
$idGrupo = $oPagamento->md5_encrypt($oPagamento->participante->grupo->id);
$idParticHash = $oPagamento->md5_encrypt($oPagamento->participante->id);
$valorPagamento = $oPagamento->valorPagamento;
$idPartic = 0;
$idGrupo = 0;
$ano = 0;
if (!isset($_REQUEST['ajax'])) {
    $tpl->BREADCRUMB = '    <ul class="breadcrumb">
    <li>
    <a href="home.php">Home</a> <span class="divider">/</span>
    </li>
    <li>
    <a href="grupos.andamento.php">Grupos</a> <span class="divider">/</span>
    </li>
	<li>
    <a href="participante.lista.php?idGrupo=' . $idGrupo . '">Participantes</a> <span class="divider">/</span>
    </li>
	<li>
 if ($oGrupo->moeda->id == $oMoeda->DOLLAR()) {
     $custoDollar = $custo;
     $custoReal = $custo * $oGrupo->cotacaoCusto;
 } else {
     $custoDollar = $custo / $cotCustpo;
     $custoReal = $custo;
 }
 //busca os abatimentos do participante
 $rsAbat = $oAbatimento->getRows(0, 9999, array(), array("participante" => "=" . $p->id));
 $contPag = 0;
 $totalAbatParticipanteReal = 0;
 $totalAbatParticipanteDollar = 0;
 foreach ($rsAbat as $keyAbat => $abat) {
     $contPag++;
     //busca o pagamento ativo do participante
     $oPagamento->getById($abat->pagamento->id);
     //somatorios dos valores
     switch ($oPagamento->tipo->id) {
         case $oTP->DINHEIRO():
             $TOTAL_ESPECIE += $abat->getValorReal();
             break;
         case $oTP->CARTAO():
             $TOTAL_CARTAO += $abat->getValorReal();
             break;
         case $oTP->DEBITO():
             $TOTAL_DEBITO += $abat->getValorReal();
             break;
         case $oTP->CHEQUE():
             $TOTAL_CHEQUE += $abat->getValorReal();
             break;
         case $oTP->CREDITO():