From c22e59cff942311efc8c57d107aa1ad6d6e73ee1 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 25 Apr 2011 15:32:50 -0400 Subject: [PATCH] fines on reservations no longer break myopac/main (my account) --- Open-ILS/examples/fm_IDL.xml | 2 ++ .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 21 +++++++++++--- .../web/templates/default/opac/myopac/main.tt2 | 33 +++++++++++----------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 724e8f55a0..f71ddd688b 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2262,6 +2262,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -2269,6 +2270,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 7b3384c8d3..c813aabca5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -612,7 +612,9 @@ sub load_myopac_main { { flesh => 4, flesh_fields => { - mobts => ['circulation', 'grocery'], + mobts => [qw/grocery circulation reservation/], + bresv => ['target_resource_type'], + brt => ['record'], mg => ['billings'], mb => ['btype'], circ => ['target_copy'], @@ -639,14 +641,25 @@ sub load_myopac_main { qw/total_paid total_owed balance_owed/ ); + my $marc_xml = undef; + if ($mobts->xact_type eq 'reservation' and + $mobts->reservation->target_resource_type->record) { + $marc_xml = XML::LibXML->new->parse_string( + $mobts->reservation->target_resource_type->record->marc + ); + } elsif ($mobts->xact_type eq 'circulation' and + $circ->target_copy->call_number->id != -1) { + $marc_xml = XML::LibXML->new->parse_string( + $circ->target_copy->call_number->record->marc + ); + } + push( @{$ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}}, { xact => $mobts, last_grocery_billing => $last_billing, - marc_xml => ($mobts->xact_type ne 'circulation' or $circ->target_copy->call_number->id == -1) ? - undef : - XML::LibXML->new->parse_string($circ->target_copy->call_number->record->marc), + marc_xml => $marc_xml } ); } diff --git a/Open-ILS/web/templates/default/opac/myopac/main.tt2 b/Open-ILS/web/templates/default/opac/myopac/main.tt2 index 6f2584b8be..a99cc2d1cb 100644 --- a/Open-ILS/web/templates/default/opac/myopac/main.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/main.tt2 @@ -33,7 +33,11 @@ [% FOR f IN ctx.fines.circulation; attrs = {marc_xml => f.marc_xml}; - PROCESS get_marc_attrs args=attrs %] + IF f.marc_xml; + PROCESS get_marc_attrs args=attrs; + ELSIF f.xact.reservation; + attrs.title = f.xact.reservation.target_resource_type.name; + END %] [% attrs.title %] @@ -42,26 +46,21 @@ [% attrs.author %] - [% date.format( - ctx.parse_datetime( - f.xact.circulation.xact_start - ), DATE_FORMAT - ) %] + [% ts = f.xact.circulation.xact_start || f.xact.reservation.start_time || 0; + IF ts; + date.format(ctx.parse_datetime(ts), DATE_FORMAT); + END %] - [% date.format( - ctx.parse_datetime( - f.xact.circulation.due_date - ), DATE_FORMAT - ) %] + [% ts = f.xact.circulation.due_date || f.xact.reservation.end_time || 0; + IF ts; + date.format(ctx.parse_datetime(ts), DATE_FORMAT); + END %] - [% IF f.xact.circulation.checkin_time; - date.format( - ctx.parse_datetime( - f.xact.circulation.checkin_time - ), DATE_FORMAT - ); + [% ts = f.xact.circulation.checkin_time || f.xact.reservation.return_time || 0; + IF ts; + date.format(ctx.parse_datetime(ts), DATE_FORMAT); ELSE %]