forked from brenddamachado/Seven_Gardens
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
126 lines (107 loc) · 5.53 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
<?php
require_once __DIR__ . '/helpers/path_helper.php'; // Inclui a função base_url
if (session_status() == PHP_SESSION_NONE) {
session_start(); // Inicia a sessão apenas se não estiver já iniciada
}
$path = __DIR__ . '/Front-end/PHP/connect.php';
if (!file_exists($path)) {
die('Arquivo de conexão não encontrado: ' . $path);
}
require $path;
// Verificar se o usuário é um 'Master' ou 'Colaborador'
$isUserMasterOrColaborador = isset($_SESSION['usuario_tipo']) && in_array($_SESSION['usuario_tipo'], ['Master', 'Colaborador']);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Seven Gardens</title>
<link rel="stylesheet" href="<?php echo base_url('Front-end/css/header.css'); ?>">
<link rel="shortcut icon" href="<?php echo base_url('Front-end/img/logoatual.svg'); ?>" type="image/x-icon" />
<link rel="stylesheet" href="<?php echo base_url('Front-end/css/style.css'); ?>">
<link rel="stylesheet" href="<?php echo base_url('Front-end/css/Card-produtos.css'); ?>">
<link rel="stylesheet" href="<?php echo base_url('Front-end/css/modalEstilos.css'); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<script src="<?php echo base_url('Front-end/js/acessibilidade.js'); ?>"></script>
</head>
<body>
<?php include('header.php'); ?>
<div class="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="<?php echo base_url('Front-end/img/banner1.svg'); ?>" alt="Imagem 1">
</div>
<div class="carousel-item">
<img src="<?php echo base_url('Front-end/img/banner2.svg'); ?>" alt="Imagem 2">
</div>
<div class="carousel-item">
<img src="<?php echo base_url('Front-end/img/banner3.svg'); ?>" alt="Imagem 3">
</div>
</div>
<button class="carousel-prev" onclick="prevSlide()"></button>
<button class="carousel-next" onclick="nextSlide()"></button>
</div>
<span class="titulopg">
<h1>Destaques</h1>
</span>
<hr>
<!-- inicio Bloco de Produtos -->
<div class="bloco-produtos">
<?php
$query = "SELECT idProduto, nome, preco, descricao, categoria, subcategoria, imagem FROM produto";
$stmt = $pdo->prepare($query);
$stmt->execute();
// Exibir os cards dos produtos
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<div class='produto-card'>";
echo "<img class='imgProduto' src='" . htmlspecialchars($row["imagem"]) . "' alt='Imagem do produto'>";
echo "<h3>" . htmlspecialchars($row["nome"]) . "</h3>";
echo "<p class='preco'>Preço: R$ " . number_format($row["preco"], 2, ',', '.') . "</p>";
echo "<p class='descricao'>" . htmlspecialchars($row["descricao"]) . "</p>";
echo "<p class='categoria'>Categoria: " . htmlspecialchars($row["categoria"]) . "</p>";
echo "<p class='subcategoria'>Subcategoria: " . htmlspecialchars($row["subcategoria"]) . "</p>";
if ($isUserMasterOrColaborador) {
echo "<div class='organiza_btns'>"; // Container para os botões
echo "<button class='editar-btn' data-id='" . htmlspecialchars($row["idProduto"]) . "' data-nome='" . htmlspecialchars($row["nome"]) . "' data-preco='" . htmlspecialchars($row["preco"]) . "' data-descricao='" . htmlspecialchars($row["descricao"]) . "' data-categoria='" . htmlspecialchars($row["categoria"]) . "' data-subcategoria='" . htmlspecialchars($row["subcategoria"]) . "'>Editar</button>";
echo "<button class='excluir-btn' data-id='" . htmlspecialchars($row["idProduto"]) . "'>Excluir</button>";
echo "</div>"; // Fim do container
} else {
echo "<button class='comprar-btn' data-id='" . htmlspecialchars($row['idProduto']) . "' onclick=\"adicionarAoCarrinho(" . htmlspecialchars($row['idProduto']) . ", '" . htmlspecialchars($row['nome']) . "', " . htmlspecialchars($row['preco']) . ", '" . htmlspecialchars($row['imagem']) . "')\">Comprar</button>";
}
echo "</div>";
}
?>
</div>
<!-- Fim Bloco de Produtos -->
<!-- Fim do Bloco de Produtos -->
<div id="itensCarrinho" class="carrinho">
<!-- Itens do carrinho serão adicionados aqui -->
</div>
<!-- ACESSIBILIDADES -->
<section id="accessibility-section">
<i class="fas fa-universal-access" id="accessibility-icon"></i>
<div id="other-things">
<i class="fas fa-sun" id="light-mode-toggle"></i>
<i class="fas fa-moon" id="dark-mode-toggle"></i>
<img class="img_letra" src="<?php echo base_url('Front-end/img/aumentartext_1.svg'); ?>" alt="" srcset="" id="increase-font">
<img class="img_letra" src="<?php echo base_url('Front-end/img/diminuirtext_1.svg'); ?>" alt="" srcset="" id="decrease-font">
</div>
</section>
<!--FIM DA ACESSIBILIDADES -->
<footer>
<br>
<div class="social-icons">
<p> Siga-nos nas nossas redes sociais:</p>
<a href="#" class="icon"><i class="fab fa-facebook"></i></a>
<a href="#" class="icon"><i class="fab fa-instagram"></i></a>
<a href="#" class="icon"><i class="fab fa-whatsapp"></i></a>
</div>
</footer>
<script src="<?php echo base_url('Front-end/js/script.js'); ?>"></script>
<script src="<?php echo base_url('Front-end/js/carrinho.js'); ?>"></script>
<script src="<?php echo base_url('Front-end/js/modal_Edit_Produtos.js'); ?>"></script>
</body>
</html>