AppML Case Study - Customers
The HTML Page
This is the HTML source:
<!DOCTYPE html>
<html>
<head>
<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>Customers</h1>
<div class="subhodaya-container subhodaya-light-grey subhodaya-padding-jumbo subhodaya-margin-bottom" appml-data="appml.php?model=model_customersform" appml-controller="myFormController" id="Form01" style="display:none;">
<div appml-include-html="inc_formcommands.htm"></div>
<p>
<label>CustomerName:</label>
<input id="customername" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>ContactName:</label>
<input id="contactname" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Address:</label>
<input id="address" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>City:</label>
<input id="city" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>PostalCode:</label>
<input id="postalcode" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Country:</label>
<input id="country" class="subhodaya-input subhodaya-border">
</p>
</div>
<div appml-data="appml.php?model=model_customerslist">
<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>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer;width:40px;" onclick="appml('Form01').run({{CustomerID}});">✎</td>
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</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>
<head>
<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>Customers</h1>
<div class="subhodaya-container subhodaya-light-grey subhodaya-padding-jumbo subhodaya-margin-bottom" appml-data="appml.php?model=model_customersform" appml-controller="myFormController" id="Form01" style="display:none;">
<div appml-include-html="inc_formcommands.htm"></div>
<p>
<label>CustomerName:</label>
<input id="customername" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>ContactName:</label>
<input id="contactname" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Address:</label>
<input id="address" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>City:</label>
<input id="city" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>PostalCode:</label>
<input id="postalcode" class="subhodaya-input subhodaya-border">
</p>
<p>
<label>Country:</label>
<input id="country" class="subhodaya-input subhodaya-border">
</p>
</div>
<div appml-data="appml.php?model=model_customerslist">
<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>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer;width:40px;" onclick="appml('Form01').run({{CustomerID}});">✎</td>
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</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
{
"rowsperpage" : 10,
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"
},
"filteritems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
],
"sortitems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
]
}
"rowsperpage" : 10,
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"
},
"filteritems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
],
"sortitems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
]
}
Form Model
{
"database" : {
"connection" : "localmysql",
"maintable" : "Customers",
"keyfield" : "CustomerID",
"sql" : "SELECT * FROM Customers"
},
"updateItems" : [
{"item" : "CustomerName"},
{"item" : "Address"},
{"item" : "PostalCode"},
{"item" : "City"},
{"item" : "Country"}
]
}
"database" : {
"connection" : "localmysql",
"maintable" : "Customers",
"keyfield" : "CustomerID",
"sql" : "SELECT * FROM Customers"
},
"updateItems" : [
{"item" : "CustomerName"},
{"item" : "Address"},
{"item" : "PostalCode"},
{"item" : "City"},
{"item" : "Country"}
]
}