-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.php
155 lines (142 loc) · 7.02 KB
/
product.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
<?php
include('header.php');
$sql = "SELECT * FROM product";
$run = mysqli_query($conn,$sql);
if(mysqli_num_rows($run) > 0){
$product = mysqli_fetch_all($run,MYSQLI_ASSOC);
}else{
$none = 0;
}
?>
<style>
.w3-modal-content{
width: 30% !important;
border-radius: 10px;
}
.ex{
border-radius: 3px;
}
</style>
<link rel="stylesheet" href="assets/css/w3.css">
<div class="main-panel">
<div class="content-wrapper">
<div class="row" id="proBanner">
<div class="col-12">
<span class="d-flex align-items-center purchase-popup">
<form class="d-flex align-items-center h-100" action="search.php" method="GET">
<div class="input-group">
<div class="input-group-prepend bg-transparent">
<i class="input-group-text border-0 mdi mdi-magnify"></i>
</div>
<input type="text" name="term" class="form-control bg-transparent border-0" placeholder="Search products">
<div class="input-group-append bg-transparent">
<button type="submit" name="submit" class="btn btn-primary">GO</button>
</div>
</div>
</form>
</span>
</div>
</div>
<div class="d-xl-flex justify-content-between align-items-start">
<div class="d-sm-flex justify-content-xl-between align-items-center mb-2">
<div class="dropdown ml-0 ml-md-4 mt-2 mt-lg-0">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="d-sm-flex justify-content-between align-items-center transaparent-tab-border ">
</div>
<div class="row">
<div class="col-md-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h4 class="card-title">Available products</h4>
<table class="table table-striped">
<thead>
<tr>
<th> ID </th>
<th> Product Name </th>
<th> Prodcut Category </th>
<th> Price </th>
<th>Upload Date</th>
<th> Check Expiry</th>
<th> Delete</th>
</tr>
</thead>
<tbody>
<?php
if(!isset($none)){
foreach($product as $prod){
$id = $prod['id'];
?>
<tr>
<td class="py-1">
<img src="product/<?php echo $prod['id']?>.jpg" alt="image" />
</td>
<td> <?php echo $prod['name']?> </td>
<td>
<!-- <div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div> -->
<b><?php echo $prod['category']?></b>
</td>
<td> ₦ <?php echo $prod['price']?> </td>
<td> <?php
$stamp = $prod['stamp'];
date_default_timezone_set('Africa/Lagos');
$day = date('F j, Y',$stamp);
echo $day;
?> </td>
<td>
<?php
$stamp = $prod['stamp'];
$now = time();
$days_gone = $now - $stamp;
$days_gone = $days_gone/86400;
// date('h',$days_gone);
// echo $days = intval(date('d',$days_gone));
// $days = $days - 1;
$days = floor($days_gone);
?>
<div id="show<?php echo $id?>" class="w3-modal">
<div class="w3-modal-content w3-card-4 w3-animate-top">
<div class="w3-container text-center">
<span onclick="document.getElementById('show<?php echo $id?>').style.display='none'"
class="w3-button w3-display-topright">×</span>
<br><br>
<p>This product will expire in</p>
<h1 class="text-primary text-bold"><?php echo $exp= $prod['inv_days'] - $days?></h1>
<p>Days</p>
</div>
</div>
</div>
<?php
if($exp > 0){?>
<a onclick="document.getElementById('show<?php echo $id?>').style.display='block'" class="btn btn-primary">Check</a>
<?php }else{?>
<label for="" class="bg-danger p-1 ex text-white">Expired</label>
<?php } ?>
</td>
<td>
<a href="delete.php?id=<?php echo $id ?>" class="btn bg-white text-danger">Delete</a>
</td>
</tr>
<?php }?>
<?php }else{?>
<tr>
<td colspan="7" class=" text-center">No Records Found</td>
<?php } ?>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
include('footer.php');
?>