Bugzilla – Attachment 127729 Details for
Bug 10762
Make it possible to adjust the barcode height and width on labels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10762: Change the size of barcodes in label creator
Bug-10762-Change-the-size-of-barcodes-in-label-cre.patch (text/plain), 13.53 KB, created by
Jérémy Breuillard
on 2021-11-17 13:21:09 UTC
(
hide
)
Description:
Bug 10762: Change the size of barcodes in label creator
Filename:
MIME Type:
Creator:
Jérémy Breuillard
Created:
2021-11-17 13:21:09 UTC
Size:
13.53 KB
patch
obsolete
>From 9ef63f8a487ac3f89a80e77022c5c84d3eb3692a Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Breuillard?= > <jeremy.breuillard@biblibre.com> >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 >--- > 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 a3216360fa..263a0d3e92 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 5f3a610079..4e7dd74b8f 100644 >--- a/C4/Labels/Label.pm >+++ b/C4/Labels/Label.pm >@@ -36,6 +36,8 @@ sub _check_params { > 'oblique_title', > 'font', > 'font_size', >+ 'scale_width', >+ 'scale_height', > 'callnum_split', > 'justify', > 'format_string', >@@ -224,8 +226,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; > } > >@@ -233,8 +235,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; >@@ -244,8 +246,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; >@@ -269,6 +271,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..edba6ac842 >--- /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 b1effad732..5d1484d3f3 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 >@@ -191,6 +191,14 @@ > <label for="font_size">Font size: </label> > <input type="text" name="font_size" id="font_size" size="2" value="[% font_size | html %]" /> > </li> >+ <li> >+ <label for="scale_width">Barcode width: </label> >+ <input type="text" name="scale_width" id="scale_width" size="2" value="[% scale_width | html %]" /> >+ </li> >+ <li> >+ <label for="scale_height">Barcode height: </label> >+ <input type="text" name="scale_height" id="scale_height" size="2" value="[% scale_height | html %]" /> >+ </li> > <li> > <label for="oblique_title">Oblique title: </label> > [% 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.17.1
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 10762
:
127729
|
134754
|
144900
|
144933
|
144939
|
144940
|
144941
|
154456
|
154457
|
154458
|
154459
|
154559
|
154560
|
154561
|
154562
|
157168
|
157169
|
157170
|
157171
|
157172
|
157999
|
158014