[open-ils-commits] r17047 - in trunk/Open-ILS: src/perlmods/OpenILS/Application xul/staff_client/chrome/content/main xul/staff_client/server/cat xul/staff_client/server/circ xul/staff_client/server/locale/en-US (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 27 18:33:40 EDT 2010
Author: phasefx
Date: 2010-07-27 18:33:34 -0400 (Tue, 27 Jul 2010)
New Revision: 17047
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
trunk/Open-ILS/xul/staff_client/server/cat/util.js
trunk/Open-ILS/xul/staff_client/server/circ/missing_pieces.xul
trunk/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
Log:
middle layer support and client-side utility function. missing messagecat for missing pieces dialog
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm 2010-07-27 22:33:10 UTC (rev 17046)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm 2010-07-27 22:33:34 UTC (rev 17047)
@@ -35,6 +35,7 @@
my $apputils = "OpenILS::Application::AppUtils";
my $U = $apputils;
+my $holdcode = "OpenILS::Application::Circ::Holds";
# ------------------------------------------------------------------------
# Top level Circ package;
@@ -1202,9 +1203,145 @@
+# ----------------------------------------------------------------------
+__PACKAGE__->register_method(
+ method => 'mark_item_missing_pieces',
+ api_name => 'open-ils.circ.mark_item_missing_pieces',
+ signature => q/
+ Changes the status of a copy to "damaged" or to a custom status based on the
+ circ.missing_pieces.copy_status org unit setting. Requires MARK_ITEM_MISSING_PIECES
+ permission.
+ @param authtoken The login session key
+ @param copy_id The ID of the copy to mark as damaged
+ @return Success event with circ and copy objects in the payload, or error Event otherwise.
+ /
+);
+sub mark_item_missing_pieces {
+ my( $self, $conn, $auth, $copy_id, $args ) = @_;
+ ### FIXME: We're starting a transaction here, but we're doing a lot of things outside of the transaction
+ my $e = new_editor(authtoken=>$auth, xact =>1);
+ return $e->die_event unless $e->checkauth;
+ $args ||= {};
+ my $copy = $e->retrieve_asset_copy([
+ $copy_id,
+ {flesh => 1, flesh_fields => {'acp' => ['call_number']}}])
+ or return $e->die_event;
+ my $owning_lib =
+ ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ?
+ $copy->circ_lib : $copy->call_number->owning_lib;
+
+ return $e->die_event unless $e->allowed('MARK_ITEM_MISSING_PIECES', $owning_lib);
+
+ #### grab the last circulation
+ my $circ = $e->search_action_circulation([
+ { target_copy => $copy->id},
+ { limit => 1,
+ order_by => {circ => "xact_start DESC"}
+ }
+ ])->[0];
+
+ if ($circ) {
+ if (! $circ->checkin_time) { # if circ active, attempt renew
+ my ($res) = $self->method_lookup('open-ils.circ.renew')->run($e->authtoken,{'copy_id'=>$circ->target_copy});
+ if (ref $res ne 'ARRAY') { $res = [ $res ]; }
+ if ( $res->[0]->{textcode} eq 'SUCCESS' ) {
+ $circ = $res->[0]->{payload}{'circ'};
+ $circ->target_copy( $copy->id );
+ $logger->info('open-ils.circ.mark_item_missing_pieces: successful renewal');
+ } else {
+ $logger->info('open-ils.circ.mark_item_missing_pieces: non-successful renewal');
+ }
+ } else {
+
+ my $co_params = {
+ 'copy_id'=>$circ->target_copy,
+ 'patron_id'=>$circ->usr,
+ 'skip_deposit_fee'=>1,
+ 'skip_rental_fee'=>1
+ };
+
+ if ($U->ou_ancestor_setting_value($e->requestor->ws_ou, 'circ.block_renews_for_holds')) {
+
+ my ($hold, undef, $retarget) = $holdcode->find_nearest_permitted_hold(
+ $e, $copy, $e->requestor, 1 );
+
+ if ($hold) { # needed for hold? then due now
+
+ $logger->info('open-ils.circ.mark_item_missing_pieces: item needed for hold, shortening due date');
+ my $due_date = DateTime->now(time_zone => 'local');
+ $co_params->{'due_date'} = cleanse_ISO8601( $due_date->strftime('%FT%T%z') );
+ } else {
+ $logger->info('open-ils.circ.mark_item_missing_pieces: item not needed for hold');
+ }
+ }
+
+ my ($res) = $self->method_lookup('open-ils.circ.checkout.full.override')->run($e->authtoken,$co_params);
+ if (ref $res ne 'ARRAY') { $res = [ $res ]; }
+ if ( $res->[0]->{textcode} eq 'SUCCESS' ) {
+ $logger->info('open-ils.circ.mark_item_missing_pieces: successful checkout');
+ $circ = $res->[0]->{payload}{'circ'};
+ } else {
+ $logger->info('open-ils.circ.mark_item_missing_pieces: non-successful checkout');
+ $e->rollback;
+ return $res;
+ }
+ }
+ } else {
+ $logger->info('open-ils.circ.mark_item_missing_pieces: no previous checkout');
+ $e->rollback;
+ return OpenILS::Event->new('ACTION_CIRCULATION_NOT_FOUND',{'copy'=>$copy});
+ }
+
+ ### Update the item status
+
+ my $custom_stat = $U->ou_ancestor_setting_value(
+ $owning_lib, 'circ.missing_pieces.copy_status', $e);
+ my $stat = $custom_stat || OILS_COPY_STATUS_DAMAGED;
+
+ my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+ $ses->request('open-ils.trigger.event.autocreate', 'missing_pieces', $copy, $owning_lib);
+
+ $copy->status($stat);
+ $copy->edit_date('now');
+ $copy->editor($e->requestor->id);
+
+ $e->update_asset_copy($copy) or return $e->die_event;
+
+ my $holds = $e->search_action_hold_request(
+ {
+ current_copy => $copy->id,
+ fulfillment_time => undef,
+ cancel_time => undef,
+ }
+ );
+
+ $logger->debug("resetting holds that target the marked copy");
+ OpenILS::Application::Circ::Holds->_reset_hold($e->requestor, $_) for @$holds;
+
+ if ($e->commit) {
+
+ my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+ $ses->request('open-ils.trigger.event.autocreate', 'checkout.missing_pieces', $circ, $circ->circ_lib);
+
+ return OpenILS::Event->new('SUCCESS',
+ payload => {
+ circ => $circ,
+ copy => $copy
+ }
+ );
+
+ } else {
+ return $e->die_event;
+ }
+}
+
+
+
+
+
# ----------------------------------------------------------------------
__PACKAGE__->register_method(
method => 'magic_fetch',
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2010-07-27 22:33:10 UTC (rev 17046)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2010-07-27 22:33:34 UTC (rev 17047)
@@ -278,6 +278,7 @@
'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', 'secure' : false },
'MARK_ITEM_DAMAGED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_damaged' },
+ 'MARK_ITEM_MISSING_PIECES' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_missing_pieces' },
'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' },
Modified: trunk/Open-ILS/xul/staff_client/server/cat/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/util.js 2010-07-27 22:33:10 UTC (rev 17046)
+++ trunk/Open-ILS/xul/staff_client/server/cat/util.js 2010-07-27 22:33:34 UTC (rev 17047)
@@ -740,7 +740,44 @@
}
cat.util.mark_item_as_missing_pieces = function(copy_ids) {
- alert(js2JSON(copy_ids));
+ var error;
+ try {
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.functional'); JSAN.use('util.date');
+ JSAN.use('util.network'); var network = new util.network();
+ var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]);
+ if (typeof copies.ilsevent != 'undefined') throw(copies);
+
+ var r = error.yns_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.ms_message', [util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", ")]),
+ $("catStrings").getString('staff.cat.util.mark_item_missing_pieces.ms_title'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing_pieces.ms_ok_label'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing_pieces.ms_cancel_label'), null,
+ $("catStrings").getString('staff.cat.util.mark_item_missing_pieces.ms_confirm_action'));
+
+ if (r == 0) {
+ var count = 0;
+ for (var i = 0; i < copies.length; i++) {
+ try {
+ var robj = network.simple_request('MARK_ITEM_MISSING_PIECES',[ses(),copies[i].id()]);
+ if (typeof robj.ilsevent != 'undefined') { throw(robj); }
+ // TODO: Print missing pieces slip
+ // TODO: Bill patron prompt
+ // TODO: Item/patron notes/messages
+ // TODO: Invoke 3rd party app with letter to patron
+ count++;
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.marking_error', [copies[i].barcode()]),E);
+ }
+ }
+ alert(count == 1 ? $("catStrings").getString('staff.cat.util.mark_item_missing_pieces.one_item_missing_pieces') :
+ $("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.multiple_item_missing_pieces', [count]));
+ }
+
+ return true;
+ } catch(E) {
+ alert('Error in cat.util.mark_item_as_missing_pieces: ' + E);
+ return false;
+ }
}
dump('exiting cat/util.js\n');
Modified: trunk/Open-ILS/xul/staff_client/server/circ/missing_pieces.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/circ/missing_pieces.xul 2010-07-27 22:33:10 UTC (rev 17046)
+++ trunk/Open-ILS/xul/staff_client/server/circ/missing_pieces.xul 2010-07-27 22:33:34 UTC (rev 17047)
@@ -29,6 +29,7 @@
<scripts id="openils_util_scripts"/>
<messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
+ <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
<script type="text/javascript" src="/xul/server/main/JSAN.js"/>
<script type="text/javascript" src="missing_pieces.js"/>
Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties 2010-07-27 22:33:10 UTC (rev 17046)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties 2010-07-27 22:33:34 UTC (rev 17047)
@@ -378,6 +378,15 @@
staff.cat.util.mark_item_missing.marking_error=Error marking item %1$s missing.
staff.cat.util.mark_item_missing.one_item_missing=Item marked Missing
staff.cat.util.mark_item_missing.multiple_item_missing=%1$s items marked Missing.
+staff.cat.util.mark_item_missing_pieces.ms_message=Mark these items as missing pieces? Barcodes: %1$s
+staff.cat.util.mark_item_missing_pieces.ms_title=Mark Missing Pieces
+staff.cat.util.mark_item_missing_pieces.ms_ok_label=OK
+staff.cat.util.mark_item_missing_pieces.ms_cancel_label=Cancel
+staff.cat.util.mark_item_missing_pieces.ms_confirm_action=Check here to confirm this action
+staff.cat.util.mark_item_missing_pieces.marking_error=Error marking item %1$s as missing pieces.
+staff.cat.util.mark_item_missing_pieces.one_item_missing_pieces=Item marked as missing pieces.
+staff.cat.util.mark_item_missing_pieces.multiple_item_missing_pieces=%1$s items marked as missing pieces.
+
staff.cat.volume_buckets.window_tab_name=Volume Buckets
staff.cat.volume_copy_creator.my_init.btn.label=Apply
staff.cat.volume_copy_creator.my_init.btn.accesskey=A
More information about the open-ils-commits
mailing list