-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-actions-nurse.php
276 lines (235 loc) · 10.7 KB
/
admin-actions-nurse.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
<?php
$stmt = $dbconn->prepare("SELECT * FROM Person NATURAL JOIN Nurse WHERE Person.Person_ID = Nurse.Nurse_ID");
$nurses = array();
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$nurseid = $row['Nurse_ID'];
$nurses[$nurseid]['Person_ID'] = $row['Person_ID'];
$nurses[$nurseid]['Name'] = $row['Name'];
$nurses[$nurseid]['Surname'] = $row['Surname'];
$nurses[$nurseid]['Dateofbirth'] = $row['Date of birth'];
$nurses[$nurseid]['Sex'] = $row['Sex'];
$nurses[$nurseid]['IDnumber'] = $row['ID number'];
$nurses[$nurseid]['Country'] = $row['Country'];
$nurses[$nurseid]['City'] = $row['City'];
$nurses[$nurseid]['Street'] = $row['Street'];
$nurses[$nurseid]['Zip'] = $row['Zip'];
$nurses[$nurseid]['Competence'] = $row['Competence'];
$nurses[$nurseid]['Department_ID'] = $row['Department_ID'];
$depid = $row['Department_ID'];
$wtf = $dbconn->prepare("SELECT Name FROM Department WHERE Department.Department_ID = '$depid' ");
$wtf->execute();
$result = $wtf->fetch(PDO::FETCH_ASSOC);
$nurses[$nurseid]['Department'] = $result['Name'];
$nurses[$nurseid]['Degree'] = $row['Degree'];
$nurses[$nurseid]['Actualstate'] = $row['Actual state'];
$nurses[$nurseid]['Turnoutdate'] = $row['Turn out date'];
//$nurses[$nurseid]['User_ID'] = $row['User_ID'];
//$nurses[$nurseid]['Username'] = $row['Username'];
//$nurses[$nurseid]['Email'] = $row['Email'];
}
}
$stmt = $dbconn->prepare("SELECT * FROM User");
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$personid = $row['Person_ID'];
foreach ($nurses as $nurseid => $array) {
if($personid == $nurseid){
$nurses[$nurseid]['User_ID'] = $row['User_ID'];
$nurses[$nurseid]['Username'] = $row['Username'];
$nurses[$nurseid]['Email'] = $row['Email'];
}
}
}
}
?>
<div class="container" style="margin-top: 10px; padding-right: 200px; padding-left: 200px;">
<div class="btn-group btn-group-justified">
<a href="#" role="button" class="btn btn-info setfilter" id="setFilter">Set filter</a>
<a href="index.php?search=2" role="button" class="btn btn-info setfilter" id="unsetFilter">Unset filter</a>
</div>
</div>
<div style="margin: 10px;">
<div class="table-responsive">
<table class="table-primary datatable">
<thead>
<tr class="header">
<?php
echo "<th>Degree</th>";
echo "<th>Full name</th>";
echo "<th>Competence</th>";
echo "<th>Department</th>";
echo "<th>Username</th>";
echo "<th>Email</th>";
echo "<th>Date of birth</th>";
echo "<th>ID number</th>";
echo "<th>Country</th>";
echo "<th>Address</th>";
echo "<th>Actual state</th>";
echo "<th>Turn out date</th>";
echo "<th>Dismiss</th>";
echo "<th>Edit</th>";
echo "<th>Delete</th>";
echo "</tr>";
echo"</thead>";
echo"<tbody>";
foreach ($nurses as $nurseid => $nursedata)
{
echo "<tr>";
echo "<td>".$nursedata['Degree']."</td>";
echo "<td>".$nursedata['Name']." ".$nursedata['Surname']."</td>";
echo "<td>".$nursedata['Competence']."</td>";
echo "<td>".$nursedata['Department']."</td>";
if(isset($nursedata['Username']) && isset($nursedata['Email'])){
echo "<td>".$nursedata['Username']."</td>";
echo "<td>".$nursedata['Email']."</td>";
}else{
echo "<td></td>";
echo "<td></td>";
}
echo "<td>".$nursedata['Dateofbirth']."</td>";
echo "<td>".$nursedata['IDnumber']."</td>";
echo "<td>".$nursedata['Country']."</td>";
echo "<td>".$nursedata['City'].", ".$nursedata['Street'].", ".$nursedata['Zip']."</td>";
echo "<td>".$nursedata['Actualstate']."</td>";
echo "<td>".$nursedata['Turnoutdate']."</td>";
$fired = $nursedata['Actualstate'];
$person_id = $nursedata['Person_ID'];
if($fired == "active"){
echo "<td><a href=\"#\" onclick=\"transferPhpArray($person_id, 'Nurse')\" role=\"button\" data-toggle=\"modal\" data-target=\"#dismissNurseModal\" class=\"btn btn-warning \"><span class=\"glyphicon glyphicon-log-out\"></span></td>";
echo "<td><a href=\"#\" onclick=\"transferPhpArray($person_id, 'Nurse')\" role=\"button\" data-toggle=\"modal\" data-id=\"1\" data-target=\"#editNurseModal\" class=\"btn btn-info \"><span class=\"glyphicon glyphicon-edit\"></span></td>";
}else{
echo "<td><a href=\"#\" role=\"button\" class=\"btn btn-default disabled\"><span class=\"glyphicon glyphicon-ban-circle\"></span></td>" ;
echo "<td><a href=\"#\" role=\"button\" class=\"btn btn-default disabled\"><span class=\"glyphicon glyphicon-ban-circle\"></span></td>" ;
}
echo "<td><a href=\"#\" onclick=\"transferPhpArray($person_id, 'Nurse')\" role=\"button\" data-toggle=\"modal\" data-target=\"#deleteNurseModal\" class=\"btn btn-danger \"><span class=\"glyphicon glyphicon-trash\"></span></td>";
echo "</tr>";
}
?>
</tr>
</tbody>
</table>
</div>
</div>
<?create_unsuccessful_delete_modal("nurseDel", "2", "The nurse record you want to delete can't be deleted due to existence of department assignment for her/him. Sorry.")?>
<? $departments=array();
$depname = $dbconn->prepare("SELECT Name FROM Department");
if($depname->execute())
{
while ($row = $depname->fetch(PDO::FETCH_ASSOC))
{
$departments[] = $row['Name'];
}
}?>
<div class="modal fade" id="editNurseModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit nurse</h4>
</div>
<div class="modal-body">
<form method="post" action="index.php?search=2">
<?php include('form-person-modal.php');?>
<?php include('form-user-modal.php');?>
<div class="form-group form-width <?php set_input_error_success("Department", $errors);?>">
<label>Department:</label>
<select class="form-control" id="Department" name="Department">
<?php add_options_from_array($departments, isset($Department) ? $Department : "")?>
</select>
</div>
<div class="form-group form-width <?php set_input_error_success("Competence", $errors);?>">
<label for="Competence">Competence:</label>
<select name="Competence" id="Competence" class="form-control">
<?php add_options_from_array($arraycompetences, isset($Competence) ? $Competence : "")?>
</select>
</div>
<div class="form-group form-width <?php set_input_error_success("Degree", $errors);?>">
<label for="Degree">Degree:</label>
<select name="Degree" id="Degree" class="form-control">
<?php add_options_from_array($arraynursedegrees, isset($Degree) ? $Degree : "")?>
</select>
</div>
<input class="hidden" name="Person_ID">
<input class="hidden" name="User_ID">
<button type="submit" name="edit-nurse" class="btn btn-primary">Save changes</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="deleteNurseModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete nurse</h4>
</div>
<div class="modal-body">
<p class="modal-delete">Do you really want to delete nurse record?</p>
<form method="post" action="index.php?search=2">
<div class="form-group">
<input class="hidden" name="Person_ID_Delete">
</div>
<div class="form-group">
<input class="hidden" name="User_ID_Delete">
</div>
<button type="submit" name="delete-nurse" class="btn btn-danger">Confirm</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="dismissNurseModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Dismiss nurse</h4>
</div>
<div class="modal-body">
<p class="modal-dismiss">Do you really want to dismiss the nurse? You can not change it later.</p>
<form method="post" action="index.php?search=2">
<div class="form-group">
<input class="hidden" name="Person_ID_Dismiss">
</div>
<div class="form-group">
<input class="hidden" name="User_ID_Dismiss">
</div>
<div class="form-group">
<input class="hidden" name="Turnoutdate" id="Turnoutdate">
</div>
<div class="form-group">
<input class="hidden" name="Actualstate">
</div>
<button type="submit" name="dismiss-nurse" class="btn btn-warning">Confirm</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
$("#dismissNurseModal").on("shown.bs.modal", function () {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
var today = dd + '/' + mm + '/' + yyyy;
$( "#Turnoutdate" ).datepicker("setDate", today);
});
</script>