From 88efaf6414b02726878717c00469daa7b94ae704 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 15 Dec 2025 22:03:28 +0000 Subject: [PATCH] Bug 12104: Add way to print custom serial labels to test: 1. APPLY PATCH and restart_all 2. Search fot the system preference SerialLabelFormat 3. It should include some default TT like: [% biblio.title %]
[% serial.serialseq %]
[% serial.publisheddate %] 4. Go Serials and find or create a new subscription 5. Revice some serials 6. Notice the "Print label" column for each serial 7. Print it and make sure it looks right. 8. Going back to SerialLabelFormat, we can now edit it to create a custom label. You can add fields from the biblio, serial, and subscription tables in TT format. 9. Test some custom labels and make sure it all works. --- .../data/mysql/atomicupdate/bug_12104.pl | 19 ++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../en/modules/admin/preferences/serials.pref | 5 ++ .../en/modules/serials/seriallabel-print.tt | 38 +++++++++++ .../en/modules/serials/serials-collection.tt | 4 ++ labels/seriallabel-print.pl | 67 +++++++++++++++++++ 6 files changed, 134 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_12104.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/seriallabel-print.tt create mode 100755 labels/seriallabel-print.pl diff --git a/installer/data/mysql/atomicupdate/bug_12104.pl b/installer/data/mysql/atomicupdate/bug_12104.pl new file mode 100755 index 00000000000..2ce03ec308c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12104.pl @@ -0,0 +1,19 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "12104", + description => "Add SerialLabelFormat system preference", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('SerialLabelFormat', '[% biblio.title %]
\n[% serial.serialseq %]
\n[% serial.publisheddate %]', '', 'Define the format for printing labels from the serials receive page.', 'Textarea'); + } + ); + say_success( $out, "SerialLabelFormat system preference added" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index d92c1b9d77c..13b3657d00e 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -739,6 +739,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), ('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'), +('SerialLabelFormat', '[% biblio.title %]
\n[% serial.serialseq %]
\n[% serial.publisheddate %]', '', 'Define the format for printing labels from the serials receive page.', 'Textarea'), ('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'), ('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'), ('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref index d91b4083367..eaa639e57a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref @@ -70,6 +70,11 @@ Serials: - pref: SerialsSearchResultsLimit class: integer - first serials when performing an advanced serials search. + - + - "Include the following fields on a serial label:" + - pref: SerialLabelFormat + type: textarea + - "Use Template Toolkit syntax with fields from the biblio, serial, and subscription tables." Notifications: - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/seriallabel-print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/seriallabel-print.tt new file mode 100644 index 00000000000..b0a4dd847d5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/seriallabel-print.tt @@ -0,0 +1,38 @@ +[% USE raw %] +[% USE Koha %] +[% PROCESS 'i18n.inc' %] +[% INCLUDE 'doc-head-open.inc' %] +[% FILTER collapse %] + [% t("Print serial label") | html %] + › [% t("Koha") | html %] + [% END %] +[% INCLUDE 'doc-head-close.inc' popup => 1 %] +[% Asset.css("css/spinelabel.css") | $raw %] + + + + +[% IF no_serial %] +
Serial not found
+[% ELSE %] +
[% content | $raw %]
+[% END %] +[% Asset.js( "lib/jquery/jquery-3.6.0.min.js" ) | $raw %] +[% Asset.js( "lib/jquery/jquery-migrate-3.3.2.min.js" ) | $raw %] + +[% INCLUDE 'popup-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index ae63fadc809..b64907a16d5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -236,6 +236,7 @@ [% IF ( routing ) %] Routing [% END %] + Print label @@ -321,6 +322,9 @@ > [% END %] + + Print label + [% END %] diff --git a/labels/seriallabel-print.pl b/labels/seriallabel-print.pl new file mode 100755 index 00000000000..38a6c1cf2ba --- /dev/null +++ b/labels/seriallabel-print.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Context; +use C4::Serials; +use Koha::Biblios; +use Koha::Serials; +use Koha::TemplateUtils qw( process_tt ); + +my $query = CGI->new; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "serials/seriallabel-print.tt", + query => $query, + type => "intranet", + flagsrequired => { serials => '*' }, + } +); + +my $serialid = $query->param('serialid'); + +my $serial = Koha::Serials->find($serialid); + +unless ( defined $serial ) { + $template->param( no_serial => 1 ); + output_html_with_http_headers $query, $cookie, $template->output; + exit; +} + +my $subscription = C4::Serials::GetSubscription( $serial->subscriptionid ); +my $biblio = Koha::Biblios->find( $subscription->{biblionumber} ); + +my $format = C4::Context->preference('SerialLabelFormat') || ''; + +my $content = process_tt( + $format, + { + serial => $serial, + subscription => $subscription, + biblio => $biblio, + } +); + +$template->param( + content => $content, +); + +output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5