-
Notifications
You must be signed in to change notification settings - Fork 0
/
billing.php
459 lines (378 loc) · 17.4 KB
/
billing.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<?php
include("db.php");
/*Billing calculation*/
if (isset($_POST['submit']) && isset($_GET['patientid'])) {
$tsql = "SELECT * FROM treatmentrecords,treatment WHERE treatmentrecords.treatmentid=treatment.Treatmentid and
treatmentrecords.appointmentid='$_GET[appointmentid]' and treatmentrecords.patientid='$_GET[patientid]'";
$tc = mysqli_query($con, $tsql);
$bsql = "SELECT * FROM doctor where doctorid='$_GET[doctorid]'";
$bcsql = mysqli_query($con, $bsql);
$drs = mysqli_fetch_array($bcsql);
$tcost = 0;
$payment = "SELECT * from appointment,billing WHERE appointment.appointmentid=billing.appointmentid and
appointment.appointmentid='$_GET[appointmentid]'";
$pc = mysqli_query($con, $payment);
if (mysqli_num_rows($pc) == 0) {
while ($trs = mysqli_fetch_array($tc)) {
$tcost = $tcost + $trs['Treatment_Cost'];
}
$billamt = $tcost + $drs['fees'];
$billing = "INSERT INTO billing (appointmentid,patientid,totalamount,status)
values ('$_GET[appointmentid]','$_GET[patientid]','$billamt','$_POST[status]')";
if ((mysqli_query($con, $billing))) {
echo "<script>alert('Treatment Record Added Succesfully');</script>";
} else {
echo "<script>alert('Failed to add bill')</script>";
}
} else {
$payrs = mysqli_fetch_array($pc);
$tcost = 0;
while ($trs = mysqli_fetch_array($tc)) {
$tcost = $tcost + $trs['Treatment_Cost'];
}
$billamt = $tcost + $drs['fees'];
$billing = "UPDATE billing SET totalamount='$billamt',status='$_POST[status]' WHERE appointmentid='$_GET[appointmentid]' and patientid='$_GET[patientid]'
and billid='$payrs[billid]' ";;
if ((mysqli_query($con, $billing))) {
echo "<script>alert('Treatment Record Updated Succesfully')</script>";
} else {
echo "<script>alert('Failed to update')</script>";
}
}
}
?>
<html>
<head>
<title>Doctor Panel</title>
<?php
$con = mysqli_connect("localhost", "root", "", "doctorappointment");
if (!($con)) {
echo "Failed connection :" . mysqli_connect_error();
}
?>
<script type="application/javascript">
(function(document) {
'use strict';
var LightTableFilter = (function(Arr) {
var _input;
function _onInputEvent(e) {
_input = e.target;
var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
Arr.forEach.call(tables, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, _filter);
});
});
}
function _filter(row) {
var text = row.textContent.toLowerCase(),
val = _input.value.toLowerCase();
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('light-table-filter');
Arr.forEach.call(inputs, function(input) {
input.oninput = _onInputEvent;
});
}
};
})(Array.prototype);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
LightTableFilter.init();
}
});
})(document);
</script>
<link rel="stylesheet" href="style/admin.css" type="text/css" />
<style type="text/css">
p {
text-align: justify;
}
.container {
height: 100%;
background-image: url(https://icons8.com/wp-content/uploads/2020/02/how-to-create-gradient-article.jpg);
position: fixed;
bottom: 0;
right: 0;
left: 0;
top: 0;
}
.header {
height: 5%;
background-image: linear-gradient(to left, aliceblue, darkslateblue, #060c21);
}
.left {
height: 95%;
width: 23%;
background-color: midnightblue;
background-image: url(https://images.unsplash.com/photo-1475274047050-1d0c0975c63e?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8bmlnaHQlMjBza3l8ZW58MHx8MHx8&ixlib=rb-1.2.1&w=1000&q=80);
background-size: 312px 715px;
position: fixed;
bottom: 0;
right: 0;
left: 0;
float: left;
}
.right {
height: 95%;
width: 77%;
background-image: url(https://t4.ftcdn.net/jpg/02/19/84/51/360_F_219845109_nVvYH8OBIaHkBnun1cQEq6smPKEHsbZW.jpg);
background-size: 100%;
}
.admintop {
height: 90%;
width: 77%;
position: fixed;
right: 0;
overflow: auto;
}
.footer {
height: 5%;
width: 77%;
position: fixed;
right: 0;
top: 595;
bottom: 0;
}
.dropdown-btn {
font-size: 18px;
font-family: arial, serif;
color: gainsboro;
border: none;
background: none;
width: 100%;
text-align: left;
outline: none;
}
.dropdown-btn:hover {
color: white;
}
/* Dropdown container (hidden by default). Optional: add a lighter background color and some left padding to change the design of the dropdown content */
.dropdown-container {
display: none;
background-color: none;
}
/* Optional: Style the caret down icon */
.fa-caret-down {
float: right;
padding-right: 8px;
}
</style>
<style>
a {
text-decoration: none;
color: black;
}
a:hover {
color: midnightblue;
text-decoration: underline;
font-weight: bold;
}
#a {
text-decoration: none;
color: gainsboro;
}
#a:hover {
color: white;
}
#button {
background-color: blueviolet;
color: white;
border-radius: 3px;
}
#button:hover {
background-color: lemonchiffon;
color: black;
}
input[type=submit] {
background-color: antiquewhite;
border-radius: 5px;
}
input[type=submit]:hover {
background-color: azure;
}
select {
width: 150px;
}
select:focus {
min-width: 150px;
width: auto;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="container">
<div class="header">
<div class="head" align="left">
<font size="5" face="forte" color="papayawhip">     Online Doctor Appointment System</font>
</div>
<div class="profile"><a href="docprofile.php"><img src="Profile-PNG-Clipart.png" height="32" width="32" align="center" height="38" width="38" align="center"></a></div>
</div>
<div class="body">
<div class="left">
<h1 align="left">
<font size="5" face="arial" color="gainsboro">
  <a href="doctor.php" id="a"><u>Doctor Dashboard</u></a>
</font>
</h1>
<table align="center">
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<th><img src="https://img.icons8.com/emoji/452/key-emoji.png" height="27" width="27"></th>
<th>
<font size="4" face="arial" color="gainsboro"><a href="docchangepassword.php" target="_self" id="a">     Change Password            </a></font>
</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<th><img src="https://icons555.com/images/icons-gray/image_icon_logout_pic_512x512.png" height="27" width="27"></th>
<th>
<font size="4" face="arial" color="gainsboro"><a href="logout.php" target="_self" id="a">Log Out                     </a></font>
</th>
</tr>
</table>
</div>
<div class="right">
<?php
if (isset($_GET['delid'])) {
$del = "DELETE FROM patient WHERE patientid ='$_GET[delid]' ";
$sdel = mysqli_query($con, $del);
$delapp = "DELETE FROM appointment WHERE patientid ='$_GET[delid]' ";
$sdelapp = mysqli_query($con, $delapp);
if (mysqli_affected_rows($con) == 1) {
echo "<script>alert('Patient successfully deleted')</script> ";
} else {
echo "<script>alert('Failed to delete')</script>";
}
}
?>
<div class="admintop">
<h2 align="center" style="color: black">Payment</h2><br>
<?php
if ((isset($_GET['appointmentid'])) || (isset($_GET['patientid']))) {
$sqlap2 = "SELECT * from treatment,treatmentrecords WHERE treatmentrecords.treatmentid=treatment.Treatmentid and treatmentrecords.appointmentid='$_GET[appointmentid]' and treatmentrecords.patientid='$_GET[patientid]'";
$csqla2 = mysqli_query($con, $sqlap2);
$rs2 = mysqli_fetch_array($csqla2);
$payment = "SELECT * from appointment,billing WHERE appointment.appointmentid=billing.appointmentid and
appointment.appointmentid='$_GET[appointmentid]'";
$pc = mysqli_query($con, $payment);
$payrs = mysqli_fetch_array($pc);
$dcsql = "SELECT * from doctor WHERE doctorid='$_GET[doctorid]'";
$dc = mysqli_query($con, $dcsql);
$dcrs = mysqli_fetch_array($dc);
?>
<form method="post" action="" name="billform">
<table class="order-table" width="550" border="3" cellpadding="4" align="center" style="border-radius: 3px; border-color: lightslategray;">
<tr>
<td><b> Payment For Appointment Number</b></td>
<td> <?php echo $_GET['appointmentid']; ?> </td>
</tr>
</table>
<br>
<table width="550" border="3" cellpadding="4" align="center" style="background-color: mistyrose; border-radius: 3px; border-color: lightslategray;">
<tr>
<th colspan="2" style="text-align:center; background-color: mediumpurple">Treatment Details</th>
</tr>
<tr>
<th style="background-color: thistle;"> Treatment</th>
<th style="background-color: thistle;">Cost </th>
</tr>
<tr>
<td> Doctor fees</td>
<td> <?php echo "$dcrs[fees]" ?> </td>
</tr>
<?php
$sqlap2 = "SELECT Treatment_Type, Treatment_Cost from treatment,treatmentrecords WHERE
treatmentrecords.treatmentid=treatment.Treatmentid and treatmentrecords.appointmentid='$_GET[appointmentid]' and treatmentrecords.patientid='$_GET[patientid]'";
$csqla2 = mysqli_query($con, $sqlap2);
$totalmon = 0;
while ($rs2 = mysqli_fetch_array($csqla2)) {
echo "<tr> <td> $rs2[Treatment_Type] </td>
<td> $rs2[Treatment_Cost] </td></tr>
";
$totalmon = $totalmon + $rs2['Treatment_Cost'];
}
$totals = $totalmon + $dcrs['fees'];
echo "<tr> <td style='background-color: plum; font-weight: bold;'> Total Amount</td>
<td style='background-color: plum; font-weight: bold;'> $totals </td></tr>";
?>
<tr>
<td style='background-color: plum; font-weight: bold;'> Payment Status</td>
<td style='background-color: plum; font-weight: bold;'> <select name="status">
<option value="Not Paid">Not Paid</option>
<option value=" Paid"> Paid</option>
</select></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Save Details" style="width:100%; border-radius:4px;"> </td>
</tr>
<?php if (isset($_POST['submit'])) {
echo "<td style='background-color: violet; font-weight: bold;'> Total amount</td>
<td style='background-color: violet; font-weight: bold;'> $payrs[totalamount]</td>
</tr>
<tr>
<td style='background-color: violet; font-weight: bold;'> Status
</td>
<td style='background-color: violet; font-weight: bold;'> $payrs[status]</td></tr>
";
}
?>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<button id="button"><?php echo "<a href='patientreports.php?appointmentid=$_GET[appointmentid]&patientid=$_GET[patientid]&doctorid=$_GET[doctorid]' style='text-decoration: none;' >View Patient report</a>" ?></button>
</td>
</tr>
</table>
</form>
<?php
}
?>
</div>
</div>
<div class="footer">
<div class="ls">
<font size="1" color="black" face="lucida bright">
<br><b>               Copyright @ 2021 All Reserved</b>
</font>
</div>
<div class="rs">
<font size="1" color="black" face="lucida bright">
<br><b>                                                                              Developed by: www.sss.com</b>
</font>
</div>
</div>
</div>
</div>
</div>
<script>
/* Loop through all dropdown buttons to toggle between hiding and showing its dropdown content - This allows the user to have multiple dropdowns without any conflict */
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
}
</script>
</body>
</html>