From 052bba6a87b64e068dc880b5f10a6890360ea220 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 23 Mar 2016 13:22:45 -0400 Subject: [PATCH] LP#1497335 Aged circs display / API / WIP Signed-off-by: Bill Erickson --- .../src/perlmods/lib/OpenILS/Application/Circ.pm | 16 +++++++++++----- Open-ILS/xul/staff_client/server/cat/util.js | 11 +++++++++++ .../server/circ/alternate_copy_summary.js | 3 ++- Open-ILS/xul/staff_client/server/circ/checkin.js | 11 ++++++++++- .../xul/staff_client/server/circ/circ_brief.xul | 22 ++++++++++++++-------- Open-ILS/xul/staff_client/server/circ/renew.js | 11 ++++++++++- Open-ILS/xul/staff_client/server/circ/util.js | 4 ++++ .../server/locale/en-US/circ.properties | 1 + 8 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 946f712542..1f9d9e2706 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -54,14 +54,20 @@ __PACKAGE__->register_method( Retrieve a circ object by id @param authtoken Login session key @pararm circid The id of the circ object + @param all_circ Returns an action.all_circulation object instead + of an action.circulation object to pick up aged circs. / ); + sub retrieve_circ { - my( $s, $c, $a, $i ) = @_; + my( $s, $c, $a, $i, $all_circ ) = @_; my $e = new_editor(authtoken => $a); return $e->event unless $e->checkauth; - my $circ = $e->retrieve_action_circulation($i) or return $e->event; - if( $e->requestor->id ne $circ->usr ) { + my $method = $all_circ ? + 'retrieve_all_action_circulation' : + 'retrieve_action_circulation'; + my $circ = $e->$method($i) or return $e->event; + if( $e->requestor->id ne ($circ->usr || '') ) { return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); } return $circ; @@ -782,7 +788,7 @@ sub view_circs { $count = 4 unless defined $count; } - return $e->search_action_circulation([ + return $e->search_action_all_circulation([ {target_copy => $copyid}, {limit => $count, order_by => { circ => "xact_start DESC" }} ]); @@ -1088,7 +1094,7 @@ sub copy_details { 'recurring_fine_rule' ], }, - order_by => { circ => 'xact_start desc' }, + order_by => { combcirc => 'xact_start desc' }, limit => 1 } ])->[0]; diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 2a7578e7dd..b31a43e963 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -418,6 +418,17 @@ 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()) { + 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 6966275efc..aac47e5034 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 @@ -440,7 +440,8 @@ function load_item() { 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) { + 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( 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..92d7428f1a 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul @@ -68,21 +68,27 @@ 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(); + alert(g.patron_id); + 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); + }); + } } catch(E) { + alert(E); g.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.circ_brief.failure'), E); } } 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'); 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 b725e7ccda..c192b2f86d 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 d5bb8d1fbd..722aa74e48 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,6 @@ staff.circ.alert=Alert staff.circ.item_no_circs=Item %1$s has never circulated. +staff.circ.item_no_user=Item %1$s circulation has no linked user. staff.circ.invalid_date=Invalid Date staff.circ.future_date=Future Date staff.circ.process_item=Check In / Process Item -- 2.11.0