-
Notifications
You must be signed in to change notification settings - Fork 0
/
brightmoorPantry.php
588 lines (476 loc) · 19.4 KB
/
brightmoorPantry.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
<?php
//code for session variable to make sure user is logged in
require_once('session_check.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="db_styles.css">
<!--include javascript for pattern field for phone numbers, dates, etc-->
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.maskedinput.js" type="text/javascript"></script>
<!-- validate form script-->
<script>
function validateDate() {
var x = document.forms["InsertAppointment"]["NewAppointmentPicker"].value;
if (x == null || x == "") {
alert("Please choose an appointment date.");
return false;
}
}
function validateReferral() {
var x = document.forms["InsertReferral"]["ReferralType"].value;
if (x == null || x == "") {
alert("Please choose a referral type.");
return false;
}
}
</script>
<!--script for pattern masks-->
<script>
jQuery(function($){
$("#EnrollmentDate").mask("99/99/99",{placeholder:"mm/dd/yy"});
$("#CoatOrderDate").mask("99/99/99",{placeholder:"mm/dd/yy"});
$("input[type=text]#HomePhoneNumber").mask("(999)999-9999");
$("input[type=text]#CellPhoneNumber").mask("(999)999-9999");
});
</script>
<!-- date pickers-->
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#ReferralDate" ).datepicker({dateFormat: "mm/dd/y"});
});
</script>
<script>
$(function() {
$( "#AppointmentDate" ).datepicker({dateFormat: "mm/dd/y"});
});
</script>
<!-- end date picker-->
<title>Brightmoor Connection Database</title>
</head>
<body id="brightmoor">
<!-- include functions to create form items-->
<?php require_once ('functions.php');?>
<header>
<img src="images/brightmoor_logo.jpg" width=500px>
<h1>Brightmoor Connection Database</h1>
</header>
<nav>
<?php require_once ('nav.html'); ?>
</nav>
<section>
<?php
require_once ('client_drop_down.php');
?>
<!--client information form-->
<div class="formStyle">
<?php
//connect to database using php script
require_once ('mysql_path.php');
require_once ($mysql_path);
if (!isset($_POST['ClientID']))
{
//If not isset -> set with dummy value
$_POST['ClientID'] = "undefined";
} else {
$client = mysqli_real_escape_string($conn, $_POST['ClientID']);
}
if (!isset($_GET['id']))
{
//If not isset -> set with dummy value
$_GET['id'] = "undefined";
} else {
$client = mysqli_real_escape_string($conn, $_GET['id']);
}
if (!isset($client)){
$client = NULL;
}
//$posts = array($_POST['ClientID']);
$stmt = $conn->prepare("SELECT * FROM Clients WHERE ClientID=?");
$stmt->bind_param('s', $client);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
/*
$sql = "SELECT * FROM Clients WHERE ClientID='$client'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
*/
echo '
<form action="update.php" method="post">';
echo '<h2>Client Information:</h2>
<h3>Basic info:</h3>
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />';
echo '<div>';
textInput("FirstName", "First Name");
textInput("LastName", "Last Name");
numberInput("Age", "Age", "100");
echo'
<div class="fieldWrapper" id="gender"><label for="Gender">Gender: </label><select name="Gender" id="Gender">
<option value="'.$row["Gender"].'">' .$row["Gender"]. '</option>
<option value="F">F</option>
<option value="M">M</option>
</select></div>';
checkBox("Pregnant", "Pregnant");
checkBox("AddressVerified", "Address Verified");
echo '</div>';
textInput("Address", "Address");
textInput("Address2", "Address 2");
echo '<div class="fieldWrapper" id="zipCode"><label class="zipCode" for="ZipCode">Zip Code: </label><input class="zipCode" type="text" name="ZipCode" id="ZipCode" value="'.$row["ZipCode"].'" maxlength="5" size="5"/></div>';
textInput("HomePhoneNumber", "Home Phone Number");
textInput("CellPhoneNumber", "Cell Phone Number");
echo '<div class="fieldWrapper">';
emailInput("EmailAddress", "Email Address");
echo '</div>';
echo '<h3>Family Information:</h3>';
numberInput("FamilySize", "Family Size");
numberInput("AdultsNumber", "Number of Adults");
numberInput("ChildrenNumber", "Number of Children");
echo '<h4>Age Range:</h4>';
numberInput("AgeRange05", "0-5");
numberInput("AgeRange617", "6-17");
numberInput("AgeRange1829", "18-29");
numberInput("AgeRange3039", "30-39");
numberInput("AgeRange4049", "40-49");
numberInput("AgeRange5064", "50-64");
numberInput("AgeRange65", "65+");
echo '<h3>Household Information. This information is to help determine future services!</h3>
<p style="display:inline;">Do you have access to facilities to prepare food (stove/oven): </p>';
$hasStoveChecked = NULL;
$noStoveChecked = NULL;
if ($row["HasStove"]=='Yes'){
$hasStoveChecked = 'checked';
}
if ($row["HasStove"]=='No'){
$noStoveChecked = 'checked';
}
echo '
<label for="stoveYes">Yes</label><input type="radio" name="HasStove" id="stoveYes" value="Yes" '.$hasStoveChecked.'>
<label for="stoveNo">No</label><input type="radio" name="HasStove" id="stoveNo" value="No" '.$noStoveChecked.'><br /><br />';
/*
checkBox("StoveYes", "Yes");
checkBox("StoveNo", "No");
*/
echo '<p>Do you need DHS provider services? </p>';
echo '<div>';
checkBox("StateEmergencyRelease", "State Emergency Release");
checkBox("FoodStampAssistance", "Food Stamp Assistance");
checkBox("LimitedHealthServicesReferral", "Limited Health Services Referral");
checkBox("ChildcareServices", "Childcare Services");
echo '</div>';
echo '<p>Are you at threat of utility shutoffs? </p>';
echo '<div>';
checkBox("HeatShutoff", "Heat");
checkBox("LightShutoff", "Light");
checkBox("WaterShutoff", "Water");
textInput("OtherShutoff", "Other");
echo '</div>';
echo '<p>Are you at threat of housing displacement?</p>';
echo '<div>';
checkBox("TaxesDifficulty", "Difficulty Paying Taxes");
checkBox("ForeclosureNotice", "Foreclosure Notice");
checkBox("LandlordEviction", "Landlord Eviction");
textInput("OtherHousingIssue", "Other");
echo '</div>';
textInput("AdditionalServices", "Are there any additional services you need?");
echo '<div class="fieldWrapper" id="divOtherNotes"><label for="OtherNotes">Other/Notes: </label><textarea id="OtherNotes" name="OtherNotes" rows="3" cols="50">' .$row["OtherNotes"]. '</textarea></div>';
dateInput("EnrollmentDate", "Enrollment Date");
echo '<h3>Christmas Coat Orders:</h3>';
checkBox("CoatOrder", "Coat Ordered");
echo 'Have you participated in previous Christmas food distributions in Brightmoor? ';
checkBox("PreviousChristmasFoodYes", "Yes");
checkBox("PreviousChristmasFoodNo", "No");
dateInput("CoatOrderDate", "Coat Order Date");
if ($row["ClientID"]!=""){
echo'<input type="submit" value="Update Client Information"/></form>';
} else{
echo '<input type="submit" value="Enter new client"/></form>';
}
?>
</div><!--end form style -->
<!--family member form -->
<div class="formStyle">
<?php
echo '<h3>Family Information</h3>';
if ($row["ClientID"]!=""){
echo '<div class="overflow-x">';
/*$familyMembersSql = "SELECT FamilyMembers.*, Clients.ClientID FROM FamilyMembers INNER JOIN Clients ON FamilyMembers.ClientID=Clients.ClientID WHERE FamilyMembers.ClientID='$row[ClientID]' ORDER BY FamilyMembers.Age DESC, FamilyMembers.FamilyMemberName ASC";
$familyMembersResult = $conn->query($familyMembersSql);*/
$familyMembersStmt = $conn->prepare("SELECT FamilyMembers.*, Clients.ClientID FROM FamilyMembers INNER JOIN Clients ON FamilyMembers.ClientID=Clients.ClientID WHERE FamilyMembers.ClientID=? ORDER BY FamilyMembers.Age DESC, FamilyMembers.FamilyMemberName ASC");
$familyMembersStmt->bind_param('s', $row['ClientID']);
$familyMembersStmt->execute();
$familyMembersResult = $familyMembersStmt->get_result();
echo '
<table border="1">
<tr>
<th>Name</th>
<th>Relationship</th>
<th>Age</th>
<th>Gender</th>
<th></th>
</tr>';
if ($familyMembersResult->num_rows > 0) {
while($familyMembersRow = $familyMembersResult->fetch_assoc()) {
//output existing family member info
echo '
<form action="UpdateFamilyMember.php" method="post">
<input type="hidden" name="FamilyMemberID" value="'.$familyMembersRow["FamilyMemberID"].'" />
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />
<tr>
<td><label for="FamilyMemberName'.$familyMembersRow["FamilyMemberID"].'"></label><input type="text" id="FamilyMemberName'.$familyMembersRow["FamilyMemberID"].'" name="FamilyMemberName" value="' .$familyMembersRow["FamilyMemberName"].'"/></td>
<td><label for="Relationship'.$familyMembersRow["FamilyMemberID"].'"></label><input type="text" id="Relationship'.$familyMembersRow["FamilyMemberID"].'" name="Relationship" value="'.$familyMembersRow["Relationship"].'"/></td>
<td><label for="FamilyMemberAge'.$familyMembersRow["FamilyMemberID"].'"></label><input type="number" id="FamilyMemberAge'.$familyMembersRow["FamilyMemberID"].'" class="rightLeftMargin" name="FamilyMemberAge" value="' .$familyMembersRow["Age"]. '" min="0" max="120"></td>
<td><label for="FamilyMemberGender'.$familyMembersRow["FamilyMemberID"].'"></label><select id="FamilyMemberGender'.$familyMembersRow["FamilyMemberID"].'" name="FamilyMemberGender">
<option value="' .$familyMembersRow["Gender"]. '">' .$familyMembersRow["Gender"]. '</option>
<option value="F">F</option>
<option value="M">M</option>
</select></td>
<td class="whiteSpaceNoWrap"><div class="displayInlineBlock"><input type="submit" name="Update" value="Update Record" /></div>
<div class="displayInlineBlock"><input type="submit" name="Delete" value="Delete Record" onClick="return confirm(\'Are you sure you want to delete this family member record?\');" /></div></td>
</tr>
</form>
';
}
}
if (!isset($_POST['autofocus']))
{
//If not isset -> set with dummy value
$_POST['autofocus'] = "undefined";
}
echo '<form action="InsertFamilyMember.php" method="post">
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />
<tr>
<td><label for="FamilyMemberName"></label><input type="text" id="FamilyMemberName" name="FamilyMemberName" '.$_POST["autofocus"].'/></td>
<td><label for="Relationship"></label><input type="text" id="Relationship" name="Relationship"/></td>
<td><label for="FamilyMemberAge"></label><input type="number" class="rightLeftMargin" id="FamilyMemberAge" name="FamilyMemberAge" min="0" max="120"></td>
<td><label for="FamilyMemberGender"></label><select id="FamilyMemberGender" name="FamilyMemberGender">
<option value=""></option>
<option value="F">F</option>
<option value="M">M</option>
</select></td>
<td><input type="submit" value="Enter new family member"/></td>
</tr>
</form>
</table>
</div>
';
} else {
echo 'Save new client before entering family information.';
}
?>
</div><!--end form style -->
<!--referrals form -->
<div class="formStyle">
<?php
echo '<h3>Referral Information</h3>';
if ($row["ClientID"]!=""){
echo '<div class="overflow-x">';
/*
$referralsSql = "SELECT Referrals.*, Clients.ClientID FROM Referrals INNER JOIN Clients ON Referrals.ClientID=Clients.ClientID WHERE Referrals.ClientID='$row[ClientID]' ORDER BY Referrals.ReferralDate ASC";
$referralsResult = $conn->query($referralsSql);*/
$referralsStmt = $conn->prepare("SELECT Referrals.*, Clients.ClientID FROM Referrals INNER JOIN Clients ON Referrals.ClientID=Clients.ClientID WHERE Referrals.ClientID=? ORDER BY Referrals.ReferralDate ASC");
$referralsStmt->bind_param('s', $row['ClientID']);
$referralsStmt->execute();
$referralsResult = $referralsStmt->get_result();
echo '
<table border="1">
<tr>
<th>Referral Type</th>
<th>Referral Date</th>
<th>Notes</th>
<th></th>
</tr>';
if ($referralsResult->num_rows > 0) {
while($referralsRow = $referralsResult->fetch_assoc()) {
echo '
<form action="UpdateReferral.php" method="post">
<input type="hidden" name="ReferralID" value="'.$referralsRow["ReferralID"].'" />
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />
<tr>';
//display referral type in drop down menu
echo '<td>';
echo '<select name="ReferralType">';
$referralTypeSql = "SELECT ReferralType FROM ReferralType;";
$referralTypeResult = $conn->query($referralTypeSql);
if ($referralTypeResult->num_rows > 0) {
// output data of each row
while($referralTypeRow = $referralTypeResult->fetch_assoc()) {
if ($referralTypeRow["ReferralType"]==$referralsRow["ReferralType"]){
$selected = "selected";
}else{
$selected = "";
}
echo '<option value="'. $referralTypeRow['ReferralType'] .'" '.$selected.'>'. $referralTypeRow['ReferralType'] .'</option>';
}
} else {
echo "0 results";
}
echo '</select></td>';
//end referral type drop down menu
//date picker for existing referral dates
echo '<script>
$(function() {
$( "#ReferralDate'.$referralsRow["ReferralID"].'" ).datepicker({dateFormat: "mm/dd/y"});
});
</script>';
//display formatted referral date
if ($referralsRow["ReferralDate"]!=NULL){
$referralDisplayDate = date("m/d/y", strtotime($referralsRow["ReferralDate"]));
}
echo '
<td class="center"><input type="text" id="ReferralDate'.$referralsRow["ReferralID"].'" name="ReferralDate" class="dateTextLength" value="'.$referralDisplayDate.'"/></td>
<td><input type="text" id="ReferralNotes" name="ReferralNotes" value="' .$referralsRow["ReferralNotes"]. '"></td>
<td class="whiteSpaceNoWrap"><div class="displayInlineBlock"><input type="submit" name="Update" value="Update Record"/></div>
<div class="displayInlineBlock"><input type="submit" name="Delete" value="Delete Record" onClick="return confirm(\'Are you sure you want to delete this referral record?\');"/></div></td>
</tr>
</form>
';
}
}
echo '<form action="InsertReferral.php" name="InsertReferral" method="post" onsubmit="return validateReferral()">
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />
<tr>';
//display referral type in drop down menu
echo '<td>';
echo '<select name="ReferralType">
<option value=""> </option>';
$referralTypeSql = "SELECT ReferralType FROM ReferralType;";
$referralTypeResult = $conn->query($referralTypeSql);
if ($referralTypeResult->num_rows > 0) {
// output data of each row
while($referralTypeRow = $referralTypeResult->fetch_assoc()) {
echo '<option value="'. $referralTypeRow['ReferralType'] .'">'. $referralTypeRow['ReferralType'] .'</option>';
}
} else {
echo "0 results";
}
echo '</select></td>';
//end referral type drop down menu
echo '
<td class="center"><input type="text" id="ReferralDate" name="ReferralDate" class="dateTextLength"/></td>
<td><input type="text" id="ReferralNotes" name="ReferralNotes"/></td>
<td><input type="submit" value="Enter new referral"/></td>
</tr>
</table>
</form>
</div>
';
} else {
echo 'Save new client before entering referral information.';
}
?>
</div><!--end form style -->
<!--appointments form -->
<div class="formStyle">
<?php
echo '<h3>Appointment Information</h3>';
if ($row["ClientID"]!=""){
echo '<div class="overflow-x">';
/*$appointmentsSql = "SELECT Appointments.*, Clients.ClientID FROM Appointments INNER JOIN Clients ON Appointments.ClientID=Clients.ClientID WHERE Appointments.ClientID='$row[ClientID]' ORDER BY Appointments.AppointmentDate ASC";
$appointmentsResult = $conn->query($appointmentsSql);*/
$appointmentsStmt = $conn->prepare("SELECT Appointments.*, Clients.ClientID FROM Appointments INNER JOIN Clients ON Appointments.ClientID=Clients.ClientID WHERE Appointments.ClientID=? ORDER BY Appointments.AppointmentDate ASC");
$appointmentsStmt->bind_param('s', $row['ClientID']);
$appointmentsStmt->execute();
$appointmentsResult = $appointmentsStmt->get_result();
echo '
<table border="1">
<tr>
<th>Appointment Date</th>
<th>Appointment Status</th>
<th>Notes</th>
<th></th>
</tr>';
if ($appointmentsResult->num_rows > 0) {
while($appointmentsRow = $appointmentsResult->fetch_assoc()) {
echo '
<form action="UpdateAppointment.php" method="post">
<input type="hidden" name="AppointmentID" value="'.$appointmentsRow['AppointmentID'].'" />
<input type="hidden" name="ClientID" value="' .$row['ClientID']. '" />
<tr>';
//date picker for existing appointment dates
echo '<script>
$(function() {
$( "#AppointmentDate'.$appointmentsRow["AppointmentID"].'" ).datepicker({dateFormat: "mm/dd/y"});
});
</script>';
//display appointment date
if ($appointmentsRow["AppointmentDate"]!=NULL){
$appointmentDisplayDate = date("m/d/y", strtotime($appointmentsRow["AppointmentDate"]));
} else {
$appointmentDisplayDate = NULL;
}
echo '<td class="center"><input type="text" id="AppointmentDate'.$appointmentsRow["AppointmentID"].'" name="AppointmentDate" class="dateTextLength" value="'.$appointmentDisplayDate.'"/></td>';
//end display existing appointment date
//display appointment status in drop down menu
echo '<td>';
echo '<select name="AppointmentStatus">';
$apptStatusSql = "SELECT AppointmentStatus FROM AppointmentStatus;";
$apptStatusResult = $conn->query($apptStatusSql);
if ($apptStatusResult->num_rows > 0) {
// output data of each row
while($apptStatusRow = $apptStatusResult->fetch_assoc()) {
if ($apptStatusRow['AppointmentStatus']==$appointmentsRow['AppointmentStatus']){
$selected = "selected";
}else{
$selected = "";
}
echo '<option value="'. $apptStatusRow['AppointmentStatus'] .'" '.$selected.'>'. $apptStatusRow['AppointmentStatus'] .'</option>';
}
} else {
echo "0 results";
}
echo '</select></td>';
//end appointment status drop down menu
echo '
<td><input type="text" id="AppointmentNotes" name="AppointmentNotes" value="' .$appointmentsRow['AppointmentNotes']. '"></td>
<td class="whiteSpaceNoWrap"><div class="displayInlineBlock"><input type="submit" name="Update" value="Update Appointment"/></div>
<div class="displayInlineBlock"><input type="submit" name="Delete" value="Delete Appointment" onClick="return confirm(\'Are you sure you want to delete this appointment record?\');"/></div></td>
</tr>
</form>
';
}
}
echo '<form action="InsertAppointment.php" method="post" name="InsertAppointment" onsubmit="return validateDate()">
<input type="hidden" name="ClientID" value="' .$row["ClientID"]. '" />
<tr>
<td class="center"><input type="text" class="dateTextLength" id="AppointmentDate" name="NewAppointmentPicker"/></td>';
//display appointment status in drop down menu
echo '<td>';
echo '<select name="AppointmentStatus">';
$apptStatusSql = "SELECT AppointmentStatus FROM AppointmentStatus;";
$apptStatusResult = $conn->query($apptStatusSql);
if ($apptStatusResult->num_rows > 0) {
// output data of each row
while($apptStatusRow = $apptStatusResult->fetch_assoc()) {
echo '<option value="'. $apptStatusRow['AppointmentStatus'] .'">'. $apptStatusRow['AppointmentStatus'] .'</option>';
}
} else {
echo "0 results";
}
echo '</select></td>';
//end appointment status drop down menu
echo'
<td><input type="text" id="AppointmentNotes" name="AppointmentNotes"/></td>
<td><input type="submit" value="Enter new appointment"/></td>
</tr>
</table>
</form>
</div>
';
} else {
echo 'Save new client before entering appointment information.';
}
?>
</div><!--end form style -->
<?php
$conn->close();
?>
</section>
</body>
</html>