recuperaPeriodoMovimentacao($rsPeriodoMovimentacao,$stFiltro); if ( $rsPeriodoMovimentacao->getNumLinhas() > 0 ) { $obTPessoalContrato = new TPessoalContrato; $stFiltro = " WHERE registro = ".$_GET["inRegistro"]; $obTPessoalContrato->recuperaTodos($rsContrato,$stFiltro); $obTFolhaPagamentoRegistroEventoDecimo = new TFolhaPagamentoRegistroEventoDecimo; $stFiltro = " AND cod_contrato = ".$rsContrato->getCampo("cod_contrato"); $stFiltro .= " AND cod_periodo_movimentacao = ".$rsPeriodoMovimentacao->getCampo("cod_periodo_movimentacao"); $stFiltro .= " AND natureza != 'B'"; $stOrdem = " descricao"; $obTFolhaPagamentoRegistroEventoDecimo->recuperaRelacionamento($rsEventos,$stFiltro,$stOrdem); if ( $rsEventos->getNumLinhas() > 0 ) { $rsEventos->addFormatacao("valor","NUMERIC_BR"); $rsEventos->addFormatacao("quantidade","NUMERIC_BR"); //retira a formatacao do campo 'quantidade' para que possa imprimir na forma quantidade/total_de_parcelas while (!$rsEventos->eof()) { $arRegistro = $rsEventos->getObjeto(); if (array_key_exists('parcela', $arRegistro) and $arRegistro['parcela'] != '') { $arRegistro['quantidade'] = number_format($rsEventos->getCampo('quantidade')).'/'.$rsEventos->getCampo('parcela'); } $arEventos[] = $arRegistro; $rsEventos->proximo(); } $rsEventos->addFormatacao("quantidade",""); $rsEventos->preenche($arEventos); $obLista = new Lista; $obLista->setTitulo("Eventos Cadastrados"); $obLista->setRecordSet( $rsEventos ); $obLista->setMostraPaginacao( false ); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo(" "); $obLista->ultimoCabecalho->setWidth( 5 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Código"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Evento"); $obLista->ultimoCabecalho->setWidth( 30 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Desdobramento"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Valor"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Quantidade"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Automático"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "codigo" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("ESQUERDA"); $obLista->ultimoDado->setCampo( "descricao" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("ESQUERDA"); $obLista->ultimoDado->setCampo( "desdobramento_texto" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "valor" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "quantidade" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("CENTRO"); $obLista->ultimoDado->setCampo( "automatico" ); $obLista->commitDado(); $obLista->montaHTML(); $stHtml = $obLista->getHTML(); $stHtml = str_replace("\n","",$stHtml); $stHtml = str_replace(" ","",$stHtml); $stHtml = str_replace("'","\\'",$stHtml); $stJs .= "d.getElementById('spnEventosCadastrados').innerHTML = '".$stHtml."'; \n"; $stJs .= gerarSpanEventosBase($arEventos,$rsContrato->getCampo("cod_contrato"),$rsPeriodoMovimentacao->getCampo("cod_periodo_movimentacao")); } } return $stJs; } function gerarSpanEventosBase($arEventos,$inCodContrato,$inCodPeriodoMovimentacao) { include_once(CAM_GRH_FOL_MAPEAMENTO."TFolhaPagamentoEventoBase.class.php"); include_once(CAM_GRH_FOL_MAPEAMENTO."TFolhaPagamentoEvento.class.php"); $rsEventosBase = new Recordset; $obTFolhaPagamentoEvento = new TFolhaPagamentoEvento; foreach ($arEventos as $arEvento) { $stCodEventos .= $arEvento['cod_evento'].","; } if ($stCodEventos != "") { $stCodEventos = substr($stCodEventos,0,strlen($stCodEventos)-1); $stFiltro = " AND evento_base.cod_evento IN ($stCodEventos)"; $stFiltro .= " AND evento_base.cod_configuracao = 3"; $stFiltro .= " AND registro_evento_decimo.cod_contrato = $inCodContrato"; $stFiltro .= " AND registro_evento_decimo.cod_periodo_movimentacao = $inCodPeriodoMovimentacao"; $obTFolhaPagamentoEventoBase = new TFolhaPagamentoEventoBase; $obTFolhaPagamentoEventoBase->recuperaEventoBaseDesdobramentoDecimo($rsEventosBase,$stFiltro); } if ( $rsEventosBase->getNumLinhas() > 0 ) { $arEventosBase = $rsEventosBase->getElementos(); foreach ($arEventosBase as $inIndex=>$arEventoBase) { $arEventoBase['descricao'] = trim($arEventoBase['descricao']); $arEventoBase['desdobramento_texto'] = trim($arEventoBase['desdobramento_texto']); $arEventoBase['valor'] = '0,00'; $arEventoBase['quantidade'] = '0,00'; $arEventoBase['automatico'] = 'Sim'; $arEventosBase[$inIndex] = $arEventoBase; } $rsEventosBase = new Recordset; $rsEventosBase->preenche($arEventosBase); $obLista = new Lista; $obLista->setTitulo("Base de Cálculo"); $obLista->setRecordSet( $rsEventosBase ); $obLista->setMostraPaginacao( false ); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo(" "); $obLista->ultimoCabecalho->setWidth( 5 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Código"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Evento"); $obLista->ultimoCabecalho->setWidth( 30 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Desdobramento"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Valor"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Quantidade"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addCabecalho(); $obLista->ultimoCabecalho->addConteudo("Automático"); $obLista->ultimoCabecalho->setWidth( 10 ); $obLista->commitCabecalho(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "codigo_base" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("ESQUERDA"); $obLista->ultimoDado->setCampo( "descricao_base" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("ESQUERDA"); $obLista->ultimoDado->setCampo( "desdobramento_texto" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "valor" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("DIREITA"); $obLista->ultimoDado->setCampo( "quantidade" ); $obLista->commitDado(); $obLista->addDado(); $obLista->ultimoDado->setAlinhamento("CENTRO"); $obLista->ultimoDado->setCampo( "automatico" ); $obLista->commitDado(); $obLista->montaHTML(); $stHtml = $obLista->getHTML(); $stHtml = str_replace("\n","",$stHtml); $stHtml = str_replace(" ","",$stHtml); $stHtml = str_replace("'","\\'",$stHtml); $stJs .= "d.getElementById('spnEventosBase').innerHTML = '".$stHtml."'; \n"; } else { $stJs .= "d.getElementById('spnEventosBase').innerHTML = ''; \n"; } return $stJs; } switch ($_GET['stCtrl']) { case "processarForm": $stJs .= processarForm(); break; } if ($stJs) { echo $stJs; } ?>