Serials: Support reader address information in routing slip template
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 23 Sep 2013 16:14:18 +0000 (12:14 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 26 Sep 2013 15:31:12 +0000 (11:31 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm
Open-ILS/src/templates/serial/print_routing_list_users.tt2
Open-ILS/web/js/ui/default/serial/print_routing_list_users.js

index c619d37..7d1ad2e 100644 (file)
@@ -3269,7 +3269,7 @@ sub get_routing_list_users {
             "flesh" => 2,
             "flesh_fields" => {
                 "srlu" => [qw/reader stream/],
-                "au" => [qw/card home_ou/],
+                "au" => [qw/card home_ou mailing_address billing_address/],
                 "sstr" => ["distribution"]
             }
         }
index 9f2936b..d37dfc1 100644 (file)
         </div>
         <ol name="users">
             <li id="user_template">
-                <span class="hidden" name="reader_container">
+                <div class="hidden" name="reader_container">
                     [% l('Reader: [_1] / [_2] ([_3])', '<span name="barcode"></span>',
                     '<span name="name"></span>',
                     '<span name="ou"></span>') %]
-                </span>
+                    <!-- XXX i18n?  This template can be customized for
+                    other address layouts if needed. -->
+                    <div name="mailing_address_container" class="hidden">
+                        <span name="mailing_address_street1"></span>
+                        <span name="mailing_address_street2"></span><br />
+                        <span name="mailing_address_city"></span>,
+                        <!-- <span name="mailing_address_county"></span> -->
+                        <span name="mailing_address_state"></span>
+                        <span name="mailing_address_post_code"></span><br />
+                        <span name="mailing_address_country"></span>
+                    </div>
+                    <div name="billing_address_container" class="hidden">
+                        <span name="billing_address_street1"></span>
+                        <span name="billing_address_street2"></span><br />
+                        <span name="billing_address_city"></span>,
+                        <!-- <span name="billing_address_county"></span> -->
+                        <span name="billing_address_state"></span>
+                        <span name="billing_address_post_code"></span><br />
+                        <span name="billing_address_country"></span>
+                    </div>
+                </div>
                 <span class="hidden" name="department_container">
                     [% l('Department: [_1]', '<span name="department"></span>') %]
                 </span>
index 94c0689..f7238eb 100644 (file)
@@ -48,6 +48,31 @@ function ListRenderer() {
         return this; /* for chaining */
     };
 
+    this._render_reader_addresses = function(reader, node) {
+        ["mailing", "billing"].forEach(
+            function(addr_type) {
+                var addr = reader[addr_type + "_address"]();
+                if (!addr || !addr.valid())
+                    return;
+
+                var prefix = addr_type + "_address_";
+                var container = n(prefix + "container", node);
+                if (container)
+                    openils.Util.show(container);
+
+                ["street1", "street2", "city", "county", "state",
+                    "country", "post_code"].forEach(
+                    function(f) {
+                        var field = prefix + f;
+                        var target = n(field, node);
+                        if (target)
+                            target.innerHTML = addr[f]();
+                    }
+                );
+            }
+        );
+    };
+
     this.render_users = function(stream, list) {
         for (var i = 0; i < this.users_by_stream[stream.id()].length; i++) {
             var user = this.users_by_stream[stream.id()][i];
@@ -63,6 +88,9 @@ function ListRenderer() {
                     ].map(function(n) { return n || ""; })
                 );
                 n("ou", node).innerHTML = user.reader().home_ou().shortname();
+
+                this._render_reader_addresses(user.reader(), node);
+
                 openils.Util.show(n("reader_container", node), "inline");
             } else if (user.department()) {
                 n("department", node).innerHTML = user.department();