From 3ba5e2e7eb4fbfb56da8a9757210dea8cc1a9eec Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 14 Aug 2006 19:07:18 +0000 Subject: [PATCH] mark item missing, mark item damaged git-svn-id: svn://svn.open-ils.org/ILS/trunk@5500 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/main/constants.js | 2 + Open-ILS/xul/staff_client/server/cat/util.js | 86 +++++++++++++++++++++- .../xul/staff_client/server/circ/copy_status.js | 18 +++++ .../xul/staff_client/server/circ/copy_status.xul | 2 + .../server/circ/copy_status_overlay.xul | 4 + 5 files changed, 111 insertions(+), 1 deletion(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 3794bbc682..1d6a0a57cd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -128,6 +128,8 @@ const api = { 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_class' }, 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_service' }, 'RETRIEVE_Z3950_SERVICES' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.retrieve_services' }, + 'MARK_ITEM_DAMAGED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_damaged' }, + 'MARK_ITEM_MISSING' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_missing' }, 'MARK_ITEM_LOST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_lost' }, 'MARK_ITEM_CLAIM_RETURNED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_claims_returned' }, 'MODS_SLIM_METARECORD_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.metarecord.mods_slim.retrieve' }, diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index af07fa9e18..fef6f332e5 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -4,7 +4,8 @@ if (typeof cat == 'undefined') var cat = {}; cat.util = {}; cat.util.EXPORT_OK = [ - 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', + 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', + 'mark_item_missing', 'mark_item_damaged', ]; cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK }; @@ -193,4 +194,87 @@ cat.util.spawn_copy_editor = function(list,edit) { } } +cat.util.mark_item_damaged = function(copy_ids) { + var error; + try { + JSAN.use('util.error'); error = new util.error(); + JSAN.use('util.functional'); + JSAN.use('util.network'); var network = new util.network(); + var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE', [ copy_ids ]); + if (typeof copies.ilsevent != 'undefined') throw(copies); + var magic_status = false; + for (var i = 0; i < copies.length; i++) { + var status = copies[i].status(); if (typeof status == 'object') status = status.id(); + if (typeof my_constants.magical_statuses[ status ] != 'undefined') magic_status = true; + } + if (magic_status) { + + error.yns_alert('Action failed. One or more of these items is in a special status (Checked Out, In Transit, etc.) and cannot be changed to the Damaged status.','Action failed.','OK',null,null,'Check here to confirm this message'); + + } else { + + var r = error.yns_alert('Change the status for these items to Damaged? You will have to manually retrieve the last circulation if you need to bill a patron. Barcodes: ' + util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", "), 'Mark Damaged', 'OK', 'Cancel', null, 'Check here to confirm this action'); + + if (r == 0) { + var count = 0; + for (var i = 0; i < copies.length; i++) { + try { + var robj = network.simple_request('MARK_ITEM_DAMAGED',[ses(),copies[i].id()]); + if (typeof robj.ilsevent != 'undefined') throw(robj); + count++; + } catch(E) { + error.standard_unexpected_error_alert('Error marking item ' + copies[i].barcode() + ' damaged.',E); + } + } + alert(count == 1 ? 'Item marked Damaged' : count + ' items marked Damaged.'); + } + } + + } catch(E) { + if (error) error.standard_unexpected_error_alert('cat.util.mark_item_damaged',E); else alert('FIXME: ' + E); + } +} + +cat.util.mark_item_missing = function(copy_ids) { + var error; + try { + JSAN.use('util.error'); error = new util.error(); + JSAN.use('util.functional'); + JSAN.use('util.network'); var network = new util.network(); + var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE', [ copy_ids ]); + if (typeof copies.ilsevent != 'undefined') throw(copies); + var magic_status = false; + for (var i = 0; i < copies.length; i++) { + var status = copies[i].status(); if (typeof status == 'object') status = status.id(); + if (typeof my_constants.magical_statuses[ status ] != 'undefined') magic_status = true; + } + if (magic_status) { + + error.yns_alert('Action failed. One or more of these items is in a special status (Checked Out, In Transit, etc.) and cannot be changed to the Missing status.','Action failed.','OK',null,null,'Check here to confirm this message'); + + } else { + + var r = error.yns_alert('Change the status for these items to Missing? Barcodes: ' + util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", "), 'Mark Missing', 'OK', 'Cancel', null, 'Check here to confirm this action'); + + if (r == 0) { + var count = 0; + for (var i = 0; i < copies.length; i++) { + try { + var robj = network.simple_request('MARK_ITEM_MISSING',[ses(),copies[i].id()]); + if (typeof robj.ilsevent != 'undefined') throw(robj); + count++; + } catch(E) { + error.standard_unexpected_error_alert('Error marking item ' + copies[i].barcode() + ' missing.',E); + } + } + alert(count == 1 ? 'Item marked Missing' : count + ' items marked Missing.'); + } + } + + } catch(E) { + if (error) error.standard_unexpected_error_alert('cat.util.mark_item_missing',E); else alert('FIXME: ' + E); + } +} + + dump('exiting cat/util.js\n'); diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index a832c536b2..af45a68d01 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -48,6 +48,8 @@ circ.copy_status.prototype = { obj.controller.view.sel_opac.setAttribute('disabled','true'); obj.controller.view.sel_bucket.setAttribute('disabled','true'); obj.controller.view.sel_copy_details.setAttribute('disabled','true'); + obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true'); + obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true'); obj.controller.view.sel_patron.setAttribute('disabled','true'); obj.controller.view.sel_spine.setAttribute('disabled','true'); obj.controller.view.sel_transit_abort.setAttribute('disabled','true'); @@ -59,6 +61,8 @@ circ.copy_status.prototype = { obj.controller.view.sel_patron.setAttribute('disabled','false'); obj.controller.view.sel_bucket.setAttribute('disabled','false'); obj.controller.view.sel_copy_details.setAttribute('disabled','false'); + obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false'); + obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false'); obj.controller.view.sel_spine.setAttribute('disabled','false'); obj.controller.view.sel_transit_abort.setAttribute('disabled','false'); obj.controller.view.sel_clip.setAttribute('disabled','false'); @@ -140,6 +144,20 @@ circ.copy_status.prototype = { } } ], + 'sel_mark_items_damaged' : [ + ['command'], + function() { + JSAN.use('cat.util'); JSAN.use('util.functional'); + cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) ); + } + ], + 'sel_mark_items_missing' : [ + ['command'], + function() { + JSAN.use('cat.util'); JSAN.use('util.functional'); + cat.util.mark_item_missing( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) ); + } + ], 'sel_bucket' : [ ['command'], function() { diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.xul b/Open-ILS/xul/staff_client/server/circ/copy_status.xul index 3548dfccdd..1e19be3bab 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.xul @@ -88,6 +88,8 @@ + + diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul b/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul index 7d00277a7b..81107fce91 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul @@ -15,6 +15,8 @@ + + @@ -58,6 +60,8 @@ + + -- 2.11.0