Dynamic transit copy status messages user/berick/transit-copy-status-message
authorBill Erickson <berick@esilibrary.com>
Thu, 18 Jul 2013 15:17:23 +0000 (11:17 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 18 Jul 2013 15:17:23 +0000 (11:17 -0400)
Via string properties, it is now possible to attach custom messages
which are displayed in the transit alert dialog and appended to printed
transit receipts based on the status of the in-transit copy.

By status in this case, I mean the status the copy will return to once it
arrives at its destination, not the literal copy status, which will always
be 'in-transit'.

To apply such a message, add a string property to
server/locale/<locale>/circ.properties with the format:

staff.circ.utils.transit.copy_status_message.<status_id>=FOO

For example:

staff.circ.utils.transit.copy_status_message.16=This item is in status
Long Overdue, additional staff action may be required.\n\n

If a message is present which matches the ID of the status of the
in-transit copy, the configured message will be appended to the transit
alert and the receipt.

In the case of receipts, newlines are replaced with <br/>'s.  Plus, the
message will be added to all transit receipts (as last item in the header),
regardless of whether a custom receipt is used.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties

index 36c168e..8d76932 100644 (file)
@@ -3501,12 +3501,29 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che
             print_data.item_author = payload_author;
             msg += print_data.item_author_msg;
             msg += '\n';
+
+            var transit_copy_status_msg; // used for receipts as well
             if (check.payload.transit) {
                 // by adding this here, we make the data available to the
-                // receipt printing engine, but since we are not appending it
-                // to the 'msg', it will not display in the pre-print dialog.
+                // receipt printing engine.
                 print_data.transit_copy_status = 
                     data.hash.ccs[check.payload.transit.copy_status()].name();
+
+                // See if there is a special message attached to the status 
+                // of the in-transit copy.  If so, append it to the alert 
+                // dialog (here) and to the header of the receipt (below).  
+                // The message  is accessed by the ID of the copy status.
+                var cp_stat = check.payload.transit.copy_status();
+                var strings = document.getElementById('circStrings');
+                var prop = 
+                    'staff.circ.utils.transit.copy_status_message.' + cp_stat;
+
+                if (strings.testString(prop)) {
+                    transit_copy_status_msg = strings.getString(prop);
+                    transit_copy_status_msg = // don't show literal \n's
+                        transit_copy_status_msg.replace(/\\n/g, '\n');
+                    msg += transit_copy_status_msg;
+                }
             }
             JSAN.use('util.date');
             if (check.payload.hold) {
@@ -3675,6 +3692,14 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che
                             'data' : print_data,
                             'context' : data.print_list_templates[ template ].context,
                         };
+
+                        if (transit_copy_status_msg) {
+                            // replace newlines with <br>'s since we're now 
+                            // dealing with HTML
+                            parms.header += 
+                                transit_copy_status_msg.replace(/\n/g, '<br/>');
+                        }
+
                         if ($('printer_prompt')) {
                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
                         }
index 74402fb..48cee81 100644 (file)
@@ -492,3 +492,4 @@ staff.circ.holds.list_view.accesskey=V
 staff.circ.missing_pieces.scan_item.prompt=Enter barcode for item missing pieces:
 staff.circ.missing_pieces.scan_item.title=Missing Pieces
 staff.circ.missing_pieces.scan_item.error_alert=No item with barcode "%1$s"
+staff.circ.utils.transit.copy_status_message.16=This item is in status Long Overdue, additional staff action may be required.\n\n