-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-order.php
More file actions
416 lines (346 loc) · 13.4 KB
/
cli-order.php
File metadata and controls
416 lines (346 loc) · 13.4 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<?php
include "cli-session.php"; //client-session and other related information
include "cli-count.php"; //client all counted variables used
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title><?php echo $username;?>'s Cart</title>
<?php include "cli-linkstyle.php"; ?> <!--Client link styles scripts and css -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
#checkout{
background:#bc3f31;
color:white;
border:none;
border-radius:5px;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
#checkout:hover{
backgrond:#dc4b41;
}
#sr{
background:#bc3f31;
padding:10px 13px;
color:white;
border:none;
border-radius:5px;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
#sr:hover{
background:#dc4b41;
text-decoration:none;
}
#on{
background:#bc3f31;
padding:10px 13px;
color:white;
border:none;
border-radius:5px;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
#on:hover{
background:#dc4b41;
text-decoration:none;
}
</style>
<body style="background:whitesmoke;">
<?php require_once "c-sidebar.php";?> <!--Side bar-->
<section class="home-section">
<div class="container-fluid" style="background-color:whitesmoke;">
<div class="card-shadow">
<?php
//if client request to department head is successful
if(isset($_SESSION['requested']))
{
?>
<div class="alert alert-success alert-dismissible fade show" id="div-success" role="alert"
style="margin-top:3%;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col">
<h1>Request Sent</h1>
</div>
<div class="col">
<h1 style="float:right;"> <i class='bx bx-check'></i></h1>
</div>
</div><hr><i><?=$_SESSION['requested'];?><?php echo $dept_head; echo " "; echo $head; echo " in "; echo $head_office;?></i>
</div>
<?php
unset($_SESSION['requested']);
}
?>
<?php
//if cart is updated
if(isset($_SESSION['updated']))
{
?>
<div class="alert alert-success alert-dismissible fade show" id="div-success" role="alert"
style="margin-top:3%;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col">
<h1>Updated</h1>
</div>
<div class="col">
<h1 style="float:right;"> <i class='bx bx-check'></i></h1>
</div>
</div><hr><i><?=$_SESSION['updated'];?></i>
</div>
<?php
unset($_SESSION['updated']);
}
?>
<?php
//if cart is updated
if(isset($_SESSION['delCart']))
{
?>
<div class="alert alert-danger alert-dismissible fade show" id="div-success" role="alert"
style="margin-top:3%;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col">
<h1>Deleted</h1>
</div>
<div class="col">
<h1 style="float:right;"> <i class='bx bx-check'></i></h1>
</div>
</div><hr><i><?=$_SESSION['delCart'];?></i>
</div>
<?php
unset($_SESSION['delCart']);
}
?>
<div class="row">
<div class="col">
<div class="card-body" style="border-top-left-radius:10px;border-top-right-radius:10px;border:1px solid #ededed;
margin-top:2%;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col" style="margin-left:-1.5%;">
<button type="button" id="cart"><i class='bx bx-cart' id="icart" style="font-size:30px;"></i><br>My Cart ( <?php echo $carty;?> )</button>
</div>
<div class="col" style="margin-right:-1.5%;">
<button type="button" id="orders"><i class='bx bx-cart-alt' id="iorder" style="font-size:30px;"></i><br>My Orders</button>
</div>
</div>
</div>
<div id="mycart-div" style="">
<div class="card-body" style="border:1px solid #ededed;;margin-left:10%;margin-right:10%;background:#f9f9f9;
color:white;border-bottom-left-radius:5px;border-bottom-right-radius:5px;">
<div class="row">
<div class="col">
<h4 style="color:grey;"><?php echo $username;?>'s Cart</h4>
</div>
<div class="col">
<input type="text" id="searchcart" placeholder="Find in Cart.."/>
</div>
<div class="col">
<?php //test if ris or ics is present in checkout
if($ris_ > 0 && $ics_ > 0)
{
echo '<a href="cli-sendrequest.php" id="checkout">Checkout('.$carty.')</a>';
}
else if($ris_ > 0 && $ics_ == 0)
{
echo '<a href="cli-sendris.php" id="checkout">Checkout('.$carty.')</a>';
}
else if($ics_ > 0 && $ris_ == 0)
{
echo '<a href="cli-sendics.php" id="checkout">Checkout('.$carty.')</a>';
}
?>
</div>
</div>
</div>
<?php //if nothings in my cart display this
if ($mycart == 0){
echo '<div class="card-body" style="border:1px solid #ededed;;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col">
</div>
<div class="col" style="text-align:center;">
<img src="image/ec.jpg" style = "oject-fit:cover;"><br><br>
<br><span style="color:grey;">Nothings in your cart.</span><br><br><br>
<a href="cli-stockroom.php" id="sr">Stockroom</a>
</div>
<div class="col">
</div>
</div>
</div>';
}
?>
<?php //show my cart query
include "connection.php";
$statt = "0";
$query=mysqli_query($conn,"select * from `cart` left join stocks on stocks.s_id=cart.item_id where cart.client_id = '$id' and cart.stat ='$statt'");
while($row=mysqli_fetch_array($query))
{
$order_price = $row['unit_price'] * $row['quantity'];
?>
<div class="card-body" style="margin-left:10%;margin-right:10%;border:1px solid #ededed;border-top:none;border-radius:0px;">
<div class="row">
<div class="col">
<span style="color:grey;font-size:12px;"><?php echo $row['datte'];?></span>
<span style="color:grey;font-size:12px;"><?php echo $row['timee'];?></span><br>
<img src="<?php echo $profile; ?>" style="object-fit:cover;border-radius:50%;" width="50px" height="50px"><br>
<img src="<?php echo $row['photo']; ?>" id="store" style="object-fit:cover;float:right;" width="200px" height="200px">
</div>
<div class="col">
<div class="row">
</div>
<div class="row"><br>
</div>
<div class="row">
<div class="col">
</div>
</div>
</div>
<div class="col"><br><br><br><br>
<span><?php echo $row['brand'];?></span>
<span><?php echo $row['stock_name'];?></span><br>
<span> Description : <i><?php echo $row['description'];?></i></span>
<?php //show item status in span color
if($row['status']=="available"){
echo '<br>Status : <span style="color:green;text-transform:capitalize;">'.$row['status'].'</span>';
}
else{
echo '<br>Status: <span style="color:red;text-transform:capitalize;">'.$row['status'].'</span>';
}
?>
<br>
<span>Order Quantity: <b><?php echo $row['quan'];?></b></span><br>
<span>Unit Cost: Php. <?php echo (number_format($row['unit_price'],2));?></span><br>
<span>Order Price: Php. <b><?php echo (number_format($order_price,2));?></b></span>
</div>
<div class="col">
<a onclick = "return confirm('Are you sure you want to delete this item?')" href="a-delCart.php?idcart=<?php echo $row['idcart'];?>" id="idelete" title="delete?"> <i class='bx bx-trash'></i> </a>
<a href="#checkoutmodal" title="edit?" data-toggle="modal" data-target="#editcart<?=$row['idcart']?>"
id="icheckout"> <i class='bx bx-edit'></i> </a>
</div>
</div>
</div>
<?php
include "modal-editcart.php"; //pop up modal for editing cart item
}
?>
</div><!-- end mycart div-->
<div id="myorder-div">
<div class="card-body" style="border:1px solid #ededed;;margin-left:10%;
margin-right:10%;background:#f9f9f9;color:white;">
<h4 style="color:grey;"><?php echo $username;?>'s Order</h4>
</div>
<?php
if ($orders == 0){
echo '<div class="card-body" style="border:1px solid #ededed;;margin-left:10%;margin-right:10%;">
<div class="row">
<div class="col">
</div>
<div class="col" style="text-align:center;">
<img src="image/ec.jpg" style = "oject-fit:cover;"><br><br>
<br><span style="color:grey;">You have no orders yet.</span><br><br><br>
<a href="cli-stockroom.php" id="on">Order Now</a>
</div>
<div class="col">
</div>
</div>
</div>';
}
?>
<?php include "connection.php"; //orders
$query=mysqli_query($conn,"select * from `orders` left join stocks on stocks.s_id=orders.item_id where orders.client_id = '$id'");
while($row=mysqli_fetch_array($query))
{
?>
<div class="card-body" style="margin-left:10%;margin-right:10%;border:1px solid #ededed;border-top:none;border-radius:0px;">
<div class="row">
<div class="col">
<img src="<?php echo $row['photo']; ?>" id="store" style="object-fit:cover;border-radius:50px;border:1px solid #ededed;"
width="100px" height="100px">
</div>
<div class="col">
<span style="color:grey;font-size:13px;font-style:italic;">Order Code : </span>
<span style="font-size:20px;">HCO<?php echo $row['orderid'];?></span><br>
<span style="color:grey;font-size:13px;font-style:italic;">Order Details : </span>
<span><?php echo $row['order_quan']; echo " "; echo $row['unit'];?></span>
<span><?php echo $row['brand']; echo $row['stock_name'];?></span><br>
<span style="color:grey;font-size:13px;font-style:italic;">Order Amount : </span>
<span><?php echo (number_format($row['unit_price'],2));?></span>
</div>
<div class="col">
<?php
if($row['remarks'] == "waiting")
{
echo '<span>waiting for acceptance</span>';
}
?>
</div>
</div>
</div>
<?php
}
?>
</div><!-- end my order div-->
</div><!--end first col-->
</div><!-- end row-->
</div>
</div>
</section>
<!-- script for tabs-->
<script src="assets/js/script.js"></script>
<script>
const cart = document.getElementById("cart"); //when cart btn is clicked
const orders = document.getElementById("orders"); //change to grey btn
const mycart = document.getElementById("mycart-div"); //un read div
const myorder = document.getElementById("myorder-div"); //recent
const icart = document.getElementById("icart");
const iorder = document.getElementById("iorder");
myorder.style.display="none";
cart.onclick = function(){
//divs
myorder.style.display="none";
mycart.style.display = "block";
//buttons
cart.style.color = "#e34836";
icart.style.fontSize="40px";
//cart.style.borderBottom="3px solid #e05a00";
orders.style.color="grey";
iorder.style.fontSize="30px";
//orders.style.borderBottom = "none";
};
</script>
<script>
//when orders btn is clicked
const orders1 = document.getElementById("orders");
//change to grey btn
const cart1 = document.getElementById("cart");
//divs to hide
const mycart1 = document.getElementById("mycart-div"); //un read div
//divs to show
const myorder1 = document.getElementById("myorder-div"); //recent div
const icart1 = document.getElementById("icart");
const iorder1 = document.getElementById("iorder");
orders1.onclick = function(){
//divs
myorder1.style.display="block";
mycart1.style.display = "none";
//buttons
orders1.style.color = "#e34836";
iorder1.style.fontSize = "40px";
//orders1.style.borderBottom="3px solid #3fd672";
cart1.style.color="grey";
icart1.style.fontSize = "30px";
//cart1.style.borderBottom = "none";
};
</script>
<script>
const cartt = document.getElementById("cart");
const divv = document.getElementById("mycart-div");
const icon = document.getElementById("icart");
if(divv.style.display = "block"){
cartt.style.color="#e34836";
icon.style.fontSize="40px";
//cartt.style.borderBottom="3px solid #e05a00 ";
}
</script>
</body>
</html>