-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorderplaced.php
More file actions
executable file
·452 lines (394 loc) · 12.9 KB
/
Copy pathorderplaced.php
File metadata and controls
executable file
·452 lines (394 loc) · 12.9 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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<!-- Start Defing Database Variables -->
<?php
if(isset($_POST))
{
$bookid= $_POST['bookid'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$gender=$_POST['gender'];
$number=$_POST['number'];
$semail=$_POST['email'];
$add1=$_POST['add1'];
$add2=$_POST['add2'];
$city=$_POST['city'];
$state=$_POST['state'];
$pin=$_POST['pin'];
$uid=$_POST['uid'];
$username=$_POST['username'];
$bookname=$_POST['bookname'];
$amount=$_POST['amount'];
$bookname=myUrlEncode($bookname);
$add1=myUrlEncode($add1);
$add2=myUrlEncode($add2);
$trackid="BP-TRACK-".rand();
$invoice="B-P-I-".rand();
}
?>
<!-- End Defing Database Variables -->
<!-- Start SQL Database Storing -->
<?php
function myUrlEncode($string) {
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", " ", "$", ",", "/", "?", "%", "#", "[", "]");
return str_replace($entities, $replacements, urlencode($string));
}
?>
<?php
$conn = mysqli_connect("localhost","root","","shop");
$sql = "INSERT INTO shipping(b_id,u_id,sf_name,sl_name,ssex,smobile,semail,saddress1,saddress2,stown,sstate,spin) VALUES('$bookid','$uid','$firstname','$lastname','$gender','$number','$semail','$add1','$add2','$city','$state','$pin')";
if($conn->query($sql) === TRUE) {
echo '';
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
<!-- End SQL Database Storing -->
<!-- Start Messege Display -->
<?php
$con=mysqli_connect("localhost","root","","shop");
$sql2="SELECT book_count from book where book_id='$bookid'";
$res=$con->query($sql2);
if($res->num_rows>0)
{
while($row=$res->fetch_assoc())
{
$count=$row["book_count"];
}
}
$count=$count-1;
$sql3="UPDATE book SET book_count='$count' WHERE book_id='$bookid'";
if($con->query($sql3)===TRUE)
{
echo '
<div class="alert alert-success" role="alert" style="margin: 15 300 15 300;">
<center> Payment Successful! Your order has been placed. Thank you for using Book Planet!</center>
</div>';
}
else
{
echo "Database error";
}
$con->close();
?>
<!-- End Messege Display -->
<!-- Start Invoice HTML -->
<html>
<head>
<title> Book Planet | Order Details </title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div id="invoice" class="container mb-4" style="border:2px #1515a2 solid;">
<div class="invoice overflow-auto">
<div style="min-width: 600px">
<header>
<div class="row">
<div class="col">
<img src="images/logo-bookplanet.png" data-holder-rendered="true" style="max-height:85px;"/>
</div>
<div class="col company-details">
<h2 class="name" style="color:#1515a2;">
Book Planet Zone
</h2>
<div>Sir M. Visvesvaraya Institute Of Technology</div>
<div>hello@bookplanet.ml</div>
</div>
</div>
</header>
<main>
<div class="row contacts">
<div class="col invoice-to">
<div class="text-gray-light">INVOICE TO:</div>
<h2 class="to"><?php echo $firstname ?> <?php echo $lastname ?></h2>
<div class="address">+91 <?php echo $number?></div>
<div class="address"><?php echo $add1?>, <?php echo $add2?> , <?php echo $city?> , <?php echo $state?>, <?php echo $pin?></div>
<div class="email"><a href="mailto:john@example.com"><?php echo $semail?></a></div>
</div>
<div class="col invoice-details">
<h1 class="invoice-id"><?php echo $invoice ?></h1>
<div class="date">Date of Invoice: <?php echo date("d/m/Y") ?></div>
<div class="date">Due Date: <?php echo date('d/m/Y', strtotime(' + 10 days')); ?></div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>#</th>
<th class="text-left">BOOK Name</th>
<th class="text-right">PRICE</th>
<th class="text-right">QUANTITY</th>
<th class="text-right">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="no">01</td>
<td class="text-left"><h3>
<a> <?php echo $bookname?> </a>
</h3>
</td>
<td class="unit">Rs.<?php echo $amount?>.00</td>
<td class="qty">01</td>
<td class="total">Rs.<?php echo $amount?>.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAL</td>
<td>Rs.<?php echo $amount?>.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">SHIPPING</td>
<td>Rs. 00.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">GRAND TOTAL</td>
<td>Rs.<?php echo $amount?>.00</td>
</tr>
</tfoot>
</table>
<div class="thanks">Thank you!</div>
<div class="notices">
<div>NOTICE:</div>
<div class="notice">Expect delivery within a week at your address. Kindly check your email and sms for tracking deatils.</div>
</div>
</main>
<footer>
<center class="mt-3 mb-3">
<div id="editor"></div>
<button onclick="printPage()" class="btn btn-warning">Print as PDF</button>
<a class="btn btn-outline-info" href="bookplanet.php" role="button">Back To Home</a>
</center>
Invoice was created on a computer and is valid without the signature and seal.
</footer>
</div>
<!--DO NOT DELETE THIS div. IT is responsible for showing footer always at the bottom-->
<div></div>
</div>
</div>
</div>
<style media="screen">
#invoice{
padding: 30px;
}
.invoice {
position: relative;
background-color: #FFF;
min-height: 680px;
padding: 15px
}
.invoice header {
padding: 10px 0;
margin-bottom: 20px;
border-bottom: 1px solid #3989c6
}
.invoice .company-details {
text-align: right
}
.invoice .company-details .name {
margin-top: 0;
margin-bottom: 0
}
.invoice .contacts {
margin-bottom: 20px
}
.invoice .invoice-to {
text-align: left
}
.invoice .invoice-to .to {
margin-top: 0;
margin-bottom: 0
}
.invoice .invoice-details {
text-align: right
}
.invoice .invoice-details .invoice-id {
margin-top: 0;
color: #3989c6
}
.invoice main {
padding-bottom: 50px
}
.invoice main .thanks {
margin-top: -100px;
font-size: 2em;
margin-bottom: 50px
}
.invoice main .notices {
padding-left: 6px;
border-left: 6px solid #3989c6
}
.invoice main .notices .notice {
font-size: 1.2em
}
.invoice table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px
}
.invoice table td,.invoice table th {
padding: 15px;
background: #eee;
border-bottom: 1px solid #fff
}
.invoice table th {
white-space: nowrap;
font-weight: 400;
font-size: 16px
}
.invoice table td h3 {
margin: 0;
font-weight: 400;
color: #3989c6;
font-size: 1.2em
}
.invoice table .qty,.invoice table .total,.invoice table .unit {
text-align: right;
font-size: 1.2em
}
.invoice table .no {
color: #fff;
font-size: 1.6em;
background: #3989c6
}
.invoice table .unit {
background: #ddd
}
.invoice table .total {
background: #3989c6;
color: #fff
}
.invoice table tbody tr:last-child td {
border: none
}
.invoice table tfoot td {
background: 0 0;
border-bottom: none;
white-space: nowrap;
text-align: right;
padding: 10px 20px;
font-size: 1.2em;
border-top: 1px solid #aaa
}
.invoice table tfoot tr:first-child td {
border-top: none
}
.invoice table tfoot tr:last-child td {
color: #3989c6;
font-size: 1.4em;
border-top: 1px solid #3989c6
}
.invoice table tfoot tr td:first-child {
border: none
}
.invoice footer {
width: 100%;
text-align: center;
color: #777;
border-top: 1px solid #aaa;
padding: 8px 0
}
@media print {
.invoice {
font-size: 11px!important;
overflow: hidden!important
}
.invoice footer {
position: absolute;
bottom: 10px;
page-break-after: always
}
.invoice>div:last-child {
page-break-before: always
}
}
</style>
<style>
.height {
min-height: 200px;
}
.icon {
font-size: 47px;
color: #5CB85C;
}
.iconbig {
font-size: 77px;
color: #5CB85C;
}
.table > tbody > tr > .emptyrow {
border-top: none;
}
.table > thead > tr > .emptyrow {
border-bottom: none;
}
.table > tbody > tr > .highrow {
border-top: 3px solid;
}
</style>
</body>
<script>
function printPage() {
window.print();
}
</script>
</html>
<!-- End Invoice HTML -->
<!-- Start Sendgrid Email -->
<?php
if(isset($_POST))
{
require 'vendor/autoload.php';
$API_KEY = "YOUR_SENDGRID_API_KEY";
$email = new \SendGrid\Mail\Mail();
$email->setFrom("admin@bookplanet.ml", "Admin - Book Planet");
$email->setSubject("Shipment Confirmation");
$email->addTo("$semail", "Book Planet Order");
// $email->addContent("text/plain", "Your Shipment is succesfully created");
$email->addContent("text/html", "<center><h1>Book Planet Order Confirmation</h1></center>
<hr style='max-width:18%;'>
<center>
<p>Hello $firstname $lastname, your order number $invoice with Book Planet for the book $bookname is Confirmed.</p>
<p>Expect the delivery within 72 hours with the Shipment ID : $trackid <br> with our courier partner Xpressbee.</p>
<br>
Regards,<br>
<strong>Team Book Planet</strong>
</center>"
);
$sendgrid = new \SendGrid($API_KEY);
if ($sendgrid->send($email)) {
print "";
}
}
?>
<!-- End Sendgrid Email -->
<!-- Start textlocal SMS -->
<?php
// Authorisation details.
$username = "YOUR_TEXT_LOCAL_USERNAME";
$hash = "HASH_CODE_GOES_HERE";
// Config variables. Consult http://api.textlocal.in/docs for more info.
$test = "0";
// Data for text message. This is the text message data.
$sender = "TXTLCL"; // This is who the message appears to be from.
// uncomment below line to send sms
$numbers = "$number"; // A single number or a comma-seperated list of numbers
// 612 chars or less
$message = "Hi $firstname, your Book Planet order has been confirmed. Check your email for details regarding shipment of package.";
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
$ch = curl_init('http://api.textlocal.in/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the API
curl_close($ch);
?>
<!-- End textlocal SMS -->