-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-shift.php
More file actions
339 lines (286 loc) · 13.1 KB
/
Copy pathadd-shift.php
File metadata and controls
339 lines (286 loc) · 13.1 KB
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
<?php
include 'includes/pre-head.php';
if (!isset($_SESSION['user'])) {
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Header include -->
<?php include 'includes/head.php';?>
<!-- END Header include -->
</head>
<body>
<!-- NAV bar include -->
<?php include 'includes/navbar.php'; ?>
<!-- END NAV bar include -->
<!-- Alert include -->
<?php include 'includes/alert-header.php' ?>
<!-- END Alert include -->
<div class="container">
<div class="row">
<div class="col-12">
<!-- NAV include -->
<?php include 'includes/nav-menu.php' ?>
<!-- END NAV include -->
</div>
</div>
<div class="row justify-content-center">
<div class="col-12">
<br>
<!-- Main Content -->
<div class="container">
<form method="post" id="shift-form" data-parsley-validate>
<div class="row justify-content-center">
<div class="col-sm-10">
<h2>Add a new Shift</h2>
<hr />
</div>
</div>
<div class="row justify-content-center">
<div class="col-sm-10 form-control-feedback hidden" id="shift-form-feedback"></div>
</div>
<div class="row justify-content-center">
<!-- STAFF SELECT -->
<div class="col-sm-10 form-group">
<label class="control-label requiredField" for="select">Select a Staff for the shift:<span class="asteriskField">*</span></label>
<select class="select form-control" id="select-staff" name="staff" required>
<!--<option value="staff_id">Last, Name - RN</option>-->
<option value="" disabled selected hidden>Please Choose...</option>
<?php
//Build Staff Select List
//use the CRUD object to access the database and build an option list of the categories
$form_select_staff = $crud->getAllStaff();
foreach ($form_select_staff as $k => $v):
?>
<option value="<?php echo ($k); ?>"><?php echo ($v); ?></option>
<?php
endforeach;
//END Build Staff Select List
?>
</select>
</div>
</div>
<div class="row justify-content-center">
<!-- DATE SELECT -->
<div class="col-sm-10 form-group">
<label class="control-label requiredField" for="date">Date<span class="asteriskField">*</span></label>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
<input class="form-control" id="date" name="date" placeholder="YYYY/MM/DD" value="<?php echo date('Y-m-d'); ?>" type="<?php echo (($detect->isMobile()) ? 'date' : 'text'); ?>" required>
</div>
</div>
</div>
<div class="row justify-content-center">
<!-- DAY / NIGHT SELECT -->
<div class="col-sm-10 btn-group requiredField" data-toggle="buttons">
<label class="btn btn-outline-primary active"><input type="radio" name="dayornight" id="radio-d-or-n-d" value="D" autocomplete="off" checked required>Day</label>
<label class="btn btn-outline-primary"><input type="radio" name="dayornight" id="radio-d-or-n-n" value="N" autocomplete="off">Night</label>
</div>
</div>
<div class="row justify-content-center">
<!-- ROLE SELECT -->
<div class="col-sm-10 form-group">
<label class="control-label requiredField" for="select1">Role<span class="asteriskField">*</span></label>
<select class="select form-control" id="select-role" name="role" required>
<?php
//Build Staff Role List
//use the CRUD object to access the database and build an option list of the categories
$form_select_role = $crud->getAllRoles();
foreach ($form_select_role as $k => $v) {?>
<option value="<?php echo ($k); ?>"><?php echo ($v); ?></option>
<?php }
//END Build Role Select List
?>
</select>
</div>
</div>
<div class="row justify-content-center">
<div class="col-sm-10 form-group">
<label class="control-label requiredField" for="select2">Pod Assignment<span class="asteriskField">*</span></label>
<select class="select form-control" id="select-assignment" name="assignment" required>
<option value="" disabled selected hidden>Please Choose...</option>
<?php
//Build Assignment Select List
//use the CRUD object to access the database and build an option list of the categories
$form_select_assignment = $crud->getAllAssignments();
foreach ($form_select_assignment as $k => $v) {?>
<option value="<?= $k ?>"><?= $v ?></option>
<?php }
//END Build Assignment Select List
?>
</select>
</div>
</div>
<div class="row justify-content-center">
<div class="col-sm-10 form-group collapse show" id="chebox-group">
<label class="control-label">Check all that apply</label>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="nonvent" class="custom-control-input" type="checkbox" value="NV" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Non-vented?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="doubled" class="custom-control-input" type="checkbox" value="D" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Doubled?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="admit" class="custom-control-input" type="checkbox" value="A" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Admitted?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="codepg" class="custom-control-input" type="checkbox" value="P" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Code pager?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="vsick" class="custom-control-input" type="checkbox" value="VS" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Very sick?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="crrt" class="custom-control-input" type="checkbox" value="C" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">CRRT?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="evd" class="custom-control-input" type="checkbox" value="E" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">EVD?</span>
</label>
</div>
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input name="burn" class="custom-control-input" type="checkbox" value="B" data-parsley-excluded>
<span class="custom-control-indicator"></span><span class="custom-control-description">Burn?</span>
</label>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-sm-10 form-group">
<div><button class="btn btn-primary btn-block btn-lg" id="shift-submit" name="btn-submit-new-shift" type="submit" value="validate">Submit</button></div>
</div>
</div>
</form>
</div>
<!-- END Main Content -->
</div>
</div>
</div>
<!-- Spacer for the bottom -->
<div class="container">
<br />
<br />
<br />
</div>
<!-- Spacer for the bottom -->
<!-- Prefooter Include -->
<?php include 'includes/script-include.php'; ?>
<!-- END Prefooter Include -->
<!-- Aux Scripts -->
<script>
var debug = true;
$(function() {
<?php if (!$detect->isMobile()): ?>
$('#date').datepicker({
format: "yyyy-mm-dd",
orientation: "bottom auto",
autoclose: true,
endDate: "0d"
});
<?php endif; ?>
//Activate the Select2 script for the staff select to search easily
$("#select-staff").select2();
//Bind the Role Select Change event to selectively display the checkboxes
$( "#select-role" ).change(function() {
var selectVal = $(this).val();
switch(selectVal) {
case "5": //If the bedside role is selected, then show the checkboxes
$("#chebox-group").collapse('show');
$("input[name='nonvent']").prop("checked", false);
break;
default: //else hide them
$("#chebox-group").collapse('hide');
$("input[name='nonvent']").prop("checked", true);
}
});
//bind the parsley.js event
$('#shift-form')
.parsley({errorClass: "form-control-danger", successClass: "form-control-success"})
.on('field:validated', function (e) {
//customize Parsely.js for Bootstrap 4
if (e.validationResult.constructor!==Array) {
this.$element.closest('.form-group').removeClass('has-danger').addClass('has-success');
} else {
this.$element.closest('.form-group').removeClass('has-success').addClass('has-danger');
}
})
.on('form:submit', function () {
var data = $('#shift-form').serialize() + '&btn-submit-new-shift=1';
//console.log(data);
$.ajax({
type: 'POST',
url: 'resource/post_single_shift.php',
data: data,
beforeSend: function () {
$('#shift-submit').html('<span class="fa fa-exchange"></span> Attempting ...');
},
success: function (response) {
if (debug) { console.log(response); }
if (response == "ok") {
//clear the feedback message
$('#shift-form-feedback').html('');
//clear the form group classes
$('.form-group').each(function(){
$(this).removeClass('has-danger').removeClass('has-success');
});
//clear the form control classes
$('.form-control-danger').each(function(){ $(this).removeClass('form-control-danger'); });
$('.form-control-success').each(function(){ $(this).removeClass('form-control-success'); });
//display the alert to success
$('#form-alert').addClass('alert-success');
$('#form-alert p').html('<h4>Shift successfully added!</h4>');
$('#alert-container').collapse('show');
$("#alert-container").focus();
//set timeout to hide the alert in x milliseconds
setTimeout(function(){
$("#alert-container").collapse('hide');
setTimeout(function(){
$("#form-alert p").html('');
$('#form-alert').removeClass('alert-success');
}, 1000);
}, 5000);
//reset the form, return focus to first name
$('#shift-form').trigger('reset');
$("#chebox-group").collapse('show');
$('#select-staff').val('').trigger('change');
//scroll to top
document.body.scrollTop = 0; // For Chrome, Safari and Opera
document.documentElement.scrollTop = 0; // For IE and Firefox
} else {
$('#shift-form-feedback').html('<span class="fa fa-info-circle"></span> There is a problem with this entry.');
//feedback logic for form submission
}
$('#shift-submit').html('Submit');
}
});
return false;
});
});
</script>
<!-- END Aux Scripts -->
<!-- Footer Include -->
<?php include 'includes/footer.php'; ?>
<!-- END Footer Include -->
</body>
</html>