From 1cfa383c14e9c4408abb063a862c1e976d7c5f72 Mon Sep 17 00:00:00 2001 From: Matheo Bonucia Date: Mon, 11 Dec 2023 14:34:17 +0000 Subject: [PATCH] Correcao da pesquisa de satisfacao e funcao APL GetOrganizacao. --- cadastros/pesquisa/pesquisaCad.php | 8 ++++---- include/util/funcoesApl.php | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cadastros/pesquisa/pesquisaCad.php b/cadastros/pesquisa/pesquisaCad.php index b9c18b6..e959b09 100644 --- a/cadastros/pesquisa/pesquisaCad.php +++ b/cadastros/pesquisa/pesquisaCad.php @@ -13,6 +13,7 @@ $fieldsTable = array("pp_nome", "pp_audio_saudacao", "pp_audio_encerramento", "p $quantidadeQuestoes = !isset($_FORMS["quantidadeQuestoes"]) ? QUANTIDADE_QUESTOES : $_FORMS["quantidadeQuestoes"]; $quantidadeOpcoes = !isset($_FORMS["quantidadeOpcoes"]) ? QUANTIDADE_OPCOES : $_FORMS["quantidadeOpcoes"]; $upload = 1; +$org_id = GetOrganizacao(); if (!IsPostBack()) { /* @@ -72,7 +73,7 @@ if (!IsPostBack()) { if (empty($msgErro)) { $valuesForm["pp_audio_saudacao"] = trim($_FILES["pp_audio_saudacao"]["name"]); $valuesForm["pp_audio_encerramento"] = trim($_FILES["pp_audio_encerramento"]["name"]); - + $valuesForm["org_id"] = $org_id; $where = " where pp_id = '$ppId'"; if ($ppId) { $msgErro = "Recurso não implementado. Se necessário alterações deverá recria-la!"; @@ -100,7 +101,7 @@ if (!IsPostBack()) { } if ($result) { - $result = InsertQuestoes($dbcon, $pp_id, $arQuetoes, $arOpcoes, $arAudio, $arAudioName, $arTipo, $arTecla); + $result = InsertQuestoes($dbcon, $pp_id, $arQuetoes, $arOpcoes, $arAudio, $arAudioName, $arTipo, $arTecla, $org_id); } if ($result) { $mesRet = explode(":", $result); @@ -217,7 +218,7 @@ function GetTable($quantidadeQuestoes, $quantidadeOpcoes, $ppId = 0, $arQuetoes return $table . $linhaQuest . ""; } -function InsertQuestoes($db, $pp_id, $arQuetoes, $arOpcoes, $arAudio, $arAudioName, $arTipo, $arTecla) +function InsertQuestoes($db, $pp_id, $arQuetoes, $arOpcoes, $arAudio, $arAudioName, $arTipo, $arTecla, $org_id) { /* * Peqga o id da Pesquisa Inserida @@ -226,7 +227,6 @@ function InsertQuestoes($db, $pp_id, $arQuetoes, $arOpcoes, $arAudio, $arAudioNa return "[ERRO]: Não foi possível gerar o identificador da pesquisa!"; } $numQuest = 0; - $org_id = GetOrganizacao(); foreach ($arQuetoes as $kQuest => $vQuest) { /* diff --git a/include/util/funcoesApl.php b/include/util/funcoesApl.php index e848136..b35396a 100755 --- a/include/util/funcoesApl.php +++ b/include/util/funcoesApl.php @@ -4095,12 +4095,19 @@ function PaginaDados($idProg, &$sql, &$params, &$regPagina, &$offSet, &$pagMostr */ $org_id = GetOrganizacao(); + // if (strpos($sql, 'org_id') === false && strpos($sql, 'id_organizacao') === false) { + // if (strpos($sql, 'where') !== false) { + // $sql = str_replace("where", "where org_id = {$org_id} and", $sql); + // } else if (strpos($sql, 'WHERE') !== false) { + // $sql = str_replace("WHERE", "WHERE org_id = {$org_id} AND", $sql); + // } + // } + if (strpos($sql, 'org_id') === false && strpos($sql, 'id_organizacao') === false) { - if (strpos($sql, 'where') !== false) { - $sql = str_replace("where", "where org_id = {$org_id} and", $sql); - } else if (strpos($sql, 'WHERE') !== false) { - $sql = str_replace("WHERE", "WHERE org_id = {$org_id} AND", $sql); - } + $org_condition = "org_id = {$org_id}"; + + // Substituir todas as ocorrências de 'where' ou 'WHERE' pela condição com 'AND' + $sql = str_ireplace(array('where', 'WHERE'), array("WHERE $org_condition AND", "WHERE $org_condition AND"), $sql); } $totalReg = is_numeric($sql) ? $sql : PaginacaoTotalReg($sql, $idProg, $force);