$valor) { $paramInsert[$key] = $valor; } } else { $jsStartup[] = "alert('Servidores OK!');"; foreach ($_POST as $key => $valor) { $paramInsert[$key] = $valor; } } } if (isset($_POST['btGravar'])) { $servers = strripos($_POST['server_address'], " ") ? explode(" ", $_POST['server_address']) : str_replace(","," ",explode(",", $_POST['server_address'])); foreach ($servers as $valor) { $query = "INSERT INTO pbx_agenda_servidores (ip_servidores, porta) " . "VALUES ('{$valor}','{$_POST['server_port']}')"; $sql = pg_query($dbcon, $query); if (!$sql) { $jsStartup[] = "alert('Erro ao salvar a operação no banco de dados local!');"; foreach ($_POST as $key => $valor) { $paramInsert[$key] = $valor; } break; } } $jsStartup[] = "alert('Servidores Cadastrados com Sucesso!');"; } if($acao == 'deleta'){ $result = pg_query($dbcon, "DELETE FROM pbx_agenda_servidores WHERE id_servidor = '$id' "); if(!$result){ $jsStartup[] = "alert('Erro ao excluir o registro!');"; }else{ $jsStartup[] = "alert('Registro Excluído com Sucesso!');"; } } if($acao == 'edita'){ $sql = "SELECT id_servidor, ip_servidores, porta FROM pbx_agenda_servidores WHERE id_servidor = {$id}"; $result = pg_query($dbcon, $sql); $server = pg_fetch_array($result, null, PGSQL_ASSOC); $server_address = $server['ip_servidores']; $server_port = $server['porta']; } if (isset($_POST['btEditar'])) { $sql = "UPDATE pbx_agenda_servidores SET ip_servidores = '{$_POST['server_address']}', porta = '{$_POST['server_port']}' " . "WHERE id_servidor = {$id}"; $result = pg_query($dbcon, $sql); if (!$result) { $jsStartup[] = "alert('Erro ao editar o registro!');"; } else { $jsStartup[] = "alert('Registro Alterado com Sucesso!');"; } } $result = pg_query($dbcon, "SELECT id_servidor, ip_servidores, porta FROM pbx_agenda_servidores WHERE 1=1"); $linhas = ''; while($row = pg_fetch_array($result, null ,PGSQL_ASSOC)){ $editar = sprintf('' . '', $row['id_servidor'], $row['ip_servidores']); $excluir = sprintf('' . '', $row['ip_servidores'], $row['id_servidor']); $linhas .= sprintf("