From 4fa8c92e0db026b98104933bdecff8331d23b5cd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 14 Feb 2011 06:28:50 -0500 Subject: [PATCH] added support for copy paging/sorting --- .../lib/OpenILS/WWW/EGCatLoader/Record.pm | 98 +++++++++++++++++-- .../web/templates/default/opac/record.tt2 | 11 +++ 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index e8f6a4af1f..aeb7108560 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -13,23 +13,101 @@ sub load_record { my $self = shift; $self->ctx->{page} = 'record'; + my $org = $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id; + my $depth = $self->cgi->param('depth') || 0; + my $copy_limit = $self->cgi->param('copy_limit'); + my $copy_offset = $self->cgi->param('copy_offset'); + my $rec_id = $self->ctx->{page_args}->[0] or return Apache2::Const::HTTP_BAD_REQUEST; - $self->ctx->{record} = $self->editor->retrieve_biblio_record_entry([ - $rec_id, - { - flesh => 2, - flesh_fields => { - bre => ['call_numbers'], - acn => ['copies'] # limit, paging, etc. - } - } - ]); + # run copy retrieval in parallel to bib retrieval + my $copy_rec = OpenSRF::AppSession->create('open-ils.cstore')->request( + 'open-ils.cstore.json_query.atomic', + $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset)); + $self->ctx->{record} = $self->editor->retrieve_biblio_record_entry($rec_id); $self->ctx->{marc_xml} = XML::LibXML->new->parse_string($self->ctx->{record}->marc); + $self->ctx->{copies} = $copy_rec->gather(1); + return Apache2::Const::OK; } +sub mk_copy_query { + my $self = shift; + my $rec_id = shift; + my $org = shift; + my $depth = shift; + my $copy_limit = shift || 20; + my $copy_offset = shift || 0; + + my $query = { + select => { + acp => ['id', 'barcode', 'circ_lib'], + acpl => [{column => 'name', alias => 'copy_location'}], + ccs => [{column => 'name', alias => 'copy_status'}], + acn => [ + {column => 'label', alias => 'call_number_label'}, + {column => 'id', alias => 'call_number'} + ], + circ => ['due_date'], + }, + from => { + acp => { + acn => {}, + acpl => {}, + ccs => {}, + circ => {type => 'left'}, + aou => {} + } + }, + where => { + '+acp' => { + deleted => 'f', + call_number => { + in => { + select => {acn => ['id']}, + from => 'acn', + where => {record => $rec_id} + } + }, + circ_lib => { + in => { + select => {aou => [{ + column => 'id', + transform => 'actor.org_unit_descendants', + result_field => 'id', + params => [$depth] + }]}, + from => 'aou', + where => {id => $org} + } + } + }, + '+acn' => {deleted => 'f'}, + '+circ' => {checkin_time => undef} + }, + + # Order is: copies with circ_lib=org, followed by circ_lib name, followed by call_number label + order_by => [ + {class => 'aou', field => 'name'}, + {class => 'acn', field => 'label'} + ], + + limit => $copy_limit, + offset => $copy_offset + }; + + # Filter hidden items if this is the public catalog + unless($self->ctx->{is_staff}) { + $query->{where}->{'+acp'}->{opac_visible} = 't'; + $query->{where}->{'+acpl'}->{opac_visible} = 't'; + $query->{where}->{'+ccs'}->{opac_visible} = 't'; + } + + return $query; + #return $self->editor->json_query($query); +} + 1; diff --git a/Open-ILS/web/templates/default/opac/record.tt2 b/Open-ILS/web/templates/default/opac/record.tt2 index 04e33cbb40..6e4368fba9 100644 --- a/Open-ILS/web/templates/default/opac/record.tt2 +++ b/Open-ILS/web/templates/default/opac/record.tt2 @@ -12,4 +12,15 @@
+ [%# TODO: TEST CODE, DELETE ME... %] + [% FOR copy_info IN ctx.copies %] +
+ [% + copy_info.id _ ' ' _ copy_info.barcode _ ' ' _ ctx.find_aou(copy_info.circ_lib).name _ + ' ' _ copy_info.copy_location _ ' ' _ copy_info.copy_status _ + ' ' _ copy_info.call_number_label _ ' ' _ copy_info.call_number _ ' '; + IF copy_info.due_date; date.format(ctx.parse_datetime(copy_info.due_date),'%m/%d/%Y'); END; + %] +
+ [% END %] [% END %] -- 2.43.2