-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.php
More file actions
111 lines (93 loc) · 2.76 KB
/
class.php
File metadata and controls
111 lines (93 loc) · 2.76 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
<?
include('Controls/header.php');
include_once('BusinessLogic/classLogic.php');
include_once('Controls/DataGrid.php');
include_once('Controls/Lookup.php');
$classID = $_GET["ID"];
$currentClass = ClassLogic::GetClass($classID);
print("<h1>Class: {$currentClass->ClassName}</h1>");
print("<b>ClassID: </b>{$currentClass->ClassID}<br />");
print("<b>Start Date: </b>{$currentClass->StartDate}<br />");
print("<b>End Date: </b>{$currentClass->EndDate}<br />");
// handle action buttons
if (isset($_POST['action']) && $_POST['action'] == "Add")
{
ClassLogic::EnrollInClass(
$classID,
$_POST['customerID']);
}
else if (isset($_POST['action']) && $_POST['action'] == "Delete")
{
ClassLogic::DeleteEnrollment($_POST['deleteID']);
}
?>
<script>
function validate(classID, customerID)
{
if (classID == "" || customerID == "")
{
alert("Please enter all fields.");
return false;
}
return true;
}
function validateForm()
{
var classID = $("#classID").val();
var customerID = $("#customerID").val();
return validate(classID, customerID);
}
function validateEdit(row)
{
var classID = $(row).find("input[name=ClassID]").val();
var customerID = $(row).find("input[name=CustomerID]").val();
return validate(classID, customerID);
}
function storeEdit(row)
{
// store values in the form
$("#classID").val( $(row).find("input[name=ClassID]").val() );
$("#customerID").val( $(row).find("input[name=CustomerID]").val() );
}
</script>
<form id="enrollmentForm" method="post">
<input type="hidden" id="deleteID" name="deleteID" />
<input type="hidden" id="editID" name="editID" />
<input type="hidden" id="action" name="action" />
<fieldset>
<legend>Enroll in Class</legend>
<table>
<tr>
<td>
<select id="customerID" name="customerID">
<?
$lookup = new Lookup("Customer", "CustomerID", "CONCAT(FirstName, ' ', LastName)");
$lookup->Render();
?>
</select>
<br />
<label for="customerID">Customer</label>
</td>
<td><input type="button" onclick="setAdd('enrollmentForm',validateForm);" value="Add"></td>
</tr>
</table>
</fieldset>
</form>
<?
// setup datagrid
$classGrid = new DataGrid();
$classGrid->DataSource = ClassLogic::GetClassRoster($classID);
$classGrid->DataSourceClassName = "ClassEnrollment";
$classGrid->IDPropertyName = "ClassEnrollmentID";
$classGrid->FormID = "enrollmentForm";
$classGrid->ValidateEditCallback = "validateEdit";
$classGrid->StoreEditCallback = "storeEdit";
// setup data columns
$idCol = $classGrid->AddColumn("ClassEnrollmentID", DataColumnType::NumberColumn, "ClassEnrollmentID");
$idCol->ReadOnly = true;
$classGrid->AddColumn("Customer", DataColumnType::StringColumn, "Name");
// draw!
$classGrid->ShowEdit = false;
$classGrid->Render();
include('Controls/footer.php');
?>