From a47fd8f882fbb4bee93c67dbd2faa9511d60440b Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Thu, 24 Jan 2013 10:56:01 +0000 Subject: [PATCH] Bug 9480: Set barcode width and height configurable with system preferences in patron card creator Problem: - barcode width scale is always set to 0.8 of the total width - barcode height scale is always set to 0.01 of total height - happens in 3.8.X, 3.10.X and master code Test plan: - Apply patch - Check if your patron cards still prints normally - Change the sysprefs BarcodeWidthScale and BarcodeHeightScale (double values) and see the barcode change - Remove the sysprefs value (empty) and your patron cards should print normally (uses the default values) Sponsored-by: KEEP SOLUTIONS --- C4/Patroncards/Patroncard.pm | 6 ++++-- installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../en/modules/admin/preferences/creators.pref | 8 ++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/C4/Patroncards/Patroncard.pm b/C4/Patroncards/Patroncard.pm index 339b969..87088a9 100644 --- a/C4/Patroncards/Patroncard.pm +++ b/C4/Patroncards/Patroncard.pm @@ -53,8 +53,10 @@ 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 + my $barcode_width_scale = C4::Context->preference('BarcodeWidthScale') ? C4::Context->preference('BarcodeWidthScale') : 0.8; + my $barcode_height_scale = C4::Context->preference('BarcodeHeightScale') ? C4::Context->preference('BarcodeHeightScale') : 0.01; + my $barcode_width = $barcode_width_scale * $self->{'width'}; + my $barcode_y_scale_factor = $barcode_height_scale * $self->{'height'}; _draw_barcode( $self, llx => $self->{'llx'} + $self->{'layout'}->{'barcode'}->[0]->{'llx'}, lly => $self->{'lly'} + $self->{'layout'}->{'barcode'}->[0]->{'lly'}, diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d5d15d7..ee57cb4 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -406,3 +406,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded