-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
443 lines (373 loc) · 19.9 KB
/
index.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?php include 'View/Templates/header.php';
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/ImovelModel.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/ImagensImovelModel.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/EstadoModel.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/TransacaoModel.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/TipoImovelModel.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/corretora/Model/BannerModel.php";
$estadoModel = new EstadoModel();
$estados = $estadoModel->getAllEstado();
$transacaoModel = new TransacaoModel();
$transacoes = $transacaoModel->getAllTransacao();
$tipoImovelModel = new TipoImovelModel();
$tiposDeImovel = $tipoImovelModel->getAllTipoImovel();
$imovelModel = new ImovelModel();
$imoveis = $imovelModel->getAllImovel();
$imagensImovelModel = new ImagensImovelModel();
$imagens = $imagensImovelModel->getAllImagens();
$bannerModel = new BannerModel();
$banner = $bannerModel->getRandomBanner();
$banner2 = $bannerModel->getRandomBanner();
$imovelModel = new ImovelModel();
$imoveisRamdom = $imovelModel->getImovelAltoRamdom();
$imovelModel = new ImovelModel();
$imoveisRamdomUno = $imovelModel->getImovelAltoRamdomUno();
?>
<script>
function Mudarestado(el) {
var display = document.getElementById(el).style.display;
if (display == "none")
document.getElementById(el).style.display = 'block';
else
document.getElementById(el).style.display = 'none';
}
</script>
<div style="padding-top: 20px; text-align: center;">
<h2>
QUER ANUNCIAR OU PROCURA UM IMÓVEL IDEAL PARA SER SEU NOVO LAR, INVESTIMENTO OU NEGÓCIO?
VOCÊ ESTÁ NO LUGAR CERTO!<br>
Gaste seu tempo organizando a mudança, deixa que a busca nós te ajudamos!
</h2>
</div>
<?php
if ($imoveisRamdom == null ) { ?>
<div class="row" style="padding-top: 60px;">
<div class="offset-md-2 col-md-8">
<!-- Search Widget -->
<form id="buscaImovel" method="GET" action="/corretora/View/Pages/busca.php" >
<div class="card my-12">
<h5 class="card-header">Pesquise seu imóvel:</h5>
<div class="card-body">
<div class="input-group">
<div class="form-group">
<b><label for="transacao">O que você deseja?</label></b>
<select id="transacao" class="form-control" name="transacao" >
<option selected value="">Selecione a opção:</option>
<?php foreach($transacoes as $transacao){?>
<?php if($transacao['descricaoTransacao'] == "Vender") { ?>
<option value="<?php echo $transacao['idTransacao'];?>"> Comprar </option>
<?php } else { ?>
<option value="<?php echo $transacao['idTransacao'];?>"> <?php echo $transacao['descricaoTransacao'];?> </option>
<?php } ?>
<?php } ?>
</select>
</div>
<hr>
<div class="form-group">
<b><label for="tipoDeImovel">Que tipo de imóvel você proucura?</label></b>
<select id="tipoDeImovel" class="form-control" name="tipoDeImovel" >
<option selected value="">Selecione o tipo do imóvel:</option>
<?php foreach($tiposDeImovel as $tipoImovel){?>
<option value="<?php echo $tipoImovel['idTipoImovel'];?>"> <?php echo $tipoImovel['descricaoTipoImovel'];?> </option>
<?php } ?>
</select>
</div>
<hr>
<div class="form-group">
<b><label for="endereco">Endereço:</label></b>
<select id="estado" class="form-control" name="estado" >
<option selected value="">Selecione seu estado:</option>
<?php foreach($estados as $estado){?>
<option value="<?php echo $estado['idEstado'];?>"> <?php echo $estado['descricaoEstado'];?> </option>
<?php }?>
</select>
<br>
<input type="text" class="form-control" id="cidade" placeholder="Digite a cidade aqui" name="cidade" >
<br>
<input type="text" class="form-control" id="bairro" placeholder="Digite o bairro aqui" name="bairro" >
</div>
</div>
<div class="form-group" id="minhaDiv" style="display:none">
<div class="form-group">
<label for="quantQuarto">Quartos:</label>
<input type="number" class="form-control" id="quantQuarto" placeholder="0" name="quantQuarto">
</div>
<div class="form-group">
<label for="quantSuite">Suítes:</label>
<input type="number" class="form-control" id="quantSuite" placeholder="0" name="quantSuite">
</div>
<div class="form-group">
<label for="quantVagaGaragem">Vagas de garagem:</label>
<input type="number" class="form-control" id="quantVagaGaragem" placeholder="0" name="quantVagaGaragem">
</div>
<div class="form-group">
<label for="quantBanheiro">Banheiros:</label>
<input type="number" class="form-control" id="quantBanheiro" placeholder="0" name="quantBanheiro">
</div>
<div class="form-group">
<label for="idImovel">Código do imóvel:</label>
<input type="number" class="form-control" id="idImovel" placeholder="0" name="idImovel">
</div>
</div>
<div class="form-group">
<button class="btn btn-warning" type="button" onclick="Mudarestado('minhaDiv')">Busca Avançada</button>
</div>
<div class="form-group">
<button type="submit" value="buscar" class="btn btn-primary"><i class="fa fa-search"></i> Buscar</button>
</div>
</div>
<br>
<br>
<hr>
</div>
</form>
</div>
</div>
<?php
}
else {
?>
<div class="row" style="padding-top: 60px;">
<div class="col-md-4">
<!-- Search Widget -->
<form id="buscaImovel" method="GET" action="/corretora/View/Pages/busca.php" >
<div class="card my-12">
<h5 class="card-header">Pesquise seu imóvel:</h5>
<div class="card-body">
<div class="input-group">
<div class="form-group">
<b><label for="transacao">O que você deseja?</label></b>
<select id="transacao" class="form-control" name="transacao" >
<option selected value="">Selecione a opção:</option>
<?php foreach($transacoes as $transacao){?>
<?php if($transacao['descricaoTransacao'] == "Vender") { ?>
<option value="<?php echo $transacao['idTransacao'];?>"> Comprar </option>
<?php } else { ?>
<option value="<?php echo $transacao['idTransacao'];?>"> <?php echo $transacao['descricaoTransacao'];?> </option>
<?php } ?>
<?php } ?>
</select>
</div>
<hr>
<div class="form-group">
<b><label for="tipoDeImovel">Que tipo de imóvel você proucura?</label></b>
<select id="tipoDeImovel" class="form-control" name="tipoDeImovel" >
<option selected value="">Selecione o tipo do imóvel:</option>
<?php foreach($tiposDeImovel as $tipoImovel){?>
<option value="<?php echo $tipoImovel['idTipoImovel'];?>"> <?php echo $tipoImovel['descricaoTipoImovel'];?> </option>
<?php } ?>
</select>
</div>
<hr>
<div class="form-group">
<b><label for="endereco">Endereço:</label></b>
<select id="estado" class="form-control" name="estado" >
<option selected value="">Selecione seu estado:</option>
<?php foreach($estados as $estado){?>
<option value="<?php echo $estado['idEstado'];?>"> <?php echo $estado['descricaoEstado'];?> </option>
<?php }?>
</select>
<br>
<input type="text" class="form-control" id="cidade" placeholder="Digite a cidade aqui" name="cidade" >
<br>
<input type="text" class="form-control" id="bairro" placeholder="Digite o bairro aqui" name="bairro" >
</div>
</div>
<div class="form-group" id="minhaDiv" style="display:none">
<div class="form-group">
<label for="quantQuarto">Quartos:
<input type="number" class="form-control" id="quantQuarto" placeholder="0" name="quantQuarto"></label>
<label for="quantSuite">Suítes:
<input type="number" class="form-control" id="quantSuite" placeholder="0" name="quantSuite"></label>
</div>
<div class="form-group">
<label for="quantVagaGaragem">Vagas de garagem:
<input type="number" class="form-control" id="quantVagaGaragem" placeholder="0" name="quantVagaGaragem"></label>
</div>
<div class="form-group">
<label for="quantBanheiro">Banheiros:
<input type="number" class="form-control" id="quantBanheiro" placeholder="0" name="quantBanheiro"></label>
</div>
<div class="form-group">
<label for="idImovel">Código do imóvel:
<input type="number" class="form-control" id="idImovel" placeholder="0" name="idImovel"></label>
</div>
</div>
<div class="form-group">
<button class="btn btn-warning" type="button" onclick="Mudarestado('minhaDiv')">Busca Avançada</button>
</div>
<div class="form-group">
<button type="submit" value="buscar" class="btn btn-primary"><i class="fa fa-search"></i> Buscar</button>
</div>
</div>
<hr>
</div>
</form>
</div>
<div class="col-md-8">
<div class="bd-example">
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<?php foreach($imoveisRamdomUno as $imovelRamdomUno){?>
<div class="carousel-item active">
<a onclick="window.location.href='/corretora/View/Pages/anuncio.php?id=<?php echo $imovelRamdomUno['idImovel'];?>'">
<?php
$idImovel = $imovelRamdomUno['idImovel'];
$res = $imagensImovelModel->getImagemImovelIndex($idImovel);
if(empty($res)){
?>
<img class="d-block w-100 img-fluid" style="width:500px;height:600px;" src="Files/no_image.png">
<?php }
foreach($res as $imagem){ ?>
<img class="d-block w-100 img-fluid" style="width:500px;height:600px;" src="Files/<?php echo $imagem;?>" >
<?php } ?>
</a>
<div class="carousel-caption d-none d-md-block">
<h5><b><u>
<?php echo $imovelRamdomUno['descricaoTransacao'];?>
<b>um(a)</b> <?php echo $imovelRamdomUno['descricaoTipoImovel'];?>
</u></b></h5>
<p></p>
</div>
</div>
<?php } ?> <!-- foreach uno fecha aki -->
<?php foreach($imoveisRamdom as $imovelRamdom){?>
<div class="carousel-item">
<a onclick="window.location.href='/corretora/View/Pages/anuncio.php?id=<?php echo $imovelRamdom['idImovel'];?>'">
<?php
$idImovel = $imovelRamdom['idImovel'];
$res = $imagensImovelModel->getImagemImovelIndex($idImovel);
if(empty($res)){
?>
<img class="d-block w-100 img-fluid" style="width:500px;height:600px;" src="Files/no_image.png">
<?php }
foreach($res as $imagem){ ?>
<img class="d-block w-100 img-fluid" style="width:500px;height:600px;" src="Files/<?php echo $imagem;?>" >
<?php } ?>
</a>
<div class="carousel-caption d-none d-md-block">
<h5><b><u>
<?php echo $imovelRamdom['descricaoTransacao'];?>
<b>um(a)</b> <?php echo $imovelRamdom['descricaoTipoImovel'];?>
</u></b></h5>
<p></p>
</div>
</div>
<?php } ?> <!-- foreach ramdom fecha aki -->
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Voltar</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Proximo</span>
</a>
</div>
</div>
</div>
<hr>
</div> <!-- finaliza o else -->
<?php
}
?>
<!-- Page Content -->
<div class="container">
<!-- Page Heading -->
<h1 class="my-4">Anúncios</h1>
<!-- Project One -->
<?php $count = 0; ?>
<?php foreach($imoveis as $imovel){?>
<div class="row">
<div class="col-md-7">
<?php
$idImovel = $imovel['idImovel'];
$res = $imagensImovelModel->getImagemImovelIndex($idImovel);
if(empty($res)){
?>
<img class="img-fluid" style="width:750px;height:300px;" src="Files/no_image.png">
<?php }
foreach($res as $imagem){ ?>
<img class="img-fluid" style="width:750px;height:300px;" src="Files/<?php echo $imagem;?>" >
<?php } ?>
</div>
<div class="col-md-5">
<p><b>Código do Imóvel: </b>
<?php echo $imovel['idImovel'];?></p>
<p><b>Transação:</b>
<?php echo $imovel['descricaoTransacao'];?>
<b>um(a)</b>
<?php echo $imovel['descricaoTipoImovel'];?>.</p>
<p><b>Preço: R$</b>
<?php if($imovel['precoImovel'] == null || $imovel['precoImovel'] == 0) {
echo "Valor a negociar";
} else {
echo $imovel['precoImovel'];
}?></p>
<p><b>Área útil:</b>
<?php echo $imovel['areaUtil'];?> M²  
<b>Área total:</b>
<?php echo $imovel['areaTotal'];?> M² </p>
<p><img src="https://img.icons8.com/windows/32/000000/bed.png" title="Quantidade de Quartos:">:
<?php echo $imovel['quantQuarto'];?> quarto(s)  
<img src="https://img.icons8.com/metro/32/000000/shower-and-tub.png" title="Quantidade de Suítes:">:
<?php echo $imovel['quantSuite'];?> suíte(s) </p>
<p><img src="https://img.icons8.com/ios/32/000000/car.png" title="Quantidade de Vagas na Garagem:">:
<?php echo $imovel['quantVagaGaragem'];?> vaga(s)  
<img src="https://img.icons8.com/ios/32/000000/shower.png" title="Quantidade de Banheiros:">:
<?php echo $imovel['quantBanheiro'];?> banheiro(s) </p>
<!-- Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalExemplo<?php echo $count; ?>">
<i class="fa fa-info-circle"></i> Detalhes
</button>
<button type="button" class="btn btn-success"
onclick="window.location.href='/corretora/View/Pages/anuncio.php?id=<?php echo $imovel['idImovel'];?>'">
<i class="fa fa-arrow-right"></i> Visualizar
</button>
<div class="modal fade" id="modalExemplo<?php echo $count; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Detalhes e Localização</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Fechar">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><b>Estado: </b>
<?php echo $imovel['descricaoEstado'];?>.</p>
<p><b>Cidade: </b>
<?php echo $imovel['nomeCidade'];?>.</p>
<p><b>Bairro: </b>
<?php echo $imovel['nomeBairro'];?>.</p>
<p><b>Rua: </b>
<?php echo $imovel['logradouro'];?>.</p>
<p><b>Número: </b>
<?php echo $imovel['numero'];?>.</p>
<p><b>Descrição do Imóvel: </b>
<?php echo $imovel['descricaoImovel'];?>.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.row -->
<hr>
<?php $count++; ?>
<?php } ?> <!-- foreach fecha aki -->
</div>
<!-- /.container -->
</div>
<!-- Banner 2-->
<?php if($banner2 != false) { ?>
<div class="offset-md-2 col-md-8" style="padding-top: 20px; padding-bottom: 20px;">
<a href="<?php echo $banner2['link']?>">
<img class="d-block w-100 img-fluid" style="width:450px;height:150px;" src="/corretora/Files/banners/<?php echo $banner2['imagemBanner']?>" alt="Anuncie aqui">
</a>
</div>
<?php } ?>
<?php include "View/Templates/footer.php"; ?>