-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
222 lines (179 loc) · 5.66 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
<?php
// Verifica se o login foi criado
session_start();
if(!isset($_SESSION["email"])==true){
header("location: login.php");
}
// Arquivo de Configuracao com o Banco de Dados
include "assets/src/cfg.php";
//### FIM - Recebimento do POST do formulario ###
// Busca os produtos no banco de dados.
$consultaProd = "SELECT * FROM produtos";
$resultListProd = mysqli_query($con,$consultaProd);
$rowListProd = mysqli_fetch_array($resultListProd);
// Busca as categorias no banco de dados.
$consultaCat = "SELECT * FROM categorias";
$resultListCat = mysqli_query($con,$consultaCat);
$rowListCat = mysqli_fetch_array($resultListCat);
// Busca os fornecedors no banco de dados.
$consultaForn = "SELECT * FROM fornecedores";
$resultListForn = mysqli_query($con,$consultaForn);
$rowListForn = mysqli_fetch_array($resultListForn);
//}
//else{
// header("location: login.php");
//}
?>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<title>PHP + Banco de Dados</title>
<!-- Bootstrap core CSS -->
<link href="assets/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.4.7/sweetalert2.all.js" integrity="sha512-dF7ro6GMO4363S7UqfqyIjiWug1bub5JAEi6jpRNzpHk0gZa8BGrhJKMeLegzgamf2nA8GGw/j80Bre1Bx8hdg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
body{padding-top: 60px !important}
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background: #ddd;
color: black;
}
.main {
padding: 16px;
margin-top: 30px;
height: 1500px; /* Used in this example to enable scrolling */
}
#myInput {
background-image: url('css/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
</style>
<!-- Criação de filtro dos produtos-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
</head>
<body>
<?php include "header.php"; ?>
<main>
<section class="py-5 text-center container">
<!-- Input com Filtro dos Produtos -->
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Filtrar Produtos..." title="Digite algo">
<div class="container text-center" >
<div class="row">
<div class="col-sm-12">
<div class="text-align">
</div>
<table class="table text-center align-middle" id="myTable">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">ID</th>
<th scope="col">Imagem</th>
<th scope="col">Produto</th>
<th scope="col">Quantidade</th>
<th scope="col">Preço</th>
<th scope="col">Fornecedor</th>
<th scope="col">Categoria</th>
</tr>
</thead>
<tbody>
<?php $i = 1; if(mysqli_num_rows($resultListProd)>0){
// Irá separar o conteúdo do array em linhas
foreach ($resultListProd as $rowListProd) {
?>
<tr>
<th scope="row"><?php echo $i++ ?></th>
<td><?php echo $rowListProd['produtoID']; ?></td>
<td><img src="uploads/<?php echo $rowListProd['produtoImagem']==''?'padrao.jpg':$rowListProd['produtoImagem'] ?>" width="32" heigth="32"> </td>
<td><?php echo $rowListProd['produtoNome']; ?></td>
<td><?php echo $rowListProd['quantidade']; ?></td>
<td><?php echo $rowListProd['preco']; ?></td>
<td>
<?php if(mysqli_num_rows($resultListForn)>0){
// Irá separar o conteúdo do array em linhas
foreach ($resultListForn as $rowListForn) {
?>
<!-- Se o status da categoria estiver como 0 desabilitada ela desabilita a seleção -->
<?php echo $rowListForn['fornecedorID']==$rowListProd['fornecedorID']? $rowListForn['nomeFantasia']:'' ;
} //Fim do Loop do foreach.
} // Fim do if(mysqli_num_rows($resultListForn).
?>
</td>
<td>
<?php if(mysqli_num_rows($resultListCat)>0){
// Irá separar o conteúdo do array em linhas
foreach ($resultListCat as $rowListCat) {
?>
<!-- Se o status da categoria estiver como 0 desabilitada ela desabilita a seleção -->
<?php echo $rowListCat['categoriaID']==$rowListProd['categoriaID']? $rowListCat['categoriaNome']:'' ;
} //Fim do Loop do foreach.
} // Fim do if(mysqli_num_rows($resultListForn).
?>
</td>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
} //Fim do Loop do foreach.
} // Fim do if(mysqli_num_rows($resultList).
?>
</tbody>
</table>
</div>
</div>
</div>
</section>
</main>
<?php include "footer.php";
?>
</body>
</html>