$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',
$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(
'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};
[%- END %]
<th scope='col'>[% l("Status") %]</th>
<th scope='col'>[% l("Due Date") %]</th>
+ [%- IF ctx.get_org_setting(ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %]
+ <th scope='col'>[% l("Courses") %]</th>
+ [%- END %]
</tr>
</thead>
<tbody class="copy_details_table">
<td>[% bib.target_copy.location.name | html %]</td>
<td>[% bib.target_copy.status.name | html %]</td>
<td>[% date.format(ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib),DATE_FORMAT) %]</td>
+ [%- IF ctx.get_org_setting(CGI.param('loc')
+ OR ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %]
+ <td></td>
+ [%- END %]
</tr>
[%- END; # FOREACH peer
END; # FOREACH bib
ELSE;
'-';
END %]</td>
+ [%- IF ctx.get_org_setting(ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %]
+ <td>[%- FOREACH course IN copy_info.courses %]
+ <div>[% course.course_number %]</div>
+ [% END %]</td>
+ [% END %]
</tr>
[% IF copy_info.notes; %]