-
Notifications
You must be signed in to change notification settings - Fork 10
/
track.php
150 lines (119 loc) · 6.22 KB
/
track.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
<?php
include './includes/config.php';
include './includes/helpers.php';
$title = "Track Order - Malgadi Electronics";
$pageDescription = "Malgadi is a for the students, by the student's venture. It is a non-profitable organization started by the college students to provide better quality electronic components at a reasonable rate.";
$imagePath = BaseAddress."/images/logo.jpg";
$canonUrl = BaseAddress."/cart.php";
$extendNavbar=0;
$searchVisibility=0;
$cartVisibility=0;
$subtitleVisibility=0;
include './includes/header.php';
$state = 'fresh';
if(isset($_GET)){
if(isset($_GET['id']) && isset($_GET['email'])){
$id = filterStringBasic($_GET['id']);
$email = filterStringBasic($_GET['email']);
$cardObject = $pdo->prepare("SELECT * FROM orders WHERE ID=:id AND Email=:email");
$cardObject->execute(['id' => $id, 'email' => $email]);
$row = $cardObject->fetch();
if(!$row){
$state = 'not-found';
}else{
$state = 'found';
}
}
}
?>
<section>
<div class="container">
<div class="row"></div>
<form action="track.php" method="get" id="track-order" class="<?php echo $state == 'fresh' ? '' : 'hide'; ?>">
<div class="row">
<div class="col s12 center">
<h4 class="light">Track Order</h4>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input placeholder="Order ID" type="number" name="id" autocomplete="off" required>
</div>
<div class="col s6 input-field">
<input placeholder="Email" type="email" name="email" autocomplete="off" required>
</div>
</div>
<div class="row">
<div class="col s12 center">
<button class="btn-large red waves-effect waves-light" type="submit" form="track-order"><i class="fa fa-search left"></i>Search</button>
</div>
</div>
</form>
<?php
if($state == 'found'){
if($row['OStatus'] == 'Canceled'){
$statusColor = 'red-text text-darken-1';
}else if($row['OStatus'] == 'Placed'){
$statusColor = 'amber-text text-darken-4';
}else if($row['OStatus'] == 'Delivered'){
$statusColor = 'green-text text-darken-3';
}
$contents='';
$contentArray = explode("*", $row['Contents']);
for($i = 0; $i < sizeof($contentArray) ;$i++){
$contentArray[$i] = explode(".", $contentArray[$i]);
$s = $pdo->prepare("SELECT `Full Name` FROM items WHERE `ID`=".$contentArray[$i][0]."");
$s->execute();
$row2 = $s->fetch();
$contents .= $row2['Full Name']." <b>X ".$contentArray[$i][1]."</b><br>";
if(!isset($requirement[$contentArray[$i][0]])){
$requirement[$contentArray[$i][0]]['quantity'] = $contentArray[$i][1];
$requirement[$contentArray[$i][0]]['name'] = $row2['Full Name'];
$requirement[$contentArray[$i][0]]['idList'] = $row['ID'];
}else{
$requirement[$contentArray[$i][0]]['quantity'] += $contentArray[$i][1];
$requirement[$contentArray[$i][0]]['name'] = $row2['Full Name'];
$requirement[$contentArray[$i][0]]['idList'] .= ", ".$row['ID'];
}
}
?>
<div class="row">
<div class="col s12 center">
<h4 class="light">Order <span class="blue-text text-darken-3"><?php echo $row['ID']; ?></span></h4>
<h6>Status: <span class="<?php echo $statusColor; ?>"><?php echo $row['OStatus']; ?></span></h6>
<br>
</div>
<div class="col s12">
<ul class="collection">
<li class="collection-item"><span class="blue-text text-darken-4">Name</span> : <?php echo $row['Name']; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Date</span> : <?php echo $row['Date']; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Email</span> : <?php echo $row['Email']; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Phone</span> : <?php echo $row['Mobile']; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Address</span> : <?php echo $row['Address']; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Contents</span> :<br><?php echo $contents; ?></li>
<li class="collection-item"><span class="blue-text text-darken-4">Amount</span> : Rs. <?php echo $row['Amount']; ?></li>
</ul>
</div>
</div>
<div class="row">
<div class="col s12 center">
<a href="./" class="btn-large red waves-light waves-effect">Home</a>
</div>
</div>
<?php
}
?>
<div class="row <?php echo $state == 'not-found' ? '' : 'hide'; ?>">
<div class="col s12 center">
<h4 class="light">Order Not Found :(</h4>
<br>
<p>Please make sure you entered correct Order ID and Email associated with that order.</p>
<br>
<a href="track.php" class="btn-large red waves-effect waves-light">Try Again</a>
</div>
</div>
</div>
</section>
<?php
include './includes/footer.php';
?>