Repository navigation
Expand file tree
/
Copy pathdashboard.php
More file actions
233 lines (197 loc) · 10.2 KB
/
Copy pathdashboard.php
File metadata and controls
233 lines (197 loc) · 10.2 KB
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
<?php
session_start();
if (!isset($_SESSION['user'])) {
header("location: /ShopNow/login.php");
}
//connect to the db
require('db.php');
if (isset($_POST['create'])) {
$productName = $_POST['productName'];
$imgSrc = $_POST['imgSrc'];
$price = $_POST['price'];
$cat_id = $_POST['cat_id'];
$sql_query = "INSERT INTO product (productName, imgSrc, price, cat_id) VALUES ( '$productName' , '$imgSrc' , '$price' , '$cat_id' )";
$res = mysqli_query($conn, $sql_query);
}
//prepare query string
$sql_query = "SELECT * FROM product_cat";
$result = mysqli_query($conn, $sql_query);
//transfoorm mysqli_results to array associative
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
//like printf
// var_dump($rows);
$sql_query = "SELECT * FROM category";
$res = mysqli_query($conn, $sql_query);
$cats = mysqli_fetch_all($res, MYSQLI_ASSOC);
$BAYC = 'BAYC';
$Dod = 'Doodle';
$WOW = 'World Of Women';
?>
<html lang="en">
<a href="/ShopNow/Dashboard.php"></a>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/ShopNow/public/css/index.css">
<link rel="stylesheet" href="/ShopNow/public/css/dashboard.css">
<link rel="stylesheet" href="/ShopNow/public/css/header-inventory.css">
<link rel="stylesheet" href="/ShopNow/public/css/sidebar-inventory.css">
<script src="https://kit.fontawesome.com/c4254e24a8.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;500;600;700;800;900&family=Roboto&display=swap" rel="stylesheet">
<title>Dashboard</title>
</head>
<body class="flex">
<!-- side bar -->
<div style="overflow: hidden; left:0; height:100%; background-color: #1F2344; " class="sidebar">
</div>
<!-- end side bar -->
<!-- body content -->
<div style=" display:none; width: 100vw; height:100vh; background-color: #000000d4; z-index:999; position:absolute; top:0;left:0;" class="flex justify-center items-center popup">
<form method="POST" style=" background-color: #1F2344;" class=" w-l-wrapper p-3 gap-3 flex rounded flex-col bg-wrapper shadow-wrapper">
<div style="justify-content: flex-end;" class="w-full flex">
<h3 onclick="closePopup()" class="cursor-pointer text-white">Cancel</h3>
</div>
<h1 class="p-1 text-white flex justify-center items-center ">Add NFT</h1>
<label for="name" class="text-white pl-3">NFT Name</label>
<input type="text" style="min-width: 320px;" name="productName" id="name" class="p-1 rounded-sm form-email outline-none" placeholder="Enter NFT Name" required>
<label for="src" class="text-white pl-3">NFT image</label>
<input type="text" style="min-width: 320px;" name="imgSrc" id="src" class="p-1 rounded-sm form-email outline-none" placeholder="Enter NFT source URL" required>
<label for="price" class="text-white pl-3">NFT price</label>
<input type="number" style="min-width: 320px;" name="price" id="price" class="p-1 rounded-sm form-email outline-none" placeholder="Enter NFT price" required>
<label for="price" class="text-white pl-3">NFT category</label>
<select name="cat_id" class="p-1 rounded-sm form-email outline-none">
<option>select category</option>
<?php foreach ($cats as $c) { ?>
<option value="<?php echo $c['id'] ?>"><?php echo $c['catName'] ?></option>
<?php } ?>
</select>
<div class="flex justify-center w-full">
<button name="create" style="min-width:300px;" class="p-3 w-btn font-xl cursor-pointer outline-none rounded flex justify-center items-center bg-primary"><span>Add</span></button>
</div>
</form>
</div>
<div class="body w-full overflow-y-scroll">
<div style="width : 100%">
<?php include('header-inventory.php'); ?>
</div>
<div style="justify-content: flex-end; margin-top:5rem; " class="flex w-full p-3">
<button onclick="showPopup()" style="background-color: deeppink;" class="p-1 cursor-pointer text-white rounded-sm">Add new NFT</button>
</div>
<div style="padding:1rem; " class="dashboard-wrapper rounded-sm w-full flex bg-violet ">
<!-- left side of body content -->
<div class="left-side">
<div class="flex justify-center">
<div style="width: 1025px; height: 323px; border-radius: 15px; background-image: url('./public/assets/images/Etherium.webp'); background-position: center; background-size: cover;" class="">
</div>
</div>
<div style="width:100%; height:75%; background-color:#12173D; margin-top:3rem; " class="pie rounded">
<canvas id="myChart" style="width:20%; height:20%;"></canvas>
</div>
</div>
<!-- end left side of body content -->
<div class="right-side">
<?php foreach ($rows as $r) { ?>
<!-- card 1 wrapper -->
<div style="width:100%; margin-bottom: 30px ; border-radius: 15px; background-color:#12173D; " class="cards-wrapper flex">
<div class="img-h3">
<div class="h3">
<h3 style="color: #FBBE54; margin-top:1rem; margin-left:1rem; font-family:poppins; font-size: 32px;">TOP SALES</h3>
</div>
<div class="img">
<div style="width: 190px; height: 170px; margin-left:1rem; border-radius: 15px; background-image: url('<?php echo $r['imgSrc'] ?>'); background-position: center; background-size: cover; background-repeat:no-repeat;" class="">
</div>
</div>
</div>
<div style="margin-left: 2rem;" class="text-content flex justify-center items-center">
<div style=" font-size: 20px;">
<h3 style="color:white; font-family:poppins;"><?php echo $r['productName']; ?></h3>
<div class="">
<p style="color: #C2C2C2; margin-top:1rem; font-family:poppins;">Sale ends January 16, 2022 <br />at 9:25am</p>
</div>
<div style="gap: 1rem; margin-top:1rem;" class="flex items-center ">
<i style="color: #ff37d7;" class="fab fa-ethereum"></i>
<p style=" font-size:1rem; color:white; font-family:poppins;"><?php echo $r['price']; ?></p>
</div>
</div>
</div>
</div>
<!-- end card 1 wrapper -->
<?php } ?>
</div>
</div>
<script>
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: [
<?php
foreach ($rows as $r) {
echo '"';
echo $r['productName'];
echo '"';
echo ",";
}
?>
],
datasets: [{
label: '# of Votes',
data: [<?php
foreach ($rows as $r) {
echo $r['price'];
echo ",";
}
?>],
backgroundColor: [
'violet','blue','purple','grey','yellow','blue','black'
],
borderColor: [
'violet','blue','purple','grey','yellow','blue','black'
],
borderWidth: 3
}]
},
});
const showPopup = () => {
document.querySelector('.popup').style.display = 'flex'
}
const closePopup = () => {
document.querySelector('.popup').style.display = 'none'
}
</script>
<script src="./public/js/helpers/helpers.js"></script>
<script src="./public/js/sidebar-inventory.js"></script>
<script>
var logo = document.querySelector('.logo');
logo.addEventListener('click', show_sidebar);
var logo_sidebar = document.querySelector('.logo_sidebar');
logo_sidebar.addEventListener('click', hide_sidebar);
function show_sidebar(){
// var sidebar = document.querySelector('.sidebar');
// sidebar.classList.(".display");
let sidebar = document.querySelector(".sidebar");
// if(sidebar.style.display == "block"){
// sidebar.style.display = "none";
// }
// else {sidebar.style.display = "block";}
sidebar.style.display = "block";
document.querySelector(".logo").style.display = "none";
// sidebar.classList.toggle(".display");
// sidebar.classList.toggle(".responsive-sidebar");
}
function hide_sidebar(){
// var sidebar = document.querySelector('.sidebar');
// sidebar.classList.(".display");
let sidebar = document.querySelector(".sidebar");
sidebar.style.display = "none";
document.querySelector(".logo").style.display = "block";
let main_page = document.querySelector(".main-page");
main_page.classList.add("w-100");
// sidebar.classList.toggle(".display");
// sidebar.classList.toggle(".responsive-sidebar");
}
</script>
</body>
</html>