-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdashboard.php
352 lines (293 loc) · 16.7 KB
/
dashboard.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
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
<?php
session_start();
if(isset($_SESSION['error'])){
$error = $_SESSION['error'];
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username'];
}
if(isset($_SESSION['success'])){
$success = $_SESSION['success'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Net Worth</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Poppins:400,700,900&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/36afc40636.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/dashboard.css">
<link rel="stylesheet" href="css/navbar.css">
<link rel="icon" type="image/x-icon" href="./img/Purple logo Group.png">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light container-fluid" id="header__nav">
<?php include('logo.php'); ?>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto navbar__menu">
<?php if(!isset($_SESSION['username'])): ?>
<li class="nav-item">
<span class="m-3 pt-1 pl-3 pr-3 pb-1" style="font-weight:bold; ">
<a href="contact.php" style="text-decoration:none!important; color:#fff !important;">Contact Us |</a>
</span>
</li>
<li class="nav-item">
<span class="m-3 pt-1 pl-3 pr-3 pb-1" style="font-weight:bold; ">
<a href="faq.php" style="text-decoration:none!important; color:#fff !important;">FAQs |</a>
</span>
</li>
<?php else: ?>
<?php include('nav.php'); ?>
<?php endif; ?>
</ul>
</div>
</nav>
</header>
<section>
<main class="container">
<?php if(isset($_SESSION['net_worth']) ): $netWorth = $_SESSION['net_worth']; ?>
<div class="alert alert-primary">
<p>Calculation Successful</p>
<h4>
Your Net worth is : ₦ <span class="badge" id="badge-bg"><?php echo number_format($netWorth); ?> </span>
<input type="hidden" id="netWorth" value="<?php echo $netWorth; ?>">
</h4>
<div class="row">
<div class="col-md-12">
<span class="text">Want to add or remove an Asset or Liability? Enter the value and press <span class="badge badge-secondary"> "+" </span> or
<span class="badge badge-secondary">"-"</span> </span>
<form style="margin-top:20px;">
<input type="number" class="form-control" id="addValue" placeholder="0 NGN">
</form>
<button type="button" class="btn btn-primary btn-sm"
style="margin:20px; border-radius:25px;" id="addMoney" disabled>+ <i class="fa fa-plus"></i></button>
<button type="button" class="btn btn-danger btn-sm" disabled style="margin:20px; border-radius:25px;" id="subtractMoney">-<i class="fa fa-minus"></i></button>
</div>
<!-- <div class="col-md-6">
</div> -->
</div>
<form>
<button type="button" class="btn btn" style="background-color:#6D1AD8; color:#fff; border-radius:10px;" id="getNetworth" name="get_networth">View Certificate</button>
</form>
</div>
<?php elseif(isset($error)): ?>
<?php include('error.php'); ?>
<?php unset($_SESSION['error']); ?>
<?php else:?>
<?php endif; ?>
<div class="row">
<div class="col-xs-12 col-md-12 col-lg-12 text-center">
<p class="main__caption">Enter the monetary value of your assets and liabilities to calculate your Net Worth </p>
</div>
</div>
<div class="line-through"></div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 mt-3 offset-md-3" style="padding:25px;">
<h1 class="form-caption" style="font-size:1.7rem !important;">Assets</h1>
<div style="position:relative; margin-bottom:20px;">
<span class="add-form-element badge" style="background-color:#6D1AD8;
color:#fff;
padding:5px;" data-toggle="modal"
data-target="#modal">Add new field <i class="fas fa-plus" style="color: #fff"></i></span>
</div>
<form action="networth.php" method="POST">
<div id="asset-form">
<div class="form-group">
<label for="Investments">Investments</label>
<input type="number" class="form-control" id="Investments" name="asset[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Cash">Cash</label>
<input type="number" class="form-control" id="Cash" name="asset[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Bank Account">Bank Account</label>
<input type="number" class="form-control" id="Bank Account" name="asset[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Real Estate">Real Estate</label>
<input type="number" class="form-control" id="Real Estate" name="asset[]" placeholder="0 NGN">
</div>
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add New Asset</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input class="form-control" id="new-asset" placeholder="Enter Asset Title">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" id="add-asset">Add Asset</button>
</div>
</div>
</div>
</div>
</div>
<h1 class="form-caption" style="font-size:1.7rem !important;">Liabilties</h1>
<div style="position:relative; margin-bottom:20px;">
<span class="add-form-element badge" style="background-color:#6D1AD8;
color:#fff;
padding:5px;"
data-toggle="modal" data-target="#modal-liability">Add new field
<i class="fas fa-plus" style="color: #fff"></i></span>
</div>
<div id="liabilities-form">
<div class="form-group">
<label for="Loans">Loans</label>
<input type="number" class="form-control " id="Loans" name="liability[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Mortgages">Mortgages</label>
<input type="number" class="form-control" id="Mortgages" name="liability[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Utility bills">Utility bills</label>
<input type="number" class="form-control" id="Utility bills" name="liability[]" placeholder="0 NGN">
</div>
<div class="form-group">
<label for="Other debts">Other debts</label>
<input type="number" class="form-control" id="Other debts" name="liability[]" placeholder="0 NGN">
</div>
<div class="modal fade" id="modal-liability" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add New Liability</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input class="form-control" id="new-liability" placeholder="Enter Liability Title">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" id="add-liability">Add Liability</button>
</div>
</div>
</div>
</div>
</div>
<hr>
<!-- <div class="form-group">
<label for="">Current Date:</label>
<input type="date" name="current_date" class="form-control">
</div> -->
<div>
<button type="submit" class="get-started" name="get_networth"> Get Net Worth</button>
</div>
</form>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 mt-3" style="padding:25px;">
<!-- <form> -->
<!-- </form> -->
</div>
</div>
</main>
</section>
<!-- Footer -->
<footer class="page-footer font-small special-color-dark pt-4">
<div class="container">
<ul class="list-unstyled list-inline text-center">
<li class="list-inline-item">
<a class="btn-floating btn-fb mx-1">
<i class="fab fa-facebook-f"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-tw mx-1">
<i class="fab fa-twitter"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-gplus mx-1">
<i class="fab fa-google-plus-g"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-li mx-1">
<i class="fab fa-linkedin-in"> </i>
</a>
</li>
</ul>
</div>
<div class="footer-copyright text-center py-3">© 2019 Copyright:
<a href="http://34.89.207.113/index.php"> NetWorth.com</a>
</div>
</footer>
<!-- Footer -->
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="js/dashboard.js"></script>
<script>
function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
document.getElementById("addValue").addEventListener("keyup", function() {
var nameInput = document.getElementById('addValue').value;
if (nameInput != "") {
document.getElementById('addMoney').removeAttribute("disabled");
} else {
document.getElementById('addMoney').setAttribute("disabled", null);
}
});
document.getElementById("addValue").addEventListener("keyup", function() {
var nameInput = document.getElementById('addValue').value;
if (nameInput != "") {
document.getElementById('subtractMoney').removeAttribute("disabled");
} else {
document.getElementById('subtractMoney').setAttribute("disabled", null);
}
});
$(document).ready(() => {
$('#addMoney').click(() => {
let networth = document.getElementById('badge-bg').innerHTML;
let userInput = $('#addValue').val();
let convertedNetWorth = parseInt(networth.replace(/,/g, ''));
let convertedUserInput = parseInt(userInput);
let sum = convertedNetWorth + convertedUserInput;
let newValue = numberWithCommas(sum);
document.getElementById('badge-bg').innerHTML = newValue;
})
$('#subtractMoney').click(() => {
let networth = document.getElementById('badge-bg').innerHTML;
let userInput = $('#addValue').val();
let convertedNetWorth = parseInt(networth.replace(/,/g, ''));
let convertedUserInput = parseInt(userInput);
let sum = convertedNetWorth - convertedUserInput;
let newValue = numberWithCommas(sum);
document.getElementById('badge-bg').innerHTML = newValue;
})
});
$(document).ready(() => {
$('#getNetworth').click(() => {
let newNetWorth = document.getElementById('badge-bg').innerHTML;
$.post('controller.php',{newNetWorth:newNetWorth},(response) => {
window.location = "certificate.php?net_session="+response;
});
})
});
</script>
</body>
</html>