Default security requests to bog
[hcoop/portal.git] / money.mlt
index 4654b06..dbad9a9 100644 (file)
--- a/money.mlt
+++ b/money.mlt
@@ -339,6 +339,27 @@ end %></textarea></td> </tr>
 </table>
 </form>
 
+<% elseif $"cmd" = "dues" then
+       Group.requireGroupName "money";
+       showNormal := false %>
+
+<h3>Monthly dues</h3>
+
+<form action="money" method="post">
+<input type="hidden" name="cmd" value="dues2">
+<table class="blanks">
+<tr> <td>Description:</td> <td><input name="descr" value="Dues"></td> </tr>
+<tr> <td>Date:</td> <td><input name="d"></td> </tr>
+<tr> <td>Amount/pledge:</td> <td><input name="base"></td> </tr>
+<tr> <td><input type="submit" value="Add"></td> </tr>
+</table>
+
+<% elseif $"cmd" = "dues2" then
+       Group.requireGroupName "money";
+       Money.billDues {descr = $"descr", base = Web.stor ($"base"), date = $"d"};
+
+       %><h3>Dues debits added.</h3>
+
 <% elseif $"cmd" = "even" then
        Group.requireGroupName "money";
        val id = Money.addTransaction ($"descr", Web.stor ($"amount"), $"d");
@@ -556,7 +577,8 @@ elseif $"cmd" = "freezeworthy" then
 <table>
 <tr> <th>Member</th> <th>Balance</th> </tr>
 <% foreach dq in dqs do %>
-<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td> </tr>
+<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
+<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
 <% end %>
 </table>
 
@@ -566,7 +588,8 @@ elseif $"cmd" = "freezeworthy" then
 <table>
 <tr> <th>Member</th> <th>Balance</th> </tr>
 <% foreach dq in dqs do %>
-<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td> </tr>
+<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
+<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
 <% end %>
 </table>
 
@@ -575,9 +598,10 @@ elseif $"cmd" = "freezeworthy" then
 <% if showNormal then
    val you = Init.getUser();
    val bal = Balance.lookupBalance (#bal you);
-   val deposit = Balance.depositAmount (#id bal) %>
+   val deposit = Balance.depositAmount (#id bal);
+   val showBal = Util.sub (#amount bal, deposit) %>
 
-<h3>Your balance: $<% Util.sub (#amount bal, deposit) %><br>
+<h3>Your balance: $<% showBal %><br>
 Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)<br>
 Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %></h3>
 
@@ -601,6 +625,8 @@ Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToI
 <br><b><u>New transaction:</u></b><br>
 <a href="money?cmd=bill">Bill for the co-op</a><br>
 <a href="money?cmd=pay">Payment from member</a><br>
+<a href="money?cmd=dues">Monthly dues</a><br>
+<a href="money?cmd=hosting">New hosting bill (old style)</a><br>
 <a href="money?cmd=evenForm">Generic/even</a><br>
 <br>
 <a href="money?cmd=equalize">Equalize balances</a><br>
@@ -637,22 +663,34 @@ end %>
 
 <% else %>
 <a href="?audit=1">Switch to audit view</a><br>
-<% val lookback = case $"lookback" of "" => 20 | lb => Web.stoi lb;
+<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb;
    @payment [] %>
 
 <h3>Your recent account activity</h3>
 
 <form>
-      Show <input name="lookback" size="5" value="<% lookback %>"> most recent transactions.
+      Show <input name="lookback" size="5" value="<% iff lookback = 0 then 20 else lookback %>"> most recent transactions.
       <input type="submit" value="Show">
 </form>
 
+<% ref running = showBal;
+val trans = iff lookback = 0 then
+        Money.listUserTransactions (Init.getUserId ())
+    else
+       Money.listUserTransactionsLimit (Init.getUserId (), lookback) %>
 <table>
-<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> </tr>
-<% foreach (amount, trn) in Money.listUserTransactionsLimit (Init.getUserId (), lookback) do %>
-<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
-<% end %>
+<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Debit</b></td> <td><b>Credit</b></td> <td><b>Balance</b></td></tr>
+<% foreach (amount, trn) in trans do %>
+<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td>
+<td align="right"><% if Util.lt (amount, 0.0) then %><% amount %><% end %></td>
+<td align="right"><% if Util.ge (amount, 0.0) then %><% amount %><% end %></td>
+<td><% running %></tr>
+<% running := Util.sub (running, amount)
+end %>
 </table>
+<% if lookback <> 0 then %>
+<a href="?lookback=inf">Show all transactions</a><br>
+<% end %>
 
 <% end
 end %>