-
Notifications
You must be signed in to change notification settings - Fork 103
/
admin-panel.php
executable file
·617 lines (491 loc) · 25.5 KB
/
admin-panel.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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<!DOCTYPE html>
<?php
include('func.php');
include('newfunc.php');
$con=mysqli_connect("localhost","root","","myhmsdb");
$pid = $_SESSION['pid'];
$username = $_SESSION['username'];
$email = $_SESSION['email'];
$fname = $_SESSION['fname'];
$gender = $_SESSION['gender'];
$lname = $_SESSION['lname'];
$contact = $_SESSION['contact'];
if(isset($_POST['app-submit']))
{
$pid = $_SESSION['pid'];
$username = $_SESSION['username'];
$email = $_SESSION['email'];
$fname = $_SESSION['fname'];
$lname = $_SESSION['lname'];
$gender = $_SESSION['gender'];
$contact = $_SESSION['contact'];
$doctor=$_POST['doctor'];
$email=$_SESSION['email'];
# $fees=$_POST['fees'];
$docFees=$_POST['docFees'];
$appdate=$_POST['appdate'];
$apptime=$_POST['apptime'];
$cur_date = date("Y-m-d");
date_default_timezone_set('Asia/Kolkata');
$cur_time = date("H:i:s");
$apptime1 = strtotime($apptime);
$appdate1 = strtotime($appdate);
if(date("Y-m-d",$appdate1)>=$cur_date){
if((date("Y-m-d",$appdate1)==$cur_date and date("H:i:s",$apptime1)>$cur_time) or date("Y-m-d",$appdate1)>$cur_date) {
$check_query = mysqli_query($con,"select apptime from appointmenttb where doctor='$doctor' and appdate='$appdate' and apptime='$apptime'");
if(mysqli_num_rows($check_query)==0){
$query=mysqli_query($con,"insert into appointmenttb(pid,fname,lname,gender,email,contact,doctor,docFees,appdate,apptime,userStatus,doctorStatus) values($pid,'$fname','$lname','$gender','$email','$contact','$doctor','$docFees','$appdate','$apptime','1','1')");
if($query)
{
echo "<script>alert('Your appointment successfully booked');</script>";
}
else{
echo "<script>alert('Unable to process your request. Please try again!');</script>";
}
}
else{
echo "<script>alert('We are sorry to inform that the doctor is not available in this time or date. Please choose different time or date!');</script>";
}
}
else{
echo "<script>alert('Select a time or date in the future!');</script>";
}
}
else{
echo "<script>alert('Select a time or date in the future!');</script>";
}
}
if(isset($_GET['cancel']))
{
$query=mysqli_query($con,"update appointmenttb set userStatus='0' where ID = '".$_GET['ID']."'");
if($query)
{
echo "<script>alert('Your appointment successfully cancelled');</script>";
}
}
function generate_bill(){
$con=mysqli_connect("localhost","root","","myhmsdb");
$pid = $_SESSION['pid'];
$output='';
$query=mysqli_query($con,"select p.pid,p.ID,p.fname,p.lname,p.doctor,p.appdate,p.apptime,p.disease,p.allergy,p.prescription,a.docFees from prestb p inner join appointmenttb a on p.ID=a.ID and p.pid = '$pid' and p.ID = '".$_GET['ID']."'");
while($row = mysqli_fetch_array($query)){
$output .= '
<label> Patient ID : </label>'.$row["pid"].'<br/><br/>
<label> Appointment ID : </label>'.$row["ID"].'<br/><br/>
<label> Patient Name : </label>'.$row["fname"].' '.$row["lname"].'<br/><br/>
<label> Doctor Name : </label>'.$row["doctor"].'<br/><br/>
<label> Appointment Date : </label>'.$row["appdate"].'<br/><br/>
<label> Appointment Time : </label>'.$row["apptime"].'<br/><br/>
<label> Disease : </label>'.$row["disease"].'<br/><br/>
<label> Allergies : </label>'.$row["allergy"].'<br/><br/>
<label> Prescription : </label>'.$row["prescription"].'<br/><br/>
<label> Fees Paid : </label>'.$row["docFees"].'<br/>
';
}
return $output;
}
if(isset($_GET["generate_bill"])){
require_once("TCPDF/tcpdf.php");
$obj_pdf = new TCPDF('P',PDF_UNIT,PDF_PAGE_FORMAT,true,'UTF-8',false);
$obj_pdf -> SetCreator(PDF_CREATOR);
$obj_pdf -> SetTitle("Generate Bill");
$obj_pdf -> SetHeaderData('','',PDF_HEADER_TITLE,PDF_HEADER_STRING);
$obj_pdf -> SetHeaderFont(Array(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN));
$obj_pdf -> SetFooterFont(Array(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN));
$obj_pdf -> SetDefaultMonospacedFont('helvetica');
$obj_pdf -> SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf -> SetMargins(PDF_MARGIN_LEFT,'5',PDF_MARGIN_RIGHT);
$obj_pdf -> SetPrintHeader(false);
$obj_pdf -> SetPrintFooter(false);
$obj_pdf -> SetAutoPageBreak(TRUE, 10);
$obj_pdf -> SetFont('helvetica','',12);
$obj_pdf -> AddPage();
$content = '';
$content .= '
<br/>
<h2 align ="center"> Global Hospitals</h2></br>
<h3 align ="center"> Bill</h3>
';
$content .= generate_bill();
$obj_pdf -> writeHTML($content);
ob_end_clean();
$obj_pdf -> Output("bill.pdf",'I');
}
function get_specs(){
$con=mysqli_connect("localhost","root","","myhmsdb");
$query=mysqli_query($con,"select username,spec from doctb");
$docarray = array();
while($row =mysqli_fetch_assoc($query))
{
$docarray[] = $row;
}
return json_encode($docarray);
}
?>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="vendor/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans&display=swap" rel="stylesheet">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
<a class="navbar-brand" href="#"><i class="fa fa-user-plus" aria-hidden="true"></i> Global Hospital </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<style >
.bg-primary {
background: -webkit-linear-gradient(left, #3931af, #00c6ff);
}
.list-group-item.active {
z-index: 2;
color: #fff;
background-color: #342ac1;
border-color: #007bff;
}
.text-primary {
color: #342ac1!important;
}
.btn-primary{
background-color: #3c50c1;
border-color: #3c50c1;
}
</style>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="logout.php"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"></a>
</li>
</ul>
</div>
</nav>
</head>
<style type="text/css">
button:hover{cursor:pointer;}
#inputbtn:hover{cursor:pointer;}
</style>
<body style="padding-top:50px;">
<div class="container-fluid" style="margin-top:50px;">
<h3 style = "margin-left: 40%; padding-bottom: 20px; font-family: 'IBM Plex Sans', sans-serif;"> Welcome  <?php echo $username ?>
</h3>
<div class="row">
<div class="col-md-4" style="max-width:25%; margin-top: 3%">
<div class="list-group" id="list-tab" role="tablist">
<a class="list-group-item list-group-item-action active" id="list-dash-list" data-toggle="list" href="#list-dash" role="tab" aria-controls="home">Dashboard</a>
<a class="list-group-item list-group-item-action" id="list-home-list" data-toggle="list" href="#list-home" role="tab" aria-controls="home">Book Appointment</a>
<a class="list-group-item list-group-item-action" href="#app-hist" id="list-pat-list" role="tab" data-toggle="list" aria-controls="home">Appointment History</a>
<a class="list-group-item list-group-item-action" href="#list-pres" id="list-pres-list" role="tab" data-toggle="list" aria-controls="home">Prescriptions</a>
</div><br>
</div>
<div class="col-md-8" style="margin-top: 3%;">
<div class="tab-content" id="nav-tabContent" style="width: 950px;">
<div class="tab-pane fade show active" id="list-dash" role="tabpanel" aria-labelledby="list-dash-list">
<div class="container-fluid container-fullw bg-white" >
<div class="row">
<div class="col-sm-4" style="left: 5%">
<div class="panel panel-white no-radius text-center">
<div class="panel-body">
<span class="fa-stack fa-2x"> <i class="fa fa-square fa-stack-2x text-primary"></i> <i class="fa fa-terminal fa-stack-1x fa-inverse"></i> </span>
<h4 class="StepTitle" style="margin-top: 5%;"> Book My Appointment</h4>
<script>
function clickDiv(id) {
document.querySelector(id).click();
}
</script>
<p class="links cl-effect-1">
<a href="#list-home" onclick="clickDiv('#list-home-list')">
Book Appointment
</a>
</p>
</div>
</div>
</div>
<div class="col-sm-4" style="left: 10%">
<div class="panel panel-white no-radius text-center">
<div class="panel-body" >
<span class="fa-stack fa-2x"> <i class="fa fa-square fa-stack-2x text-primary"></i> <i class="fa fa-paperclip fa-stack-1x fa-inverse"></i> </span>
<h4 class="StepTitle" style="margin-top: 5%;">My Appointments</h2>
<p class="cl-effect-1">
<a href="#app-hist" onclick="clickDiv('#list-pat-list')">
View Appointment History
</a>
</p>
</div>
</div>
</div>
</div>
<div class="col-sm-4" style="left: 20%;margin-top:5%">
<div class="panel panel-white no-radius text-center">
<div class="panel-body" >
<span class="fa-stack fa-2x"> <i class="fa fa-square fa-stack-2x text-primary"></i> <i class="fa fa-list-ul fa-stack-1x fa-inverse"></i> </span>
<h4 class="StepTitle" style="margin-top: 5%;">Prescriptions</h2>
<p class="cl-effect-1">
<a href="#list-pres" onclick="clickDiv('#list-pres-list')">
View Prescription List
</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="list-home" role="tabpanel" aria-labelledby="list-home-list">
<div class="container-fluid">
<div class="card">
<div class="card-body">
<center><h4>Create an appointment</h4></center><br>
<form class="form-group" method="post" action="admin-panel.php">
<div class="row">
<!-- <?php
$con=mysqli_connect("localhost","root","","myhmsdb");
$query=mysqli_query($con,"select username,spec from doctb");
$docarray = array();
while($row =mysqli_fetch_assoc($query))
{
$docarray[] = $row;
}
echo json_encode($docarray);
?> -->
<div class="col-md-4">
<label for="spec">Specialization:</label>
</div>
<div class="col-md-8">
<select name="spec" class="form-control" id="spec">
<option value="" disabled selected>Select Specialization</option>
<?php
display_specs();
?>
</select>
</div>
<br><br>
<script>
document.getElementById('spec').onchange = function foo() {
let spec = this.value;
console.log(spec)
let docs = [...document.getElementById('doctor').options];
docs.forEach((el, ind, arr)=>{
arr[ind].setAttribute("style","");
if (el.getAttribute("data-spec") != spec ) {
arr[ind].setAttribute("style","display: none");
}
});
};
</script>
<div class="col-md-4"><label for="doctor">Doctors:</label></div>
<div class="col-md-8">
<select name="doctor" class="form-control" id="doctor" required="required">
<option value="" disabled selected>Select Doctor</option>
<?php display_docs(); ?>
</select>
</div><br/><br/>
<script>
document.getElementById('doctor').onchange = function updateFees(e) {
var selection = document.querySelector(`[value=${this.value}]`).getAttribute('data-value');
document.getElementById('docFees').value = selection;
};
</script>
<!-- <div class="col-md-4"><label for="doctor">Doctors:</label></div>
<div class="col-md-8">
<select name="doctor" class="form-control" id="doctor1" required="required">
<option value="" disabled selected>Select Doctor</option>
</select>
</div>
<br><br> -->
<!-- <script>
document.getElementById("spec").onchange = function updateSpecs(event) {
var selected = document.querySelector(`[data-value=${this.value}]`).getAttribute("value");
console.log(selected);
var options = document.getElementById("doctor1").querySelectorAll("option");
for (i = 0; i < options.length; i++) {
var currentOption = options[i];
var category = options[i].getAttribute("data-spec");
if (category == selected) {
currentOption.style.display = "block";
} else {
currentOption.style.display = "none";
}
}
}
</script> -->
<!-- <script>
let data =
document.getElementById('spec').onchange = function updateSpecs(e) {
let values = data.filter(obj => obj.spec == this.value).map(o => o.username);
document.getElementById('doctor1').value = document.querySelector(`[value=${values}]`).getAttribute('data-value');
};
</script> -->
<div class="col-md-4"><label for="consultancyfees">
Consultancy Fees
</label></div>
<div class="col-md-8">
<!-- <div id="docFees">Select a doctor</div> -->
<input class="form-control" type="text" name="docFees" id="docFees" readonly="readonly"/>
</div><br><br>
<div class="col-md-4"><label>Appointment Date</label></div>
<div class="col-md-8"><input type="date" class="form-control datepicker" name="appdate"></div><br><br>
<div class="col-md-4"><label>Appointment Time</label></div>
<div class="col-md-8">
<!-- <input type="time" class="form-control" name="apptime"> -->
<select name="apptime" class="form-control" id="apptime" required="required">
<option value="" disabled selected>Select Time</option>
<option value="08:00:00">8:00 AM</option>
<option value="10:00:00">10:00 AM</option>
<option value="12:00:00">12:00 PM</option>
<option value="14:00:00">2:00 PM</option>
<option value="16:00:00">4:00 PM</option>
</select>
</div><br><br>
<div class="col-md-4">
<input type="submit" name="app-submit" value="Create new entry" class="btn btn-primary" id="inputbtn">
</div>
<div class="col-md-8"></div>
</div>
</form>
</div>
</div>
</div><br>
</div>
<div class="tab-pane fade" id="app-hist" role="tabpanel" aria-labelledby="list-pat-list">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Doctor Name</th>
<th scope="col">Consultancy Fees</th>
<th scope="col">Appointment Date</th>
<th scope="col">Appointment Time</th>
<th scope="col">Current Status</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
$con=mysqli_connect("localhost","root","","myhmsdb");
global $con;
$query = "select ID,doctor,docFees,appdate,apptime,userStatus,doctorStatus from appointmenttb where fname ='$fname' and lname='$lname';";
$result = mysqli_query($con,$query);
while ($row = mysqli_fetch_array($result)){
#$fname = $row['fname'];
#$lname = $row['lname'];
#$email = $row['email'];
#$contact = $row['contact'];
?>
<tr>
<td><?php echo $row['doctor'];?></td>
<td><?php echo $row['docFees'];?></td>
<td><?php echo $row['appdate'];?></td>
<td><?php echo $row['apptime'];?></td>
<td>
<?php if(($row['userStatus']==1) && ($row['doctorStatus']==1))
{
echo "Active";
}
if(($row['userStatus']==0) && ($row['doctorStatus']==1))
{
echo "Cancelled by You";
}
if(($row['userStatus']==1) && ($row['doctorStatus']==0))
{
echo "Cancelled by Doctor";
}
?></td>
<td>
<?php if(($row['userStatus']==1) && ($row['doctorStatus']==1))
{ ?>
<a href="admin-panel.php?ID=<?php echo $row['ID']?>&cancel=update"
onClick="return confirm('Are you sure you want to cancel this appointment ?')"
title="Cancel Appointment" tooltip-placement="top" tooltip="Remove"><button class="btn btn-danger">Cancel</button></a>
<?php } else {
echo "Cancelled";
} ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
<div class="tab-pane fade" id="list-pres" role="tabpanel" aria-labelledby="list-pres-list">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Doctor Name</th>
<th scope="col">Appointment ID</th>
<th scope="col">Appointment Date</th>
<th scope="col">Appointment Time</th>
<th scope="col">Diseases</th>
<th scope="col">Allergies</th>
<th scope="col">Prescriptions</th>
<th scope="col">Bill Payment</th>
</tr>
</thead>
<tbody>
<?php
$con=mysqli_connect("localhost","root","","myhmsdb");
global $con;
$query = "select doctor,ID,appdate,apptime,disease,allergy,prescription from prestb where pid='$pid';";
$result = mysqli_query($con,$query);
if(!$result){
echo mysqli_error($con);
}
while ($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['doctor'];?></td>
<td><?php echo $row['ID'];?></td>
<td><?php echo $row['appdate'];?></td>
<td><?php echo $row['apptime'];?></td>
<td><?php echo $row['disease'];?></td>
<td><?php echo $row['allergy'];?></td>
<td><?php echo $row['prescription'];?></td>
<td>
<form method="get">
<!-- <a href="admin-panel.php?ID="
onClick=""
title="Pay Bill" tooltip-placement="top" tooltip="Remove"><button class="btn btn-success">Pay</button>
</a></td> -->
<a href="admin-panel.php?ID=<?php echo $row['ID']?>">
<input type ="hidden" name="ID" value="<?php echo $row['ID']?>"/>
<input type = "submit" onclick="alert('Bill Paid Successfully');" name ="generate_bill" class = "btn btn-success" value="Pay Bill"/>
</a>
</td>
</form>
</tr>
<?php }
?>
</tbody>
</table>
<br>
</div>
<div class="tab-pane fade" id="list-messages" role="tabpanel" aria-labelledby="list-messages-list">...</div>
<div class="tab-pane fade" id="list-settings" role="tabpanel" aria-labelledby="list-settings-list">
<form class="form-group" method="post" action="func.php">
<label>Doctors name: </label>
<input type="text" name="name" placeholder="Enter doctors name" class="form-control">
<br>
<input type="submit" name="doc_sub" value="Add Doctor" class="btn btn-primary">
</form>
</div>
<div class="tab-pane fade" id="list-attend" role="tabpanel" aria-labelledby="list-attend-list">...</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.10.1/sweetalert2.all.min.js">
</script>
</body>
</html>