function calcula_rcl2($anousu, $dtini, $dtfin, $db_selinstit, $matriz = false, $codrel = 5, $data = 0) { require_once "libs/db_utils.php"; require_once "model/linhaRelatorioContabil.model.php"; global $o57_fonte, $janeiro, $fevereiro, $marco, $abril, $maio, $junho, $julho, $agosto, $setembro, $outubro, $novembro, $dezembro, $bimestre, $dt; if ($data == 0) { $dt = split("-", $dtfin); } else { $dt = split("-", $data); } $bimestre = (int) substr(db_retorna_periodo($dt[1], "B"), 0, 1); $bimestre = $dt[1]; $flag_anterior = false; if ($anousu < db_getsession("DB_anousu")) { // Exercicio anterior $bimestre += 1; $flag_anterior = true; } $result_rec = new cl_receita_saldo_mes(); $result_rec->anousu = $anousu; $result_rec->dtini = $dtini; $result_rec->dtfim = $dtfin; $result_rec->usa_datas = 'sim'; $result_rec->instit = $db_selinstit; $result_rec->sql_record(); $result_rec = $result_rec->result; @pg_exec("drop table work_plano"); // pega parametros do relatorio de rcl $orcparamrel = new cl_orcparamrel(); $param[1] = $orcparamrel->sql_parametro($codrel, '1', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[2] = $orcparamrel->sql_parametro($codrel, '2', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[3] = $orcparamrel->sql_parametro($codrel, '3', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[4] = $orcparamrel->sql_parametro($codrel, '4', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[5] = $orcparamrel->sql_parametro($codrel, '5', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[6] = $orcparamrel->sql_parametro($codrel, '6', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[7] = $orcparamrel->sql_parametro($codrel, '7', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[8] = $orcparamrel->sql_parametro($codrel, '8', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[9] = $orcparamrel->sql_parametro($codrel, '9', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[10] = $orcparamrel->sql_parametro($codrel, '10', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[11] = $orcparamrel->sql_parametro($codrel, '11', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[12] = $orcparamrel->sql_parametro($codrel, '12', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[13] = $orcparamrel->sql_parametro($codrel, '13', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[14] = $orcparamrel->sql_parametro($codrel, '14', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[15] = $orcparamrel->sql_parametro($codrel, '15', 'f', str_replace('-', ', ', $db_selinstit), $anousu); // inicio dedução em 2007 $param[16] = $orcparamrel->sql_parametro($codrel, '16', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[17] = $orcparamrel->sql_parametro($codrel, '17', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[18] = $orcparamrel->sql_parametro($codrel, '18', 'f', str_replace('-', ', ', $db_selinstit), $anousu); if ($codrel == 27) { $param[19] = $orcparamrel->sql_parametro($codrel, '19', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[20] = $orcparamrel->sql_parametro($codrel, '20', 'f', str_replace('-', ', ', $db_selinstit), $anousu); $param[21] = $orcparamrel->sql_parametro($codrel, '21', 'f', str_replace('-', ', ', $db_selinstit), $anousu); } if ($codrel == 59 || ($codrel = 81)) { for ($iLinha = 1; $iLinha <= 22; $iLinha++) { $param[$iLinha] = new linhaRelatorioContabil($codrel, $iLinha); $param[$iLinha]->parametro = $param[$iLinha]->getParametros($anousu); } } $total = 0; $rcl_matriz2['janeiro'] = 0; $rcl_matriz2['fevereiro'] = 0; $rcl_matriz2['marco'] = 0; $rcl_matriz2['abril'] = 0; $rcl_matriz2['maio'] = 0; $rcl_matriz2['junho'] = 0; $rcl_matriz2['julho'] = 0; $rcl_matriz2['agosto'] = 0; $rcl_matriz2['setembro'] = 0; $rcl_matriz2['outubro'] = 0; $rcl_matriz2['novembro'] = 0; $rcl_matriz2['dezembro'] = 0; // Arrecadacao $rcl_matriz[0][1] = 0; // Janeiro $rcl_matriz[0][2] = 0; // Fevereiro $rcl_matriz[0][3] = 0; // Marco $rcl_matriz[0][4] = 0; // Abril $rcl_matriz[0][5] = 0; // Maio $rcl_matriz[0][6] = 0; // Junho $rcl_matriz[0][7] = 0; // Julho $rcl_matriz[0][8] = 0; // Agosto $rcl_matriz[0][9] = 0; // Setembro $rcl_matriz[0][10] = 0; // Outubro $rcl_matriz[0][11] = 0; // Novembro $rcl_matriz[0][12] = 0; // Dezembro // Deducoes $rcl_matriz[1][1] = 0; // Janeiro $rcl_matriz[1][2] = 0; // Fevereiro $rcl_matriz[1][3] = 0; // Marco $rcl_matriz[1][4] = 0; // Abril $rcl_matriz[1][5] = 0; // Maio $rcl_matriz[1][6] = 0; // Junho $rcl_matriz[1][7] = 0; // Julho $rcl_matriz[1][8] = 0; // Agosto $rcl_matriz[1][9] = 0; // Setembro $rcl_matriz[1][10] = 0; // Outubro $rcl_matriz[1][11] = 0; // Novembro $rcl_matriz[1][12] = 0; // Dezembro $tot_param = 18; $ult_param = 15; if ($codrel == 27) { $tot_param = 21; $ult_param = 18; } else { if ($codrel == 59 || $codrel == 81) { $tot_param = 22; $ult_param = 19; } } for ($p = 1; $p <= $tot_param; $p++) { // 18 para 2007 e 21 para 2008 é a quantidade de parametros ou linhas existentes nos parametros for ($i = 0; $i < pg_numrows($result_rec); $i++) { $oReceita = db_utils::fieldsmemory($result_rec, $i); $estrutural = $oReceita->o57_fonte; $oParametro = $param[$p]->parametro; foreach ($oParametro->contas as $oEstrutural) { $oRetornoVerificacao = $param[$p]->match($oEstrutural, $oParametro->orcamento, $oReceita, 1); if ($oRetornoVerificacao->match) { if ($oRetornoVerificacao->exclusao) { $oReceita->janeiro *= -1; $oReceita->fevereiro *= -1; $oReceita->marco *= -1; $oReceita->abril *= -1; $oReceita->maio *= -1; $oReceita->junho *= -1; $oReceita->julho *= -1; $oReceita->agosto *= -1; $oReceita->setembro *= -1; $oReceita->outubro *= -1; $oReceita->novembro *= -1; $oReceita->dezembro *= -1; } if ($p == $tot_param) { $oReceita->janeiro *= -1; $oReceita->fevereiro *= -1; $oReceita->marco *= -1; $oReceita->abril *= -1; $oReceita->maio *= -1; $oReceita->junho *= -1; $oReceita->julho *= -1; $oReceita->agosto *= -1; $oReceita->setembro *= -1; $oReceita->outubro *= -1; $oReceita->novembro *= -1; $oReceita->dezembro *= -1; } if ($p <= $ult_param) { $rcl_matriz[0][1] += $oReceita->janeiro; $rcl_matriz[0][2] += $oReceita->fevereiro; $rcl_matriz[0][3] += $oReceita->marco; $rcl_matriz[0][4] += $oReceita->abril; $rcl_matriz[0][5] += $oReceita->maio; $rcl_matriz[0][6] += $oReceita->junho; $rcl_matriz[0][7] += $oReceita->julho; $rcl_matriz[0][8] += $oReceita->agosto; $rcl_matriz[0][9] += $oReceita->setembro; $rcl_matriz[0][10] += $oReceita->outubro; $rcl_matriz[0][11] += $oReceita->novembro; $rcl_matriz[0][12] += $oReceita->dezembro; } else { if (db_conplano_grupo($anousu, substr($estrutural, 0, 3) . "%", 9001) == true) { $rcl_matriz[1][1] += $oReceita->janeiro; $rcl_matriz[1][2] += $oReceita->fevereiro; $rcl_matriz[1][3] += $oReceita->marco; $rcl_matriz[1][4] += $oReceita->abril; $rcl_matriz[1][5] += $oReceita->maio; $rcl_matriz[1][6] += $oReceita->junho; $rcl_matriz[1][7] += $oReceita->julho; $rcl_matriz[1][8] += $oReceita->agosto; $rcl_matriz[1][9] += $oReceita->setembro; $rcl_matriz[1][10] += $oReceita->outubro; $rcl_matriz[1][11] += $oReceita->novembro; $rcl_matriz[1][12] += $oReceita->dezembro; } else { $rcl_matriz[1][1] += $oReceita->janeiro; $rcl_matriz[1][2] += $oReceita->fevereiro; $rcl_matriz[1][3] += $oReceita->marco; $rcl_matriz[1][4] += $oReceita->abril; $rcl_matriz[1][5] += $oReceita->maio; $rcl_matriz[1][6] += $oReceita->junho; $rcl_matriz[1][7] += $oReceita->julho; $rcl_matriz[1][8] += $oReceita->agosto; $rcl_matriz[1][9] += $oReceita->setembro; $rcl_matriz[1][10] += $oReceita->outubro; $rcl_matriz[1][11] += $oReceita->novembro; $rcl_matriz[1][12] += $oReceita->dezembro; } } } } } } if ($flag_anterior == false) { // Exercicio Atual for ($y = 1; $y <= $bimestre; $y++) { $total += $rcl_matriz[0][$y] - $rcl_matriz[1][$y]; } } else { // Exercicio Anterior for ($y = $bimestre; $y <= 12; $y++) { $total += $rcl_matriz[0][$y] - $rcl_matriz[1][$y]; } } if ($matriz == true) { // Arrecadacao - Deducoes $rcl_matriz2['janeiro'] = $rcl_matriz[0][1] - $rcl_matriz[1][1]; $rcl_matriz2['fevereiro'] = $rcl_matriz[0][2] - $rcl_matriz[1][2]; $rcl_matriz2['marco'] = $rcl_matriz[0][3] - $rcl_matriz[1][3]; $rcl_matriz2['abril'] = $rcl_matriz[0][4] - $rcl_matriz[1][4]; $rcl_matriz2['maio'] = $rcl_matriz[0][5] - $rcl_matriz[1][5]; $rcl_matriz2['junho'] = $rcl_matriz[0][6] - $rcl_matriz[1][6]; $rcl_matriz2['julho'] = $rcl_matriz[0][7] - $rcl_matriz[1][7]; $rcl_matriz2['agosto'] = $rcl_matriz[0][8] - $rcl_matriz[1][8]; $rcl_matriz2['setembro'] = $rcl_matriz[0][9] - $rcl_matriz[1][9]; $rcl_matriz2['outubro'] = $rcl_matriz[0][10] - $rcl_matriz[1][10]; $rcl_matriz2['novembro'] = $rcl_matriz[0][11] - $rcl_matriz[1][11]; $rcl_matriz2['dezembro'] = $rcl_matriz[0][12] - $rcl_matriz[1][12]; return $rcl_matriz2; } return $total; }
/** * Função que calcula o valor total da inicial * */ function valorInicialAtualizado($iInicial, $dDtEmiss = null) { require_once "libs/db_sql.php"; $nValor = 0; $sSqlCertidoesInicial = "select v51_inicial, \n \t v13_certid, \n \t v13_dtemis \n \t from inicialcert\n \t inner join certid on v13_certid = v51_certidao \n \t where v51_inicial = {$iInicial} "; $rsCertidoesInicial = db_query($sSqlCertidoesInicial); for ($iCertidoesInicial = 0; $iCertidoesInicial < pg_num_rows($rsCertidoesInicial); $iCertidoesInicial++) { $oCertidoesInicial = db_utils::fieldsMemory($rsCertidoesInicial, $iCertidoesInicial); if ($dDtEmiss == null) { $dDtEmiss = $oCertidoesInicial->v13_dtemis; } $sSqlParcelamentos = " select v14_parcel, "; $sSqlParcelamentos .= " v07_numpre "; $sSqlParcelamentos .= " from certter"; $sSqlParcelamentos .= " inner join termo on v07_parcel = v14_parcel"; $sSqlParcelamentos .= " where v14_certid = {$oCertidoesInicial->v13_certid} "; $rsParcelamentos = db_query($sSqlParcelamentos); $iLinhasParcel = pg_num_rows($rsParcelamentos); for ($iIndParcel = 0; $iIndParcel < $iLinhasParcel; $iIndParcel++) { $oDadosParcel = db_utils::fieldsMemory($rsParcelamentos, $iIndParcel); $rsDadosDebitoCorrigido = debitos_numpre($oDadosParcel->v07_numpre, 0, 0, mktime(0, 0, 0, substr($dDtEmiss, 5, 2), substr($dDtEmiss, 8, 2), substr($dDtEmiss, 0, 4)), substr($dDtEmiss, 0, 4), 0); if ($rsDadosDebitoCorrigido != false) { $iLinhasDebito = pg_num_rows($rsDadosDebitoCorrigido); for ($iIndDebito = 0; $iIndDebito < $iLinhasDebito; $iIndDebito++) { $nValor += db_utils::fieldsMemory($rsDadosDebitoCorrigido, $iIndDebito)->total; } } } $sSqlDadosDebitos = " select distinct "; $sSqlDadosDebitos .= " k00_numpre, "; $sSqlDadosDebitos .= " k00_numpar "; $sSqlDadosDebitos .= " from certdiv"; $sSqlDadosDebitos .= " inner join divida on certdiv.v14_coddiv = divida.v01_coddiv"; $sSqlDadosDebitos .= " inner join arrecad on arrecad.k00_numpre = divida.v01_numpre "; $sSqlDadosDebitos .= " and arrecad.k00_numpar = divida.v01_numpar"; $sSqlDadosDebitos .= " where v14_certid in ({$oCertidoesInicial->v13_certid})"; $rsDadosDebitos = db_query($sSqlDadosDebitos); $iLinhasDadosDebitos = pg_num_rows($rsDadosDebitos); for ($iIndDadosDebitos = 0; $iIndDadosDebitos < $iLinhasDadosDebitos; $iIndDadosDebitos++) { $oDivida = db_utils::fieldsmemory($rsDadosDebitos, $iIndDadosDebitos); $rsDadosDebitoCorrigido = debitos_numpre($oDivida->k00_numpre, 0, 0, mktime(0, 0, 0, substr($dDtEmiss, 5, 2), substr($dDtEmiss, 8, 2), substr($dDtEmiss, 0, 4)), substr($dDtEmiss, 0, 4), $oDivida->k00_numpar); for ($iIndDebito = 0; $iIndDebito < pg_numrows($rsDadosDebitoCorrigido); $iIndDebito++) { $nValor += db_utils::fieldsMemory($rsDadosDebitoCorrigido, $iIndDebito)->total; } } } return $nValor; }
function MensagemCarne($exerc, $arretipo, $dtbase, $matric, $arrematric = "w_arrematric as arrematric") { $mensagem = ""; // Verifica Debitos Vencidos $sql = " select arrecad.k00_tipo, "; $sql .= " arretipo.k03_tipo, "; $sql .= " count(distinct arrecad.k00_numpar) as qtdatraso "; $sql .= " from arrecad "; $sql .= " inner join arretipo on arretipo.k00_tipo = arrecad.k00_tipo "; $sql .= " where arrecad.k00_numpre in (select k00_numpre from {$arrematric}) "; $sql .= " and arrecad.k00_dtvenc < '{$dtbase}' "; $sql .= "group by arrecad.k00_tipo, "; $sql .= " arretipo.k03_tipo "; $sql .= "order by 3 desc "; // ordena pela qtd parcelas em atraso em ordem descendente //die($sql); $resDebitos = db_query($sql); $rowsDebitos = pg_numrows($resDebitos); for ($iDeb = 0; $iDeb < $rowsDebitos; $iDeb++) { $oDebito = db_utils::fieldsmemory($resDebitos, $iDeb); if ($oDebito->qtdatraso >= 2) { // se tem duas ou mais parcelas em aberto... $mensagem = "AVISO DE SUSPENSÃO DO FORNECIMENTO DE ÁGUA: Fica o usuário avisado que a não regularização dos débitos do imóvel no prazo de 30 (trinta) dias, a contar do vencimento da segunda parcela em atraso, acarretará na suspensão do fornecimento de água (art. 40, V, §2º da Lei n.º 11.445/07)."; break; } else { // Verifica o CADTIPO switch ($oDebito->k03_tipo) { // Divida Ativa case 5: case 18: if (empty($mensagem)) { $mensagem = "Imovel possui Divida Ativa"; } else { $mensagem .= " / Divida Ativa"; } break; // Parcelamento // Parcelamento case 6: case 13: if (empty($mensagem)) { $mensagem = "Imovel possui Parcelamento em Atraso"; } else { $mensagem .= " / Parcelamento em Atraso"; } break; // Saneamento Básico (Agua Exercicio) // Saneamento Básico (Agua Exercicio) case 20: if (empty($mensagem)) { $mensagem = "Imovel possui Debito no Exercicio"; } else { $mensagem .= " / Debito no Exercicio "; } break; // Outros Débitos // Outros Débitos default: if (empty($mensagem)) { $mensagem = "Imovel possui Outros Debitos em Atraso"; } else { $mensagem .= " / Outros Debitos em Atraso "; } break; } } } if (empty($mensagem)) { // se nao tem nada em aberto $mensagem = "Obrigado pela pontualidade!!!"; } db_query("set enable_bitmapscan to off"); return $mensagem; }
} $pdf->Cell(180, 3, "", "", 1, "L", 0); $pdf->Cell(200, 4, "", "", 1, "C", 0); $pdf->setX(5); $pdf->SetFont('Arial', 'B', 9); $pdf->Cell(200, 4, "Atividades", "LRBT", 1, "C", 0); $pdf->setX(5); $pdf->Cell(200, 4, "", "", 1, "C", 0); if ($iLinhasConsultaAtividade > 0) { $pdf->setX(10); $pdf->SetFont('Arial', '', $titulo); $pdf->cell(15, 4, "Cod.", 0, 0, "C", 1); $pdf->cell(95, 4, "Atividade", 0, 0, "C", 1); $pdf->cell(10, 4, "Tipo", 0, 1, "C", 1); for ($iInd = 0; $iInd < $iLinhasConsultaAtividade; $iInd++) { $oDadosAtividade = db_utils::fieldsmemory($rsSimulacaoCalculoAtividade, $iInd); $sTipoAtividade = "S"; if ($oDadosAtividade->q131_principal == "t") { $sTipoAtividade = "P"; } $pdf->setX(10); $pdf->SetFont('Arial', '', $texto); $pdf->cell(15, 4, $oDadosAtividade->q131_atividade, 0, 0, "C", 0); $pdf->cell(95, 4, $oDadosAtividade->q03_descr, 0, 0, "L", 0); $pdf->cell(10, 4, $sTipoAtividade, 0, 1, "L", 0); } } else { $pdf->cell(190, 4, "NÃO POSSUI ATIVIDADE", 0, 1, "C", 0); } $pdf->Cell(180, 3, "", "", 1, "L", 0); $pdf->Cell(200, 4, "", "", 1, "C", 0);
<?php db_logs(0, 0, 0, "Licitações em Aberto."); /* * T. 43860 * Separar as Licit. Julgadas, e indicar o numero do empenho * */ $sSqlParam = " select l12_tipoliberacaoweb, "; $sSqlParam .= " l12_qtdediasliberacaoweb "; $sSqlParam .= " from licitaparam "; $sSqlParam .= " where l12_instit = " . db_getsession('DB_instit'); $rsSqlParam = db_query($sSqlParam); $iNumRows = pg_num_rows($rsSqlParam); if ($iNumRows > 0) { $l12_tipoliberacaoweb = db_utils::fieldsmemory($rsSqlParam, 0)->l12_tipoliberacaoweb; $l12_qtdediasliberacaoweb = db_utils::fieldsmemory($rsSqlParam, 0)->l12_qtdediasliberacaoweb; } $data = date("Y-m-d"); $sWhere = "where l29_datapublic<='{$data}' and l20_dataaber>='{$data}' "; if ($l12_tipoliberacaoweb == 2) { $sWhere = "left join liclicitasituacao on l11_liclicita = l20_codigo "; $sWhere .= " and l20_licsituacao = l11_licsituacao "; $sWhere .= "where l29_datapublic<='{$data}' "; $sWhere .= " and ( l11_licsituacao = 1 "; $sWhere .= " and l11_data +'{$l12_qtdediasliberacaoweb} days'::interval >='{$data}') "; } $sql = "select distinct l03_descr,l03_codigo\n\t\t from liclicita\n\t\t inner join cflicita on l03_codigo=l20_codtipocom \n\t\t inner join liclicitaweb on l29_liclicita=l20_codigo\n\t\t {$sWhere}\n "; $result = db_query($sql); $linhas = pg_num_rows($result); ?> <table width="100%" border="0" align= "top" cellpadding="0" cellspacing="0">
$mesFolha = db_mesfolha($instituicao); db_logs("", "", 0, "Consulta Funcional."); $sUrl = base64_encode("iMatric=" . $matricula . "&iInstit=" . $instituicao); $sUrlAverba = base64_encode("&averba"); /** * Caso o cliente seja Bage (codcli = 15) * Então a variável lBloqueio passa a ser true e não mostrará os menus: * - Assentamento * - Averbação do tempo de serviço * - Férias * * Do contrário todos os menus são mostrados normalmente. */ $lBloqueio = false; $rsCodCli = db_query("select db21_codcli from db_config where prefeitura is true limit 1"); $iCodCli = db_utils::fieldsmemory($rsCodCli)->db21_codcli; if ($iCodCli == 15) { $lBloqueio = true; } /** * Declara a estrutura da folha de pagamento conforme a instituição do servidor informado. */ try { cl_cfpess::declararEstruturaFolhaPagamento($instituicao); } catch (Exception $ex) { db_msgbox($ex->getMessage()); } /** * Verifica para quais matriculas não deve ser exibido o menu de Comprovante * de rendimentos atraves da seleção "MAT COMPR REND ECIDADEONLINE". */