AppML Case Study - Employees
The HTML Page
This is the HTML source:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Employees</title>
<link rel="stylesheet" href="http://tutorials/lib/subhodaya.css">
<script src="http://tutorials/appml/2.0.3/appml.js"></script>
</head>
<body>
<div class="subhodaya-container subhodaya-content">
<h1>Employees</h1>
<div id="Form01" class="subhodaya-container subhodaya-light-grey subhodaya-padding-jumbo subhodaya-margin-bottom" appml-data="appml.php?model=model_employeesform" appml-controller="myFormController" style="display:none;">
<div appml-include-html="inc_formcommands.htm"></div>
<p>
<label>Last Name:</label>
<input id="LastName" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>First Name:</label>
<input id="FirstName" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Date of Birth:</label>
<input id="BirthDate" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Photo:</label>
<input id="Photo" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Notes:</label>
<input id="Notes" class="subhodaya-input subhodaya-border">
</p>
</div>
<div appml-data="appml.php?model=model_employeeslist">
<div appml-include-html="inc_listcommands.htm"></div>
<div appml-include-html="inc_filter.htm"></div>
<table class="subhodaya-table-all">
<tr>
<th></th>
<th>Last Name</th>
<th>First Name</th>
<th>Date of Birth</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer" onclick="appml('Form01').run({{EmployeeID}})">✎</td>
<td>{{LastName}}</td>
<td>{{FirstName}}</td>
<td>{{BirthDate}}</td>
</tr>
</table>
</div>
</div>
<script>
function myFormController($appml) {
if ($appml.message == "ready") {return -1;}
if ($appml.message == "loaded") {
document.getElementById("Form01").style.display = "";
}
}
</script>
</body>
</html>
PHP »
.NET »
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Employees</title>
<link rel="stylesheet" href="http://tutorials/lib/subhodaya.css">
<script src="http://tutorials/appml/2.0.3/appml.js"></script>
</head>
<body>
<div class="subhodaya-container subhodaya-content">
<h1>Employees</h1>
<div id="Form01" class="subhodaya-container subhodaya-light-grey subhodaya-padding-jumbo subhodaya-margin-bottom" appml-data="appml.php?model=model_employeesform" appml-controller="myFormController" style="display:none;">
<div appml-include-html="inc_formcommands.htm"></div>
<p>
<label>Last Name:</label>
<input id="LastName" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>First Name:</label>
<input id="FirstName" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Date of Birth:</label>
<input id="BirthDate" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Photo:</label>
<input id="Photo" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Notes:</label>
<input id="Notes" class="subhodaya-input subhodaya-border">
</p>
</div>
<div appml-data="appml.php?model=model_employeeslist">
<div appml-include-html="inc_listcommands.htm"></div>
<div appml-include-html="inc_filter.htm"></div>
<table class="subhodaya-table-all">
<tr>
<th></th>
<th>Last Name</th>
<th>First Name</th>
<th>Date of Birth</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer" onclick="appml('Form01').run({{EmployeeID}})">✎</td>
<td>{{LastName}}</td>
<td>{{FirstName}}</td>
<td>{{BirthDate}}</td>
</tr>
</table>
</div>
</div>
<script>
function myFormController($appml) {
if ($appml.message == "ready") {return -1;}
if ($appml.message == "loaded") {
document.getElementById("Form01").style.display = "";
}
}
</script>
</body>
</html>
Models
These are the models used in the application:
List Model
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Employees",
"orderby" : "LastName"
},
"filteritems" : [
{"item" : "LastName"},
{"item" : "FirstName"}
],
"sortitems" : [
{"item" : "LastName"},
{"item" : "FirstName"}
]
}
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Employees",
"orderby" : "LastName"
},
"filteritems" : [
{"item" : "LastName"},
{"item" : "FirstName"}
],
"sortitems" : [
{"item" : "LastName"},
{"item" : "FirstName"}
]
}
Form Model
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Employees",
"maintable" : "Employees",
"keyfield" : "EmployeeID"
},
"updateItems" : [
{"item" : "LastName"},
{"item" : "FirstName"},
{"item" : "BirthDate"},
{"item" : "Photo"},
{"item" : "Notes"}
]
}
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Employees",
"maintable" : "Employees",
"keyfield" : "EmployeeID"
},
"updateItems" : [
{"item" : "LastName"},
{"item" : "FirstName"},
{"item" : "BirthDate"},
{"item" : "Photo"},
{"item" : "Notes"}
]
}