From: Kyle Huckins Date: Fri, 6 Dec 2019 23:12:25 +0000 (+0000) Subject: OPAC Catalog Result Course Column X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3fe7cbb017b8c48d9b304cb8cde9693a0614db49;p=working%2FEvergreen.git OPAC Catalog Result Course Column - Implement Course column to view Course Numbers of classes associated with individual copies. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm modified: Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm modified: Open-ILS/src/templates/opac/parts/record/copy_table.tt2 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index bb4412b6d9..4543301bb3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -1044,6 +1044,44 @@ sub delete_copy_note { $e->commit; return 1; } +__PACKAGE__->register_method( + method => 'fetch_course_materials', + autoritative => 1, + api_name => 'open-ils.circ.course_materials.retrieve', + signature => q/ + Returns an array of course materials. + @params copy_id : The id of the item who's materials we want to retrieve + /); + +__PACKAGE__->register_method( + method => 'fetch_courses', + autoritative => 1, + api_name => 'open-ils.circ.courses.retrieve', + signature => q/ + Returns an array of course materials. + @params course_id: The id of the course we want to retrieve + /); + +sub fetch_course_materials { + my ($self, $conn, $copy_id) = @_; + my $e = new_editor(); + + return $e->search_asset_course_module_course_materials({item => $copy_id}); +} + +sub fetch_courses { + my ($self, $conn, @course_ids) = @_; + my $e = new_editor(); + return unless @course_ids; + + my $targets = (); + foreach my $course_id (@course_ids) { + my $target = $e->retrieve_asset_course_module_course($course_id); + push @$targets, $target; + } + + return $targets; +} __PACKAGE__->register_method( method => 'fetch_copy_tags', 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 bc3972bac8..9057258112 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -102,8 +102,13 @@ sub load_record { $ctx->{copies} = $copy_rec->gather(1); + my $course_module_opt_in = 0; + if ($ctx->{get_org_setting}->($org, "circ.course_materials_opt_in")) { + $course_module_opt_in = 1; + } + # Add public copy notes to each copy - and while we're in there, grab peer bib records - # and copy tags + # and copy tags. Oh and if we're working with course materials, those too. my %cached_bibs = (); foreach my $copy (@{$ctx->{copies}}) { $copy->{notes} = $U->simplereq( @@ -111,6 +116,23 @@ sub load_record { 'open-ils.circ.copy_note.retrieve.all', {itemid => $copy->{id}, pub => 1 } ); + if ($course_module_opt_in) { + $copy->{course_materials} = $U->simplereq( + 'open-ils.circ', + 'open-ils.circ.course_materials.retrieve', + $copy->{id} + ); + my %course_ids; + for my $material (@{$copy->{course_materials}}) { + $course_ids{$material->course} = 1; + } + + $copy->{courses} = $U->simplereq( + 'open-ils.circ', + 'open-ils.circ.courses.retrieve', + keys %course_ids + ); + } $self->timelog("past copy note retrieval call"); my $meth = 'open-ils.circ.copy_tags.retrieve'; $meth .= ".staff" if $ctx->{is_staff}; diff --git a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 index 9d126f6444..f09e37b645 100644 --- a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 @@ -54,6 +54,9 @@ IF has_copies or ctx.foreign_copies; [%- END %] [% l("Status") %] [% l("Due Date") %] + [%- IF ctx.get_org_setting(ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %] + [% l("Courses") %] + [%- END %] @@ -75,6 +78,10 @@ IF has_copies or ctx.foreign_copies; [% bib.target_copy.location.name | html %] [% bib.target_copy.status.name | html %] [% date.format(ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib),DATE_FORMAT) %] + [%- IF ctx.get_org_setting(CGI.param('loc') + OR ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %] + + [%- END %] [%- END; # FOREACH peer END; # FOREACH bib @@ -223,6 +230,11 @@ END; # FOREACH bib ELSE; '-'; END %] + [%- IF ctx.get_org_setting(ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %] + [%- FOREACH course IN copy_info.courses %] +
[% course.course_number %]
+ [% END %] + [% END %] [% IF copy_info.notes; %]