$tpl->PAGINA = $pagina;
foreach ($rsPartic as $key => $participante) {
    //$tpl->ID = $participante->id;
    //calcula o status dos pagamentos;
    $tpl->STATUS_ABAT = 'status-ok';
    $rsPag = $oP->getRows(0, 999, array("id" => "asc"), array("participante" => " = " . $participante->id, "cancelado" => "=0"));
    foreach ($rsPag as $key => $pagamento) {
        $totalAbatMoedaGrupo = $oA->totalAbatimentos($pagamento->id);
        $totalAbatMoedaPagamento = $pagamento->CALCULA_MOEDA($totalAbatMoedaGrupo, $participante->grupo->moeda->id);
        if ($totalAbatMoedaPagamento < $pagamento->valorPagamento && $pagamento->devolucao == 0) {
            $tpl->STATUS_ABAT = 'status-alert';
        }
    }
    $tpl->CIFRAO = $oGrupo->moeda->cifrao;
    $tpl->PAGO = $oParticipante->money($participante->recuperaValorPago(), "atb") . "/" . $oParticipante->money($participante->valorTotal, "atb");
    $tpl->RESTA = "Pendêndia: " . $oGrupo->moeda->cifrao . " " . $oParticipante->money($participante->valorTotal - $participante->recuperaValorPago(), "atb");
    $tpl->DT_INSCR = $participante->convdata($participante->dataInscricao, "mtn");
    $tpl->NOME = $participante->cliente->nomeCompleto;
    $tpl->OPCIONAL = $participante->pacoteOpcional ? "Sim" : "Não";
    $tpl->ID_CLIENTE_HASH = $oParticipante->md5_encrypt($participante->cliente->id);
    $tpl->CPF = $oParticipante->formataCPFCNPJ($participante->cliente->cpf);
    $tpl->SITUACAO = $participante->status->descricao;
    $tpl->ID_HASH = $oParticipante->md5_encrypt($participante->id);
    if ($participante->status->id != $oParticipante->STATUS_DESISTENTE()) {
        $tpl->block("BLOCK_ACTIONS");
    } else {
        $tpl->block("BLOCK_REATIVAR");
    }
    $tpl->block("BLOCK_ITEM_LISTA");
}
include "tupi.template.finalizar.php";
<?php

include "tupi.inicializar.php";
$codTemplate = 'template_envelope';
include "tupi.template.inicializar.php";
$codAcesso = 22;
include "tupi.seguranca.php";
//titulo do relatorio
$tpl->TITULO = "Envelopes de Participantes";
$opartic = new Participante();
$rs = $opartic->getRows(0, 999, array("id" => "asc"), array("grupo" => "=" . $opartic->md5_decrypt($_REQUEST['idGrupo']), "status" => "!=" . $opartic->STATUS_DESISTENTE()));
foreach ($rs as $key => $p) {
    $tpl->NOME_GRUPO = $p->grupo->nomePacote;
    $tpl->DATA_SAIDA = $p->convdata($p->grupo->dataEmbarque, "mtn");
    $tpl->DATA_CHEGADA = $p->convdata($p->grupo->dataChegada, "mtn");
    $sobrenome = explode(" ", $p->nomeFamilia());
    $tpl->SOBRENOME = $sobrenome[0];
    $tpl->NOME = $sobrenome[2];
    $tpl->DATA_NASC = $p->convdata($p->cliente->dataNascimento, "mtn");
    $tpl->CIDADE_NASC = $p->cliente->cidadeNascimento;
    $tpl->FONE1 = $p->cliente->telefoneResidencial;
    $tpl->FONE2 = $p->cliente->telefoneComercial;
    $tpl->FONE3 = $p->cliente->celular;
    $tpl->PASSAPORTE = $p->cliente->passaporte;
    $tpl->EXPEDICAO = $p->convdata($p->cliente->dataEmissaoPassaporte, "mtn");
    $tpl->VALIDADE = $p->convdata($p->cliente->dataValidadePassaporte, "mtn");
    $tpl->VALOR_TOTAL = $p->grupo->moeda->cifrao . " " . $p->money($p->valorTotal, "atb");
    $oAbat = new Abatimento();
    $rsAbats = $oAbat->getRows(0, 999, array(), array("participante" => "=" . $p->id));
    foreach ($rsAbats as $keyA => $abat) {
        $tpl->DATA_PAG = $abat->pagamento->dataPagamento;
 $valorDeposito = 0;
 $valorCreditoCliente = 0;
 $tpl->GRUPO = $grupo->nomePacote;
 $tpl->N_PARTICIPANTE = $oPartic->recuperaTotalAtivo($grupo->id);
 //PEGA OS CHEQUES
 $rsCheques = $oC->pesquisa($dataRelatorio, $dataFimRelatorio, "", 0, $grupo->id);
 //somatorio dos cheques
 foreach ($rsCheques as $key => $cheque) {
     $valorChequed += @($cheque->valor / $cheque->pagamento->cotacaoReal);
     $valorCheque += $cheque->valor;
 }
 //recupera os participantes
 $rsPartic = $oPartic->getRows(0, 999, array(), array("grupo" => "=" . $grupo->id));
 foreach ($rsPartic as $keyPart => $part) {
     //somatorios do custo
     if ($part->status->id != $oPartic->STATUS_DESISTENTE()) {
         if ($grupo->moeda->id == $om->DOLLAR()) {
             @($custoDollar += $part->custoTotal);
         } else {
             @($custoDollar += $part->custoTotal / $grupo->cotacaoCusto);
         }
     }
     //RECUPERA TODOS OS PAGAMENTOS DO GRUPO NO PERIODO
     $rsPgt = $oP->getRows(0, 999, array(), array("participante" => "=" . $part->id, "dataPagamento" => "between '" . $dataRelatorio . "' and '" . $dataFimRelatorio . "'", "cancelado" => "=0"));
     foreach ($rsPgt as $keyPag => $p) {
         switch ($p->tipo->id) {
             case $oTP->DINHEIRO():
                 //somatorios dos valores
                 $recebimentoDollar += @$p->CALCULA_DOLLAR();
                 $recebimentoReal += @$p->CALCULA_REAL();
                 $valorEspecie += $p->CALCULA_REAL();
<?php

include "tupi.inicializar.php";
$codTemplate = "relatorioHorizontal";
include "tupi.template.inicializar.php";
$codAcesso = 14;
include "tupi.seguranca.php";
$ogrupo = new Grupo();
$ogrupo->getById($ogrupo->md5_decrypt($_REQUEST['idGrupo']));
$tpl->COD_GRUPO = str_pad($ogrupo->id, 7, "0", STR_PAD_LEFT);
$tpl->NOME_GRUPO = $ogrupo->nomePacote;
$tpl->ID_GRUPO_HASH = $_REQUEST['idGrupo'];
//recupera participantes aprovados
$opartic = new Participante();
$rs = $opartic->getRows(0, 999, array("id" => "asc"), array("grupo" => "=" . $ogrupo->id, "status" => "!=" . $opartic->STATUS_DESISTENTE()));
$cont = 1;
foreach ($rs as $key => $p) {
    $tpl->ID = $cont;
    $tpl->NOME = $p->nomeFamilia();
    $tpl->DATA_NASCIMENTO = $opartic->convdata($p->cliente->dataNascimento, "mtn");
    $tpl->LOCAL_NASCIMENTO = $p->cliente->cidadeNascimento . "-" . $p->cliente->estadoNascimento;
    $tpl->NACIONALIDADE = $p->cliente->nacionalidade;
    $tpl->SEXO = $p->cliente->sexo == "M" ? "MASC" : "FEM";
    $tpl->PASSAPORTE = $p->cliente->passaporte;
    $tpl->DATA = $opartic->convdata($p->cliente->dataEmissaoPassaporte, "mtn");
    $tpl->ORGAO = $p->cliente->orgaoExpedidorPassaporte;
    $tpl->VALIDADE = $opartic->convdata($p->cliente->dataValidadePassaporte, "mtn");
    $tpl->block("BLOCK_ITEM_LISTA");
    $cont++;
}
if (!isset($_REQUEST['tupiSendEmail'])) {
<?php

include "tupi.inicializar.php";
$codTemplate = "relatorioHorizontal";
include "tupi.template.inicializar.php";
$codAcesso = 18;
include "tupi.seguranca.php";
$ogrupo = new Grupo();
$ogrupo->getById($ogrupo->md5_decrypt($_REQUEST['idGrupo']));
$tpl->COD_GRUPO = str_pad($ogrupo->id, 7, "0", STR_PAD_LEFT);
$tpl->NOME_GRUPO = $ogrupo->nomePacote;
$tpl->ID_GRUPO_HASH = $_REQUEST['idGrupo'];
$tpl->DATA_RELATORIO = "Data/Hora:" . date("d/m/Y h:i:s");
//recupera participantes aprovados
$opartic = new Participante();
$rs = $opartic->relatListaParticipante($ogrupo->id, $opartic->STATUS_DESISTENTE());
$cont = 1;
foreach ($rs as $key => $p) {
    $tpl->NUMERO = $cont;
    $tpl->NOME = $p->cliente->nomeCompleto;
    $tpl->IDENTIDADE = $p->cliente->rg . "-" . $p->cliente->orgaoEmissorRg;
    $tpl->CPF = $p->cliente->cpf;
    $tsdata = strtotime($p->cliente->dataNascimento);
    $tpl->DATA_NASCIMENTO = date("d/m/Y", $tsdata);
    $tpl->block("BLOCK_ITEM_LISTA");
    $cont++;
}
if (!isset($_REQUEST['tupiSendEmail'])) {
    $tpl->block("BLOCK_ENVIO_EMAIL");
}
include "tupi.template.finalizar.php";
$om = new Moeda();
$oP = new Pagamento();
$oTP = new TipoPagamento();
$oTT = new TipoTransferencia();
$oG = new Grupo();
$oPartic = new Participante();
$oF = new FinalidadePagamento();
$oC = new Credito();
$oG->getById($oG->md5_decrypt($_REQUEST['idGrupo']));
$totalRecebDollar = 0;
$totalRecebReal = 0;
$totalDevolucaoDollar = 0;
$totalDevolucaoReal = 0;
$qtdParticipante = 0;
//recupera os participantes
$rsPartic = $oPartic->getRows(0, 999, array(), array("grupo" => "=" . $oG->id, "status" => "=" . $oPartic->STATUS_DESISTENTE()));
foreach ($rsPartic as $keyPart => $part) {
    $qtdParticipante++;
    $RecebDollar = 0;
    $RecebReal = 0;
    $CanceladoDollar = 0;
    $CanceladoReal = 0;
    $CreditoDollar = 0;
    $CreditoReal = 0;
    //RECUPERA TODOS OS PAGAMENTOS CANCELADOS DO PARTICIPANTE
    $rsPgt = $oP->getRows(0, 999, array(), array("participante" => "=" . $part->id, "cancelado" => "=1"));
    foreach ($rsPgt as $keyPag => $p) {
        $RecebDollar += $p->CALCULA_DOLLAR();
        $RecebReal += $p->CALCULA_REAL();
    }
    //recupera os pagamentos de cancelamento do participante
<?php

include "tupi.inicializar.php";
$codTemplate = "relatorioHorizontal";
include "tupi.template.inicializar.php";
$codAcesso = 18;
include "tupi.seguranca.php";
$ogrupo = new Grupo();
$ogrupo->getById($ogrupo->md5_decrypt($_REQUEST['idGrupo']));
$tpl->COD_GRUPO = str_pad($ogrupo->id, 7, "0", STR_PAD_LEFT);
$tpl->NOME_GRUPO = $ogrupo->nomePacote;
$tpl->ID_GRUPO_HASH = $_REQUEST['idGrupo'];
$tpl->DATA_RELATORIO = "Data/Hora:" . date("d/m/Y h:i:s");
//recupera participantes aprovados
$opartic = new Participante();
$rs = $opartic->relatListaSaude($ogrupo->id, $opartic->STATUS_DESISTENTE());
$cont = 1;
foreach ($rs as $key => $p) {
    $tpl->NUMERO = $cont;
    $tpl->NOME = $p->cliente->nomeCompleto;
    $tpl->ALIMENTO = $p->cliente->restricaoAlimentar;
    $tpl->SAUDE = $p->cliente->problemasSaude;
    $tpl->block("BLOCK_ITEM_LISTA");
    $cont++;
}
if (!isset($_REQUEST['tupiSendEmail'])) {
    $tpl->block("BLOCK_ENVIO_EMAIL");
}
include "tupi.template.finalizar.php";
$oTT = new TipoTransferencia();
$oG = new Grupo();
$oPartic = new Participante();
$oF = new FinalidadePagamento();
$oC = new Credito();
$dataRelatorio = $om->convdata($_REQUEST['dataInicio'], "ntm");
$dataFimRelatorio = $om->convdata($_REQUEST['dataFim'], "ntm");
$rsGrupo = $oG->gruposComDesistentesPeriodo($dataRelatorio, $dataFimRelatorio);
$totalRecebDollar = 0;
$totalRecebReal = 0;
$totalDevolucaoDollar = 0;
$totalDevolucaoReal = 0;
$qtdParticipante = 0;
foreach ($rsGrupo as $key => $grupo) {
    //recupera os participantes
    $rsPartic = $oPartic->getRows(0, 999, array(), array("grupo" => "=" . $grupo->id, "status" => "=" . $oPartic->STATUS_DESISTENTE(), "dataInscricao" => "between '" . $dataRelatorio . "' and '" . $dataFimRelatorio . "'"));
    foreach ($rsPartic as $keyPart => $part) {
        $qtdParticipante++;
        $RecebDollar = 0;
        $RecebReal = 0;
        $CanceladoDollar = 0;
        $CanceladoReal = 0;
        $CreditoDollar = 0;
        $CreditoReal = 0;
        //RECUPERA TODOS OS PAGAMENTOS CANCELADOS DO PARTICIPANTE
        $rsPgt = $oP->getRows(0, 999, array(), array("participante" => "=" . $part->id, "cancelado" => "=1"));
        foreach ($rsPgt as $keyPag => $p) {
            $RecebDollar += $p->CALCULA_DOLLAR();
            $RecebReal += $p->CALCULA_REAL();
        }
        //recupera os pagamentos de cancelamento do participante