Bugzilla – Attachment 191393 Details for
Bug 12104
Add print label to serials receive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12104: Add way to print custom serial labels
Bug-12104-Add-way-to-print-custom-serial-labels.patch (text/plain), 9.16 KB, created by
Lucas Gass (lukeg)
on 2026-01-13 19:48:19 UTC
(
hide
)
Description:
Bug 12104: Add way to print custom serial labels
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2026-01-13 19:48:19 UTC
Size:
9.16 KB
patch
obsolete
>From 88efaf6414b02726878717c00469daa7b94ae704 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >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 %]<br /> > [% serial.serialseq %]<br /> > [% 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 %]<br />\n[% serial.serialseq %]<br />\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 %]<br />\n[% serial.serialseq %]<br />\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 <code>biblio</code>, <code>serial</code>, and <code>subscription</code> 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' %] >+<title >+ >[% FILTER collapse %] >+ [% t("Print serial label") | html %] >+ › [% t("Koha") | html %] >+ [% END %]</title >+> >+[% INCLUDE 'doc-head-close.inc' popup => 1 %] >+[% Asset.css("css/spinelabel.css") | $raw %] >+<style> >+ @media print { >+ .noprint { >+ display: none; >+ } >+ } >+</style> >+</head> >+<body id="labels_seriallabel_print" class="labels"> >+ >+[% IF no_serial %] >+ <div class="error">Serial not found</div> >+[% ELSE %] >+ <div class="serial-label"> [% content | $raw %] </div> >+[% END %] >+[% Asset.js( "lib/jquery/jquery-3.6.0.min.js" ) | $raw %] >+[% Asset.js( "lib/jquery/jquery-migrate-3.3.2.min.js" ) | $raw %] >+<script> >+ function autoPrintAndClose() { >+ window.print(); >+ window.close(); >+ } >+ >+ window.addEventListener("load", autoPrintAndClose); >+</script> >+[% 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 ) %] > <th class="no-sort">Routing</th> > [% END %] >+ <th>Print label</th> > </tr> > </thead> > <tbody> >@@ -321,6 +322,9 @@ > > > </td> > [% END %] >+ <td class="actions"> >+ <a href="/cgi-bin/koha/labels/seriallabel-print.pl?serialid=[% serial.serialid | uri %]" class="btn btn-default btn-xs print_list"><i class="fa fa-print"></i> Print label</a> >+ </td> > </tr> > [% END %] > </tbody> >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 <https://www.gnu.org/licenses>. >+ >+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
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 12104
:
190525
|
190526
|
191393
|
192823