Search by real name in money matters
authorClinton Ebadi <clinton@unknownlamer.org>
Fri, 15 Nov 2013 07:18:02 +0000 (02:18 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Fri, 15 Nov 2013 07:18:02 +0000 (02:18 -0500)
I hear this will make the life of a treasurer much easier for that
occasional member with out of date payment info.

init.sig
init.sml
money.mlt

index 303e1be..4c0ffa3 100644 (file)
--- a/init.sig
+++ b/init.sig
@@ -69,4 +69,5 @@ signature INIT = sig
 
     val searchPaypal : string -> user list
     val searchCheckout : string -> user list
+    val searchRealName : string -> user list
 end
index ba3b2bf..789fcbc 100644 (file)
--- a/init.sml
+++ b/init.sml
@@ -311,4 +311,10 @@ fun searchCheckout checkout =
                                  WHERE checkout = ^(C.stringToSql (normEmail checkout))
                                  ORDER BY name`)
 
+fun searchRealName realname =
+    C.map (getDb ()) mkUserRow ($`SELECT id, name, rname, bal, joined, app, shares, paypal, checkout
+                                 FROM WebUser
+                                 WHERE rname ILIKE ^(C.stringToSql ("%" ^ realname ^ "%"))
+                                 ORDER BY name`)
+
 end
index dbad9a9..fd3cc86 100644 (file)
--- a/money.mlt
+++ b/money.mlt
@@ -497,6 +497,23 @@ end %>
      (nil, nil) => %>No matches.<%
    end
 
+elseif $"cmd" = "realname" then
+   showNormal := false;
+   val users = Init.searchRealName ($"rname");
+
+   switch users of
+     _ :: _ =>
+     %><h3>Members</h3>
+
+     <% foreach user in users do %>
+       <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
+     <% end
+   end;
+
+   switch users of
+     nil => %>No matches.<%
+   end
+
 elseif $"cmd" = "checkout" then
    showNormal := false;
    val apps = App.searchCheckout ($"email");
@@ -646,6 +663,13 @@ Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToI
 <input name="email"> <input type="submit" value="Look up">
 </form>
 
+<h3>Look up a Real Name</h3>
+
+<form method="post">
+<input type="hidden" name="cmd" value="realname">
+<input name="rname"> <input type="submit" value="Look up">
+</form>
+
 <h3>Most recent transactions</h3>
 
 <table>