-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactiveDoctors3.php
152 lines (116 loc) · 4.16 KB
/
activeDoctors3.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?php
include "Session.php";
include "Slot.php";
$mediID=3;
$today= date("Y-m-d");
$time=time();
//connect database
$conn = new mysqli("localhost", "root", "", "testdocdb");
//connect slot table
$sql = "SELECT slotID,sesID,status,slotNumber,channeledUserID FROM Slots";
$slotResult = $conn->query($sql);
//connect session table
$sql1 = "SELECT sesID,docID,mediCenID,numOfSlots,date,start,end FROM Sessions";
$sesResult = $conn->query($sql1);
//connect doctors table
$sql2 = "SELECT id,first_name,last_name FROM doctors";
$docResult = $conn->query($sql2);
$startingSlotIDNumbers=array();
$sessions=array();
$doctors=array();
// array_push($doctors,"Kaveesha Silva")?>
<?php while($row = $sesResult->fetch_assoc()):?>
<?php
$foundSession=false;
if (($today==$row["date"]) ){ // get active sessions and ($row["start"]<=$time and $time<=$row["end"] )
echo "sesFound!";
if($mediID==$row["mediCenID"]){
$sesID=$row["sesID"];
$docID=$row["docID"];
$date=$row["date"];
$start=$row["start"];
$end=$row["end"];
$numOfSlots=$row["numOfSlots"];
$foundSession=true;
}
}
?>
<?php
if($foundSession):?>
<?php
//get Doctor's name
while($row = $docResult->fetch_assoc()) {
echo $docID." ".$row["id"]."<br>";
if($docID==$row["id"]){
echo "docFound!";
$docName= $row["first_name"]." ".$row["last_name"];
array_push($doctors,$docName);
break;
}
}
//create new session object
$ses=new Session($numOfSlots,$docID, $mediID,$date,$start,$end);
$startingSlotID;
$slots=array();
// output data of each row
$found=false;// variable for finding the correct session in slot table
while($row = $slotResult->fetch_assoc()) {
if (!$found){
if ($sesID==$row["sesID"]){ // found the correct session
$found=true;
$slotNumber=1;
$startingSlotID=$row["slotID"];
array_push($startingSlotIDNumbers,$startingSlotID);
}
}
if ($found){
$status=$row["status"];
$userID=$row["channeledUserID"];
$slot=new Slot($sesID,$status,$userID);
array_push($slots,$slot);
// $status=$slot->getState();
//codes to update the rectangles according to status
// echo $status;//."status"."<br>";
//code to create a button for each slot
if($slotNumber<$numOfSlots){
$slotNumber++;
}
else{
array_push($sessions,$slots);
break;
}
}
}?>
<?php endif;?>
<?php endwhile;?>
<form method="POST">
<?php for($s=0;$s<count($doctors);$s++):?>
<input type="radio" name="num" value="<?=$s?>" > <h2><?php echo $doctors[$s];?></h2><br>
<?php endfor?>
<button name="test">Display</button>
</form>
<?php
if(isset($_POST['test'])){
if(isset($_POST['num'])){
$n=$_POST['num']; // order in array
$name=$doctors[$n];
$a=array();
$o=array();
$c=array();
for($s=1;$s<=count($sessions[$n]);$s++){
if($sessions[$n][$s-1]->getState()==0){array_push($a,$s);}
else if($sessions[$n][$s-1]->getState()==1){array_push($o,$s);}
else if($sessions[$n][$s-1]->getState()==2){array_push($c,$s);}
}
include "display.php";
}
}
?>
</body>
</html>