From: phasefx Date: Tue, 12 Jan 2010 15:52:41 +0000 (+0000) Subject: Backport changesets 14820, 15063, 15064, 15066: duedate virtual field for non-cat... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=420e0ee3584138d4e09cf0b41009fcdde27fd48e;p=Evergreen.git Backport changesets 14820, 15063, 15064, 15066: duedate virtual field for non-cat circs that honors closed dates, etc. git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@15303 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 5f36e4fa5a..c31c32f57b 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3316,6 +3316,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm index 4c1226b129..c8c1978087 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm @@ -3,6 +3,9 @@ use base 'OpenILS::Application'; use strict; use warnings; use OpenSRF::EX qw(:try); use Data::Dumper; +use DateTime; +use DateTime::Format::ISO8601; +use OpenSRF::Utils qw/:datetime/; use OpenSRF::Utils::Logger qw(:logger); use OpenILS::Application::AppUtils; use OpenILS::Utils::Fieldmapper; @@ -11,6 +14,7 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/; $Data::Dumper::Indent = 0; my $U = "OpenILS::Application::AppUtils"; +my $_dt_parser = DateTime::Format::ISO8601->new; # returns ( $newid, $evt ). If $evt, then there was an error @@ -34,6 +38,7 @@ sub create_non_cat_circ { $evt = $editor->event unless $circ = $editor->create_action_non_cataloged_circulation( $circ ) + } else { $id = $U->simplereq( 'open-ils.storage', @@ -42,6 +47,11 @@ sub create_non_cat_circ { $circ->id($id); } + if($circ) { + my $e = ($editor) ? $editor : new_editor(); + $circ = noncat_due_date($e, $circ); + } + return( $circ, $evt ); } @@ -145,16 +155,40 @@ __PACKAGE__->register_method( / ); + sub fetch_noncat { my( $self, $conn, $auth, $circid ) = @_; - my $e = OpenILS::Utils::Editor->new( authtoken => $auth ); + my $e = new_editor( authtoken => $auth ); return $e->event unless $e->checkauth; my $c = $e->retrieve_action_non_cataloged_circulation($circid) or return $e->event; if( $c->patron ne $e->requestor->id ) { return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); # XXX rely on editor perm } - return $c; + return noncat_due_date($e, $c); +} + +sub noncat_due_date { + my($e, $circ) = @_; + + my $otype = $e->retrieve_config_non_cataloged_type($circ->item_type) + or return $e->die_event; + + my $duedate = $_dt_parser->parse_datetime( clense_ISO8601($circ->circ_time) ); + $duedate = $duedate + ->add( seconds => interval_to_seconds($otype->circ_duration) ) + ->strftime('%FT%T%z'); + + my $offset = $U->storagereq( + 'open-ils.storage.actor.org_unit.closed_date.overlap', + $circ->circ_lib, + $duedate + ); + + $duedate = $offset->{end} if ($offset); + $circ->duedate($duedate); + + return $circ; } diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index 3e080db9e2..5714540c79 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -289,25 +289,25 @@ circ.checkout.prototype = { var obj = this; try { obj.patron = obj.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ses(),obj.patron_id]); - var params = { - 'patron' : obj.patron, - 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ], - 'staff' : obj.data.list.au[0], - 'template' : 'checkout', - 'callback' : function() { - setTimeout( - function(){ - if (typeof f == 'function') { - setTimeout( - function() { - f(); - }, 1000 - ); - } - }, 1000 - ); - } - }; + var params = { + 'patron' : obj.patron, + 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ], + 'staff' : obj.data.list.au[0], + 'template' : 'checkout', + 'callback' : function() { + setTimeout( + function(){ + if (typeof f == 'function') { + setTimeout( + function() { + f(); + }, 1000 + ); + } + }, 1000 + ); + } + }; if (silent) { params.no_prompt = true; } obj.list.print(params); } catch(E) { @@ -378,16 +378,7 @@ circ.checkout.prototype = { checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() ); checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() ); checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() ); - - JSAN.use('util.date'); - var c = checkout.payload.noncat_circ.circ_time(); - var d = c == "now" ? new Date() : util.date.db_date2Date( c ); - var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ]; - var cd = t.circ_duration() || "14 days"; - var i = util.date.interval_to_seconds( cd ) * 1000; - d.setTime( Date.parse(d) + i ); - checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') ); - + checkout.payload.circ.due_date( checkout.payload.noncat_circ.duedate() ); } } @@ -465,7 +456,7 @@ circ.checkout.prototype = { } document.getElementById('msg_area').appendChild(x); - /* + /* obj.network.request( api.CHECKOUT.app, api.CHECKOUT.method, @@ -474,12 +465,12 @@ circ.checkout.prototype = { _checkout_callback(req,x); } ); - */ + */ if (typeof params.noncat == 'undefined') { obj.items_out_count++; } - - /* new */ - _checkout_callback({ 'getResultObject' : function() { return permit; } },x); + + /* new */ + _checkout_callback({ 'getResultObject' : function() { return permit; } },x); } catch(E) { x.setAttribute('style','color: red'); @@ -558,12 +549,12 @@ circ.checkout.prototype = { { 'title' : document.getElementById('circStrings').getString('staff.circ.checkout.override.confirm'), 'overridable_events' : [ - null /* custom event */, + null /* custom event */, 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */, 1213 /* PATRON_BARRED */, 1215 /* CIRC_EXCEEDS_COPY_RANGE */, - 1232 /* ITEM_DEPOSIT_REQUIRED */, - 1233 /* ITEM_RENTAL_FEE_REQUIRED */, + 1232 /* ITEM_DEPOSIT_REQUIRED */, + 1233 /* ITEM_RENTAL_FEE_REQUIRED */, 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */, 7003 /* COPY_CIRC_NOT_ALLOWED */, 7004 /* COPY_NOT_AVAILABLE */, @@ -573,12 +564,12 @@ circ.checkout.prototype = { 7013 /* PATRON_EXCEEDS_FINES */ ], 'text' : { - '1232' : function(r) { - return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_deposit_required.warning'); - }, - '1233' : function(r) { - return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_rental_fee_required.warning'); - }, + '1232' : function(r) { + return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_deposit_required.warning'); + }, + '1233' : function(r) { + return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_rental_fee_required.warning'); + }, '7004' : function(r) { return r.payload.status().name(); }, @@ -654,7 +645,7 @@ circ.checkout.prototype = { } } - return; + return; } var test_permit; diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index ce474f70c7..661aba4beb 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -156,12 +156,9 @@ patron.items.prototype = { fake_circ.xact_start( nc_circ.circ_time() ); fake_circ.renewal_remaining(0); fake_circ.stop_fines('Non-Cataloged'); + fake_circ.due_date( nc_circ.duedate() ); - JSAN.use('util.date'); - var c = nc_circ.circ_time(); - var d = c == "now" ? new Date() : util.date.db_date2Date( c ); - var t = obj.data.hash.cnct[ nc_circ.item_type() ]; - if (!t) { + if (!obj.data.hash.cnct[ nc_circ.item_type() ]) { var robj2 = obj.network.simple_request('FM_CNCT_RETRIEVE',[ nc_circ.circ_lib() ]); if (typeof robj2.ilsevent != 'undefined') throw(robj); obj.data.stash_retrieve(); @@ -172,12 +169,7 @@ patron.items.prototype = { } } obj.data.stash('hash','list'); - t = obj.data.hash.cnct[ nc_circ.item_type() ]; } - var cd = t.circ_duration() || $("patronStrings").getString('staff.patron.items.show_noncats.14_days'); - var i = util.date.interval_to_seconds( cd ) * 1000; - d.setTime( Date.parse(d) + i ); - fake_circ.due_date( util.date.formatted_date(d,'%F') ); var fake_record = new mvr(); fake_record.title( obj.data.hash.cnct[ nc_circ.item_type() ].name()); @@ -202,12 +194,12 @@ patron.items.prototype = { var obj = this; try { var list = (which==2 ? obj.list2 : obj.list); - JSAN.use('patron.util'); - var params = { - 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), - 'template' : 'items_out' - }; - list.print( params ); + JSAN.use('patron.util'); + var params = { + 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), + 'template' : 'items_out' + }; + list.print( params ); } catch(E) { obj.error.standard_unexpected_error_alert('printing 1',E); } @@ -277,28 +269,28 @@ patron.items.prototype = { } var renew = circ.util.renew_via_barcode( bc, obj.patron_id, function(r) { - try { - if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) { - l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewed',[bc])); - obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ; - obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy; - obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record; - // A renewed circ is a new circ, and has a new circ_id. - obj.list_circ_map[ r[0].payload.circ.id() ] = obj.list_circ_map[ circ_id ]; - } else { - var msg = $("patronStrings").getFormattedString('staff.patron.items.items_renew.not_renewed',[bc, r[0].textcode + r[0].desc]); - l.setAttribute('value', msg); - alert(msg); - } - count--; - if (count == 0) { - //if (window.confirm('Action completed. Refresh list?')) obj.retrieve(); - JSAN.use('util.widgets'); util.widgets.remove_children(x); - } - obj.refresh(circ_id); - } catch(E) { - obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E); - } + try { + if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) { + l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewed',[bc])); + obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ; + obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy; + obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record; + // A renewed circ is a new circ, and has a new circ_id. + obj.list_circ_map[ r[0].payload.circ.id() ] = obj.list_circ_map[ circ_id ]; + } else { + var msg = $("patronStrings").getFormattedString('staff.patron.items.items_renew.not_renewed',[bc, r[0].textcode + r[0].desc]); + l.setAttribute('value', msg); + alert(msg); + } + count--; + if (count == 0) { + //if (window.confirm('Action completed. Refresh list?')) obj.retrieve(); + JSAN.use('util.widgets'); util.widgets.remove_children(x); + } + obj.refresh(circ_id); + } catch(E) { + obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E); + } } ); } @@ -387,15 +379,15 @@ patron.items.prototype = { dump($("patronStrings").getFormattedString('staff.patron.items.items_edit.mark_barcode_lost', [barcode])); var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]); if (typeof robj.ilsevent != 'undefined') { - switch(Number(robj.ilsevent)) { - case 7018 /* COPY_MARKED_LOST */ : - alert( $("patronStrings").getFormattedString('staff.patron.items.items_edit.item_barcode', [barcode, robj.desc]) ); - break; - default: throw(robj); - } - } else { - obj.refresh(retrieve_ids[i].circ_id,true); - } + switch(Number(robj.ilsevent)) { + case 7018 /* COPY_MARKED_LOST */ : + alert( $("patronStrings").getFormattedString('staff.patron.items.items_edit.item_barcode', [barcode, robj.desc]) ); + break; + default: throw(robj); + } + } else { + obj.refresh(retrieve_ids[i].circ_id,true); + } } } catch(E) { obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.items_not_marked_lost'),E); @@ -566,75 +558,75 @@ patron.items.prototype = { ); function retrieve_row(params) { - try { - var row = params.row; - - if (!row.my.circ_id) { - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); - } - return row; - } - - if (!row.my.circ) { - obj.network.simple_request( - 'FM_CIRC_DETAILS.authoritative', - [ row.my.circ_id ], - function(req) { - try { - var robj = req.getResultObject(); - if (typeof robj.ilsevent != 'undefined') throw(robj); - if (typeof robj.ilsevent == 'null') throw('null result'); - row.my.circ = robj.circ; - row.my.acp = robj.copy; - row.my.mvr = robj.mvr; - row.my.acn = robj.volume; - row.my.record = robj.record; - - var copy_id = row.my.circ.target_copy(); - if (typeof copy_id == 'object') { - if (copy_id != null) { - copy_id = copy_id.id(); - } else { - if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); - } - } else { - if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); - } - - params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) ); - - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); - } - } catch(E) { - obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.callback_error'), E); - } - } - ); - } else { - var copy_id = row.my.circ ? row.my.circ.target_copy() : null; - if (typeof copy_id == 'object') { - if (copy_id != null) { - copy_id = copy_id.id(); - } else { - if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id(); - } - } else { - if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id(); - } + try { + var row = params.row; + + if (!row.my.circ_id) { + if (typeof params.on_retrieve == 'function') { + params.on_retrieve(row); + } + return row; + } + + if (!row.my.circ) { + obj.network.simple_request( + 'FM_CIRC_DETAILS.authoritative', + [ row.my.circ_id ], + function(req) { + try { + var robj = req.getResultObject(); + if (typeof robj.ilsevent != 'undefined') throw(robj); + if (typeof robj.ilsevent == 'null') throw('null result'); + row.my.circ = robj.circ; + row.my.acp = robj.copy; + row.my.mvr = robj.mvr; + row.my.acn = robj.volume; + row.my.record = robj.record; + + var copy_id = row.my.circ.target_copy(); + if (typeof copy_id == 'object') { + if (copy_id != null) { + copy_id = copy_id.id(); + } else { + if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); + } + } else { + if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); + } + + params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) ); + + if (typeof params.on_retrieve == 'function') { + params.on_retrieve(row); + } + } catch(E) { + obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.callback_error'), E); + } + } + ); + } else { + var copy_id = row.my.circ ? row.my.circ.target_copy() : null; + if (typeof copy_id == 'object') { + if (copy_id != null) { + copy_id = copy_id.id(); + } else { + if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id(); + } + } else { + if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id(); + } - params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':row.my.acp.id(),'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (row.my.record ? row.my.record.id() : null) }) ); - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); - } - } - - return row; - } catch(E) { - obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.error_in_retrieve_row'),E); - return params.row; - } + params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':row.my.acp.id(),'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (row.my.record ? row.my.record.id() : null) }) ); + if (typeof params.on_retrieve == 'function') { + params.on_retrieve(row); + } + } + + return row; + } catch(E) { + obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.error_in_retrieve_row'),E); + return params.row; + } } JSAN.use('util.list'); obj.list = new util.list('items_list'); @@ -690,24 +682,24 @@ patron.items.prototype = { var obj = this; try { var nparams = obj.list_circ_map[circ_id]; - if (move_to_bottom_list) { - obj.list_circ_map[circ_id].my_node.setAttribute('hidden','true'); + if (move_to_bottom_list) { + obj.list_circ_map[circ_id].my_node.setAttribute('hidden','true'); var nparams2 = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : 1 } ); obj.list_circ_map[circ_id] = nparams2; - } else { - var which_list = nparams.which_list; - switch(which_list) { - case 1: + } else { + var which_list = nparams.which_list; + switch(which_list) { + case 1: case '1': - setTimeout(function(){try{obj.list2.refresh_row(nparams);}catch(E){ + setTimeout(function(){try{obj.list2.refresh_row(nparams);}catch(E){ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000); - break; - default: - setTimeout(function(){try{obj.list.refresh_row(nparams);}catch(E){ + break; + default: + setTimeout(function(){try{obj.list.refresh_row(nparams);}catch(E){ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000); - break; - } - } + break; + } + } } catch(E) { obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row', [circ_id, nparams]),E); }