Bugzilla – Attachment 156440 Details for
Bug 33949
Replace GetAllIssues with Koha::Checkouts - opac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33949: Replace GetAllIssues with Koha::Checkouts - opac
Bug-33949-Replace-GetAllIssues-with-KohaCheckouts-.patch (text/plain), 16.22 KB, created by
David Nind
on 2023-09-30 20:55:11 UTC
(
hide
)
Description:
Bug 33949: Replace GetAllIssues with Koha::Checkouts - opac
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-30 20:55:11 UTC
Size:
16.22 KB
patch
obsolete
>From 3738f9df944a7d05d93284a07893693692fc22b0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Jun 2023 10:00:53 +0200 >Subject: [PATCH] Bug 33949: Replace GetAllIssues with Koha::Checkouts - opac > >Same as bug 33948 for the OPAC side. >Additionally you will test >* OPACMySummaryHTML >* The different cover images services >* Display of ISBN >* Display of UPC >* Ratings > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../en/modules/opac-readingrecord.tt | 90 +++++++++-------- > opac/opac-readingrecord.pl | 98 ++++++------------- > 2 files changed, 79 insertions(+), 109 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >index 947561e9ae..6fe6bd9a76 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >@@ -47,8 +47,8 @@ > > <div id="userreadingrecord" class="maincontent"> > <h1>Checkout history</h1> >- >- [% IF READING_RECORD.size == 0 %] >+ [% SET all_checkouts = checkouts.merge(old_checkouts) %] >+ [% IF all_checkouts.size == 0 %] > You have never borrowed anything from this library. > [% ELSE %] > <div id="opac-user-readingrec"> >@@ -96,16 +96,16 @@ > [% END # /WRAPPER tabs_nav %] > [% WRAPPER tab_panels %] > [% WRAPPER tab_panel tabname="tabs-container" bt_active= 1 %] >- [% PROCESS checkout_history_table %] >+ [% PROCESS checkout_history_table checkouts=all_checkouts %] > [% END # /tab_panel# %] > [% END # /WRAPPER tab_panels %] > [% END # /WRAPPER tabs %] > [% ELSE %] >- [% PROCESS checkout_history_table %] >+ [% PROCESS checkout_history_table checkouts=all_checkouts %] > [% END %] > > </div> <!-- / .opac-user-readingrec --> >- [% END # / IF READING_RECORD.size %] >+ [% END # / IF checkouts.size == 0 %] > </div> <!-- / .userreadingrecord --> > </div> <!-- / .col-lg-10 --> > </div> <!-- / .row --> >@@ -125,91 +125,103 @@ > <th>Call number</th> > <th>Vol info</th> > <th>Date</th> >- [% IF ( OPACMySummaryHTML ) %] >+ [% IF Koha.Preference('OPACMySummaryHTML') %] > <th class="NoSort noExport">Links</th> > [% END %] > <th></th> > </tr> > </thead> > <tbody> >- [% FOREACH issue IN READING_RECORD %] >+ [% FOREACH checkout IN checkouts %] >+ [% SET item = checkout.item %] >+ [% SET biblio = item.biblio %] > <tr> > <td style="display:none;"> >- [% IF issue.onsite_checkout %][% issuetype = 'onsite_checkout' %] >+ [% IF checkout.onsite_checkout %][% issuetype = 'onsite_checkout' %] > [% ELSE %][% issuetype = 'standard_checkout' %] > [% END %] > [% issuetype | html %] > </td> > <td> >- [% IF OPACAmazonCoverImages %] >- [% IF issue.normalized_isbn %] >- <a href="http://www.amazon.com/gp/reader/[% issue.normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"><img src="https://images-na.ssl-images-amazon.com/images/P/[% issue.normalized_isbn | html %].01.THUMBZZZ.jpg" alt="" class="item-thumbnail" /></a> >+ [% SET normalized_isbn = biblio.normalized_isbn %] >+ [% IF OPACAmazonCoverImages %] >+ [% IF normalized_isbn %] >+ <a href="http://www.amazon.com/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"><img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.THUMBZZZ.jpg" alt="" class="item-thumbnail" /></a> > [% ELSE %] > <span class="no-image">No cover image available</span> > [% END %] > [% END %] > > [% IF GoogleJackets %] >- [% IF issue.normalized_isbn %] >- <div title="[% issue.biblionumber |url %]" class="[% issue.normalized_isbn | html %]" id="gbs-thumbnail[% loop.count | html %]"></div> >+ [% IF normalized_isbn %] >+ <div title="[% biblio.biblionumber |url %]" class="[% normalized_isbn | html %]" id="gbs-thumbnail[% loop.count | html %]"></div> > [% ELSE %] >- <span class="no-image">No cover image available</span> >+ <span class="no-image">No cover image available</span> > [% END %] > [% END %] > >- [% IF BakerTaylorEnabled %] >- [% bt_id = ( issue.normalized_upc || issue.normalized_isbn ) %] >- [% IF ( bt_id ) %] >- <a href="https://[% BakerTaylorBookstoreURL | uri %][% bt_id | uri %]"><img alt="See Baker & Taylor" src="[% BakerTaylorImageURL | html %][% bt_id | html %]" /></a> >- [% ELSE %] >- <span class="no-image">No cover image available</span> >- [% END %] >+ [% IF BakerTaylorEnabled || SyndeticsEnabled && SyndeticsCoverImages %] >+ [% SET normalized_upc = biblio.normalized_upc %] >+ [% END %] >+ [% IF BakerTaylorEnabled %] >+ [% bt_id = ( normalized_upc || normalized_isbn ) %] >+ [% IF ( bt_id ) %] >+ <a href="https://[% BakerTaylorBookstoreURL | uri %][% bt_id | uri %]"><img alt="See Baker & Taylor" src="[% BakerTaylorImageURL | html %][% bt_id | html %]" /></a> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] > [% END %] > > [% IF SyndeticsEnabled && SyndeticsCoverImages %] >- <img src="https://secure.syndetics.com/index.aspx?isbn=[% issue.normalized_isbn | html %]/[% SyndeticsCoverImageSize | uri %].GIF&client=[% SyndeticsClientCode | html %]&type=xw10&upc=[% issue.normalized_upc | html %]&oclc=[% issue.normalized_oclc | html %]" alt="" class="item-thumbnail" /> >+ <img src="https://secure.syndetics.com/index.aspx?isbn=[% normalized_isbn | html %]/[% SyndeticsCoverImageSize | uri %].GIF&client=[% SyndeticsClientCode | html %]&type=xw10&upc=[% normalized_upc | html %]&oclc=[% biblio.normalized_oclc | html %]" alt="" class="item-thumbnail" /> > [% END %] > </td> > <td> >- [% INCLUDE 'biblio-title.inc' biblio=issue, link => 1 %] >+ [% INCLUDE 'biblio-title.inc' biblio=biblio, link => 1 %] > [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' ) %] >- [% INCLUDE 'user-star-ratings.inc' item=issue %] >+ [% SET ratings = {ratings => biblio.ratings, itemnumber => item.itemnumber, biblionumber => biblio.biblionumber, my_rating => biblio.ratings.search( borrowernumber => logged_in_user.borrowernumber ).next } %] >+ [% INCLUDE 'user-star-ratings.inc' item=ratings %] > [% END %] > </td> >- <td>[% issue.author | html %]</td> >+ <td>[% biblio.author | html %]</td> > <td> >+ [% SET item_type = item_types.${item.effective_itemtype} %] > [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] >- [% IF ( issue.imageurl ) %] >- <img src="[% issue.imageurl | html %]" alt="" /> >+ [% SET image_location = item_type.image_location %] >+ [% IF image_location %] >+ <img src="[% image_location | html %]" alt="" /> > [% END %] > [% END %] >- <span class="itypetext"><span class="tdlabel">Item type:</span> >- [% issue.translated_description | html %]</span> >+ <span class="itypetext"> >+ <span class="tdlabel">Item type:</span> >+ [% item_type.translated_description | html %] >+ </span> > </td> > <td> > <span class="tdlabel">Call number:</span> >- [% issue.itemcallnumber | html %] >+ [% item.itemcallnumber | html %] > </td> > <td> >- [% IF issue.enumchron %] >- [% issue.enumchron | html %] >+ [% IF item.enumchron %] >+ [% item.enumchron | html %] > [% END %] > </td> >- [% IF issue.returndate %] >- <td data-order="[% issue.returndate | html %]"> >+ [% IF checkout.returndate %] >+ <td data-order="[% checkout.returndate | html %]"> > <span class="tdlabel">Check-in date:</span> >- [% issue.returndate | $KohaDates %] >+ [% checkout.returndate | $KohaDates %] >+ </td> > [% ELSE %] > <td data-order="Checked out"> > <em>(Checked out)</em> >+ </td> > [% END %] >- </td> >- [% IF OPACMySummaryHTML %] >- <td>[% issue.MySummaryHTML | $raw %]</td> >+ [% IF Koha.Preference('OPACMySummaryHTML') %] >+ <td>[% biblio.opac_summary_html | $raw %]</td> > [% END %] > <td></td> > </tr> >- [% END # / FOREACH issue %] >+ [% END # / FOREACH checkout %] > </tbody> > </table> > [% END %] >diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl >index 7ee0a5f697..a671ca0f01 100755 >--- a/opac/opac-readingrecord.pl >+++ b/opac/opac-readingrecord.pl >@@ -21,23 +21,14 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > > use C4::Auth qw( get_template_and_user ); >-use C4::Koha qw( >- getitemtypeimagelocation >- GetNormalizedISBN >- GetNormalizedUPC >- GetNormalizedOCLCNumber >-); > use C4::Biblio; >-use C4::Members qw( GetAllIssues ); > use C4::External::BakerTaylor qw( image_url link_url ); > use MARC::Record; > > use C4::Output qw( output_html_with_http_headers ); >-use C4::Charset qw( StripNonXmlChars ); > use Koha::Patrons; > > use Koha::ItemTypes; >-use Koha::Ratings; > > my $query = CGI->new; > >@@ -55,7 +46,12 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; >+my $patron = Koha::Patrons->find( $borrowernumber ); >+my @itemtypes = Koha::ItemTypes->search_with_localization->as_list; >+my %item_types = map { >+ $_->itemtype => $_ >+} @itemtypes; >+$template->param(item_types => \%item_types); > > # get the record > my $order = $query->param('order') || ''; >@@ -75,64 +71,27 @@ my $limit = $query->param('limit'); > $limit //= ''; > $limit = ( $limit eq 'full' ) ? 0 : 50; > >-my $issues = GetAllIssues( $borrowernumber, $order, $limit ); >- >-my $itype_attribute = >- ( C4::Context->preference('item-level_itypes') ) ? 'itype' : 'itemtype'; >- >-my $opac_summary_html = C4::Context->preference('OPACMySummaryHTML'); >-foreach my $issue ( @{$issues} ) { >- $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} ); >- if ( $issue->{$itype_attribute} ) { >- $issue->{translated_description} = >- $itemtypes->{ $issue->{$itype_attribute} }->{translated_description}; >- $issue->{imageurl} = >- getitemtypeimagelocation( 'opac', >- $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} ); >- } >- >- if ( C4::Context->preference('BakerTaylorEnabled') >- || C4::Context->preference('SyndeticsEnabled') >- || C4::Context->preference('SyndeticsCoverImages') ) >- { >- my $marcxml = C4::Biblio::GetXmlBiblio( $issue->{biblionumber} ); >- if ( $marcxml ) { >- $marcxml = StripNonXmlChars( $marcxml ); >- my $marc_rec = >- MARC::Record::new_from_xml( $marcxml, 'UTF-8', >- C4::Context->preference('marcflavour') ); >- $issue->{normalized_upc} = GetNormalizedUPC( $marc_rec, C4::Context->preference('marcflavour') ); >- $issue->{normalized_oclc} = GetNormalizedOCLCNumber($marc_rec, C4::Context->preference('marcflavour')); >+my $checkouts = [ >+ $patron->checkouts( >+ {}, >+ { >+ order_by => $order, >+ prefetch => { item => { biblio => 'biblioitems' } }, >+ ( $limit ? ( limit => $limit ) : () ), > } >- >- } >- # My Summary HTML >- if ($opac_summary_html) { >- my $my_summary_html = $opac_summary_html; >- $issue->{author} >- ? $my_summary_html =~ s/{AUTHOR}/$issue->{author}/g >- : $my_summary_html =~ s/{AUTHOR}//g; >- my $title = $issue->{title}; >- $title =~ s/\/+$//; # remove trailing slash >- $title =~ s/\s+$//; # remove trailing space >- $title >- ? $my_summary_html =~ s/{TITLE}/$title/g >- : $my_summary_html =~ s/{TITLE}//g; >- $issue->{normalized_isbn} >- ? $my_summary_html =~ s/{ISBN}/$issue->{normalized_isbn}/g >- : $my_summary_html =~ s/{ISBN}//g; >- $issue->{biblionumber} >- ? $my_summary_html =~ s/{BIBLIONUMBER}/$issue->{biblionumber}/g >- : $my_summary_html =~ s/{BIBLIONUMBER}//g; >- $issue->{MySummaryHTML} = $my_summary_html; >- } >- # Star ratings >- if ( C4::Context->preference('OpacStarRatings') eq 'all' ) { >- my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} }); >- $issue->{ratings} = $ratings; >- $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef; >- } >-} >+ )->as_list >+]; >+$limit -= scalar(@$checkouts) if $limit; >+my $old_checkouts = [ >+ $patron->old_checkouts( >+ {}, >+ { >+ order_by => $order, >+ prefetch => { item => { biblio => 'biblioitems' } }, >+ ( $limit ? ( limit => $limit ) : () ), >+ } >+ )->as_list >+]; > > if (C4::Context->preference('BakerTaylorEnabled')) { > $template->param( >@@ -152,15 +111,14 @@ for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above > > my $saving_display = C4::Context->preference('OPACShowSavings'); > if ( $saving_display =~ /checkouthistory/ ) { >- my $patron = Koha::Patrons->find( $borrowernumber ); > $template->param( savings => $patron->get_savings ); > } > > $template->param( >- READING_RECORD => $issues, >+ checkouts => $checkouts, >+ old_checkouts => $old_checkouts, > limit => $limit, > readingrecview => 1, >- OPACMySummaryHTML => $opac_summary_html ? 1 : 0, > ); > > output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33949
:
152155
|
152177
|
155781
|
155782
|
156440
|
156441
|
156957
|
156958