3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 use C4::Charset qw(StripNonXmlChars);
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38 template_name => "opac-readingrecord.tmpl",
42 flagsrequired => { borrow => 1 },
47 # get borrower information ....
48 my ( $borr ) = GetMemberDetails( $borrowernumber );
50 $template->param(%{$borr});
52 my $itemtypes = GetItemTypes();
55 my $order = $query->param('order') || '';
56 if ( $order eq 'title' ) {
57 $template->param( orderbytitle => 1 );
59 elsif ( $order eq 'author' ) {
60 $template->param( orderbyauthor => 1 );
63 $order = "date_due desc";
64 $template->param( orderbydate => 1 );
68 my $limit = $query->param('limit');
70 $limit = ( $limit eq 'full' ) ? 0 : 50;
72 my $issues = GetAllIssues( $borrowernumber, $order, $limit );
75 ( C4::Context->preference('item-level_itypes') ) ? 'itype' : 'itemtype';
77 my $opac_summary_html = C4::Context->preference('OPACMySummaryHTML');
78 foreach my $issue ( @{$issues} ) {
79 $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
80 if ( $issue->{$itype_attribute} ) {
81 $issue->{description} =
82 $itemtypes->{ $issue->{$itype_attribute} }->{description};
84 getitemtypeimagelocation( 'opac',
85 $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
87 if ( $issue->{marcxml} ) {
88 my $marcxml = StripNonXmlChars( $issue->{marcxml} );
90 MARC::Record::new_from_xml( $marcxml, 'utf8',
91 C4::Context->preference('marcflavour') );
93 GetRecordValue( 'subtitle', $marc_rec, $issue->{frameworkcode} );
96 if ($opac_summary_html) {
97 my $my_summary_html = $opac_summary_html;
99 ? $my_summary_html =~ s/{AUTHOR}/$issue->{author}/g
100 : $my_summary_html =~ s/{AUTHOR}//g;
101 my $title = $issue->{title};
102 $title =~ s/\/+$//; # remove trailing slash
103 $title =~ s/\s+$//; # remove trailing space
105 ? $my_summary_html =~ s/{TITLE}/$title/g
106 : $my_summary_html =~ s/{TITLE}//g;
107 $issue->{normalized_isbn}
108 ? $my_summary_html =~ s/{ISBN}/$issue->{normalized_isbn}/g
109 : $my_summary_html =~ s/{ISBN}//g;
110 $issue->{biblionumber}
111 ? $my_summary_html =~ s/{BIBLIONUMBER}/$issue->{biblionumber}/g
112 : $my_summary_html =~ s/{BIBLIONUMBER}//g;
113 $issue->{MySummaryHTML} = $my_summary_html;
117 if (C4::Context->preference('BakerTaylorEnabled')) {
120 BakerTaylorEnabled => 1,
121 BakerTaylorImageURL => &image_url(),
122 BakerTaylorLinkURL => &link_url(),
123 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
128 if (C4::Context->preference('BakerTaylorEnabled')) {
129 require C4::External::BakerTaylor;
130 import C4::External::BakerTaylor qw(&image_url &link_url);
134 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
135 C4::Context->preference($_) or next;
136 $template->param($_=>1);
137 $template->param(JacketImages=>1);
141 READING_RECORD => $issues,
145 OPACMySummaryHTML => $opac_summary_html ? 1 : 0,
148 output_html_with_http_headers $query, $cookie, $template->output;