Bug 19935: Replace GetPendingIssues - opac-ics.pl
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 8 Jan 2018 14:47:46 +0000 (11:47 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 3 Apr 2018 14:43:38 +0000 (11:43 -0300)
We only need the biblio title and the barcode, we should not need the
whole prefetch.

Test plan:
On your OPAC summary page export your checkout list using the
"Download as iCal/.ics file" link.
Before and after the patchset, the generated files must be the same

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@deichman.no>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
opac/opac-ics.pl

index c4da67e..1fbf351 100755 (executable)
@@ -50,13 +50,15 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 # Create Calendar
 my $calendar = Data::ICal->new();
 
-# get issued items ....
-my $issues = GetPendingIssues($borrowernumber);
+my $patron = Koha::Patrons->find( $borrowernumber );
+my $pending_checkouts = $patron->pending_checkouts;
 
-foreach my $issue ( @$issues ) {
+while ( my $c = $pending_checkouts->next ) {
+    my $issue = $c->unblessed_all_relateds;
     my $vevent = Data::ICal::Entry::Event->new();
     my $timestamp = DateTime->now(); # Defaults to UTC
     # Send some values to the template to generate summary and description
+    $issue->{overdue} = $c->is_overdue;
     $template->param(
         overdue => $issue->{'overdue'},
         title   => $issue->{'title'},