<?php include "tupi.inicializar.php"; $codTemplate = "relatorio"; include "tupi.template.inicializar.php"; $codAcesso = 16; include "tupi.seguranca.php"; //titulo do relatorio $tpl->TITULO = "Relatório de Pagamentos de Participantes"; $tpl->DATA_RELATORIO = "Data/Hora:" . date("d/m/Y h:i:s"); $ogrupo = new Grupo(); $om = new Moeda(); $oAbat = new Abatimento(); $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->VALOR_GRUPO = $ogrupo->money($ogrupo->getValorTotal(0), "atb"); $tpl->CIFRAO_GRUPO = $ogrupo->moeda->cifrao; $tpl->MOEDA_GRUPO_PLURAL = $ogrupo->moeda->plural; //$tpl->DATA_ATUAL = date("d/m/Y"); //pacote opcional if ($ogrupo->possuiPacoteOpcional == 1) { $tpl->NOME_GRUPO_OPCIONAL = $ogrupo->nomePacoteOpcional; $tpl->VALOR_GRUPO_OPCIONAL = $ogrupo->money($ogrupo->getValorTotalOpcional(), "atb"); $tpl->block("BLOCK_OPCIONAL"); } if ($ogrupo->moeda->id == $om->DOLLAR()) { $tpl->block("BLOCK_GRUPO_DOLLAR_HEAD"); } //recupera participantes aprovados $opartic = new Participante();
</li> <li> <a href="grupos.andamento.php">Grupos</a> <span class="divider">/</span> </li> <li class="active">Lista de Participantes</li> </ul>'; } //configura o grupo na pagina $oGrupo = new Grupo(); $idGrupo = $oGrupo->md5_decrypt($_REQUEST['idGrupo']); $oGrupo->getById($idGrupo); $tpl->NOME_GRUPO = $oGrupo->nomePacote; $tpl->ID_GRUPO_HASH = $_REQUEST['idGrupo']; $oP = new Pagamento(); $oA = new Abatimento(); $oParticipante = new Participante(); $strBusca = isset($_REQUEST['busca']) ? str_replace(".", "", str_replace("-", "", $_REQUEST['busca'])) : ""; $totalParticipantes = $oParticipante->recuperaTotal($idGrupo, $strBusca); $pagina = isset($_REQUEST['pagina']) ? $_REQUEST['pagina'] : 1; $configPaginacao = $oParticipante->paginar($totalParticipantes, $pagina); $rsPartic = $oParticipante->pesquisa($configPaginacao['primeiroRegistro'], $configPaginacao['quantidadePorPagina'], $idGrupo, $strBusca); $tpl->MODELO_CONTRATO = $oGrupo->modeloContrato; $tpl->MODELO_FICHA = $oGrupo->modeloFicha; if ($configPaginacao['totalPaginas'] > 1) { $tpl->block("BLOCK_PAGINACAO"); } $tpl->TOTAL_PAGINAS = $configPaginacao['totalPaginas']; $tpl->PAGINA_ANTERIOR = $configPaginacao['paginaAnterior']; $tpl->PROXIMA_PAGINA = $configPaginacao['proximaPagina']; $tpl->PAGINA = $pagina;
<li> <a href="participante.abatimentos.php?idPagamento=' . $_REQUEST['idPagamento'] . '">Abatimentos</a> <span class="divider">/</span> </li> <li class="active">Editar Abatimento</li> </ul>'; } $tpl->NOME_GRUPO = $nomeGrupo; $tpl->MOEDA_GRUPO = $oPagamento->participante->grupo->moeda->descricao; $tpl->VALOR_TOTAL_PAG = $oPagamento->moeda->cifrao . " " . $oPagamento->money($valorPagamento, "atb"); $tpl->MOEDA_PAG = $oPagamento->moeda->descricao; //$tpl->CIFRAO_PAG = $oPagamento->moeda->cifrao; $tpl->ID_PAGAMENTO_HASH = $_REQUEST['idPagamento']; $tpl->ACAO = 'IncluirAbatimento'; //carrega dados do pagamento if (isset($_REQUEST['idAbatimento'])) { $oAbat = new Abatimento(); $oAbat->getById($oAbat->md5_decrypt($_REQUEST['idAbatimento'])); $tpl->ACAO = 'AlterarAbatimento'; $idPartic = $oAbat->participante->id; $idGrupo = $oAbat->participante->grupo->id; $ano = $oAbat->participante->grupo->ano; $tpl->VALOR_ABATIMENTO = $oAbat->money($oAbat->valor, "atb"); $tpl->ID = $oAbat->id; $rsPartic = $oParticipante->getRows(0, 999, array("id" => "asc"), array("grupo" => " = " . $idGrupo)); foreach ($rsPartic as $key => $partic) { $tpl->ID_PARTICIPANTE = $partic->id; $tpl->LABEL_PARTICIPANTE = $partic->cliente->nomeCompleto; if ($idPartic == $partic->id) { $tpl->SELECTED_PARTICIPANTE = "selected"; } $tpl->block("BLOCK_PARTICIPANTE");
<?php include "tupi.inicializar.php"; $codTemplate = "relatorioHorizontal"; include "tupi.template.inicializar.php"; $codAcesso = 38; include "tupi.seguranca.php"; $oGrupo = new Grupo(); $oMoeda = new Moeda(); $oPagamento = new Pagamento(); $oAbatimento = new Abatimento(); $oTP = new TipoPagamento(); $oTT = new TipoTransferencia(); $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->DATA_RELATORIO = "Data/Hora:" . date("d/m/Y h:i:s"); //recupera participantes aprovados $opartic = new Participante(); $rs = $opartic->getRows(0, 999, array("id" => "asc"), array("grupo" => "=" . $oGrupo->id)); $cont = 1; foreach ($rs as $key => $p) { $tpl->ID = $cont; $tpl->PARTICIPANTE = $p->cliente->nomeCompleto; $tpl->STATUS = $p->status->descricao; //calcula custo: $custo = $p->custoTotal; if ($oGrupo->moeda->id == $oMoeda->DOLLAR()) { $custoDollar = $custo; $custoReal = $custo * $oGrupo->cotacaoCusto; } else {
function incluirPagamento() { $oPartic = new Participante(); $oPartic->getById($this->md5_decrypt($_REQUEST['idParticipante'])); $oTipoP = new TipoPagamento(); $oFin = new FinalidadePagamento(); $oFin->id = $_REQUEST['finalidade']; $oTipoP->getById($_REQUEST['tipo']); $om = new Moeda(); $om->getById($_REQUEST['moeda']); $this->dataPagamento = $this->convdata($_REQUEST['dataPagamento'], "ntm"); $this->obs = $_REQUEST['obs']; $this->abatimentoAutomatico = isset($_REQUEST['abatimentoAutomatico']) ? 1 : 0; $this->moeda = $om; $this->participante = $oPartic; $this->tipo = $oTipoP; $this->finalidade = $oFin; $this->cancelado = 0; $this->devolucao = $_REQUEST['dev']; $this->valorParcela = 0; switch ($_REQUEST['tipo']) { case $oTipoP->DINHEIRO(): $this->valorPagamento = $this->money($_REQUEST['valorPagamento'], "bta"); $this->cotacaoMoedaReal = isset($_REQUEST['cotacaoMoedaReal']) ? $_REQUEST['cotacaoMoedaReal'] != "" ? $this->money($_REQUEST['cotacaoMoedaReal'], "bta") : 0 : 0; $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->parcela = 1; break; case $oTipoP->CARTAO(): $this->valorPagamento = $this->money($_REQUEST['valorPagamento'], "bta"); $this->valorParcela = $this->money($_REQUEST['valorParcela'], "bta"); $this->cotacaoMoedaReal = 0; $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->codAutorizacao = isset($_REQUEST['codAutorizacao']) ? $_REQUEST['codAutorizacao'] : ""; $this->parcela = $_REQUEST['parcelaCartao']; $oband = new BandeiraCartao(); $oband->id = $_REQUEST['bandeira']; $this->bandeira = $oband; break; case $oTipoP->DEBITO(): $this->cotacaoMoedaReal = 0; $this->codAutorizacao = isset($_REQUEST['codAutorizacao']) ? $_REQUEST['codAutorizacao'] : ""; $this->valorPagamento = $this->money($_REQUEST['valorPagamento'], "bta"); $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->parcela = 1; $oband = new BandeiraCartao(); $oband->id = $_REQUEST['bandeira']; $this->bandeira = $oband; break; case $oTipoP->CHEQUE(): $ob = new Banco(); $ob->id = $_REQUEST['banco']; $this->banco = $ob; $Status = new StatusCheque(); $Status->id = 1; $oclienteEmissor = new Cliente(); $arrayEmissor = explode("-", $_REQUEST['nomeEmissor']); if (count($arrayEmissor) > 1) { $oclienteEmissor->id = $arrayEmissor[1]; } else { $oec = new EstadoCivil(); $oec->id = 1; $oclienteEmissor->nomeCompleto = $_REQUEST['nomeEmissor']; $oclienteEmissor->oclienteEmissor->cpf = ""; $oclienteEmissor->estadoCivil = $oec; $oclienteEmissor->dataNascimento = date("Y-m-d"); $oclienteEmissor->sexo = ""; $oclienteEmissor->endereco = ""; $oclienteEmissor->bairro = ""; $oclienteEmissor->cep = ""; $oclienteEmissor->telefoneResidencial = ""; $oclienteEmissor->telefoneComercial = ""; $oclienteEmissor->celular = ""; $oclienteEmissor->fax = ""; $oclienteEmissor->rg = ""; $oclienteEmissor->orgaoEmissorRg = ""; $oclienteEmissor->passaporte = ""; $oclienteEmissor->nomeCracha = ""; $oclienteEmissor->tamanhoCamisa = ""; $oclienteEmissor->problemasSaude = ""; $oclienteEmissor->restricaoAlimentar = ""; $oclienteEmissor->email = ""; $oclienteEmissor->nacionalidade = ""; $oclienteEmissor->cidadeEndereco = ""; $oclienteEmissor->estadoEndereco = ""; $oclienteEmissor->paisEndereco = ""; $oclienteEmissor->cidadeNascimento = ""; $oclienteEmissor->paisNascimento = ""; $oclienteEmissor->estadoNascimento = ""; $oclienteEmissor->preferencial = 0; $oclienteEmissor->enviaCorrespondencia = 0; $oclienteEmissor->save(); } $this->parcela = 1; $this->emissorCheque = $oclienteEmissor; $this->numeroCheque = isset($_REQUEST['numeroCheque1']) ? $_REQUEST['numeroCheque1'] : ""; $this->dataCompensacao = isset($_REQUEST['dataCompensacao1']) ? $this->convdata($_REQUEST['dataCompensacao1'], "ntm") : ''; $this->valorPagamento = $this->money($_REQUEST['valorCheque1'], "bta"); $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; break; case $oTipoP->BANCO(): $ott = new TipoTransferencia(); $ott->id = $_REQUEST['tipoTranferencia']; $this->tipoTransferencia = $ott; $this->valorPagamento = $this->money($_REQUEST['valorPagamento'], "bta"); $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; $this->parcela = 1; break; case $oTipoP->CREDITO(): //atualizar o credito para utilizado $oCredito = new Credito(); $oCredito->getById($_REQUEST['credito']); $oCredito->bitUtilizado = 1; $oCredito->save(); $this->valorPagamento = $oCredito->valor; $this->moeda = $oCredito->moeda; $this->creditoCliente = $oCredito; $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; $this->parcela = 1; break; case $oTipoP->CARNE(): $this->parcela = 1; $this->dataCompensacao = isset($_REQUEST['dataVencimento1']) ? $this->convdata($_REQUEST['dataVencimento1'], "ntm") : ''; $this->valorPagamento = $this->money($_REQUEST['valorCarne1'], "bta"); $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; break; } $idPagamento = $this->save(); //cheques if ($oTipoP->CHEQUE() == $_REQUEST['tipo']) { $parcelas = 0; $valorTotal = 0; for ($i = 1; $i <= 10; $i++) { if ($_REQUEST['dataCompensacao' . $i] != "" && $_REQUEST['numeroCheque' . $i] != "" && $_REQUEST['valorCheque' . $i] != "") { //inclui o cheque $parcelas++; $oCheque = new Cheque(); $oCheque->status = $Status; $oCheque->emissor = $oclienteEmissor; $oCheque->numeroCheque = $_REQUEST['numeroCheque' . $i]; $oCheque->valor = $ob->money($_REQUEST['valorCheque' . $i], "bta"); $oCheque->pagamento = $this; $oCheque->dataCompensacao = $ob->convdata($_REQUEST['dataCompensacao' . $i], "ntm"); $oCheque->parcela = $i; $oCheque->save(); $valorTotal += $oCheque->valor; } } $this->parcela = $parcelas; $this->emissorCheque = $oclienteEmissor; $this->numeroCheque = isset($_REQUEST['numeroCheque1']) ? $_REQUEST['numeroCheque1'] : ""; $this->dataCompensacao = isset($_REQUEST['dataCompensacao1']) ? $this->convdata($_REQUEST['dataCompensacao1'], "ntm") : ''; $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; $this->valorPagamento = $valorTotal; $this->save(); } //carnes if ($oTipoP->CARNE() == $_REQUEST['tipo']) { $parcelas = 0; $valorTotal = 0; for ($i = 1; $i <= $_REQUEST['parcelaCarne']; $i++) { if ($_REQUEST['dataVencimento' . $i] != "" && $_REQUEST['valorCarne' . $i] != "") { //inclui o cheque $parcelas++; $oCarne = new Carne(); $oCarne->valor = $oCarne->money($_REQUEST['valorCarne' . $i], "bta"); $oCarne->pagamento = $this; $oCarne->dataVencimento = $oCarne->convdata($_REQUEST['dataVencimento' . $i], "ntm"); $oCarne->parcela = $i; $oCarne->save(); $valorTotal += $oCarne->valor; } } $this->parcela = $parcelas; $this->dataCompensacao = isset($_REQUEST['dataVencimento1']) ? $this->convdata($_REQUEST['dataVencimento1'], "ntm") : ''; $this->cotacaoReal = $this->money($_REQUEST['cotacaoReal'], "bta"); $this->cotacaoMoedaReal = 0; $this->valorPagamento = $valorTotal; $this->save(); } //REALIZA O ABATIMENTO AUTOMATICO DO PARTICIPANTE if ($this->abatimentoAutomatico == 1) { if ($oTipoP->CARTAO() == $_REQUEST['tipo'] && $this->codAutorizacao != "" || $oTipoP->CARTAO() != $_REQUEST['tipo']) { $oG = new Grupo(); $oG->getById($this->md5_decrypt($_REQUEST['idGrupo'])); $oAbat = new Abatimento(); if ($oG->moeda->id == $om->DOLLAR()) { $oAbat->valor = $this->devolucao == 0 ? $this->CALCULA_DOLLAR() : -$this->CALCULA_DOLLAR(); } else { $oAbat->valor = $this->devolucao == 0 ? $this->CALCULA_REAL() : -$this->CALCULA_REAL(); } $oAbat->participante = $oPartic; $oAbat->pagamento = $this; $oAbat->save(); } } //FAZ A CONFERENCIA PARA MUDAR O STATUS DO PARTICIPANTE $oPartic->atualiza_status(); //grava log de pagamento $oLog = new LogUsuario(); $usuario = new Usuario(); $usuario->id = $_SESSION['ag_idUsuario']; $data = date("Y-m-d H:i:s"); $movimento = "INCLUIR PAGAMENTO<BR> MOEDA: " . $this->moeda->descricao . "<BR> VALOR: " . $this->money($this->valorPagamento, "atb") . "<BR> TIPO: " . $this->tipo->descricao . "<BR> CLIENTE: " . $this->participante->cliente->nomeCompleto . "<BR> GRUPO: " . $this->participante->grupo->nomePacote; $oLog->usuario = $usuario; $oLog->data = $data; $oLog->movimento = $movimento; $oLog->save(); //fim da log $_SESSION['tupi.mensagem'] = 36; return $idPagamento; }
<?php include "tupi.inicializar.php"; $codAcesso = 13; include "tupi.seguranca.php"; //classes $oParticipante = new Participante(); $oPagamento = new Pagamento(); $oAbatimento = new Abatimento(); //inclusao de perfil if (isset($_REQUEST['acao'])) { if ($_REQUEST['acao'] == "Incluir") { $oParticipante->incluir(); header("Location:participante.lista.php?idGrupo=" . $_REQUEST['idGrupo']); } if ($_REQUEST['acao'] == "IncluirPorId") { $oParticipante->incluirPorId(); header("Location:participante.lista.php?idGrupo=" . $_REQUEST['idGrupo']); } if ($_REQUEST['acao'] == "Cancelar") { $oParticipante->cancelar(); header("Location:participante.lista.php?idGrupo=" . $_REQUEST['idGrupo']); } if ($_REQUEST['acao'] == "Excluir") { $oParticipante->excluir(); header("Location:participante.lista.php?idGrupo=" . $_REQUEST['idGrupo']); } if ($_REQUEST['acao'] == "Editar") { $oParticipante->editar(); header("Location:participante.lista.php?idGrupo=" . $_REQUEST['idGrupo']); }
function recuperaValorTodosAbatimentos($idMoeda) { $oPagamento = new Pagamento(); $oAbatimento = new Abatimento(); $om = new Moeda(); $total = 0; $rs = $oAbatimento->getRows(0, 999, array(), array("participante" => "=" . $this->id)); foreach ($rs as $key => $abat) { if ($idMoeda == $om->DOLLAR()) { $total += $abat->getValorDollar(); } else { $total += $abat->getValorReal(); } } return $total; }