if $"cmd" = "Create" then
if not (Balance.validBalanceName ($"name")) then %>
- <h3><b>Invalid balance name</b></h3>
+ <h3>Invalid balance name</h3>
<% else switch Balance.balanceNameToId ($"name") of
SOME _ => %>
- <h3><b>Balance name already in use</b></h3>
+ <h3>Balance name already in use</h3>
<% | NONE =>
val id = Balance.addBalance ($"name") %>
- <h3><b>Balance added</b></h3>
+ <h3>Balance added</h3>
<% end
end
elseif $"mod" <> "" then
showNormal := false;
val balance = Balance.lookupBalance (Web.stoi ($"mod")) %>
-<h3><b>Modify balance record</b></h3>
+<h3>Modify balance record</h3>
-<form action="balances">
+<form action="balances" method="post">
<input type="hidden" name="id" value="<% $"mod" %>">
-<table>
-<tr> <td align="right"><b>Name</b>:</td> <td><input name="name" value="<% #name balance %>"></td> </tr>
+<table class="blanks">
+<tr> <td>Name:</td> <td><input name="name" value="<% #name balance %>"></td> </tr>
<tr> <td><input type="submit" name="cmd" value="Save"></td> </tr>
</table>
</form>
<% elseif $"cmd" = "Save" then
val balance = Balance.lookupBalance (Web.stoi ($"id"));
Balance.modBalance {balance with name = $"name"} %>
- <h3><b>Balance record saved.</b></h3>
+ <h3>Balance record saved.</h3>
<% elseif $"del" <> "" then
showNormal := false;
val balance = Balance.lookupBalance (Web.stoi ($"del")) %>
- <h3><b>Are you sure you want to delete balance <% #name balance %></a>?</b></h3>
+ <h3>Are you sure you want to delete balance <% #name balance %></a>?</h3>
<a href="balances?del2=<% $"del" %>">Yes, delete <% #name balance %>!</a>
<% elseif $"del2" <> "" then
val balance = Balance.lookupBalance (Web.stoi ($"del2"));
Balance.deleteBalance (Web.stoi ($"del2")) %>
- <h3><b><% #name balance %> deleted!</b></h3>
+ <h3><% #name balance %> deleted!</h3>
<% end %>
-<% if showNormal then %>
-<h3><b>New balance</b></h3>
+<% if showNormal then
+ ref total = 0.0 %>
+<h3>New balance</h3>
-<form action="balances">
-<table>
-<tr> <td align="right"><b>Name</b>:</td> <td><input name="name"></td> </tr>
+<form action="balances" method="post">
+<table class="blanks">
+<tr> <td>Name:</td> <td><input name="name"></td> </tr>
<tr> <td><input type="submit" name="cmd" value="Create"></td> </tr>
</table>
</form>
-<h3><b>Manage current balances</b></h3>
+<h3>Manage current balances</h3>
<table>
-<% foreach balance in Balance.listBalances () do %>
+<% foreach balance in Balance.listBalances () do
+ total := Util.add (total, #amount balance) %>
<tr> <td><% Web.html (#name balance) %></td> <td><% #amount balance %></td> <td><a href="balances?mod=<% #id balance %>">[Modify]</a> <a href="balances?del=<% #id balance %>">[Delete]</a></td> </tr>
<% end %>
</table>
+<br><b>Total</b>: $<% total %>
+
<% end %>
<% @footer [] %>