From 2cf45462fe7f4cc3aefadf0c03d73cab57c48f64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9my=20Breuillard?= Date: Wed, 17 Nov 2021 10:08:49 +0100 Subject: [PATCH] Bug 10762: Change the size of barcodes in label creator Test plan: 1)Home > Tools > Label creator > Manage Layout or New Layout 2)Make a new layout or edit an existing one 3)Notice the 2 new fields "Barcode width/Barcode height" 4)Save it like this 5)Create a batch of barcode and export if in PDF 6)Notice the size of barcode 7)Go back to your existing layout 8)Enter some values (Barcode width: 1.6 / Barcode height: 0.04), save 9)Take back your batch of barcode and export it in PDF 10)The barcode should be 2x bigger Signed-off-by: Owen Leonard Signed-off-by: Lucas Gass Signed-off-by: Johanna Miettunen Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Creators/Layout.pm | 4 ++++ C4/Labels/Label.pm | 16 ++++++++----- .../mysql/atomicupdate/update-BZ_10762.pl | 23 +++++++++++++++++++ .../en/modules/labels/label-edit-layout.tt | 8 +++++++ labels/label-create-pdf.pl | 6 +++++ labels/label-edit-layout.pl | 4 ++++ 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/update-BZ_10762.pl diff --git a/C4/Creators/Layout.pm b/C4/Creators/Layout.pm index 4ac7908123..d1c889e550 100644 --- a/C4/Creators/Layout.pm +++ b/C4/Creators/Layout.pm @@ -31,6 +31,8 @@ sub _check_params { 'oblique_title', 'font', 'font_size', + 'scale_width', + 'scale_height', 'callnum_split', 'text_justify', 'format_string', @@ -77,6 +79,8 @@ sub new { oblique_title => 1, font => 'TR', font_size => 3, + scale_width => 0.8, + scale_height => 0.02, callnum_split => 0, text_justify => 'L', format_string => join(', ', @{ PRESET_FIELDS() }), diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index eadf9cce0a..9fbd20be3f 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -37,6 +37,8 @@ sub _check_params { 'oblique_title', 'font', 'font_size', + 'scale_width', + 'scale_height', 'callnum_split', 'justify', 'format_string', @@ -225,8 +227,8 @@ sub _BAR { my $self = shift; my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($llx) my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly) - my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width - my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height + my $barcode_width = $self->{'scale_width'} * $self->{'width'}; # You can choose the width of barcode, default value is 0.8 : 80% of the label width + my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}; # You can choose the height of barcode, default value is 0.01 : 10% of the label height return 0, 0, 0, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor; } @@ -234,8 +236,8 @@ sub _BIBBAR { my $self = shift; my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'}) my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly) - my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width - my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height + my $barcode_width = $self->{'scale_width'} * $self->{'width'}; # You can choose the width of barcode, default value is 0.8 : 80% of the label width + my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}; # You can choose the height of barcode, default value is 0.01 : 10% of the label height my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.). my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'})); return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor; @@ -245,8 +247,8 @@ sub _BARBIB { my $self = shift; my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'}) my $barcode_lly = ($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance below the top of the label ($self->{'lly'}) - my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width - my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height + my $barcode_width = $self->{'scale_width'} * $self->{'width'}; # You can choose the width of barcode, default value is 0.8 : 80% of the label width + my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}; # You can choose the height of barcode, default value is 0.01 : 10% of the label height my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.). my $text_lly = (($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'} - (($self->{'lly'} + $self->{'height'}) - $barcode_lly)); return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor; @@ -270,6 +272,8 @@ sub new { oblique_title => $params{'oblique_title'}, font => $params{'font'}, font_size => $params{'font_size'}, + scale_width => $params{'scale_width'}, + scale_height => $params{'scale_height'}, callnum_split => $params{'callnum_split'}, justify => $params{'justify'}, format_string => $params{'format_string'}, diff --git a/installer/data/mysql/atomicupdate/update-BZ_10762.pl b/installer/data/mysql/atomicupdate/update-BZ_10762.pl new file mode 100644 index 0000000000..408e3dace5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/update-BZ_10762.pl @@ -0,0 +1,23 @@ +use Modern::Perl; + +return { + bug_number => "10762", + description => "Add 2 columns in 'creator_layouts' which define the width and height of barcodes", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + unless ( column_exists ( 'creator_layouts', 'scale_width' )) { + $dbh->do( q { + ALTER TABLE creator_layouts + ADD COLUMN scale_width FLOAT default 0.8 NOT NULL AFTER font_size + }); + } + unless ( column_exists ( 'creator_layouts', 'scale_height')) { + $dbh->do( q { + ALTER TABLE creator_layouts + ADD COLUMN scale_height FLOAT default 0.01 NOT NULL AFTER scale_width + }); + } + say $out "Table creator_layouts updated with 2 new columns"; + }, +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt index a73d2572a6..5660650ed8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt @@ -193,6 +193,14 @@ +
  • + + +
  • +
  • + + +
  • [% IF ( oblique_title ) %] diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl index f1cd47183c..3ce90363fc 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -145,6 +145,8 @@ foreach my $item (@{$items}) { oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), + scale_width => $layout->get_attr('scale_width'), + scale_height => $layout->get_attr('scale_height'), callnum_split => $layout->get_attr('callnum_split'), justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), @@ -169,6 +171,8 @@ foreach my $item (@{$items}) { oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), + scale_width => $layout->get_attr('scale_width'), + scale_height => $layout->get_attr('scale_height'), callnum_split => $layout->get_attr('callnum_split'), justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), @@ -196,6 +200,8 @@ foreach my $item (@{$items}) { oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), + scale_width => $layout->get_attr('scale_width'), + scale_height => $layout->get_attr('scale_height'), callnum_split => $layout->get_attr('callnum_split'), justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index f1fc6878a1..7d6ef2d219 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -112,6 +112,8 @@ elsif ($op eq 'save') { oblique_title => ($cgi->param('oblique_title') ? 1 : 0), font => scalar $cgi->param('font') || 'TR', font_size => scalar $cgi->param('font_size') || 3, + scale_width => scalar $cgi->param('scale_width') || 0.8, + scale_height => scalar $cgi->param('scale_height') || 0.01, callnum_split => ($cgi->param('callnum_split') ? 1 : 0), text_justify => scalar $cgi->param('text_justify') || 'L', format_string => scalar $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber', @@ -150,6 +152,8 @@ $template->param( guidebox => $layout->get_attr('guidebox'), oblique_title => $layout->get_attr('oblique_title'), font_size => $layout->get_attr('font_size'), + scale_width => $layout->get_attr('scale_width'), + scale_height => $layout->get_attr('scale_height'), callnum_split => $layout->get_attr('callnum_split'), format_string => $layout->get_attr('format_string'), layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN -- 2.39.5