LP#1619703 Transfer ACQ lineitem browser UI
authorBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 19:36:35 +0000 (15:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Supports marking a bib record as a lineitem transfer destination in the
web staff bib record detail interface.  Found in the 'Mark For:' selector
menu.

Supports inititiating the transfer from the embedded ACQ purchase order
interface.  ACQ action is found in the Actions selector for each
lineitem.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/src/templates/staff/cat/catalog/index.tt2
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/common/li_table.js

index 93668dc..9961074 100644 (file)
@@ -4492,12 +4492,10 @@ sub transfer_lineitem {
         where => {lineitem => $li_id}
     });
 
-    # TODO: Transfer monograph parts.
+    if (@$acp_ids) {
 
-    my $copies = $e->search_asset_copy(
-        {id => [map {$_->{eg_copy_id}} @$acp_ids]});
-
-    if (@$copies) {
+        my $copies = $e->search_asset_copy(
+            {id => [map {$_->{eg_copy_id}} @$acp_ids]});
 
         # Group copies into call number batches so each call number can
         # be assessed and processed once.
index eafd398..dd4c058 100644 (file)
                     </td>
                     <td>
                         <select name='actions'>
-                            <option name='action_none'>[% l('-- Actions --') %]</option>
-                            <option name='action_mark_recv' disabled='disabled'>Mark Received</option>
-                            <option name='action_mark_unrecv' disabled='disabled'>Un-Receive</option>
-                            <option name='action_update_barcodes'>[% l('Update Barcodes') %]</option>
-                            <option name='action_holdings_maint'>[% l('Holdings Maint.') %]</option>
-                            <option name='action_manage_claims'>[% l('Claims') %]</option>
-                            <option name='action_view_history'>[% l('View History') %]</option>
+                            <option name='action_none' value='action_none'>[% l('-- Actions --') %]</option>
+                            <option name='action_mark_recv' value='action_mark_recv' disabled='disabled'>Mark Received</option>
+                            <option name='action_mark_unrecv' value='action_mark_unrecv' disabled='disabled'>Un-Receive</option>
+                            <option name='action_update_barcodes' value='action_update_barcodes'>[% l('Update Barcodes') %]</option>
+                            <option name='action_holdings_maint' value='action_holdings_maint'>[% l('Holdings Maint.') %]</option>
+                            <option name='action_manage_claims' value='action_manage_claims'>[% l('Claims') %]</option>
+                            <option name='action_view_history' value='action_view_history'>[% l('View History') %]</option>
+                            <option name='action_transfer_to_bib' value='action_transfer_to_bib'>[% l('Transfer To Bib Record') %]</option>
                         </select>
                     </td>
                     <td>
index ddb6a8c..f2eff0b 100644 (file)
     s.MARK_CONJ_TARGET =                                                                                                            
       "[% l('Conjoined Item Target set') %]";                
     s.MARK_HOLDINGS_TARGET = "[% l('Holdings transfer target set') %]";
+    s.MARK_VOL_TARGET =                                                                                                            
+      "[% l('Volume Transfer Target set') %]";                
+    s.MARK_LI_TARGET =                                                                                                            
+      "[% l('Lineitem Transfer Target set') %]"; 
+    s.MARK_ITEM_TARGET =                                                                                                            
+      "[% l('Item Transfer Target set') %]";                
     s.MARK_OVERLAY_TARGET =                                                                                                            
       "[% l('Record Overlay Target set') %]";                
 
index 2fca11d..b00d422 100644 (file)
     "ACTIVATE_BIBS_PROCESSED"           : "Bib Records Merged/Imported: ${0}",
     "ACTIVATE_LID_PROCESSED"            : "ACQ Copies Processed: ${0}",
     "ACTIVATE_DEBITS_ACCRUED_PROCESSED" : "Debits Encumbered: ${0}",
-    "ACTIVATE_COPIES_PROCESSED"         : "Real Copies Processed: ${0}"
+    "ACTIVATE_COPIES_PROCESSED"         : "Real Copies Processed: ${0}",
+    "LI_TRANSFER_NO_TARGET"             : "No transfer destination selected",
+    "LI_TRANSFER_CONFIRM"               : "Transfer lineitem #${0} to bib record ID ${1}?\n\nTitle: ${2}"
 }
index b41cc0f..3e4c502 100644 (file)
@@ -747,6 +747,46 @@ function AcqLiTable() {
         );
     }
 
+    this.transferLiToBib = function(li_id) {
+        var self = this;
+        var target = openils.XUL.localStorage().getItem(
+            'eg.cat.marked_lineitem_transfer_record');
+
+        if (!target) {
+            alert(localeStrings.LI_TRANSFER_NO_TARGET);
+            return;
+        }
+
+        // Data stored by the browser client are JSON-encoded.
+        target = JSON2js(target);
+
+        self.pcrud.retrieve('rmsr', target, {   
+            async : true, 
+            oncomplete : function(r) {
+                var rec = openils.Util.readResponse(r);
+
+                if (!confirm(dojo.string.substitute(
+                        localeStrings.LI_TRANSFER_CONFIRM, 
+                        [li_id, target, rec.title()]))) return;
+
+                console.debug('Transfering lineitem ' + 
+                    li_id + ' to bib ' + target);
+
+                fieldmapper.standardRequest(
+                    ['open-ils.acq', 
+                        'open-ils.acq.lineitem.transfer_to_bib'],
+                    {   params : [self.authtoken, li_id, target],
+                        oncomplete : function(r) {
+                            var li = openils.Util.readResponse(r);
+                            // no events fired, reload the page.
+                            location.href = location.href;
+                        }
+                    }
+                );
+            }
+        });
+    }
+
     // fetch an updated copy of the lineitem 
     // and add it back to the lineitem table
     this.refreshLineitem = function(li, focus) {
@@ -1398,8 +1438,25 @@ function AcqLiTable() {
                 case 'action_view_history':
                     location.href = oilsBasePath + '/acq/lineitem/history/' + li.id();
                     break;
+
+                // KCLS CUSTOM / LP#1619703
+                case 'action_transfer_to_bib':
+                    self.transferLiToBib(li.id());
+                    nodeByName("action_none", row).selected = true;
+                    break;
+
+                // KCLS CUSTOM
+                case 'action_mark_recv':
+                    if (self.checkLiAlerts(li.id()))
+                        self.issueReceive(li);
+                    break;
+                case 'action_mark_unrecv':
+                    if (confirm(localeStrings.UNRECEIVE_LI))
+                        self.issueReceive(li, /* rollback */ true);
+                    break;
             }
         };
+
         var actUpdateBarcodes = nodeByName("action_update_barcodes", row);
         var actHoldingsMaint = nodeByName("action_holdings_maint", row);
 
@@ -1480,23 +1537,11 @@ function AcqLiTable() {
 
         } else if (li.state() == 'on-order') { 
             // KCLS CUSTOM -- activate LI receive action
-
             actReceive.disabled = false;
-            actReceive.onclick = function() {
-                if (self.checkLiAlerts(li.id()))
-                    self.issueReceive(li);
-                nodeByName("action_none", row).selected = true;
-            };
 
         } else if (li.state() == 'received') { 
             // KCLS CUSTOM -- activate LI un-receive action
-
             actUnRecv.disabled = false;
-            actUnRecv.onclick = function() {
-                if (confirm(localeStrings.UNRECEIVE_LI))
-                    self.issueReceive(li, /* rollback */ true);
-                nodeByName("action_none", row).selected = true;
-            };
         }
 
         openils.Util.show(state_cell);