-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintbill.php
157 lines (139 loc) · 6.07 KB
/
printbill.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
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<?php
session_start();
require 'connection.php';
$conn = Connect();
?>
<head>
<link rel="shortcut icon" type="image/png" href="assets/img/P.png.png">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
<link rel="stylesheet" href="assets/w3css/w3.css">
<link rel="stylesheet" type="text/css" href="assets/css/customerlogin.css">
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/clientpage.css" />
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/bookingconfirm.css" />
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<!-- Navigation -->
<?php include 'navbar.php'; ?>
<body>
<?php
$id = $_GET["id"];
$distance = NULL;
$distance_or_days = $conn->real_escape_string($_POST['distance_or_days']);
$fare = $conn->real_escape_string($_POST['hid_fare']);
$total_amount = $distance_or_days * $fare;
$car_return_date = date('Y-m-d');
$return_status = "R";
$login_customer = $_SESSION['login_customer'];
$sql0 = "SELECT rc.id, rc.rent_end_date, rc.charge_type, rc.rent_start_date, c.car_name, c.car_nameplate FROM rentedcars rc, cars c WHERE id = '$id' AND c.car_id = rc.car_id";
$result0 = $conn->query($sql0);
if(mysqli_num_rows($result0) > 0) {
while($row0 = mysqli_fetch_assoc($result0)){
$rent_end_date = $row0["rent_end_date"];
$rent_start_date = $row0["rent_start_date"];
$car_name = $row0["car_name"];
$car_nameplate = $row0["car_nameplate"];
$charge_type = $row0["charge_type"];
}
}
function dateDiff($start, $end) {
$start_ts = strtotime($start);
$end_ts = strtotime($end);
$diff = $end_ts - $start_ts;
return round($diff / 86400);
}
$extra_days = dateDiff("$rent_end_date", "$car_return_date");
$total_fine = $extra_days*200;
$duration = dateDiff("$rent_start_date","$rent_end_date");
if($extra_days>0) {
$total_amount = $total_amount + $total_fine;
}
if($charge_type == "days"){
$no_of_days = $distance_or_days;
$sql1 = "UPDATE rentedcars SET car_return_date='$car_return_date', no_of_days='$no_of_days', total_amount='$total_amount', return_status='$return_status' WHERE id = '$id' ";
} else {
$distance = $distance_or_days;
$sql1 = "UPDATE rentedcars SET car_return_date='$car_return_date', distance='$distance', no_of_days='$duration', total_amount='$total_amount', return_status='$return_status' WHERE id = '$id' ";
}
$result1 = $conn->query($sql1);
if ($result1){
$sql2 = "UPDATE cars c, driver d, rentedcars rc SET c.car_availability='yes', d.driver_availability='yes'
WHERE rc.car_id=c.car_id AND rc.driver_id=d.driver_id AND rc.customer_username = '$login_customer' AND rc.id = '$id'";
$result2 = $conn->query($sql2);
}
else {
echo $conn->error;
}
?>
<div class="container">
<div class="jumbotron">
<h1 class="text-center" style="color: green;"><span class="glyphicon glyphicon-ok-circle"></span> Car Returned</h1>
</div>
</div>
<br>
<h2 class="text-center"> Thank you for visiting Car Rentals! We wish you have a safe ride. </h2>
<h3 class="text-center"> <strong>Your Order Number:</strong> <span style="color: blue;"><?php echo "$id"; ?></span> </h3>
<div class="container">
<div class="box">
<div class="col-md-10" style="float: none; margin: 0 auto; text-align: center;">
<h3 style="color: orange;">Invoice</h3>
<br>
</div>
<div class="col-md-10" style="float: none; margin: 0 auto; ">
<h4> <strong>Vehicle Name: </strong> <?php echo $car_name;?></h4>
<br>
<h4> <strong>Vehicle Number:</strong> <?php echo $car_nameplate; ?></h4>
<br>
<h4> <strong>Fare: </strong> Rs. <?php
if($charge_type == "days"){
echo ($fare . "/day");
} else {
echo ($fare . "/km");
}
?></h4>
<br>
<h4> <strong>Booking Date: </strong> <?php echo date("Y-m-d"); ?> </h4>
<br>
<h4> <strong>Start Date: </strong> <?php echo $rent_start_date; ?></h4>
<br>
<h4> <strong>Rent End Date: </strong> <?php echo $rent_end_date; ?></h4>
<br>
<h4> <strong>Car Return Date: </strong> <?php echo $car_return_date; ?> </h4>
<br>
<?php if($charge_type == "days"){?>
<h4> <strong>Number of days:</strong> <?php echo $distance_or_days; ?>day(s)</h4>
<?php } else { ?>
<h4> <strong>Distance Travelled:</strong> <?php echo $distance_or_days; ?>km(s)</h4>
<?php } ?>
<br>
<?php
if($extra_days > 0){
?>
<h4> <strong>Total Fine:</strong> <label class="text-danger"> Rs. <?php echo $total_fine; ?>/- </label> for <?php echo $extra_days;?> extra days.</h4>
<br>
<?php } ?>
<h4> <strong>Total Amount: </strong> Rs. <?php echo $total_amount; ?>/- </h4>
<br>
</div>
</div>
<div class="col-md-12" style="float: none; margin: 0 auto; text-align: center;">
<h6>Warning! <strong>Do not reload this page</strong> or the above display will be lost. If you want a hardcopy of this page, please print it now.</h6>
</div>
</div>
</body>
<footer class="site-footer">
<div class="container">
<hr>
<div class="row">
<div class="col-sm-6">
<h5>© <?php echo date("Y"); ?> DriveEase Car Rentals</h5>
</div>
</div>
</div>
</footer>
</html>