-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturnpro.php
More file actions
241 lines (205 loc) · 9.39 KB
/
returnpro.php
File metadata and controls
241 lines (205 loc) · 9.39 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
<!DOCTYPE html>
<html>
<?php
session_start();
require 'connection.php';
$conn = Connect();
?>
<head>
<link rel="shortcut icon" type="image/png" href="assets/img/fav.png">
<title>Rentaru</title>
<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" />
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<!-- Navigation -->
<nav class="navbar navbar-custom navbar" role="navigation" style="color: White; background-color:#000F64;">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="index.php">
<strong>Rentaru </strong></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<?php
if (isset($_SESSION['login_customer'])){
?>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li><a href=""> <strong>Welcome <?php echo $_SESSION['login_customer']; ?></strong></a></li>
<li><a href="index.php"> <strong>Home</strong></a></li>
<li><a href="prereturnpro.php"><strong>Return</strong></a></li>
<li><a href="mybookings.php"> <strong>Bookings</strong></a></li>
<li><a href="enterproduct.php"><strong>Add Product</strong></a></li><li><a href="myproduct.php"><strong>My Product</strong></a></li>
<li><a href="customerview.php"><strong>View History</strong></a></li>
<li><a href="logout.php"><strong>Logout</strong></a></li>
</ul>
</div>
<?php
}
else {
?>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.php"><strong>Home</strong></a>
</li>
<li>
<a href="customerlogin.php"><strong>Login</strong></a>
</li>
<li>
<a href="about.php"> <strong>About </strong></a>
</li>
<li>
<a href="contact.php"> <strong>Contact</strong> </a>
</li>
</ul>
</div>
<?php }
?>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<?php
function dateDiff($start, $end) {
$start_ts = strtotime($start);
$end_ts = strtotime($end);
$diff = $end_ts - $start_ts;
return round($diff / 86400);
}
$id = $_GET["id"];
$sql1 = "SELECT p.pro_name, p.pro_des, p.pro_city, p.pro_img, p.pro_cat, rp.rent_start_date, rp.rent_end_date, rp.fare, rp.alt_fare, rp.charge_type
FROM rentedpro rp, products p
WHERE id = '$id' AND p.pro_id=rp.pro_id";
$result1 = $conn->query($sql1);
if (mysqli_num_rows($result1) > 0) {
while($row = mysqli_fetch_assoc($result1)) {
$pro_name = $row["pro_name"];
$pro_des = $row["pro_des"];
$pro_cat = $row["pro_cat"];
$pro_city = $row["pro_city"];
$pro_img = $row["pro_img"];
$rent_start_date = $row["rent_start_date"];
$rent_end_date = $row["rent_end_date"];
$fare = $row["fare"];
$alt_fare = $row["alt_fare"];
$charge_type = $row["charge_type"];
$return_date = date('Y-m-d');
$days_actual = dateDiff("$rent_start_date", "$return_date");
if($days_actual<0)
{
$days_actual = 0;
}
$days_proposed = dateDiff("$rent_start_date", "$rent_end_date");
if ($days_proposed >= $days_actual)
{
$no_of_days = $days_actual+1;
$days_proposed +=1;
$days_actual +=1;
}
else
{
$extra = $days_actual - $days_proposed;
$change = $extra*1.2;
$added = $change - $extra;
$no_of_days = $days_actual+$change+1;
$days_proposed +=1;
$days_actual +=1;
}
$no_of_month = $no_of_days/30;
}
}
?>
<div class="container">
<strong><h3 style="margin-bottom: 25px; text-align: center; font-size: 30px; margin-left:40px; margin-right:40px; padding:20px; color:white; background-color:green;"> <strong> Product Details </strong></h3></strong>
<div class="col-md-10" style="float: none; margin: 0 auto; background-color:#F4FBA6; padding:60px;margin-bottom:20px;">
<div class="form-area" >
<form role="form" action="printbill.php?id=<?php echo $id ?>" method="POST" >
<br style="clear: both">
<img class="card-img-top,center" src="<?php echo $pro_img; ?>" alt="Card image cap"><hr>
<h5> <strong>Product: </strong> <?php echo($pro_name);?></h5>
<h5> <strong> Description : </strong> <?php echo($pro_des);?></h5>
<h5> <strong> Location : </strong> <?php echo($pro_city);?></h5>
<h5> <strong> Rent date: </strong> <?php echo($rent_start_date);?></h5>
<h5> <strong> End Date: </strong> <?php echo($rent_end_date);?></h5>
<?php
if($charge_type == 'months')
{
if($days_actual<30)
{
$fare = $alt_fare;
$charge_type == 'days'
?>
<h5 style="color:red;"><strong>You had choose a monthly option but used for less than a month so applying daily rent.</strong></h5>
<?php
}
}
?>
<h5> <strong>Fare: </strong> ₹<?php
if($charge_type == "days"){
echo ($fare . "/day");
} else if ($charge_type == "months" && $days_actual<30){
echo ($alt_fare . "/day");
} else {
echo ($fare . "/month");
}
?>
</h5>
<hr>
<?php
if ($days_proposed >= $days_actual)
{ ?>
<strong><p style="color:green;">Wow, You are returning on time.</p></strong>
<h5> <strong> Proposed Days : </strong> <?php echo($days_proposed);?></h5>
<h5> <strong> Your Days : </strong> <?php echo($days_actual);?></h5>
<?php }
else
{ ?>
<strong><p style="color:red;">Sorry, You took <?php echo($extra);?> extra days.</p></strong>
<h5> <strong> Proposed Days : </strong> <?php echo($days_proposed);?></h5>
<h5> <strong> Your Days : </strong> <?php echo($days_actual);?></h5>
<h5> <strong> Extra Days : </strong> <?php echo($extra);?></h5>
<h5> <strong> Days as fine : </strong> <?php echo($added);?></h5>
<strong><p style="color:red;">So 20% fine of <?php echo($extra);?> days will increase extra days by <?php echo($added);?> days.</p></strong>
<?php } ?>
<?php
if($charge_type == "days"){ ?>
<hr><h5> <strong>Number of Day(s): </strong> <?php echo($no_of_days);?></h5>
<input type="hidden" name="months_or_days" value="<?php echo $no_of_days; ?>">
<?php } else if ($charge_type == "months" && $days_actual<30){ ?>
<hr><h5> <strong>Number of Day(s): </strong> <?php echo($no_of_days);?></h5>
<input type="hidden" name="months_or_days" value="<?php echo $no_of_days; ?>">
<?php } else { ?>
<h5> <strong>Number of Month(s): </strong> <?php echo($no_of_month);?></h5>
<input type="hidden" name="months_or_days" value="<?php echo $no_of_month; ?>">
<?php } ?>
<input type="hidden" name="hid_fare" value="<?php echo $fare; ?>">
<input type="submit" name="submit" value="submit" class="btn btn-success pull-right">
</form>
</div>
</div>
</div>
<div >
<div class="site-footer" style="color:#ddd;background-color:#282E34;text-align:center;padding:20px 20px;text-align: justify;">
<footer class="site-footer">
<div class="container">
<div class="row">
<div class="col-sm-6">
<h5 style="color:white;">© 2020 Rentaru</h5>
</div>
</div>
</div>
</footer>
</div>
</div>
</body>
</html>