replace barcode entry points
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Aug 2006 20:18:51 +0000 (20:18 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Aug 2006 20:18:51 +0000 (20:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5789 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/copy_browser.js
Open-ILS/xul/staff_client/server/cat/copy_browser.xul
Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul

index b8aea5d..caf89c5 100644 (file)
@@ -238,6 +238,42 @@ cat.copy_browser.prototype = {
                                                                }
                                                        }
                                                ],
+                                               'cmd_replace_barcode' : [
+                                                       ['command'],
+                                                       function() {
+                                                               try {
+                                                                       JSAN.use('util.functional');
+
+                                                                       var list = util.functional.filter_list(
+                                                                               obj.sel_list,
+                                                                               function (o) {
+                                                                                       return o.split(/_/)[0] == 'acp';
+                                                                               }
+                                                                       );
+
+                                                                       list = util.functional.map_list(
+                                                                               list,
+                                                                               function (o) {
+                                                                                       return obj.map_acp[ o ].barcode();
+                                                                               }
+                                                                       );
+
+                                                                       JSAN.use('cat.util');
+                                                                       for (var i = 0; i < list.length; i++) {
+                                                                               try {
+                                                                                       cat.util.replace_barcode(list[i]);
+                                                                               } catch(E) {
+                                                                                       obj.error.standard_unexpected_error_alert('Barcode ' +list[i] + ' not likely replaced.',E);
+                                                                               }
+                                                                       }
+                                                                       obj.refresh_list();
+
+                                                               } catch(E) {
+                                                                       obj.error.standard_unexpected_error_alert('copy browser -> replace barcode',E);
+                                                                       obj.refresh_list();
+                                                               }
+                                                       }
+                                               ],
                                                'cmd_edit_items' : [
                                                        ['command'],
                                                        function() {
@@ -280,6 +316,7 @@ cat.copy_browser.prototype = {
                                                                        }
 
                                                                        JSAN.use('cat.util'); cat.util.spawn_copy_editor(list,edit);
+                                                                       obj.refresh_list();
 
                                                                } catch(E) {
                                                                        obj.error.standard_unexpected_error_alert('Copy Browser -> Edit Items',E);
@@ -1357,6 +1394,7 @@ cat.copy_browser.prototype = {
                        obj.controller.view.cmd_add_items.setAttribute('disabled','true');
                        obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
                        obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
+                       obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
                        obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
                        obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
                        obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
@@ -1386,6 +1424,7 @@ cat.copy_browser.prototype = {
                                obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
                                obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
                                obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
+                               obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
                                obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
                                obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
                                obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
index 8ee92c7..f6c9d4c 100644 (file)
@@ -78,6 +78,7 @@
                <command id="cmd_add_items"/>
                <command id="cmd_add_items_to_buckets"/>
                <command id="cmd_edit_items"/>
+               <command id="cmd_replace_barcode"/>
                <command id="cmd_delete_items"/>
                <command id="cmd_transfer_items"/>
                <command id="cmd_print_spine_labels"/>
                        <menuitem command="sel_mark_items_damaged" label="Mark Item Damaged" accesskey="D"/>
                        <menuitem command="sel_mark_items_missing" label="Mark Item Missing" accesskey="g"/>
                        <menuitem command="cmd_edit_items" label="Edit Item Attributes" accesskey="E"/>
+                       <menuitem command="cmd_replace_barcode" label="Replace Barcode" accesskey=""/>
                        <menuitem command="cmd_delete_items" label="Delete Items" accesskey=""/>
                        <menuitem command="cmd_transfer_items" label="Transfer Items to Previously Marked Volume" accesskey="T"/>
                        <menuitem command="cmd_print_spine_labels" label="Print Item Spine Labels" accesskey="P"/>
                                                        <menuitem command="sel_mark_items_damaged" label="Mark Item Damaged" accesskey="D"/>
                                                        <menuitem command="sel_mark_items_missing" label="Mark Item Missing" accesskey="g"/>
                                                        <menuitem command="cmd_edit_items" label="Edit Item Attributes" accesskey="E"/>
+                                                       <menuitem command="cmd_replace_barcode" label="Replace Barcode" accesskey=""/>
                                                        <menuitem command="cmd_delete_items" label="Delete Items" accesskey=""/>
                                                        <menuitem command="cmd_transfer_items" label="Transfer Items to Previously Marked Volume" accesskey="T"/>
                                                        <menuitem command="cmd_print_spine_labels" label="Print Item Spine Labels" accesskey="P"/>
index 814d724..a0b009d 100644 (file)
@@ -5,10 +5,43 @@ cat.util = {};
 
 cat.util.EXPORT_OK     = [ 
        'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', 
-       'mark_item_missing', 'mark_item_damaged',
+       'mark_item_missing', 'mark_item_damaged', 'replace_barcode',
 ];
 cat.util.EXPORT_TAGS   = { ':all' : cat.util.EXPORT_OK };
 
+cat.util.replace_barcode = function(old_bc) {
+       try {
+               JSAN.use('util.network');
+               var network = new util.network();
+
+               if (!old_bc) old_bc = window.prompt('Enter original barcode for the copy:','','Replace Barcode');
+               if (!old_bc) return;
+
+               var copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
+               if (typeof copy.ilsevent != 'undefined') throw(copy); 
+               if (!copy) throw(copy);
+
+               // Why did I want to do this twice?  Because this copy is more fleshed?
+               copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
+               if (typeof copy.ilsevent != 'undefined') throw(copy);
+               if (!copy) throw(copy);
+
+               var new_bc = window.prompt('Enter the replacement barcode for the copy with barcode ' + old_bc + ':','','Replace Barcode');
+
+               var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ ses(), new_bc ]);
+               if (typeof test.ilsevent == 'undefined') {
+                       alert('Rename aborted.  Another copy has that barcode');
+                       return;
+               }
+               copy.barcode(new_bc); copy.ischanged('1');
+               var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
+               if (typeof r.ilsevent != 'undefined') { if (r.ilsevent != 0) throw(r); }
+       } catch(E) {
+               JSAN.use('util.error'); var error = new util.error();
+               error.standard_unexpected_error_alert('Rename did not likely occur.',E);
+       }
+}
+
 cat.util.transfer_copies = function(params) {
        JSAN.use('util.error'); var error = new util.error();
        JSAN.use('OpenILS.data'); var data = new OpenILS.data();
index f4a7d1b..7291cb0 100644 (file)
@@ -44,6 +44,7 @@ circ.copy_status.prototype = {
                                                obj.error.sdump('D_TRACE','circ/copy_status: selection list = ' + js2JSON(obj.selection_list) );
                                                if (obj.selection_list.length == 0) {
                                                        obj.controller.view.sel_checkin.setAttribute('disabled','true');
+                                                       obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
                                                        obj.controller.view.sel_edit.setAttribute('disabled','true');
                                                        obj.controller.view.sel_opac.setAttribute('disabled','true');
                                                        obj.controller.view.sel_bucket.setAttribute('disabled','true');
@@ -56,6 +57,7 @@ circ.copy_status.prototype = {
                                                        obj.controller.view.sel_clip.setAttribute('disabled','true');
                                                } else {
                                                        obj.controller.view.sel_checkin.setAttribute('disabled','false');
+                                                       obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
                                                        obj.controller.view.sel_edit.setAttribute('disabled','false');
                                                        obj.controller.view.sel_opac.setAttribute('disabled','false');
                                                        obj.controller.view.sel_patron.setAttribute('disabled','false');
@@ -97,6 +99,24 @@ circ.copy_status.prototype = {
                                                        }
                                                }
                                        ],
+                                       'cmd_replace_barcode' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                                               JSAN.use('cat.util');
+                                                               for (var i = 0; i < obj.selection_list.length; i++) {
+                                                                       try { 
+                                                                               var barcode = obj.selection_list[i].barcode;
+                                                                               cat.util.replace_barcode( barcode );
+                                                                       } catch(E) {
+                                                                               obj.error.standard_unexpected_error_alert('Barcode ' + barcode + ' was not likely replaced.',E);
+                                                                       }
+                                                               }
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('Barcode replacements did not likely happen.',E);
+                                                       }
+                                               }
+                                       ],
                                        'sel_edit' : [
                                                ['command'],
                                                function() {
index 43c592f..171aff1 100644 (file)
@@ -91,6 +91,7 @@
                <command id="sel_copy_details" disabled="true"/>
                <command id="sel_mark_items_damaged" disabled="true"/>
                <command id="sel_mark_items_missing" disabled="true"/>
+               <command id="cmd_replace_barcode" disabled="true"/>
                <command id="sel_patron" disabled="true"/>
                <command id="sel_checkin" disabled="true"/>
                <command id="sel_edit" disabled="true"/>
index bcbc4c1..2679a66 100644 (file)
@@ -20,6 +20,7 @@
                <menuitem command="sel_mark_items_damaged" label="Mark Item Damaged" accesskey="D"/>
                <menuitem command="sel_mark_items_missing" label="Mark Item Missing" accesskey="M"/>
                <menuitem command="sel_edit" label="Edit Item Attributes" accesskey="E" />
+               <menuitem command="cmd_replace_barcode" label="Replace Barcode" accesskey=""/>
                <menuitem command="sel_transit_abort" label="Abort Transits" />
                <menuseparator/>
                <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>
@@ -67,6 +68,7 @@
                        <menuitem command="sel_mark_items_damaged" label="Mark Item Damaged" accesskey="D"/>
                        <menuitem command="sel_mark_items_missing" label="Mark Item Missing" accesskey="M"/>
                        <menuitem command="sel_edit" label="Edit Item Attributes" accesskey="E" />
+                       <menuitem command="cmd_replace_barcode" label="Replace Barcode" accesskey=""/>
                        <menuitem command="sel_transit_abort" label="Abort Transits" />
                        <menuseparator />
                        <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>