[open-ils-commits] r15304 - in branches/rel_1_4/Open-ILS: examples src/perlmods/OpenILS/Application/Circ xul/staff_client/server/circ xul/staff_client/server/patron (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 12 11:07:16 EST 2010
Author: phasefx
Date: 2010-01-12 11:07:13 -0500 (Tue, 12 Jan 2010)
New Revision: 15304
Modified:
branches/rel_1_4/Open-ILS/examples/fm_IDL.xml
branches/rel_1_4/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm
branches/rel_1_4/Open-ILS/xul/staff_client/server/circ/checkout.js
branches/rel_1_4/Open-ILS/xul/staff_client/server/patron/items.js
Log:
Backport changesets 14820, 15063, 15064, 15066: duedate virtual field for non-cat circs that honors closed dates, etc.
Modified: branches/rel_1_4/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/rel_1_4/Open-ILS/examples/fm_IDL.xml 2010-01-12 15:52:41 UTC (rev 15303)
+++ branches/rel_1_4/Open-ILS/examples/fm_IDL.xml 2010-01-12 16:07:13 UTC (rev 15304)
@@ -3025,6 +3025,7 @@
<field reporter:label="Non-cat Item Type" name="item_type" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="link"/>
<field reporter:label="Patron" name="patron" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="link"/>
<field reporter:label="Circulating Staff" name="staff" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field reporter:label="Virtual Due Date/Time" name="duedate" reporter:datatype="timestamp" oils_persist:virtual="true"/>
</fields>
<links>
<link field="item_type" reltype="has_a" key="id" map="" class="cnct"/>
Modified: branches/rel_1_4/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm
===================================================================
--- branches/rel_1_4/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm 2010-01-12 15:52:41 UTC (rev 15303)
+++ branches/rel_1_4/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm 2010-01-12 16:07:13 UTC (rev 15304)
@@ -3,6 +3,9 @@
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 @@
$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 @@
$evt = $editor->event unless
$circ = $editor->create_action_non_cataloged_circulation( $circ )
+
} else {
$id = $U->simplereq(
'open-ils.storage',
@@ -42,6 +47,11 @@
$circ->id($id);
}
+ if($circ) {
+ my $e = ($editor) ? $editor : new_editor();
+ $circ = noncat_due_date($e, $circ);
+ }
+
return( $circ, $evt );
}
@@ -145,20 +155,44 @@
/
);
+
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;
+}
+
+
+
__PACKAGE__->register_method(
method => 'fetch_open_noncats',
authoritative => 1,
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/server/circ/checkout.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/server/circ/checkout.js 2010-01-12 15:52:41 UTC (rev 15303)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/server/circ/checkout.js 2010-01-12 16:07:13 UTC (rev 15304)
@@ -289,25 +289,25 @@
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,15 +378,7 @@
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.due_date() );
}
}
@@ -465,7 +457,7 @@
}
document.getElementById('msg_area').appendChild(x);
- /*
+ /*
obj.network.request(
api.CHECKOUT.app,
api.CHECKOUT.method,
@@ -474,12 +466,12 @@
_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');
@@ -561,8 +553,8 @@
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 */,
@@ -572,12 +564,12 @@
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();
},
@@ -653,7 +645,7 @@
}
}
- return;
+ return;
}
var test_permit;
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/server/patron/items.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/server/patron/items.js 2010-01-12 15:52:41 UTC (rev 15303)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/server/patron/items.js 2010-01-12 16:07:13 UTC (rev 15304)
@@ -156,12 +156,9 @@
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 @@
}
}
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 @@
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 @@
}
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 @@
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 @@
);
function retrieve_row(params) {
- try {
- var row = params.row;
+ 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();
- }
+ 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 @@
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);
}
More information about the open-ils-commits
mailing list