Show copy receiver in ACQ copy grid
authorBill Erickson <berick@esilibrary.com>
Wed, 24 Aug 2011 19:28:56 +0000 (15:28 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 25 Aug 2011 00:06:27 +0000 (20:06 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/templates/default/acq/common/li_table.tt2

index 0b9b642..cf54585 100644 (file)
@@ -29,6 +29,8 @@ function nodeByName(name, context) {
     return dojo.query('[name='+name+']', context)[0];
 }
 
+// for caching linked users.  e.g. lineitem_detail.receiver
+var userCache = {};
 
 var liDetailBatchFields = ['fund', 'owning_lib', 'location', 'collection_code', 'circ_modifier', 'cn_label'];
 var liDetailFields = liDetailBatchFields.concat(['barcode', 'note']);
@@ -1439,6 +1441,21 @@ function AcqLiTable() {
 
         acqLitCopyCountInput.attr('value', self.copyCount()+'');
 
+        var rcvr = copy.receiver();
+        if (rcvr) {
+            if (!userCache[rcvr]) {
+                if(rcvr == openils.User.user.id()) {
+                    userCache[rcvr] = openils.User.user;
+                } else {
+                    userCache[rcvr] = fieldmapper.standardRequest(
+                        ['open-ils.actor', 'open-ils.actor.user.retrieve'],
+                        {params: [openils.User.authtoken, rcvr]}
+                    );
+                }
+            }
+            dojo.query('[name=receiver]', row)[0].innerHTML =  userCache[rcvr].usrname();
+        }
+
         dojo.forEach(liDetailFields,
             function(field) {
                 var searchFilter;
@@ -1464,6 +1481,7 @@ function AcqLiTable() {
                     readOnly = true;
                 }
 
+
                 var widget = new openils.widget.AutoFieldWidget({
                     fmObject : copy,
                     fmField : field,
index 28ef757..1851833 100644 (file)
                     <td>Callnumber</td>
                     <td>Barcode</td>
                     <td>Notes</td>
+                    <td>Receiver</td>
                     <td colspan='0'></td>
                 </tr>
             </tbody>
                     <td><div name='cn_label'></div></td>
                     <td><div name='barcode'></div></td>
                     <td><div name='note'></div></td>
+                    <td><div name='receiver'></div></td>
                     <td><a href="javascript:void(0);" name="receive">Mark&nbsp;Received</a><a href="javascript:void(0);" name="unreceive">Un-Receive</a>&nbsp;<a href="javascript:void(0);" name="cancel">Cancel</a><span class="hidden" name="cancel_reason"></span>&nbsp;<a href="javascript:void(0);" name="claim">Claim</a></td>
                     <td><div name='delete' dojoType='dijit.form.Button' style='color:red;' scrollOnFocus='false'>X</div></td>
                 </tr>