forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
214 lines
6.5 KiB
214 lines
6.5 KiB
<?php |
|
include('util/util.php'); |
|
//ini_set('display_errors', 1); |
|
//ini_set('display_startup_errors', 1); |
|
//error_reporting(E_ALL); |
|
|
|
|
|
// Definindo as variáveis de conexão |
|
$host = '127.0.0.1'; |
|
$db = 'pbx'; |
|
$user = 'contacte'; |
|
$pass = 'ctepgSQL'; |
|
$charset = 'utf8mb4'; |
|
|
|
$dsn = "pgsql:host=$host;dbname=$db"; |
|
$options = [ |
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, |
|
PDO::ATTR_EMULATE_PREPARES => false, |
|
]; |
|
|
|
// Criando a conexão com o banco de dados |
|
try { |
|
$pdo = new PDO($dsn, $user, $pass, $options); |
|
} catch (\PDOException $e) { |
|
throw new \PDOException($e->getMessage(), (int)$e->getCode()); |
|
} |
|
|
|
// Obtendo UF |
|
$ufs = $pdo->query("SELECT DISTINCT acob_uf FROM opr_area_cobertura ORDER BY acob_uf")->fetchAll(); |
|
$municipio = ""; |
|
$municipioFiltro = ''; |
|
$ufFiltro = ''; |
|
|
|
// Consulta da Área |
|
|
|
$uf = $_POST['uf']; |
|
$municipio = trim(strtoupper(RemoveAcentos($_POST['municipio']))); |
|
|
|
if($uf){ |
|
$ufFiltro = "\n and acob_uf = '$uf'" ; |
|
} |
|
|
|
if(!empty($municipio)){ |
|
$municipioFiltro = "\n and acob_municipio_nome like '%$municipio%'"; |
|
} |
|
|
|
$sql = "SELECT DISTINCT acob_municipio_nome, acob_uf, acob_cn, case when(acob_tipo_conexao = 'MOVEL-DATORA')THEN 'DID-MOVEL' else 'DID-FIXO' end as tipo_linha |
|
FROM opr_area_cobertura |
|
WHERE 1=1 |
|
$ufFiltro |
|
$municipioFiltro |
|
order by acob_uf, acob_municipio_nome\n"; |
|
|
|
$results = $pdo->query($sql)->fetchAll(); |
|
$numeroArea = count($results); |
|
|
|
|
|
?> |
|
|
|
<!DOCTYPE html> |
|
<html lang="pt-br"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>Consulta de Área de Cobertura - Simples IP</title> |
|
<!-- Insira estilos e scripts necessários aqui --> |
|
<style> |
|
body { |
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
|
background-color: #f4f4f4; |
|
margin: 0; |
|
padding: 0; |
|
} |
|
.result { |
|
font-size: 12px; |
|
font-style: italic; |
|
margin: 0; |
|
padding: 0; |
|
margin-top: 8px; |
|
} |
|
#container { |
|
width: 80%; |
|
max-width: 800px; |
|
margin: 20px auto; |
|
background-color: #fff; |
|
padding: 20px; |
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
|
border-radius: 8px; |
|
} |
|
img { |
|
max-width: 200px; |
|
display: block; |
|
margin: 0 auto 20px; |
|
} |
|
.title { |
|
text-align: center; |
|
font-size: 24px; |
|
margin-bottom: 20px; |
|
color: #007bff; |
|
} |
|
form { |
|
display: flex; |
|
flex-wrap: wrap; |
|
justify-content: flex-start; |
|
gap: 2px; |
|
margin-bottom: 5px; |
|
} |
|
form label { |
|
flex-basis: 100%; |
|
text-align: left; |
|
margin: 0; |
|
padding: 2px; |
|
} |
|
form select, form input { |
|
padding: 2px; |
|
border: 1px solid #ddd; |
|
border-radius: 4px; |
|
margin-bottom: 5px; |
|
} |
|
form select { |
|
width: 100%; /* Ajuste para ocupar o espaço disponível */ |
|
max-width: 100px; /* Largura máxima limitada */ |
|
font-size: 16px; /* Tamanho maior de fonte para melhor leitura */ |
|
} |
|
form input { |
|
width: 100%; /* Ajuste para ocupar o espaço disponível */ |
|
max-width: 400px; /* Largura máxima limitada */ |
|
} |
|
@media (max-width: 600px) { |
|
form select, form input { |
|
max-width: none; /* Remover limites de largura em telas pequenas */ |
|
|
|
} |
|
} |
|
button { |
|
padding: 10px 10px; |
|
background-color: #007bff; |
|
color: #fff; |
|
border: none; |
|
border-radius: 4px; |
|
cursor: pointer; |
|
transition: background-color 0.3s; |
|
} |
|
button:hover { |
|
background-color: #0056b3; |
|
} |
|
table { |
|
width: 100%; |
|
border-collapse: collapse; |
|
} |
|
th, td { |
|
padding: 10px; |
|
border: 1px solid #ddd; |
|
text-align: left; |
|
} |
|
th { |
|
background-color: #007bff; |
|
color: #fff; |
|
} |
|
tr:nth-child(even) { |
|
background-color: #f2f2f2; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div id="container"> |
|
<img src="logo-simplesip.png" alt="Logo Simples IP"> |
|
<div class="title">Área de Cobertura da Simples IP</div> |
|
<form action="index.php" method="post"> |
|
<label for="uf">UF:</label> |
|
<select name="uf" id="uf"> |
|
<?php $selected = $uf == "0" ? ' selected="selected"' : ""; ?> |
|
<option value="0"<?= $selected; ?>>Todos</option> |
|
<?php foreach ($ufs as $ufList): |
|
$selected = $uf == $ufList['acob_uf'] ? ' selected="selected"' : ""; |
|
|
|
?> |
|
<option value="<?= htmlspecialchars($ufList['acob_uf']); ?>" <?= $selected; ?>><?= htmlspecialchars($ufList['acob_uf']); ?></option> |
|
<?php endforeach; ?> |
|
</select> |
|
<label for="municipio">Município:</label> |
|
<input type="text" name="municipio" id="municipio" value="<?= $municipio; ?>"> |
|
<button type="submit">Pesquisar</button> |
|
<div class="result"> <?php |
|
$str = "A consulta retornou %s %s %s pela Simples IP"; |
|
echo sprintf($str, $numeroArea, $numeroArea > 1 ? "localidades" : "localidade", $numeroArea > 1 ? "atendidas" : "atendida"); |
|
?> |
|
</div> |
|
</form> |
|
<?php if (isset($results)): ?> |
|
<table> |
|
<thead> |
|
<tr> |
|
<th>Município</th> |
|
<th width="90">UF</th> |
|
<th width="90">DDD</th> |
|
<th width="90">TIPO</th> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<?php foreach ($results as $area): ?> |
|
<tr> |
|
<td><?= htmlspecialchars($area['acob_municipio_nome']); ?></td> |
|
<td><?= htmlspecialchars($area['acob_uf']); ?></td> |
|
<td><?= htmlspecialchars($area['acob_cn']); ?></td> |
|
<td><?= htmlspecialchars($area['tipo_linha']); ?></td> |
|
</tr> |
|
<?php endforeach; ?> |
|
</tbody> |
|
</table> |
|
<?php endif; ?> |
|
</div> |
|
</body> |
|
</html>
|
|
|