Some coding improvement and misc changes to BIBBAR labels
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
e88cf181c0
commit
a035678a17
2 changed files with 77 additions and 44 deletions
115
C4/Labels.pm
115
C4/Labels.pm
|
@ -25,7 +25,7 @@ use Text::Wrap;
|
||||||
use Algorithm::CheckDigits;
|
use Algorithm::CheckDigits;
|
||||||
use C4::Members;
|
use C4::Members;
|
||||||
use C4::Branch;
|
use C4::Branch;
|
||||||
# use Data::Dumper;
|
use Data::Dumper;
|
||||||
# use Smart::Comments;
|
# use Smart::Comments;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
@ -200,42 +200,72 @@ sub get_text_fields {
|
||||||
|
|
||||||
my $sortorder = get_layout($layout_id);
|
my $sortorder = get_layout($layout_id);
|
||||||
|
|
||||||
# $sortorder
|
# FIXME: This is all hardcoded and should be user selectable I think or are these the only text fields? -fbcit
|
||||||
|
|
||||||
$a = {
|
$a = {
|
||||||
code => 'itemtype',
|
code => 'itemtype',
|
||||||
desc => "Item Type",
|
desc => "Item Type",
|
||||||
order => $sortorder->{'itemtype'}
|
order => $sortorder->{'itemtype'}
|
||||||
};
|
};
|
||||||
|
|
||||||
$b = {
|
$b = {
|
||||||
code => 'dewey',
|
code => 'dewey',
|
||||||
desc => "Dewey",
|
desc => "Dewey",
|
||||||
order => $sortorder->{'dewey'}
|
order => $sortorder->{'dewey'}
|
||||||
};
|
};
|
||||||
$c = { code => 'issn', desc => "ISSN",
|
|
||||||
order => $sortorder->{'issn'} };
|
$c = {
|
||||||
$d = { code => 'isbn', desc => "ISBN",
|
code => 'issn',
|
||||||
order => $sortorder->{'isbn'} };
|
desc => "ISSN",
|
||||||
|
order => $sortorder->{'issn'}
|
||||||
|
};
|
||||||
|
|
||||||
|
$d = {
|
||||||
|
code => 'isbn',
|
||||||
|
desc => "ISBN",
|
||||||
|
order => $sortorder->{'isbn'}
|
||||||
|
};
|
||||||
|
|
||||||
$e = {
|
$e = {
|
||||||
code => 'class',
|
code => 'class',
|
||||||
desc => "Classification",
|
desc => "Classification",
|
||||||
order => $sortorder->{'class'}
|
order => $sortorder->{'class'}
|
||||||
};
|
};
|
||||||
|
|
||||||
$f = {
|
$f = {
|
||||||
code => 'subclass',
|
code => 'subclass',
|
||||||
desc => "Sub-Class",
|
desc => "Sub-Class",
|
||||||
order => $sortorder->{'subclass'}
|
order => $sortorder->{'subclass'}
|
||||||
};
|
};
|
||||||
|
|
||||||
$g = {
|
$g = {
|
||||||
code => 'barcode',
|
code => 'barcode',
|
||||||
desc => "Barcode",
|
desc => "Barcode",
|
||||||
order => $sortorder->{'barcode'}
|
order => $sortorder->{'barcode'}
|
||||||
};
|
};
|
||||||
$h =
|
|
||||||
{ code => 'author', desc => "Author", order => $sortorder->{'author'} };
|
$h = {
|
||||||
$i = { code => 'title', desc => "Title", order => $sortorder->{'title'} };
|
code => 'author',
|
||||||
$j = { code => 'itemcallnumber', desc => "Call Number", order => $sortorder->{'itemcallnumber'} };
|
desc => "Author",
|
||||||
$k = { code => 'subtitle', desc => "Subtitle", order => $sortorder->{'subtitle'} };
|
order => $sortorder->{'author'}
|
||||||
|
};
|
||||||
|
|
||||||
|
$i = {
|
||||||
|
code => 'title',
|
||||||
|
desc => "Title",
|
||||||
|
order => $sortorder->{'title'}
|
||||||
|
};
|
||||||
|
|
||||||
|
$j = {
|
||||||
|
code => 'itemcallnumber',
|
||||||
|
desc => "Call Number",
|
||||||
|
order => $sortorder->{'itemcallnumber'}
|
||||||
|
};
|
||||||
|
|
||||||
|
$k = {
|
||||||
|
code => 'subtitle',
|
||||||
|
desc => "Subtitle",
|
||||||
|
order => $sortorder->{'subtitle'}
|
||||||
|
};
|
||||||
|
|
||||||
my @text_fields = ( $a, $b, $c, $d, $e, $f, $g, $h, $i ,$j, $k );
|
my @text_fields = ( $a, $b, $c, $d, $e, $f, $g, $h, $i ,$j, $k );
|
||||||
|
|
||||||
|
@ -245,12 +275,17 @@ sub get_text_fields {
|
||||||
}
|
}
|
||||||
|
|
||||||
my @sorted_fields = sort by_order @new_fields;
|
my @sorted_fields = sort by_order @new_fields;
|
||||||
|
|
||||||
my $active_fields;
|
my $active_fields;
|
||||||
foreach my $field (@sorted_fields) {
|
|
||||||
$sorttype eq 'codes' ? $active_fields .= "$field->{'code'} " :
|
if ($sorttype eq 'codes') { # FIXME: This sub should really always return the array of hashrefs and let the caller take what he wants from that -fbcit
|
||||||
$active_fields .= "$field->{'desc'} ";
|
return @sorted_fields;
|
||||||
|
} else {
|
||||||
|
foreach my $field (@sorted_fields) {
|
||||||
|
$active_fields .= "$field->{'desc'} ";
|
||||||
|
}
|
||||||
|
return $active_fields;
|
||||||
}
|
}
|
||||||
return $active_fields;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,7 +917,7 @@ sub deduplicate_batch {
|
||||||
sub DrawSpineText {
|
sub DrawSpineText {
|
||||||
|
|
||||||
my ( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin,
|
my ( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin,
|
||||||
$text_wrap_cols, $item, $conf_data, $printingtype )
|
$text_wrap_cols, $item, $conf_data, $printingtype, $nowrap )
|
||||||
= @_;
|
= @_;
|
||||||
# hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification
|
# hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification
|
||||||
$$item->{'class'} = $$item->{'classification'};
|
$$item->{'class'} = $$item->{'classification'};
|
||||||
|
@ -895,21 +930,16 @@ sub DrawSpineText {
|
||||||
my $top_text_margin = ( $fontsize + 3 ); #FIXME: This should be a template parameter and passed in...
|
my $top_text_margin = ( $fontsize + 3 ); #FIXME: This should be a template parameter and passed in...
|
||||||
my $line_spacer = ( $fontsize * 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 $line_spacer = ( $fontsize * 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.).
|
||||||
|
|
||||||
# add your printable fields manually in here
|
|
||||||
|
|
||||||
my $layout_id = $$conf_data->{'id'};
|
my $layout_id = $$conf_data->{'id'};
|
||||||
|
|
||||||
# my @fields = GetItemFields();
|
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
|
||||||
|
|
||||||
my $str_fields = get_text_fields($layout_id, 'codes' );
|
|
||||||
my @fields = split(/ /, $str_fields);
|
|
||||||
#warn Dumper(@fields);
|
|
||||||
|
|
||||||
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
|
|
||||||
my $font = prFont($fontname);
|
my $font = prFont($fontname);
|
||||||
|
|
||||||
# warn Dumper $conf_data;
|
my @str_fields = get_text_fields($layout_id, 'codes' );
|
||||||
#warn Dumper $item;
|
my @fields;
|
||||||
|
foreach my $field (@str_fields) {
|
||||||
|
push (@fields, $field->{'code'});
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $field (@fields) {
|
foreach my $field (@fields) {
|
||||||
|
|
||||||
|
@ -927,19 +957,22 @@ sub DrawSpineText {
|
||||||
# strip out naughty existing nl/cr's
|
# strip out naughty existing nl/cr's
|
||||||
$str =~ s/\n//g;
|
$str =~ s/\n//g;
|
||||||
$str =~ s/\r//g;
|
$str =~ s/\r//g;
|
||||||
# wrap lines based on call number dividers '/'
|
|
||||||
my @strings;
|
my @strings;
|
||||||
|
if (($nowrap == 0) || (!$nowrap)) {
|
||||||
|
# wrap lines based on segmentation markers: '/' (other types of segmentation markers can be added as needed here or this could be added as a syspref.)
|
||||||
|
|
||||||
while ( $str =~ /\// ) {
|
while ( $str =~ /\// ) {
|
||||||
$str =~ /^(.*)\/(.*)$/;
|
$str =~ /^(.*)\/(.*)$/;
|
||||||
|
|
||||||
#warn "\$2=$2";
|
#warn "\$2=$2";
|
||||||
unshift @strings, $2;
|
unshift @strings, $2;
|
||||||
$str = $1;
|
$str = $1;
|
||||||
|
}
|
||||||
|
unshift @strings, $str;
|
||||||
|
} else {
|
||||||
|
push @strings, $str; # if we are not wrapping the call number just send it along as we found it...
|
||||||
}
|
}
|
||||||
|
|
||||||
unshift @strings, $str;
|
|
||||||
|
|
||||||
# strip out division slashes
|
# strip out division slashes
|
||||||
#$str =~ s/\///g;
|
#$str =~ s/\///g;
|
||||||
#warn "\$str after striping division marks: $str";
|
#warn "\$str after striping division marks: $str";
|
||||||
|
|
|
@ -222,7 +222,7 @@ foreach $item (@resultsloop) {
|
||||||
DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width,
|
DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width,
|
||||||
$item->{'barcode'}, $barcodetype );
|
$item->{'barcode'}, $barcodetype );
|
||||||
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
||||||
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ foreach $item (@resultsloop) {
|
||||||
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $item->{'barcode'},
|
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $item->{'barcode'},
|
||||||
$barcodetype );
|
$barcodetype );
|
||||||
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
||||||
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype, '1' );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ foreach $item (@resultsloop) {
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
|
drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
|
||||||
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize,
|
||||||
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue