-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbill.php
More file actions
135 lines (100 loc) · 3.19 KB
/
bill.php
File metadata and controls
135 lines (100 loc) · 3.19 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
<?php
require 'dbConnect.php';
$conn = getConnection();
if($conn->connect_error)
{
header("Location: signUp.php?status=&failed" );
}
session_start();
if(isset($_SESSION['username']))
echo 'Signed In as '.$_SESSION['username'].'<a href="userlog.php?userid='.$_SESSION['userid'].'&type=logout"> Log Out</a>';
else
die ("not logged in, please log in!!!!<br> <a href=\"login.php\">login</a>");
if(!isset($_POST['car_type']))
{
if(isset($_GET['cust_id']))
$_SESSION['cust_id']=$_GET['cust_id'];
//echo $cust_id;
else
echo ("not set");
if(isset($_GET['start_time']))
{
$_SESSION['start_time']=$_GET['start_time'];
//echo $start_time.'<br>';
} else
die ("not set");
}
function getseconds($start_time)
{
$mon=((int)$start_time[5])*10+(int)$start_time[6];
$day=((int)$start_time[8])*10+(int)$start_time[9];
$hr=((int)$start_time[11])*10+(int)$start_time[12];
$min=((int)$start_time[14])*10+(int)$start_time[15];
$sec=((int)$start_time[17])*10+(int)$start_time[18];
$seconds=mktime($hr,$min.$sec,$mon,$day,2019);
return($seconds);
}
$startseconds=getseconds($_SESSION['start_time']);
$parkedtime=$startseconds- (time());
$parkedtime=(int)(($parkedtime/3600)/36000)+1;
//echo $parkedtime;
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<style>
</style>
</head>
<body>
<form action="bill.php" name="searchForm" method="POST">
car type id <input type="number" name="car_type" value="" placeholder="car type id" required>
penalty<input type="number" name="penalty" value="" required>
<button type="submit">submit</button>
</form>
<?php
if(isset($_POST['car_type']))
{
$car_type=$_POST['car_type'];
$penalty=$_POST['penalty'];
$sql = "SELECT * FROM price_scheme where vehicle_type_id='$car_type'" ;
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
$base_price=$row['base_price_perhour'];
$totalprice=$base_price+$penalty;
echo '<h3>TOTOAL PRICE= '.$totalprice.'</h3>';
}
$cust_id=$_SESSION['cust_id'];
$sql = "SELECT * FROM customer where cust_id='$cust_id'";
$result = $conn->query($sql);
$is_got=0;
if ($result->num_rows > 0)
{
$isgot=1;
while($row = $result->fetch_assoc())
{
$isregular=$row['is_regular_cust'];
}
}
if($isgot==1)
{
if($isregular=='no')
echo '<a href="addreceipt.php?cust_id='.$_SESSION['cust_id'].'&baseprice='.$base_price.'&penalty='.$penalty.'">PAID?</a>';
else
{
echo '<a href="addreceipt.php?cust_id='.$_SESSION['cust_id'].'&baseprice='.$base_price.'&penalty='.$penalty.'">DONE?</a>';
}
}
else {
die("car type not found");
}
}
}
?>
</body>
</html>