-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent_family.php
109 lines (101 loc) · 3.96 KB
/
student_family.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
<?php
include('includes/formValidation.php');
include($classpath . 'StudentDAO.php');
$userDAO = new UserDAO($DB_server, $DB_user, $DB_pass, $DB_conn);
$isAdmin = $userDAO->isSuperAdmin($_COOKIE["uid"]);
$studentDAO = new StudentDAO($DB_server, $DB_user, $DB_pass, $DB_conn, $_COOKIE["uid"], $isAdmin);
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$birthDate = digitMasker($dob_mo) . '-' . digitMasker($dob_day) . '-' . $dob_yr;
$errMsg = addStudentValidate($firstName, $lastName, $beltSize, $birthDate);
if(strlen($errMsg) == 0){
$birthDate = $dob_yr . '-' . digitMasker($dob_mo) . '-' . digitMasker($dob_day);
$studentExists = $studentDAO->getStudents($schoolID, 0, $firstName, $lastName, 2, '', '', '', '', 0, $birthDate);
if(mysqli_num_rows($studentExists) > 0){
$isUpdated = false;
$errMsg = "Student with the name [$firstName $lastName] already exists...";
}else{
$isUpdated = $studentDAO->insertStudent($firstName, $lastName, $rankID, $beltSize, $schoolID, $birthDate, $isActive);
if(!$isUpdated){
$errMsg = "An error has occurred while trying to add [$firstName $lastName]";
}
}
}
}
if (!$isUpdated){
$schoolListRS = $studentDAO->getSchoolList($_COOKIE["uid"]);
$rankListRS = $studentDAO->getRankList();
}
?>
<form name="studentAdd" action="index.php?action=stu.add" method="POST">
<table align="left" bgcolor="White" width="100%">
<tr>
<th class="title" colspan="2">Add A New Family</th>
</tr>
<tr><td> </td></tr>
<?php
if(isset($isUpdated) && $isUpdated == true){
?>
<tr><td align="center" colspan="2">Family has been <b>successfully</b> added!</td></tr>
<tr><td> </td></tr>
<tr><td align="center"><a href="index.php?action=stu.add">Add Another</a> <a href="index.php?action=stu">Goto Top Menu</a></td></tr>
<?php
}else{
?>
<tr><td align="center" colspan="2" class="error"><?= $errMsg ?></td></tr>
<tr><td> </td></tr>
<tr>
<td align="right" width="15%">Family Display Name: </td>
<td align="left" width="85%"><input name="firstName" type="text" value="<?= $firstName ?>"></td>
</tr>
<tr>
<td align="right" width="15%">School: </td>
<td align="left" width="85%">
<select name="schoolID">
<?php
if($schoolListRS != false){
while($row = mysqli_fetch_assoc($schoolListRS)){
?>
<option value="<?= $row['id'] ?>" <?php if($schoolID == $row['id']){echo 'SELECTED';} ?>><?= $row['location_code'] ?></option>
<?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td align="right" width="15%">Rank: </td>
<td align="left" width="85%">
<select name="rankID">
<?php
if($rankListRS != false){
while($row = mysqli_fetch_assoc($rankListRS)){
?>
<option value="<?= $row['id'] ?>" <?php if($rankID == $row['id']){echo 'SELECTED';} ?>><?= $row['rank_name'] ?></option>
<?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td align="right" width="15%">Status: </td>
<td align="left" width="85%">
<select name="isActive">
<option value="1" SELECTED>Active</option>
<option value="0">Inactive</option>
</select>
</td>
</tr>
<tr>
<td align="right" width="15%">Belt Size: </td>
<td align="left" width="85%"><input name="beltSize" type="text" value="<?= $beltSize ?>" size="3"></td>
</tr>
<tr><td> </td></tr>
<tr><td> </td><td><input name="addButton" type="submit" value="Add Student"> <input name="cancelButton" type="reset" value="Reset"></td></tr>
<?php
}
?>
</table>
</form>