diff --git a/cadastros/organizacao/cadOrganizacao.php b/cadastros/organizacao/cadOrganizacao.php index 9f7b7f3d..77725939 100644 --- a/cadastros/organizacao/cadOrganizacao.php +++ b/cadastros/organizacao/cadOrganizacao.php @@ -5,8 +5,8 @@ $tpLayout = 1; $id = isset($_GET["id"]) ? $_GET["id"] : $_POST["id"]; $nome = isset($_POST["nome"]) ? $_POST["nome"] : null; -$status = isset($_POST["status"]) ? $_POST["status"] : "checked"; -$master = isset($_POST["master"]) ? "checked" : 0; +$status = isset($_POST["status"]); +$master = isset($_POST["master"]); try { @@ -44,8 +44,8 @@ function setOrganizacao($dbcon, $dados, $id = null) } $isExistsMaster = verificaMaster($dbcon); - if ($isExistsMaster == true && $dados['master'] == "checked") { - throw new Exception("Já existe uma empresa master ativa!"); + if ($isExistsMaster == true && $dados['master'] == "checked"){ + throw new Exception("Já existe uma empresa master ativa!"); } if ($id) { @@ -54,22 +54,22 @@ function setOrganizacao($dbcon, $dados, $id = null) status = %s, master = %s WHERE id = %s;"; - $query = sprintf($query, QuotedStr($dados['nome']), $dados['status'], $dados['master'], $id); + $query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, $dados['master'] == "checked" ? 1 : 0, $id); } else { $query = "INSERT INTO pbx_organizacao (nome, status, master) VALUES(%s, %s, %s) RETURNING id"; - $query = sprintf($query, QuotedStr($dados['nome']), $dados['status'], $dados['master']); + $query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, $dados['master'] == "checked" ? 1 : 0); } $result = pg_query($dbcon, $query); if (!$result) { - throw new Exception("Não foi possí­vel gravar as informações da organizações!"); + throw new Exception("Não foi possível gravar as informações da organização!"); } $ret = pg_fetch_assoc($result); if ($ret['id'] && !$id) { $isImport = importIdTables($dbcon, $ret['id']); if (!$isImport) { - throw new Exception("Não foi possí­vel importar tabelas das organizações!"); + throw new Exception("Não foi possível importar tabelas das organizações!"); } criarGruposDefault($dbcon, $ret['id']); addUserOrganizacaoGrupo($dbcon, $ret['id']); @@ -82,7 +82,7 @@ function getOrganizacaoById($dbcon, $id) $query = "SELECT id, nome, status, master FROM pbx_organizacao WHERE id = $id;"; $result = pg_query($dbcon, $query); if (!$result) { - throw new Exception("Não foi possí­vel buscar a organização selecionada!"); + throw new Exception("Não foi possível buscar a organização selecionada!"); } $dados = pg_fetch_assoc($result); return $dados; @@ -123,7 +123,7 @@ function importIdTables($dbcon, $organizacao) $result = pg_query($dbcon, $query); if (!$result) { - throw new Exception("Não foi possí­vel criar a tabela default [ {$table} ]!"); + throw new Exception("Não foi possível criar a tabela default [ {$table} ]!"); } pg_query($dbcon, "DROP TABLE IF EXISTS t{$table};"); } @@ -188,8 +188,8 @@ function verificaMaster($dbcon) $query = "SELECT id, master, status FROM pbx_organizacao;"; $result = pg_query($dbcon, $query); $resposta = false; - if (!$result) { - throw new Exception("Não foi possí­vel verificar se existe organização master!"); + if(!$result){ + throw new Exception("Não foi possível verificar se existe organizaçao master!"); } $dados = pg_fetch_all($result); if ($dados) {