From cb195553d34bd40f04a9adbf50d433bfb3fb8e4e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 7 Jan 2022 15:55:29 +0000 Subject: [PATCH] Bug 29821: Add interface for generating barcodes using svc/barcode This patch adds a new page providing an interface for generating barcodes using svc/barcode. A form allows the user to choose various parameters and see the resulting barcode image. To test, apply the patch and rebuild the staff interface SCSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). - Go to the "Tools" home page. Follow the link to "Barcode image generator." - On the barcode image generator page, confirm that there is a "Barcode image generator" link in the sidebar and that it is displayed with bold text. - Test the features of the form: - Enter a numeric value in the "Barcode" field and tab out of the field or click "Show barcode" button. A barcode of type "Code39" should be shown with the text of the barcode included in the image below the barcode. - A text area below the barcode image should show the HTML used to generate the preview image. - Clicking in this textarea should automatically add the contents to the clipboard. You should be shown a message, "HTML copied to the clipboard." - Check the "hide text" checkbox. The barcode should be redisplayed without the text. - Check that changing the "barcode height" value is reflected correctly in the barcode image. - Try adding non-numeric data in the "Barcode" field. You should be shown an error message, "Barcodes of type [type] must be numeric." - Test these other numeric barcode types: Code39, COOP2of5, EAN13, EAN8, IATA2of5, Industrial2of5, ITF, Matrix2of5, NW7, UPCA, and UPCE. Note that EAN13, EAN8, UPCA, and UPCE expect specific patterns. Test values (found here: https://barcode.tec-it.com/en/UPCE): EAN13: 978020137962 EAN8: 9031101 UPCA: 72527273070 UPCE: 0123456 - Change the barcode type to "QRcode." - The form should change, hiding the "Hide text" checkbox and showing a new ranger slider for "QR Code module size." - The barcode field should now be labeled "Text, URL, or barcode, etc" - The barcode field hint should change to a hint about QRcode dimensions. - Changing the "module size" slider should change the size of the generated QR code. As you change the slider the selected value should be reflected in the box. Signed-off-by: Lucas Gass Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- .../prog/css/src/staff-global.scss | 11 +- .../prog/en/includes/tools-menu.inc | 1 + .../prog/en/modules/labels/barcode-print.tt | 212 ++++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 7 +- koha-tmpl/intranet-tmpl/prog/js/tools-menu.js | 2 +- labels/barcode-print.pl | 33 +++ 6 files changed, 260 insertions(+), 6 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/labels/barcode-print.tt create mode 100755 labels/barcode-print.pl diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 7352f3e3e2..327fe0632a 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -712,6 +712,12 @@ fieldset { } li { + margin-top: 1em; + + &:first-child { + margin-top: 0; + } + &[aria-disabled="true"] { color: #999; } @@ -908,10 +914,6 @@ fieldset { padding-left: 0; } } - - legend { - margin-bottom: 0; - } } ol { @@ -1037,6 +1039,7 @@ legend { border-radius: 3px; font-size: 123.1%; font-weight: bold; + margin-bottom: 0; padding: .2em .5em; width: auto; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index 0b5f33110f..7ec650be1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -73,6 +73,7 @@ [% IF ( CAN_user_tools_label_creator ) %]
  • Label creator
  • Quick spine label creator
  • +
  • Barcode image generator
  • [% END %] [% IF ( CAN_user_tools_rotating_collections ) %]
  • Rotating collections
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/barcode-print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/barcode-print.tt new file mode 100644 index 0000000000..f020565e43 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/barcode-print.tt @@ -0,0 +1,212 @@ +[% USE raw %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %]Barcode image generator › Tools › Koha +[% INCLUDE 'doc-head-close.inc' %] +[% Asset.css("css/humanmsg.css") | $raw %] +[% FILTER collapse %] + +[% END %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    +
    +
    +

    Barcode image generator

    + +
    +
    +
    +
    +
      +
    1. + + +
    2. +
    3. + + + 3 +
      Module size refers to the pixel dimensions of each black or white square in the generated QR code.
      +
    4. +
    5. + +
    6. +
    7. + + +
    8. +
    9. + + + +
      Actual dimensions of the QR code depend on the amount of characters being encoded.
      +
      Barcode text must be numeric (0-9)
      +
    10. +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/tools-menu.js") | $raw %] + [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 5d0d7f84cb..22dab0b384 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -224,7 +224,12 @@
    Label creator
    Create printable labels and barcodes from catalog data
    [% END %] - + + [% IF ( CAN_user_tools_label_creator ) %] +
    Barcode image generator
    +
    Configure and create barcodes of various types to be output as an image
    + [% END %] + [% IF ( CAN_user_tools_label_creator ) %]
    Quick spine label creator
    Enter a barcode to generate a printable spine label. For use with dedicated label printers
    diff --git a/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js b/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js index 14325b6f9d..8fad270f87 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js @@ -1,6 +1,6 @@ $(document).ready(function() { var path = location.pathname.substring(1); - if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) { + if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 && path.indexOf("barcode") < 0 ) { $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current"); } else if (path.indexOf("patroncards") >= 0 ) { $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').addClass("current"); diff --git a/labels/barcode-print.pl b/labels/barcode-print.pl new file mode 100755 index 0000000000..2707521575 --- /dev/null +++ b/labels/barcode-print.pl @@ -0,0 +1,33 @@ +#!/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; + +my $query = CGI->new; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "labels/barcode-print.tt", + query => $query, + type => "intranet", + flagsrequired => { catalogue => 1 }, + } +); + +output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5