-
Notifications
You must be signed in to change notification settings - Fork 0
/
paymentdischarge.php
323 lines (296 loc) · 11.4 KB
/
paymentdischarge.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
<!-- Author Name: Sudipto Ghosh-->
<?php require_once('check_login.php');?>
<?php include('head.php');?>
<?php include('header.php');?>
<?php include('sidebar.php');?>
<?php include('connect.php');
if(isset($_POST["submitfullamount"]))
{
$sql ="INSERT INTO payment(patientid,appointmentid,paiddate,paidtime,paidamount,status) values('$_GET[patientid]','$_GET[appointmentid]','$dt','$tim','$_POST[paidamount]','Active')";
if($qsql = mysqli_query($conn,$sql))
{
?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Success
</h3>
<p>Payment record inserted successfully.</p>
<p>
<!-- <a href="index.php"><button class="button button--success" data-for="js_success-popup"></button></a> -->
<?php echo "<script>setTimeout(\"location.href = 'patientreport.php';\",1500);</script>"; ?>
</p>
</div>
</div>
<?php
//echo "<script>alert('payment record inserted successfully...');</script>";
}
else
{
echo mysqli_error($conn);
}
$sql ="UPDATE billing SET discount=$_POST[discountamount]+ discount, discountreason=CONCAT('$_POST[discountreason] , ', discountreason),discharge_time='$_POST[dischargetime]',discharge_date='$_POST[dischargedate]' WHERE appointmentid='$_GET[appointmentid]'";
$qsql = mysqli_query($conn,$sql);
echo mysqli_error($conn);
echo "<script>window.location='patientreport.php?patientid=$_GET[patientid]&appointmentid=$_GET[appointmentid]'</script>";
}
if(isset($_SESSION['patientid']))
{
$sql="SELECT * FROM payment WHERE paymentid='$_GET[editid]' ";
$qsql = mysqli_query($con,$sql);
$rsedit = mysqli_fetch_array($qsql);
}
$billappointmentid = $_GET['appointmentid'];
?>
<?php
if(isset($_GET['id']))
{ ?>
<div class="popup popup--icon -question js_question-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Sure
</h1>
<p>Are You Sure To Delete This Record?</p>
<p>
<a href="view-pending-appointment.php?delid=<?php echo $_GET['id']; ?>" class="button button--success" data-for="js_success-popup">Yes</a>
<a href="view-pending-appointment.php" class="button button--error" data-for="js_success-popup">No</a>
</p>
</div>
</div>
<?php } ?>
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-8">
<div class="page-header-title">
<div class="d-inline">
<h4>Make Payment</h4>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="page-header-breadcrumb">
<ul class="breadcrumb-title">
<li class="breadcrumb-item">
<a href="dashboard.php"> <i class="feather icon-home"></i> </a>
</li>
<li class="breadcrumb-item"><a>Make Payment</a>
</li>
<li class="breadcrumb-item"><a href="#">Make Payment</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="page-body">
<div class="card">
<div class="card-header">
<div class="col-sm-10">
</div>
<!-- <h5>DOM/Jquery</h5>
<span>Events assigned to the table can be exceptionally useful for user interaction, however you must be aware that DataTables will add and remove rows from the DOM as they are needed (i.e. when paging only the visible elements are actually available in the DOM). As such, this can lead to the odd hiccup when working with events.</span> -->
</div>
<div class="card-block">
<?php
$sqlbilling_records ="SELECT * FROM billing WHERE appointmentid='$billappointmentid'";
$qsqlbilling_records = mysqli_query($conn,$sqlbilling_records);
$rsbilling_records = mysqli_fetch_array($qsqlbilling_records);
?>
<div class="table-responsive dt-responsive">
<table id="dom-jqry" class="table table-striped table-bordered nowrap">
<tbody>
<tr>
<th scope="col"><div align="right">Bill number </div></th>
<td><?php echo $rsbilling_records['billingid']; ?></td>
<td>Appointment Number </td>
<td><?php echo $rsbilling_records['appointmentid']; ?></td>
</tr>
<tr>
<th width="442" scope="col"><div align="right">Billing Date </div></th>
<td width="413"><?php echo $rsbilling_records['billingdate']; ?></td>
<td width="413">Billing time </td>
<td width="413"><?php echo $rsbilling_records['billingtime'] ; ?></td>
</tr>
<tr>
<th scope="col"><div align="right"></div></th>
<td></td>
<th scope="col"><div align="right">Bill Amount </div></th>
<td><?php
$sql ="SELECT * FROM billing_records where billingid='$rsbilling_records[billingid]'";
$qsql = mysqli_query($conn,$sql);
$billamt= 0;
while($rs = mysqli_fetch_array($qsql))
{
$billamt = $billamt + $rs['bill_amount'];
}
?>
Tk. <?php echo $billamt; ?></td>
</tr>
<tr>
<th width="442" scope="col"><div align="right"></div></th>
<td width="413"> </td>
<th width="442" scope="col"><div align="right">Tax Amount (5%) </div></th>
<td width="413"> Tk. <?php echo $taxamt = 5 * ($billamt / 100); ?></td>
</tr>
<tr>
<th scope="col"><div align="right">Disount reason</div></th>
<td rowspan="4" valign="top"><?php echo $rsbilling_records['discountreason']; ?></td>
<th scope="col"><div align="right">Discount </div></th>
<td> Tk. <?php echo $rsbilling_records['discount']; ?></td>
</tr>
<tr>
<th rowspan="3" scope="col"> </th>
<th scope="col"><div align="right">Grand Total </div></th>
<td> Tk. <?php echo $grandtotal = ($billamt + $taxamt) - $rsbilling_records['discount'] ; ?></td>
</tr>
<tr>
<th scope="col"><div align="right">Paid Amount </div></th>
<td>Tk. <?php
$sqlpayment ="SELECT sum(paidamount) FROM payment where appointmentid='$billappointmentid'";
$qsqlpayment = mysqli_query($conn,$sqlpayment);
$rspayment = mysqli_fetch_array($qsqlpayment);
echo $rspayment[0];
?></td>
</tr>
<tr>
<th scope="col"><div align="right">Balance Amount</div></th>
<td>Tk. <?php echo $balanceamt = $grandtotal - $rspayment[0] ; ?></td>
</tr>
</tbody>
</table>
<p><strong>Payment report:</strong></p>
<?php
$sqlpayment = "SELECT * FROM payment where appointmentid='$billappointmentid'";
$qsqlpayment = mysqli_query($conn,$sqlpayment);
if(mysqli_num_rows($qsqlpayment) == 0)
{
echo "<strong>No transaction details found..</strong>";
}
else
{
?>
<div class="table-responsive dt-responsive">
<table id="dom-jqry" class="table table-striped table-bordered nowrap">
<tbody>
<tr>
<th scope="col">Paid Date</th>
<th scope="col">Paid time</th>
<th scope="col">Paid amount</th>
</tr>
<?php
while($rspayment = mysqli_fetch_array($qsqlpayment))
{
?>
<tr>
<td> <?php echo $rspayment['paiddate']; ?></td>
<td> <?php echo $rspayment['paidtime']; ?></td>
<td> Tk. <?php echo $rspayment['paidamount']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php } ?><br><br>
<form method="post" action="">
<div class="table-responsive dt-responsive">
<table id="dom-jqry" class="table table-striped table-bordered nowrap">
<thead>
<tr>
<th colspan="2">Discharge</th>
</tr>
</thead>
<tbody>
<tr>
<td>Discharge date</td>
<td><input class="form-control" name="dischargedate" type="text" id="dischargedate" value="<?php echo date("Y-m-d"); ?>" readonly></td>
</tr>
<tr>
<td>Discharge time</td>
<td><input class="form-control" name="dischargetime" type="text" id="dischargetime" value="<?php echo date("h:i:s"); ?>" readonly></td>
</tr>
<tr>
<td>Balance amount</td>
<td><input class="form-control" name="balamt" type="text" id="balamt" value="<?php echo $balanceamt; ?>" readonly onkeyup="calculatepayable()"></td>
</tr>
<tr>
<td>Discount *</td>
<td><input class="form-control" name="discountamount" type="text" id="discountamount" value="0" onkeyup="calculatepayable()"></td>
</tr>
<tr>
<td>Payable amount</td>
<td><input class="form-control" name="paidamount" type="text" id="paidamount" value="<?php echo $balanceamt; ?>" readonly></td>
</tr>
<tr>
<td>Discount reason</td>
<td><textarea name="discountreason" id="discountreason"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input class="form-control" type="submit" name="submitfullamount" id="submitfullamount" value="Submit" /></td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div id="#">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php');?>
<?php if(!empty($_SESSION['success'])) { ?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Success
</h1>
<p><?php echo $_SESSION['success']; ?></p>
<p>
<?php echo "<script>setTimeout(\"location.href = 'view_user.php';\",1500);</script>"; ?>
<!-- <button class="button button--success" data-for="js_success-popup">Close</button> -->
</p>
</div>
</div>
<?php unset($_SESSION["success"]);
} ?>
<?php if(!empty($_SESSION['error'])) { ?>
<div class="popup popup--icon -error js_error-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Error
</h1>
<p><?php echo $_SESSION['error']; ?></p>
<p>
<?php echo "<script>setTimeout(\"location.href = 'view_user.php';\",1500);</script>"; ?>
<!-- <button class="button button--error" data-for="js_error-popup">Close</button> -->
</p>
</div>
</div>
<?php unset($_SESSION["error"]); } ?>
<script>
var addButtonTrigger = function addButtonTrigger(el) {
el.addEventListener('click', function () {
var popupEl = document.querySelector('.' + el.dataset.for);
popupEl.classList.toggle('popup--visible');
});
};
Array.from(document.querySelectorAll('button[data-for]')).
forEach(addButtonTrigger);
</script>