-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproducts.php
159 lines (149 loc) · 7.2 KB
/
products.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
<?php
include 'db.php';
$search = '';
if (isset($_GET['search'])) {
$search = $_GET['search'];
}
$sql = "SELECT * FROM produit WHERE
assets LIKE '%$search%' OR
description LIKE '%$search%' OR
`Inventory-method` LIKE '%$search%' OR
SN LIKE '%$search%' OR
location LIKE '%$search%' OR
user LIKE '%$search%' OR
`Purchase-Date` LIKE '%$search%' OR
Warranty LIKE '%$search%' OR `category` LIKE '%$search%'";
$result = $conn->query($sql);
session_start(); // Start session to access user information
// Check if user is logged in
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
} else {
// Redirect to login page if user is not logged in
header("Location: index.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="button.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Magazain Yazaki IT</title>
</head>
<body>
<script>
function confirmDelete() {
return confirm("Are you sure you want to delete this item?");
}
</script>
<div class="container">
<nav class="navbar bg-body-tertiary fixed-top">
<div class="container-fluid">
<img src="image/logo.png" alt="logo" class="logo">
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Menu</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="home.php"><i class="fas fa-home"></i> Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-box"></i> Products</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="products.php">Product List</a></li>
<li><a class="dropdown-item" href="scrap.php">Scrap List</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="product.php">Products Catalog</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="about.php"><i class="fas fa-info-circle"></i> About</a></li>
<li class="nav-item"><a class="nav-link" href="contact.php"><i class="fas fa-envelope"></i> contact</a></li>
<li class="nav-item"><a class="nav-link" href="settings.php"><i class="fas fa-cog"></i> User Settings</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
</ul>
<form class="d-flex mt-3" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit"><i class="fas fa-search"></i> Search</button>
</form>
</div>
</div>
</div>
</nav>
<span class='result-count'><?php echo $result->num_rows; ?> product(s) found</span>
<h1>Products List</h1>
<a href="create.php" class="button button-add">Add a product</a>
<button type="button" class="button button-add" data-bs-toggle="modal" data-bs-target="#uploadModal">
Delete product
</button>
<div class="modal fade" id="uploadModal" tabindex="-1" aria-labelledby="uploadModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="uploadModalLabel">delete product</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img src="image/logo.png" alt="Logo" class="logo">
<form action="delete.php" method="get">
<label for="asset_number">Asset Number:</label>
<input type="text" id="id" name="id" required>
<input type="submit" value="Delete" onclick="return confirmDelete()">
</form>
</div>
</div>
</div>
</div>
<table>
<tr>
<th>Asset Number</th>
<th>Description</th>
<th>Inventory Method</th>
<th>Serial Number</th>
<th>Location</th>
<th>User</th>
<th>Purchase Date</th>
<th>Warranty</th>
<th>Status</th>
</tr>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["assets"] . "</td>";
echo "<td>" . $row["description"] . "</td>";
echo "<td>" . $row["Inventory-method"] . "</td>";
echo "<td>" . $row["SN"] . "</td>";
echo "<td>" . $row["location"] . "</td>";
echo "<td>" . $row["user"] . "</td>";
echo "<td>" . $row["Purchase-Date"] . "</td>";
echo "<td>" . $row["Warranty"] . "</td>";
echo "<td>" . $row["category"] . "</td>";
echo "<td>
<a href='update.php?id=" . $row["assets"] . "' class='button button-edit'>Edit</a>
</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='10'>Aucun produit trouvé</td></tr>";
}
?>
</table>
</div>
<footer>
<p>© 2024 Yazaki IT Store. All rights reserved.</p>
</footer>
<button onclick="topFunction()" id="myBtn" title="Go to top"><i class="fa-solid fa-arrow-up"></i></button>
<script src="index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>