-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompararua.php
165 lines (154 loc) · 4.73 KB
/
compararua.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
session_start();
if(!isset($_SESSION['logado'])){
header("location: login.php");
}
if($_SESSION['permissao']==1){
header("location: redirect.php");
}
?>
<html lang="pt-br">
<!------BY BRUNO VASCONCELLOS - VIP DESENVOLVIMENTO------->
<head>
<title>Comparar</title>
<meta charset="iso-8859-1">
<script src="jquery-3.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="icon" type="icon" href="img/csv-logo.png">
</head>
<body>
<table align="center" width="100%" style="background-color: #150a50" border="0">
<tr>
<td align="right" style="width: 46%">
<a href="index2.php">
<img src="img/vip-white.png" width="100%" style="max-width: 200px">
</a>
</td>
<td>
<font style="font-weight: bold; font-size: 24px; font-family: Verdana; color: white">CSV</font>
</td>
</tr>
</table>
<div style="position: absolute; right: 2px; top: 2px;" onclick="sair()">
<img src="img/sairr.png" width="60px" title='Sair'>
</div>
<script>
function sair(){
var op = confirm("Deseja realmente sair?");
if(op){
location.href = 'logout.php';
}
}
</script>
<div class="container" style="margin-top: 50px; border: 1px solid black">
<label>Formato do CSV:</label>
<table class="table-hover table">
<tr>
<td>
coluna 1
</td>
<td>
coluna 2
</td>
<td>
coluna 3
</td>
<td>
coluna 4
</td>
<td>
coluna 5
</td>
<td>
coluna 6
</td>
<td>
coluna 7
</td>
</tr>
<tr>
<td>
CEP
</td>
<td>
endereço
</td>
<td>
Bairro
</td>
<td>
Cidade
</td>
<td>
Base
</td>
<td>
Técnologia
</td>
<td>
Velocidades
</td>
</tr>
<tr>
<td title="Caso a rua não tenha cep, no lugar coloque 'SEM CEP' ">
09999-999 ou SEM CEP
</td>
<td>
rua Matriz
</td>
<td>
Matriz
</td>
<td>
Mauá
</td>
<td>
Mauá
</td>
<td>
FTTC
</td>
<td title=" separar cada velocidade por '/' e a ultima velocidade colocar 'MB' ">
8 / 12 / 20MB
</td>
</tr>
</table>
<label class="p-2 bd-highlight">Selecione o arquivo CSV</label>
<form action="" method="post" name="uploadCSV" enctype="multipart/form-data">
<input type="file" name="file" id="file" class="form-control-file form-control-sm" accept=".csv .txt .stt">
<br>
<select name="tipo" class="form-control-sm" required>
<option value="">--TIPO--</option>
<option value="casa" >Casa</option>
<option value="Predio">Predio</option>
</select>
<br>
<br>
<button type="submit" id="submit" name="import" class="btn btn-secondary">Comparar</button>
</form>
<?php
require 'connect.php';
header("Content-type: text/html; charset=UTF-8");
if(isset($_POST["import"])) {
$tipo = $_POST['tipo'];
$fileName = $_FILES["file"]["tmp_name"];
if ($_FILES["file"]["size"] > 0) {
$handle = @fopen($fileName, "r");
if ($handle) {
while ($line = fgetcsv($handle, 5000, ";")) {
$column = array_map("utf8_encode", $line);
$linhas =0;
if($column[0] != "" and $column[1] != ""){
$query1 = "SELECT cep, logradouro FROM ".$tipo." where cep = '".$column[0]."' and logradouro = '".$column[1]."' ";
$outpt = mysqli_query($connection, $query1);
$linhas = mysqli_num_rows($outpt);
if($linhas == 0){
echo "<b>".$column[0]." - ". $column[1]."</b> Não existe no Geovendas</br>";
}
}
}
}
fclose($handle);
}
}
?>