OPAC Search Result Course Information
authorKyle Huckins <khuckins@catalyte.io>
Sat, 7 Dec 2019 07:39:24 +0000 (07:39 +0000)
committerKyle Huckins <khuckins@catalyte.io>
Thu, 9 Jan 2020 17:45:32 +0000 (17:45 +0000)
- Provide Associated Course names and numbers on
OPAC Catalog search results.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
 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/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
modified:   Open-ILS/src/templates/opac/parts/result/table.tt2

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/templates/opac/parts/result/table.tt2

index d3ecaf8..09e219e 100644 (file)
@@ -1062,17 +1062,17 @@ __PACKAGE__->register_method(
     /);
 
 sub fetch_course_materials {
-    my ($self, $conn, $copy_id) = @_;
+    my ($self, $conn, $args) = @_;
     my $e = new_editor();
 
-    return $e->search_asset_course_module_course_materials({item => $copy_id});
+    return $e->search_asset_course_module_course_materials($args);
 }
 
 sub fetch_courses {
     my ($self, $conn, @course_ids) = @_;
     my $e = new_editor();
-    return unless @course_ids;
 
+    return unless @course_ids;
     my $targets = ();
     foreach my $course_id (@course_ids) {
         my $target = $e->retrieve_asset_course_module_course($course_id);
index 9057258..6cb4df9 100644 (file)
@@ -120,7 +120,7 @@ sub load_record {
             $copy->{course_materials} = $U->simplereq(
                 'open-ils.circ',
                 'open-ils.circ.course_materials.retrieve',
-                $copy->{id}
+                {item => $copy->{id}}
             );
             my %course_ids;
             for my $material (@{$copy->{course_materials}}) {
index c21566a..39d86ae 100644 (file)
@@ -568,10 +568,32 @@ sub load_rresults {
         }
     }
 
+    my $course_module_opt_in = 0;
+    if ($ctx->{get_org_setting}->($self->_get_search_lib, "circ.course_materials_opt_in")) {
+        $course_module_opt_in = 1;
+    }
+
     for my $rec (@{$ctx->{records}}) {
         my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
         $rec->{badges} = [split(',', $res_rec->[1])] if $res_rec->[1];
         $rec->{popularity} = $res_rec->[2];
+        if ($course_module_opt_in) {
+            $rec->{course_materials} = $U->simplereq(
+                'open-ils.circ',
+                'open-ils.circ.course_materials.retrieve',
+                {record => $rec->{id}}
+            );
+            my %course_ids;
+            for my $material (@{$rec->{course_materials}}) {
+                $course_ids{$material->course} = 1;
+            }
+
+            $rec->{courses} = $U->simplereq(
+                'open-ils.circ',
+                'open-ils.circ.courses.retrieve',
+                keys %course_ids
+            );
+        }
         if ($tag_circs) {
             # index 3 (5 for MR) in the per-record result array is a boolean which
             # indicates whether the record in question is in the users
@@ -580,6 +602,7 @@ sub load_rresults {
             $rec->{user_circulated} = 1 if $res_rec->[$index];
         }
     }
+    
 
     $ctx->{search_facets} = $facets;
 
@@ -898,4 +921,4 @@ sub staff_save_search {
     return ($cache_key, $list);
 }
 
-1;
+1;
\ No newline at end of file
index c06f440..772ec4e 100644 (file)
@@ -405,6 +405,17 @@ END;
                                                     [% UNLESS rec.mmr_id;
                                                             PROCESS "opac/parts/result/copy_counts.tt2";
                                                         END; %]
+                                                    [%- IF ctx.get_org_setting(ctx.search_ou, 'circ.course_materials_opt_in') == 1 %]
+                                                        [%- courseStrings = [] %]
+                                                        [% FOREACH course IN rec.courses %]
+                                                            [% courseString = course.name _ ' (' _ course.course_number _ ')' %]
+                                                            [% courseStrings.push(courseString); %]
+                                                        [% END %]
+                                                        [% IF courseStrings.size > 0 %]
+                                                            <span><strong>[% l('Associated Courses: ') %]</strong></span>
+                                                            <span>[% courseStrings.join(', ') %]</span>
+                                                        [% END %]
+                                                    [% END %]
                                                     [% IF rec.user_circulated %]
                                                     <div class="result_item_circulated">
                                                         <img src="[% ctx.media_prefix %]/images/green_check.png[% ctx.cache_key %]" alt="[% l('Checked Out Before') %]"/>