@@ -, +, @@ --- 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 --- a/C4/Creators/Layout.pm +++ a/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() }), --- a/C4/Labels/Label.pm +++ a/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'}, --- a/installer/data/mysql/atomicupdate/update-BZ_10762.pl +++ a/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"; + }, +} --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt @@ -191,6 +191,14 @@ +
  • + + +
  • +
  • + + +
  • [% IF ( oblique_title ) %] --- a/labels/label-create-pdf.pl +++ a/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'), --- a/labels/label-edit-layout.pl +++ a/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 --