-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewplan.php
More file actions
194 lines (170 loc) · 8.46 KB
/
Copy pathviewplan.php
File metadata and controls
194 lines (170 loc) · 8.46 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
<?php
require 'includes/common.php';
if (isset($_GET['id']))
{
$id = mysqli_real_escape_string($con, $_GET['id']);
$sql = "SELECT * FROM plan_details WHERE id=$id";
$result = mysqli_query($con, $sql);
$plan = mysqli_fetch_assoc($result);
$stmt= "SELECT * FROM names WHERE plan_id=$id ";
$rows = mysqli_query($con,$stmt);
$sql1 = "SELECT title, spent, id, by_person,date, bill FROM new_expense WHERE plan_id = $id";
$res = mysqli_query($con,$sql1);
$expenses = mysqli_fetch_all($res, MYSQLI_ASSOC);
$query=mysqli_query($con,"SELECT SUM(spent) AS total FROM new_expense WHERE plan_id=$id");
$row = mysqli_fetch_assoc($query);
$sum = $row['total'];
//TO GET THE REMAINING AMOUNT/ BALANCE
$remaining= htmlspecialchars($plan['initial_budget'])-htmlspecialchars($sum);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Plan</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<?php include 'includes/header.php';
?>
<div class="container" style="margin-top:100px;">
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading" style="background-color: #00bca0; color:white; text-align:center;">
<?php echo $plan['title']; ?> <span class="glyphicon glyphicon-user" style="float: right;">
<?php echo htmlspecialchars($plan['no_of_people']); ?> </span>
</div>
<table style="width:100%; margin:30px; line-height:250%;">
<tr>
<td>Budget</td>
<td> ₹ <?php echo htmlspecialchars($plan['initial_budget']); ?> </td>
</tr>
<tr>
<td>Remaining Amount</td>
<td> <?php if($remaining>0)
{
?>
<p style="color:#19FF19; display:inline"> ₹ <?php echo $remaining; ?></p>
<?php
}
else if ($remaining<0)
{
?>
<p style="color: red; display:inline;">₹ <?php echo $remaining; ?></p>
<?php }
else
{ ?>
<p style="color: black; display:inline;">₹ <?php echo $remaining; ?></p>
<?php } ?>
</td>
</tr>
<tr>
<td>Date</td>
<td> <?php $date_from= htmlspecialchars($plan['from_date']);
$date_to =htmlspecialchars($plan['to_date']);
echo date("jS M Y -", strtotime("$date_from")).date(" jS M Y", strtotime("$date_to")); ?> </td>
</tr>
</table>
</div>
</div>
<div class="col-md-4" style="text-align: right; height:200px;">
<a class="btn" href="expense_distribution.php?id=<?php echo htmlspecialchars($id);?>"
style="color:#00bca0; border:#00bca0 1px solid; background-color:white; padding: 10px; top:50%; position:relative;">
Expense Distribution </a></Expense>
</div>
</div>
<div class="row" style="margin-top: 30px;">
<div class="col-md-6 col-sm-12">
<?php
foreach ($expenses as $expense)
{
?>
<div class="col-md-6 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading" style="background-color: #00bca0; color:white;">
<center><?php echo $expense['title']; ?></center>
</div>
<table style="width:100%; margin:20px; line-height:250%;">
<tr>
<td>Amount</td>
<td> ₹ <?php echo htmlspecialchars($expense['spent']);?></td>
</tr>
<tr>
<td>Paid by</td>
<td><?php echo htmlspecialchars($expense['by_person']);?></td>
</tr>
<tr>
<td>Paid on</td>
<td> <?php echo htmlspecialchars($expense['date']);?> </td>
</tr>
</table>
<div class="bill">
<?php if(!isset($expense['bill'])){
?> <p style="text-align:center; color:#40bad5;"> <?php echo "You don't have bill"; ?></p>
<?php } else {?><p style="text-align:center; color:#40bad5;"> <a href="showbill.php?id=<?php echo htmlspecialchars($expense['id']); ?>" style="color: #40bad5;"><?php echo "Show Bill"; ?></a> </p> <?php } ?>
</div>
</div>
</div>
<?php
}
?> </div>
<div class="col-md-6">
<div class="panel panel-default" style="width: 90%; float:right;">
<div class="panel-heading" style="background-color: #00bca0; color:white;">
<center>Add New Expense</center>
</div>
<form action="new_expense_script.php" method="POST" style="padding: 10px 10px;" enctype='multipart/form-data'>
<?php foreach ($rows as $row)
{ ?>
<input type="hidden" value="<?php echo $row['plan_id']; ?>" name="id">
<?php
} ?>
<label for="title">Title</label>
<div class="form-group">
<input class="form-control" placeholder="Expense Name" name="title" required>
</div>
<label for="date">Date</label>
<div class="form-group">
<input type="text" class="form-control" placeholder="dd/mm/yyyy" name="date" required>
</div>
<label for="amount_spent">Amount Spent</label>
<div class="form-group">
<input type="text" class="form-control" placeholder="Amount Spent" name="spent" required>
</div>
<div class="form-group">
<select class="form-control" name="choice" required>
<option value="" disabled selected hidden>Choose</option>
<?php
foreach ($rows as $row)
{
?>
<option value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?></option>
<?php }
?>
</select>
</div>
<label for="file">Upload Bill</label>
<div class="form-group">
<input type="file" class="form-control" placeholder="No file chosen" name="bill">
</div>
<button type="submit" name="submit" class="btn fx"
style="width: 100%; border: 1px solid #00bca0; cursor: pointer;">Add</button>
</form>
</div>
</div>
</div>
</div>
<br> <br>
<?php include 'includes/footer.php';
?>
</body>
</html>