join: update library paths, install to new location
[hcoop/portal.git] / money.mlt
CommitLineData
208e2cbc
AC
1<% @header [("title", ["MoneyMatters"])];
2
d5f8418b
AC
3val root = Group.inGroupNum 0;
4
208e2cbc
AC
5ref showNormal = true;
6
d1d096bb
AC
7if $"hist" <> "" then
8 showNormal := false;
9 val id = Web.stoi ($"hist") %>
10<table>
11<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> </tr>
12<% foreach (amount, trn) in Money.listUserTransactions id do %>
13<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
14<% end %>
15</table>
16
17<% elseif $"cmd" = "list" then
9bda1e7f 18 val admin = Group.inGroupName "money";
208e2cbc
AC
19 showNormal := false %>
20
b6dd1aaf 21<h3>Transactions</h3>
208e2cbc
AC
22
23<table>
24<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Last modified</b></td> <td><b>Participants</b></td> </tr>
25<% foreach trn in Money.listTransactions () do %>
26<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td> <td><% #stamp trn %></td>
27<% switch Money.listChargesWithNames (#id trn) of
9bda1e7f
AC
28 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
29 | _ => %><td><i>multi</i></td><%
30end;
31if admin then
104fbeb6
AC
32 %><td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
33 <td><a href="money?del=<% #id trn %>">[Delete]</a></td><%
34end
35%></tr><%
36end %>
37</table>
38
39<% elseif $"cmd" = "primary" then
40 val admin = Group.inGroupName "money";
41 showNormal := false %>
42
43<h3>Primary Transactions</h3>
44
45<table>
46<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Last modified</b></td> <td><b>Participants</b></td> </tr>
47<% foreach (amt, trn) in Money.listUserTransactions (valOf (Init.userNameToId "hcoop")) do %>
48<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td> <td><% #stamp trn %></td>
49<% switch Money.listChargesWithNames (#id trn) of
50 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
51 | _ => %><td><i>multi</i></td><%
52end;
53if admin then
54 %><td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
9bda1e7f 55 <td><a href="money?del=<% #id trn %>">[Delete]</a></td><%
208e2cbc 56end
9bda1e7f 57%></tr><%
208e2cbc
AC
58end %>
59</table>
60
61<% elseif $"cmd" = "bals" then
62 showNormal := false %>
63
8ffa2c9e 64<h3>Active Balances</h3>
208e2cbc
AC
65
66<table>
afc975d0 67<% foreach bal in Balance.listOwnedBalances () do %>
208e2cbc
AC
68<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
69<% switch Balance.listBalanceUsers (#id bal) of
70 [] =>
71 | (user :: users) =>
104fbeb6 72 %><a href="money?hist=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
208e2cbc 73 foreach user in users do
d1d096bb 74 %>, <a href="money?hist=<% # id user %>"><% Web.html (#name user) %></a><%
208e2cbc
AC
75 end
76end %></td> </tr>
77<% end %>
78</table>
79
8ffa2c9e
AC
80<% elseif $"cmd" = "deadbals" then
81 showNormal := false %>
82
83<h3>Retired Balances</h3>
84
85<table>
86<% foreach bal in Balance.listUnownedBalances () do %>
87<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
88<% switch Balance.listBalanceUsers (#id bal) of
89 [] =>
90 | (user :: users) =>
711471a2 91 %><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
8ffa2c9e 92 foreach user in users do
711471a2
AC
93 %>, <a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
94 end
95end %></td> </tr>
96<% end %>
97</table>
98
99<% elseif $"cmd" = "nbals" then
100 showNormal := false;
101 val bals = Balance.listNegativeOwnedBalances () %>
102
103<h3>Negative Active Balances (<% length bals %>)</h3>
104
105<table>
106<% foreach bal in bals do %>
107<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
108<% switch Balance.listBalanceUsers (#id bal) of
109 [] =>
110 | (user :: users) =>
111 %><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
112 foreach user in users do
113 %>, <a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
8ffa2c9e
AC
114 end
115end %></td> </tr>
116<% end %>
117</table>
118
208e2cbc
AC
119<% elseif $"cmd" = "hosting" then
120 Group.requireGroupName "money";
121 showNormal := false %>
122
b6dd1aaf 123<h3>New hosting bill</h3>
208e2cbc 124
a4ccdb5e 125<form action="money" method="post">
208e2cbc 126<input type="hidden" name="cmd" value="hosting2">
b6dd1aaf
AC
127<table class="blanks">
128<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
129<tr> <td>Date:</td> <td><input name="d"></td> </tr>
130<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
131<tr> <td>Free bandwidth cutoff (MB):</td> <td><input name="cutoff" value="200"></td> </tr>
132<tr> <td>Cost/GB:</td> <td><input name="cost" value="4"></td> </tr>
133<tr> <td>Member usage:</td> <td><textarea wrap="soft" name="usage" rows="24" cols="80"></textarea></td> </tr>
208e2cbc
AC
134<tr> <td><input type="submit" value="Add"></td> </tr>
135</table>
136
137<% elseif $"cmd" = "hosting2" then
f49e1088
AC
138 Group.requireGroupName "money";
139 val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d");
208e2cbc
AC
140 Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"};
141
b6dd1aaf 142 %><h3>Hosting transaction added.</h3>
208e2cbc 143
f49e1088
AC
144<% elseif $"modHosting" <> "" then
145 Group.requireGroupName "money";
146 showNormal := false;
147 val id = Web.stoi ($"modHosting");
148 val trn = Money.lookupTransaction id %>
149
b6dd1aaf 150<h3>Modify hosting bill</h3>
f49e1088 151
a4ccdb5e 152<form action="money" method="post">
f49e1088 153<input type="hidden" name="saveHosting" value="<% id %>">
b6dd1aaf
AC
154<table class="blanks">
155<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
156<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
157<tr> <td>Amount:</td> <td><input name="amount" value="<% Util.neg (#amount trn) %>"></td> </tr>
158<tr> <td>Free bandwidth cutoff (MB):</td> <td><input name="cutoff" value="200"></td> </tr>
159<tr> <td>Cost/GB:</td> <td><input name="cost" value="4"></td> </tr>
160<tr> <td>Member usage:</td> <td><textarea wrap="soft" name="usage" rows="24" cols="80"><%
e84acecc
AC
161switch Money.lookupHostingUsage id of
162 SOME s => s
163end %></textarea></td> </tr>
f49e1088
AC
164<tr> <td><input type="submit" value="Save"></td> </tr>
165</table>
166
167<% elseif $"saveHosting" <> "" then
168 Group.requireGroupName "money";
169 val id = Web.stoi ($"saveHosting");
170 val trn = Money.lookupTransaction id;
171
172 Money.clearCharges id;
173 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))};
174 Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"};
175
b6dd1aaf 176 %><h3>Hosting transaction modified.</h3>
f49e1088 177
104fbeb6
AC
178<% elseif $"cmd" = "bill" then
179 Group.requireGroupName "money";
180 showNormal := false %>
181
182<h3>New bill for the co-op</h3>
183
184<form action="money" method="post">
185<input type="hidden" name="cmd" value="bill2">
186<table class="blanks">
187<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
188<tr> <td>Date:</td> <td><input name="d"></td> </tr>
189<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
190<tr> <td><input type="submit" value="Add"></td> </tr>
191</table>
192
193<% elseif $"cmd" = "bill2" then
194 Group.requireGroupName "money";
195 val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d");
196 Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))};
197 Money.applyCharges id;
198
199 %><h3>Bill added.</h3>
200
201<% elseif $"modBill" <> "" then
202 Group.requireGroupName "money";
203 showNormal := false;
204 val id = Web.stoi ($"modBill");
205 val trn = Money.lookupTransaction id %>
206
207<h3>Modify bill</h3>
208
209<form action="money" method="post">
210<input type="hidden" name="saveBill" value="<% id %>">
211<table class="blanks">
212<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
213<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
214<tr> <td>Amount:</td> <td><input name="amount" value="<% Util.neg (#amount trn) %>"></td> </tr>
215<tr> <td><input type="submit" value="Save"></td> </tr>
216</table>
217
218<% elseif $"saveBill" <> "" then
219 Group.requireGroupName "money";
220 val id = Web.stoi ($"saveBill");
221 val trn = Money.lookupTransaction id;
222
223 Money.clearCharges id;
224 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))};
225 Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))};
226 Money.applyCharges id;
227
228 %><h3>Bill modified.</h3>
229
f49e1088
AC
230<% elseif $"cmd" = "evenForm" then
231 Group.requireGroupName "money";
232 showNormal := false %>
b6dd1aaf 233<h3>New generic/even transaction</h3>
a4ccdb5e 234<form action="money" method="post">
f49e1088 235<input type="hidden" name="cmd" value="even">
b6dd1aaf
AC
236<table class="blanks">
237<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
238<tr> <td>Date:</td> <td><input name="d"></td> </tr>
239<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
240<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
f49e1088
AC
241<% foreach usr in Init.listUsers () do %>
242 <option value="<% #id usr %>"><% #name usr %></option>
243<% end %>
244</select></td> </tr>
245<tr> <td><input type="submit" value="Add"></td> </tr>
246</table>
247</form>
248
249<% elseif $"cmd" = "pay" then
250 Group.requireGroupName "money";
d5f8418b 251 val uid = (case $"user" of "" => ~1 | s => Web.stoi s);
f49e1088
AC
252 showNormal := false %>
253
b6dd1aaf 254<h3>New member payment</h3>
f49e1088 255
a4ccdb5e 256<form action="money" method="post">
f49e1088 257<input type="hidden" name="cmd" value="pay2">
b6dd1aaf 258<table class="blanks">
dcfe5198 259<tr> <td>Description:</td> <td><select name="descr">
ba6996e3
AC
260 <option<% if $"checkout" = "" then %> selected<% end %>>PayPal</option>
261 <option<% if $"checkout" <> "" then %> selected<% end %>>Google Checkout</option>
dcfe5198
AC
262 <option>Check</option>
263 <option>Direct transfer</option>
264 <option value="">Other:</option>
265</select> <input name="descr2"></td> </tr>
d5f8418b 266<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (Date.fmt "%B %d, %Y" (Date.fromTimeLocal (Time.now ()))) %>"></td> </tr>
b6dd1aaf
AC
267<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
268<tr> <td>Member:</td> <td><select name="usr">
f49e1088 269<% foreach usr in Init.listUsers () do %>
d5f8418b 270 <option value="<% #id usr %>"<% if #id usr = uid then %> selected<% end %>><% #name usr %></option>
f49e1088
AC
271<% end %>
272</select></td> </tr>
273<tr> <td><input type="submit" value="Add"></td> </tr>
274</table>
275</form>
276
277<% elseif $"cmd" = "pay2" then
278 Group.requireGroupName "money";
279 val amount = Web.stor ($"amount");
dcfe5198
AC
280 val descr = $"descr";
281 val descr = iff descr = "" then $"descr2" else descr;
f47fcc40 282 val id = Money.addTransaction (descr, amount, $"d");
f49e1088
AC
283 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
284 Money.applyCharges id;
285
b6dd1aaf 286 %><h3>Payment transaction added.</h3>
f49e1088
AC
287
288<% elseif $"modPay" <> "" then
289 Group.requireGroupName "money";
290 showNormal := false;
291 val id = Web.stoi ($"modPay");
292 val trn = Money.lookupTransaction id %>
293
b6dd1aaf 294<h3>Modify member payment</h3>
f49e1088 295
a4ccdb5e 296<form action="money" method="post">
f49e1088 297<input type="hidden" name="savePay" value="<% id %>">
b6dd1aaf
AC
298<table class="blanks">
299<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
300<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
301<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
302<tr> <td>Member:</td> <td><select name="usr">
f49e1088
AC
303<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
304 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
305<% end %>
306</td></tr>
307<tr> <td><input type="submit" value="Save"></td> </tr>
308</table>
309
310<% elseif $"savePay" <> "" then
311 Group.requireGroupName "money";
312 val id = Web.stoi ($"savePay");
313 val trn = Money.lookupTransaction id;
314
315 val amount = Web.stor ($"amount");
316 Money.clearCharges id;
317 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = amount};
318 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
319 Money.applyCharges id;
320
b6dd1aaf 321 %><h3>Member payment modified.</h3>
f49e1088 322
208e2cbc
AC
323<% elseif $"cmd" = "evenForm" then
324 Group.requireGroupName "money";
325 showNormal := false %>
b6dd1aaf 326<h3>New generic/even transaction</h3>
a4ccdb5e 327<form action="money" method="post">
208e2cbc 328<input type="hidden" name="cmd" value="even">
b6dd1aaf
AC
329<table class="blanks">
330<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
331<tr> <td>Date:</td> <td><input name="d"></td> </tr>
332<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
333<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
334<% foreach usr in Init.listUsers () do %>
335 <option value="<% #id usr %>"><% #name usr %></option>
336<% end %>
337</select></td> </tr>
338<tr> <td><input type="submit" value="Add"></td> </tr>
339</table>
340</form>
341
5c705bcb
AC
342<% elseif $"cmd" = "dues" then
343 Group.requireGroupName "money";
344 showNormal := false %>
345
346<h3>Monthly dues</h3>
347
348<form action="money" method="post">
349<input type="hidden" name="cmd" value="dues2">
350<table class="blanks">
ca39ffcd 351<tr> <td>Description:</td> <td><input name="descr" value="Dues"></td> </tr>
5c705bcb
AC
352<tr> <td>Date:</td> <td><input name="d"></td> </tr>
353<tr> <td>Amount/pledge:</td> <td><input name="base"></td> </tr>
354<tr> <td><input type="submit" value="Add"></td> </tr>
355</table>
356
357<% elseif $"cmd" = "dues2" then
358 Group.requireGroupName "money";
359 Money.billDues {descr = $"descr", base = Web.stor ($"base"), date = $"d"};
360
361 %><h3>Dues debits added.</h3>
362
208e2cbc 363<% elseif $"cmd" = "even" then
f49e1088 364 Group.requireGroupName "money";
208e2cbc
AC
365 val id = Money.addTransaction ($"descr", Web.stor ($"amount"), $"d");
366 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
367
b6dd1aaf 368 %><h3>Even transaction added.</h3>
208e2cbc
AC
369
370<% elseif $"modEven" <> "" then
f49e1088 371 Group.requireGroupName "money";
208e2cbc
AC
372 showNormal := false;
373 val trn = Money.lookupTransaction (Web.stoi ($"modEven")) %>
b6dd1aaf 374<h3>Modify even transaction</h3>
208e2cbc 375
a4ccdb5e 376<form action="money" method="post">
208e2cbc 377<input type="hidden" name="saveEven" value="<% $"modEven" %>">
b6dd1aaf
AC
378<table class="blanks">
379<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
380<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
381<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
382<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
383<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
384 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
385<% end %>
386</select></td> </tr>
387<tr> <td><input type="submit" value="Save"></td> </tr>
388</table>
389</form>
390
391<% elseif $"saveEven" <> "" then
f49e1088 392 Group.requireGroupName "money";
208e2cbc
AC
393 val id = Web.stoi ($"saveEven");
394 val trn = Money.lookupTransaction id;
395 Money.clearCharges id;
396 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Web.stor ($"amount")};
397 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
398
b6dd1aaf 399 %><h3>Even transaction modified</h3>
208e2cbc
AC
400
401<% elseif $"del" <> "" then
f49e1088 402 Group.requireGroupName "money";
208e2cbc
AC
403 showNormal := false;
404 val trn = Money.lookupTransaction (Web.stoi ($"del")) %>
b6dd1aaf 405 <h3>Are you sure you want to delete transaction <a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a>?</h3>
208e2cbc
AC
406 <a href="money?del2=<% $"del" %>">Yes, delete <% Web.html (#descr trn) %>!</a>
407
408<% elseif $"del2" <> "" then
f49e1088 409 Group.requireGroupName "money";
208e2cbc
AC
410 val id = Web.stoi ($"del2");
411 val trn = Money.lookupTransaction id;
412 Money.clearCharges id;
413 Money.deleteTransaction id %>
b6dd1aaf 414 <h3><% Web.html (#descr trn) %> deleted!</h3>
208e2cbc 415
2d795343
AC
416<% elseif $"cmd" = "equalize" then
417 Group.requireGroupName "money";
418 Money.equalizeBalances ();
b6dd1aaf 419 %><h3>Balances equalized</h3>
2d795343 420
208e2cbc
AC
421<% elseif $"trn" <> "" then
422 showNormal := false;
423 val id = Web.stoi ($"trn");
424 val trn = Money.lookupTransaction id %>
b6dd1aaf
AC
425<table class="blanks">
426<tr> <td>TRN#:</td> <td><% id %></td> </tr>
427<tr> <td>Description:</td> <td><% Web.html (#descr trn) %></td> </tr>
428<tr> <td>Date:</td> <td><% #d trn %></td> </tr>
429<tr> <td>Amount:</td> <td>$<% #amount trn %></td> </tr>
430<tr> <td>Distribution:</td>
af6f6078 431
208e2cbc
AC
432<% ref first = true;
433foreach (name, cha) in Money.listChargesWithNames id do
434 if first then
435 first := false
436 else
437 %><tr> <td></td> <%
438 end
439 %><td><a href="user?id=<% #usr cha %>"><% name %></a></td> <td>$<% #amount cha %></td> </tr><%
440end %>
441</table>
442
d5f8418b
AC
443<% elseif $"cmd" = "paypal" then
444 showNormal := false;
445 val apps = App.searchPaypal ($"email");
446 val users = Init.searchPaypal ($"email");
447
448 switch apps of
449 _ :: _ =>
450 %><h3>Approved applications</h3>
451
452 <% foreach appl in apps do %>
453 <br><hr><br>
454 <table class="blanks">
455 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
456 <tr> <td>Approved by:</td> <td><%
457 ref first = true;
458 ref found = false;
459 foreach (id, name) in App.votes (#id appl) do
460 if first then
461 first := false
462 else
463 %>, <%
464 end
465 %><a href="user?id=<% id %>"><% name %></a><%
466 end %> </td> </tr>
467 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
468 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
469 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
470 <% switch #paypal appl of
471 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
472 <% end;
473 switch #checkout appl of
474 SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
475 <% end %>
476 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
477 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
478 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
479 </table>
480
481 <% if root then %>
482 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
483 <% end
484 end
485 end;
486
487 switch users of
488 _ :: _ =>
489 %><h3>Members</h3>
490
491 <% foreach user in users do %>
492 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
493 <% end
494 end;
495
496 switch (apps, users) of
497 (nil, nil) => %>No matches.<%
498 end
499
b1bb018a
CE
500elseif $"cmd" = "realname" then
501 showNormal := false;
502 val users = Init.searchRealName ($"rname");
503
504 switch users of
505 _ :: _ =>
506 %><h3>Members</h3>
507
508 <% foreach user in users do %>
509 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
510 <% end
511 end;
512
513 switch users of
514 nil => %>No matches.<%
515 end
516
d5f8418b
AC
517elseif $"cmd" = "checkout" then
518 showNormal := false;
519 val apps = App.searchCheckout ($"email");
520 val users = Init.searchCheckout ($"email");
521
522 switch apps of
523 _ :: _ =>
524 %><h3>Approved applications</h3>
525
526 <% foreach appl in apps do %>
527 <br><hr><br>
528 <table class="blanks">
529 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
530 <tr> <td>Approved by:</td> <td><%
531 ref first = true;
532 ref found = false;
533 foreach (id, name) in App.votes (#id appl) do
534 if first then
535 first := false
536 else
537 %>, <%
538 end
539 %><a href="user?id=<% id %>"><% name %></a><%
540 end %> </td> </tr>
541 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
542 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
543 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
544 <% switch #paypal appl of
545 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
546 <% end;
547 switch #checkout appl of
548 SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
549 <% end %>
550 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
551 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
552 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
553 </table>
554
555 <% if root then %>
556 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
557 <% end
558 end
559 end;
560
561 switch users of
562 _ :: _ =>
563 %><h3>Members</h3>
564
565 <% foreach user in users do %>
566 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>&checkout=1">[add payment]</a></li>
567 <% end
568 end;
569
570 switch (apps, users) of
571 (nil, nil) => %>No matches.<%
572 end
573
1b566e48
AC
574elseif $"cmd" = "delinq" then
575 showNormal := false;
576 val dqs = Money.delinquentPledgers () %>
577<table>
578<tr> <th>Member</th> <th>Pledge</th> <th>Balance</th> </tr>
579<% foreach dq in dqs do %>
580<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td><% #shares dq %></td> <td>$<% #balance dq %></td> </tr>
581<% end %>
582</table>
583
584<a href="?lower=<% String.concatWith "," (List.map (fn dq => Int.toString (#id dq)) dqs) %>">Lower these pledges to 1</a>
585
586<% elseif $"lower" <> "" then
587 Money.resetPledges (List.map Web.stoi (String.tokens (fn ch => ch = #",") ($"lower")))
588
589 %><h3>Pledges reset.</h3><%
590
eafe3d52
AC
591elseif $"cmd" = "freezeworthy" then
592 showNormal := false;
593 val dqs = Money.freezeworthyPledgers () %>
594<table>
595<tr> <th>Member</th> <th>Balance</th> </tr>
596<% foreach dq in dqs do %>
27e65914
AC
597<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
598<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
599<% end %>
600</table>
601
602<% elseif $"cmd" = "bootworthy" then
603 showNormal := false;
604 val dqs = Money.bootworthyPledgers () %>
605<table>
606<tr> <th>Member</th> <th>Balance</th> </tr>
607<% foreach dq in dqs do %>
950a4fad
AC
608<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
609<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
610<% end %>
611</table>
612
613<% end %>
208e2cbc 614
466c5944
AC
615<% if showNormal then
616 val you = Init.getUser();
617 val bal = Balance.lookupBalance (#bal you);
b5dc79ca
AC
618 val deposit = Balance.depositAmount (#id bal);
619 val showBal = Util.sub (#amount bal, deposit) %>
208e2cbc 620
b5dc79ca 621<h3>Your balance: $<% showBal %><br>
104fbeb6
AC
622Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)<br>
623Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %></h3>
96bd398e 624
c8abf2d9 625<!--h3>Your balance: $<% #amount bal %></h3-->
96bd398e 626
96662fd8 627<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %><h3>Sum of all active balances: $<% Balance.sumOwnedBalances () %></h3><% end %>
ee5c7008 628
208e2cbc 629<a href="money?cmd=list">List all transactions</a><br>
104fbeb6 630<a href="money?cmd=primary">List primary transactions</a><br>
8ffa2c9e 631<a href="money?cmd=bals">List active balances</a><br>
711471a2 632<a href="money?cmd=nbals">List negative active balances</a><br>
eafe3d52
AC
633<a href="money?cmd=freezeworthy">List members who deserve account freezing</a><br>
634<a href="money?cmd=bootworthy">List members who deserve to be kicked out</a><br>
8ffa2c9e 635<a href="money?cmd=deadbals">List retired balances</a><br>
208e2cbc 636
96662fd8 637<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %>
cf10853e 638
1b566e48 639<a href="?cmd=delinq">Drop pledges of delinquent members</a><br>
cf10853e 640<a href="?lookback=20">Switch to regular member view</a><br>
208e2cbc
AC
641
642<br><b><u>New transaction:</u></b><br>
104fbeb6 643<a href="money?cmd=bill">Bill for the co-op</a><br>
f49e1088 644<a href="money?cmd=pay">Payment from member</a><br>
5c705bcb
AC
645<a href="money?cmd=dues">Monthly dues</a><br>
646<a href="money?cmd=hosting">New hosting bill (old style)</a><br>
208e2cbc 647<a href="money?cmd=evenForm">Generic/even</a><br>
2d795343
AC
648<br>
649<a href="money?cmd=equalize">Equalize balances</a><br>
d5f8418b
AC
650<br>
651
652<h3>Look up a PayPal e-mail address</h3>
653
654<form method="post">
655<input type="hidden" name="cmd" value="paypal">
656<input name="email"> <input type="submit" value="Look up">
657</form>
658
659<h3>Look up a Google Checkout e-mail address</h3>
660
661<form method="post">
662<input type="hidden" name="cmd" value="checkout">
663<input name="email"> <input type="submit" value="Look up">
b1bb018a
CE
664</form>
665
666<h3>Look up a Real Name</h3>
667
668<form method="post">
669<input type="hidden" name="cmd" value="realname">
670<input name="rname"> <input type="submit" value="Look up">
d5f8418b 671</form>
208e2cbc 672
b6dd1aaf 673<h3>Most recent transactions</h3>
208e2cbc
AC
674
675<table>
676<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Participants</b></td> <td><b>Replace</b></td> <td><b>Delete</b></td> </tr>
677<% foreach trn in Money.listTransactionsLimit 20 do %>
678<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td>
679<% switch Money.listChargesWithNames (#id trn) of
680 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
681 | _ => %><td><i>multi</i></td><%
682end %>
104fbeb6 683<td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
f49e1088 684<td><a href="money?del=<% #id trn %>">[Delete]</a></td> </tr>
208e2cbc
AC
685<% end %>
686</table>
687
96662fd8
AC
688<% else %>
689<a href="?audit=1">Switch to audit view</a><br>
60465e67 690<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb;
cf10853e 691 @payment [] %>
b251872c 692
b6dd1aaf 693<h3>Your recent account activity</h3>
208e2cbc 694
cf10853e 695<form>
60465e67 696 Show <input name="lookback" size="5" value="<% iff lookback = 0 then 20 else lookback %>"> most recent transactions.
cf10853e
AC
697 <input type="submit" value="Show">
698</form>
699
60465e67
AC
700<% ref running = showBal;
701val trans = iff lookback = 0 then
702 Money.listUserTransactions (Init.getUserId ())
703 else
704 Money.listUserTransactionsLimit (Init.getUserId (), lookback) %>
208e2cbc 705<table>
60465e67
AC
706<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>
707<% foreach (amount, trn) in trans do %>
708<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td>
709<td align="right"><% if Util.lt (amount, 0.0) then %><% amount %><% end %></td>
710<td align="right"><% if Util.ge (amount, 0.0) then %><% amount %><% end %></td>
b5dc79ca
AC
711<td><% running %></tr>
712<% running := Util.sub (running, amount)
713end %>
208e2cbc 714</table>
60465e67
AC
715<% if lookback <> 0 then %>
716<a href="?lookback=inf">Show all transactions</a><br>
717<% end %>
208e2cbc
AC
718
719<% end
720end %>
721
722<% @footer [] %>