-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_order.php
142 lines (116 loc) · 6.13 KB
/
view_order.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
<?php
include 'components/connection.php';
session_start();
if (isset($_SESSION['user_id'])) {
$user_id = $_SESSION['user_id'];
} else {
$user_id = '';
}
if (isset($_POST['layout'])) {
session_destroy();
header("location:login.php");
}
if (isset($_GET['get_id'])) {
$get_id = $_GET['get_id'];
} else {
$get_id = "";
header('location:order.php');
}
if (isset($_POST['cancle'])) {
$update_order = $conn->prepare("UPDATE `orders` SET status=? WHERE id=?");
$update_order->execute(['canceled', $get_id]);
header('location:order.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="style.css">
<title>MyWebsite - order detail</title>
</head>
<body>
<?php include './components/header.php'; ?>
<div class="main">
<div class="banner">
<h1>order detail</h1>
</div>
<div class="title2">
<a href="home.php">home</a><span>/ order detail</span>
</div>
<section class="order-detail">
<div class="title">
<img src="img/download.png" class="logo" alt="">
<h1>order detail</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Veritatis, aut? Similique, itaque. Obcaecati quidem sint iusto iste accusamus veniam cum.</p>
</div>
<div class="box-container">
<?php
$grand_total = 0;
$select_orders = $conn->prepare("SELECT * FROM `orders` WHERE id=? LIMIT 1");
$select_orders->execute([$get_id]);
if ($select_orders->rowCount() > 0) {
while ($fetch_order = $select_orders->fetch(PDO::FETCH_ASSOC)) {
$select_product = $conn->prepare("SELECT * FROM `products` WHERE id=? LIMIT 1");
$select_product->execute([$fetch_order['product_id']]);
if ($select_product->rowCount() > 0) {
while ($fetch_product = $select_product->fetch(PDO::FETCH_ASSOC)) {
$sub_total = ($fetch_order['price'] * $fetch_order['qty']);
$grand_total += $sub_total;
?>
<div class="box">
<div class="col">
<p class="title"><i class="bi bi-calender-fill"></i><?= $fetch_order['date'] ?></p>
<img src="image/<?= $fetch_product['image'] ?>" class="image" alt="">
<p class="price"><?= $fetch_product['price'] ?> x <?= $fetch_order['qty'] ?></p>
<h3 class="name"><?= $fetch_product['name'] ?></h3>
<p class="grand-total">Total amount payable: <span>$<?= $grand_total ?></span></p>
</div>
<div class="col">
<p class="title">
billing address
</p>
<p class="user"><i class="bi bi-person-bounding-box"></i><?= $fetch_order['name'] ?></p>
<p class="user"><i class="bi bi-phone"></i><?= $fetch_order['number'] ?></p>
<p class="user"><i class="bi bi-envelope"></i><?= $fetch_order['email'] ?></p>
<p class="user"><i class="bi bi-pin-map-fill"></i><?= $fetch_order['address'] ?></p>
<p class="title">status</p>
<p class="status" style="color: <?php if ($fetch_order['status'] == 'delevered') {
echo "green";
} elseif ($fetch_order['status'] == 'canceled') {
echo "red";
} else {
echo "orange";
} ?>"><?= $fetch_order['status'] ?></p>
<?php if ($fetch_order['status'] == 'canceled') {
?>
<a href="checkout.php?get_id=<?= $fetch_product['id'] ?>" class="btn">order again</a> <?php
} else { ?>
<form action="" method="post">
<button type="submit" name="cancle" class="btn" onclick="return confirm('do you want to cancel this order')">cancle order</button>
</form> <?php
}
?>
</div>
</div>
<?php
}
} else {
echo "<p class='empty'>product not found</p>";
}
}
} else {
echo "<p class='empty'>no order found</p>";
}
?>
</div>
</section>
<?php include 'components/footer.php'; ?>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
<script src="script.js"></script>
<?php include './components/alert.php'; ?>
</body>
</html>