Bugzilla – Attachment 38764 Details for
Bug 14107
Patron cards: Make barcode width and height scaling editable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14107 - Patron cards: Make barcode width and height scaling editable
Bug-14107---Patron-cards-Make-barcode-width-and-he.patch (text/plain), 6.56 KB, created by
Marc Véron
on 2015-05-02 05:50:50 UTC
(
hide
)
Description:
Bug 14107 - Patron cards: Make barcode width and height scaling editable
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-05-02 05:50:50 UTC
Size:
6.56 KB
patch
obsolete
>From a0af3ff7367d7e476650b2edce8e554d827b2b37 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Sat, 2 May 2015 07:20:22 +0200 >Subject: [PATCH] Bug 14107 - Patron cards: Make barcode width and height > scaling editable > >The size of the barcode in patron card creator was hardcoded to 1% of the card height and 80% of the card width. >This patch exposes both values in the layout editor. If no values are given, the previousely hard coded values (0.01 / 0.8) are used in order to work with existing card definitions. > >To test: >- Go to Home > Tools > Patron card creator >- Export a patron card (PDF) from en existing definition >- Apply patch >- Export patron card again, compare results (should be the same) >- Go to Home > Tools > Patron card creator > Manage card layouts >- Edit the layout you use for testing and set barcode scaling values e.g. to 0.03 for height and 0.4 for widht >- Export patron card again, verify that barcode size changed >--- > C4/Patroncards/Patroncard.pm | 13 ++++++++----- > .../prog/en/modules/patroncards/edit-layout.tt | 8 ++++++++ > patroncards/create-pdf.pl | 3 ++- > patroncards/edit-layout.pl | 2 ++ > 4 files changed, 20 insertions(+), 6 deletions(-) > >diff --git a/C4/Patroncards/Patroncard.pm b/C4/Patroncards/Patroncard.pm >index d780607..f6a1812 100644 >--- a/C4/Patroncards/Patroncard.pm >+++ b/C4/Patroncards/Patroncard.pm >@@ -45,6 +45,8 @@ sub new { > width => $params{'width'}, > layout => $params{'layout'}, > text_wrap_cols => $params{'text_wrap_cols'}, >+ barcode_height_scale => $params{'layout'}->{'barcode'}[0]->{'height_scale'} || 0.01, >+ barcode_width_scale => $params{'layout'}->{'barcode'}[0]->{'width_scale'} || 0.8, > }; > bless ($self, $type); > return $self; >@@ -52,14 +54,15 @@ sub new { > > sub draw_barcode { > my ($self, $pdf) = @_; >-#FIXME: We do some scaling foo on the barcode here which probably should be done by the one invoking draw_barcode >- 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 1% of the label height >+ # Default values for barcode scaling are set in constructor to work with pre-existing installations >+ my $barcode_height_scale = $self->{'barcode_height_scale'}; >+ my $barcode_width_scale = $self->{'barcode_width_scale'}; >+ > _draw_barcode( $self, > llx => $self->{'llx'} + $self->{'layout'}->{'barcode'}->[0]->{'llx'}, > lly => $self->{'lly'} + $self->{'layout'}->{'barcode'}->[0]->{'lly'}, >- width => $barcode_width, >- y_scale_factor => $barcode_y_scale_factor, >+ width => $self->{'width'} * $barcode_width_scale, >+ y_scale_factor => $self->{'height'} * $barcode_height_scale, > barcode_type => $self->{'layout'}->{'barcode'}->[0]->{'type'}, > barcode_data => $self->{'layout'}->{'barcode'}->[0]->{'data'}, > text => $self->{'layout'}->{'barcode'}->[0]->{'text_print'}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >index 606a6ac..3394a67 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >@@ -384,6 +384,14 @@ > <input type="text" name="barcode_lly" id="barcode_lly" size="2" value="[% barcode_lly |html %]" /> > </li> > <li> >+ <label for="barcode_height_scale">Scale height (relative to card): </label> >+ <input type="text" name="barcode_height_scale" id="barcode_height_scale" size="2" value="[% barcode_height_scale |html %]" /> >+ </li> >+ <li> >+ <label for="barcode_width_scale">Scale width (relative to card): </label> >+ <input type="text" name="barcode_width_scale" id="barcode_width_scale" size="2" value="[% barcode_width_scale |html %]" /> >+ </li> >+ <li> > <label for="barcode_type">Barcode type: </label> > <select name="barcode_type" id="barcode_type"> > [% FOREACH barcode_typ IN barcode_type %] >diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl >index 7a3136c..e76f1af 100755 >--- a/patroncards/create-pdf.pl >+++ b/patroncards/create-pdf.pl >@@ -129,8 +129,9 @@ foreach my $item (@{$items}) { > height => $pc_template->get_attr('label_height'), # of the card > width => $pc_template->get_attr('label_width'), > layout => $layout_xml, >- text_wrap_cols => 30, #FIXME: hardcoded >+ text_wrap_cols => 30, #FIXME: hardcoded, > ); >+ > $patron_card->draw_guide_box($pdf) if $layout_xml->{'guide_box'}; > $patron_card->draw_barcode($pdf) if $layout_xml->{'barcode'}; > >diff --git a/patroncards/edit-layout.pl b/patroncards/edit-layout.pl >index e28dda3..a1fb9f5 100755 >--- a/patroncards/edit-layout.pl >+++ b/patroncards/edit-layout.pl >@@ -96,6 +96,8 @@ if ($op eq 'edit') { > push @text_fields, ( > "field_" . $field_number . "_llx" => $field_params->{'llx'}, > "field_" . $field_number . "_lly" => $field_params->{'lly'}, >+ "field_" . $field_number . "_height_scale" => $field_params->{'height_scale'}, >+ "field_" . $field_number . "_width_scale" => $field_params->{'width_scale'}, > "field_" . $field_number . "_font" => _set_selected($field_params->{'font'}, $font_types), > "field_" . $field_number . "_font_size" => $field_params->{'font_size'}, > "field_" . $field_number . "_text_alignment" => _set_selected($field_params->{'text_alignment'}, $alignment_types), >-- >1.7.10.4
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 14107
:
38764
|
38767
|
38768
|
38769
|
38829
|
38848
|
40764