From a9ee3c97ede84012dd8c13826bfa34e3d2808367 Mon Sep 17 00:00:00 2001 From: danyonsewell Date: Tue, 20 Aug 2024 05:11:45 +0000 Subject: [PATCH] Bug 37463: Show Amazon cover images in checkouts table for selected patron categories This patch allows cover images to display in the patron checkout module for selected patron categories but only ones from Amazon for now. Test plan: Step 1 - apply this patch Step 2 - Make sure AmazonCoverImages syspref is set to "show" step 3 - Search for the CoverImagesCategories syspref and enable it for a specific patron category (choose the category that your patron account is) step 4 - checkout an item to your patron account step 5 - in the patron checkouts page, click the "show checkouts" button, you should see the items cover image there, as long as there is one available from Amazon Signed-off-by: Roman Dolny --- ...ug_37463-add_CoverImagesCategories_syspref.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/circulation.pref | 5 +++++ koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 8 ++++++++ svc/checkouts | 16 ++++++++++++++-- 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_37463-add_CoverImagesCategories_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_37463-add_CoverImagesCategories_syspref.pl b/installer/data/mysql/atomicupdate/bug_37463-add_CoverImagesCategories_syspref.pl new file mode 100755 index 0000000000..0ab6e4d78b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37463-add_CoverImagesCategories_syspref.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "37463", + description => "Add new system preference CoverImagesCategories", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('CoverImagesCategories', '', NULL, 'Cover images will show in the patron checkouts table for selected patron categories. Please note: this only currently works for Amazon cover images.:', 'Free')} + ); + + say $out "Added system preference 'CoverImagesCategories'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 1a7cd033e9..99561ee36f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -175,6 +175,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ContentWarningField', '', NULL, 'MARC field to use for content warnings', 'Free'), ('CookieConsent', '0', NULL, 'Require cookie consent to be displayed', 'YesNo'), ('CookieConsentedJS', '', NULL, 'Add Javascript code that will run if cookie consent is provided (e.g. tracking code).', 'Free'), +('CoverImagesCategories', '', NULL, 'Cover images will show in the patron checkouts table for selected patron categories. Please note: this only currently works for Amazon cover images', 'Free'), ('CreateAVFromCataloguing', '1', '', 'Ability to create authorized values from the cataloguing module', 'YesNo'), ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'), ('CSVDelimiter',',',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 76983576a6..2951e64b4d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -1284,6 +1284,11 @@ Circulation: - pref: SelfCheckAllowByIPRanges class: short - (Leave blank if not used. Use ranges or simple IP addresses separated by spaces, like 192.168.1.1 192.168.0.0/24.) + - + - "Cover images will show in the patron checkouts table for selected patron categories. Please note: this only currently works for Amazon cover images" + - pref: CoverImagesCategories + choices: patron-categories + class: multiple - - "Patron categories allowed to check out in a batch while logged into the self checkout system:" - pref: SCOBatchCheckoutsValidCategories diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index a2b540e971..52e81275ea 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -145,6 +145,14 @@ function LoadIssuesTable() { + "" + onsite_checkout + if (oObj.showcoverimage == 1 ) { + title += '
' + + 'Amazon cover image
Image from Amazon.com
'; + } return title; }, "type": "anti-the" diff --git a/svc/checkouts b/svc/checkouts index 4c2ce32609..c2720606fe 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -239,6 +239,16 @@ while ( my $c = $sth->fetchrow_hashref() ) { } } + my @coverimagescategories = split( ",", C4::Context->preference("CoverImagesCategories") ); + my $showcoverimage = 0; + my $patroncategory = Koha::Patrons->find( $c->{borrowernumber} )->categorycode; + if ( grep( /^$patroncategory$/, @coverimagescategories ) ) { + $showcoverimage = 1; + } + + my $biblio = Koha::Biblios->find( $c->{biblionumber} ); + my $isbn = $biblio->normalized_isbn; + my $checkout = { DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, title => $c->{title}, @@ -303,8 +313,10 @@ while ( my $c = $sth->fetchrow_hashref() ) { firstname => $c->{firstname}, cardnumber => $c->{cardnumber}, }, - issued_today => !$c->{not_issued_today}, - recalled => $recalled, + issued_today => !$c->{not_issued_today}, + recalled => $recalled, + isbn => $isbn, + showcoverimage => $showcoverimage, }; if ( $c->{not_issued_today} ) { -- 2.39.2