From b9e5c623f2cde86b1b87d07ba9e4a637f1b3ac5e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 3 Aug 2016 14:45:39 -0400 Subject: [PATCH] LP#1497335 Item details shows aged circs (XUL edition) * Item Status -> Circulation History now displays aged circulations as appropriate, showing "" in lieu the patron's name. * Item Status (and others) -> Show Last Few Circulations, ditto above. Also, the 'Add Billing' button is disabled when displayed with an aged circulation row. * Copy -> Retrieve Last Patron action now includes aged circulations when looking for the most recent circulation. When the most recent circ is an aged circ, the UI reports "Item XXX circulation is an aged circulation and has no linked user". Among other things, this means the 3rd from last circ will not be confused as the 2nd to last circ when the 2nd to last is aged. * Mark Item Damaged will warn if the circ in question is aged. This is just a sanity check and should never happen in reality, since the UI only supports this option on checked out items (i.e. active circs). Signed-off-by: Bill Erickson --- Open-ILS/xul/staff_client/server/cat/util.js | 14 +++++ .../server/circ/alternate_copy_summary.js | 53 ++++++++++++------- .../xul/staff_client/server/circ/checkin.js | 11 +++- .../staff_client/server/circ/circ_brief.xul | 26 +++++---- .../xul/staff_client/server/circ/renew.js | 11 +++- Open-ILS/xul/staff_client/server/circ/util.js | 4 ++ .../server/locale/en-US/circ.properties | 2 + 7 files changed, 91 insertions(+), 30 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 2a7578e7dd..f7da88609c 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -418,6 +418,20 @@ cat.util.mark_item_damaged = function(copy_ids) { /* short-circuit this behavior. We don't want to mark an item damaged and still have it circulating. At least for now. Wait until someone asks for it. */ auto_checkin = true; JSAN.use('patron.util'); + + if (!my_circ.usr()) { + // Since we are looking at copies that are still checked out, + // we should never get here. Best to be safe, though. + alert( + document.getElementById('catStrings') + .getFormattedString( + 'staff.cat.util.mark_item_damaged.item_no_linked_patron', + copies[i].barcode() + ) + ); + continue; + } + var patron_obj = patron.util.retrieve_fleshed_au_via_id( ses(), my_circ.usr() ); var patron_name = patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode(); var msg = $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.item_circulating_to_patron', [ diff --git a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js index 43c52ff8a5..17abb99d82 100644 --- a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js +++ b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js @@ -448,17 +448,26 @@ function load_item() { set("stop_fines", details.circ.stop_fines()); set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' )); set("target_copy", details.circ.target_copy()); - set("circ_usr", details.circ.usr()); - network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), details.circ.usr() ], function(preq) { - var r_au = preq.getResultObject(); - JSAN.use('patron.util'); - set( - 'patron_name', - patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(), - details.circ.usr() - ); + + if (details.circ.usr()) { + set("circ_usr", details.circ.usr()); + network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID', + [ ses(), details.circ.usr() ], function(preq) { + var r_au = preq.getResultObject(); + JSAN.use('patron.util'); + set( + 'patron_name', + patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(), + details.circ.usr() + ); + set_tooltip('patron_name','circ id ' + details.circ.id()); + }); + } else { + set("circ_usr", ""); + set('patron_name', document.getElementById( + 'circStrings').getString('staff.circ.aged_circ')); set_tooltip('patron_name','circ id ' + details.circ.id()); - }); + } set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' )); set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' )); set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' )); @@ -491,16 +500,22 @@ function load_item() { var robj = req.getResultObject(); if (!robj || typeof robj == 'null') { return; } var summary = robj['summary']; - network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), robj['usr'] ], function(preq) { - var r_au = preq.getResultObject(); - JSAN.use('patron.util'); - set( - 'prev_patron_name', - patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(), - robj['usr'] - ); + if (robj['usr']) { + network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), robj['usr'] ], function(preq) { + var r_au = preq.getResultObject(); + JSAN.use('patron.util'); + set( + 'prev_patron_name', + patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(), + robj['usr'] + ); + set_tooltip('prev_patron_name','circ chain prior to circ id ' + details.circ.id()); + }); + } else { + set('prev_patron_name', document.getElementById( + 'circStrings').getString('staff.circ.aged_circ')); set_tooltip('prev_patron_name','circ chain prior to circ id ' + details.circ.id()); - }); + } set("prev_num_circs", summary.num_circs()); set("prev_num_renewals", Number(summary.num_circs()) - 1); set("prev_xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index 2cde9de83f..999ed31725 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -190,7 +190,16 @@ circ.checkin.prototype = { for (var i = 0; i < obj.selection_list.length; i++) { var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]); if (circs.length > 0) { - patrons[circs[0].usr()] = 1; + if (circs[0].usr()) { + patrons[circs[0].usr()] = 1; + } else { + alert( + document.getElementById('circStrings') + .getFormattedString( + 'staff.circ.item_no_user', + [obj.selection_list[i].barcode]) + ); + } } else { alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode])); } diff --git a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul index c207a3ae7d..9b1eb06d85 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul @@ -68,13 +68,21 @@ if (get_bool(r_circ.opac_renewal() ) ) r += 'OPAC '; if (get_bool(r_circ.phone_renewal() ) ) r += 'PHONE '; $('renewal').value = r || document.getElementById('circStrings').getString('staff.circ.checkout.no.btn'); - g.patron_id = r_circ.usr(); $('add_billing').disabled = false; - g.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), r_circ.usr() ], function(preq) { - var r_au = preq.getResultObject(); - JSAN.use('patron.util'); - $('patron_name').value = patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(); - patron.util.set_penalty_css(r_au); - }); + g.patron_id = r_circ.usr(); + if (g.patron_id) { + $('add_billing').disabled = false; + g.network.simple_request( + 'FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), r_circ.usr() ], function(preq) { + var r_au = preq.getResultObject(); + JSAN.use('patron.util'); + $('patron_name').value = patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(); + patron.util.set_penalty_css(r_au); + }); + } else { + $('patron_name').value = + document.getElementById('circStrings') + .getString('staff.circ.aged_circ'); + } } catch(E) { g.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.circ_brief.failure'), E); @@ -82,7 +90,7 @@ } if (g.circ_id) { - g.network.simple_request( 'FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.circ_id ], circ_callback); + g.network.simple_request( 'FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.circ_id, true ], circ_callback); } else { g.circ = g.data.temp_circ; g.data.temp_circ = null; g.data.stash('temp_circ'); g.circ_id = g.data.temp_circ_id; g.data.temp_circ_id = null; g.data.stash('temp_circ_id'); @@ -90,7 +98,7 @@ if (g.circ) { circ_callback( { 'getResultObject' : function() { return g.circ; } } ); } else { - g.network.simple_request( 'FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.circ_id ], circ_callback); + g.network.simple_request( 'FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.circ_id, true ], circ_callback); } } diff --git a/Open-ILS/xul/staff_client/server/circ/renew.js b/Open-ILS/xul/staff_client/server/circ/renew.js index cf538a13cf..5e5b01740c 100644 --- a/Open-ILS/xul/staff_client/server/circ/renew.js +++ b/Open-ILS/xul/staff_client/server/circ/renew.js @@ -152,7 +152,16 @@ circ.renew.prototype = { for (var i = 0; i < obj.selection_list.length; i++) { var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]); if (circs.length > 0) { - patrons[circs[0].usr()] = 1; + if (circs[0].usr()) { + patrons[circs[0].usr()] = 1; + } else { + alert( + document.getElementById('circStrings') + .getFormattedString( + 'staff.circ.item_no_user', + [obj.selection_list[i].barcode]) + ); + } } else { alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode])); } diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 9d372d84b9..346a4252c8 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -141,6 +141,10 @@ circ.util.show_last_few_circs = function(selection_list) { if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue; var patrons = my_xulG.retrieve_these_patrons; for (var j = 0; j < patrons.length; j++) { + + // combcirc objects may have a null value for user + if (!patrons[j]) continue; + if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') { try { window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } ); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties index 0e6cd05492..926e3a21f6 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties @@ -1,5 +1,7 @@ staff.circ.alert=Alert staff.circ.item_no_circs=Item %1$s has never circulated. +staff.circ.item_no_user=Item %1$s circulation is an aged circulation and has no linked user. +staff.circ.aged_circ= staff.circ.invalid_date=Invalid Date staff.circ.future_date=Future Date staff.circ.process_item=Check In / Process Item -- 2.43.2