Skip to content

Commit

Permalink
[#16893161] (fixup) another sub calling package globals
Browse files Browse the repository at this point in the history
  • Loading branch information
ctfliblime committed Aug 11, 2011
1 parent a7a6379 commit 89f93fa
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions labels/label-create-pdf.pl
Expand Up @@ -34,28 +34,6 @@
my $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);

sub _calc_next_label_pos {
my ($row_count, $col_count, $llx, $lly) = @_;
if ($col_count lt $template->get_attr('cols')) {
$llx = ($llx + $template->get_attr('label_width') + $template->get_attr('col_gap'));
$col_count++;
}
else {
$llx = $template->get_attr('left_margin');
if ($row_count eq $template->get_attr('rows')) {
$pdf->Page();
$lly = ($template->get_attr('page_height') - $template->get_attr('top_margin') - $template->get_attr('label_height'));
$row_count = 1;
}
else {
$lly = ($lly - $template->get_attr('row_gap') - $template->get_attr('label_height'));
$row_count++;
}
$col_count = 1;
}
return ($row_count, $col_count, $llx, $lly);
}

my $fs = $layout->get_attr('format_string');
$| = 1;

Expand Down Expand Up @@ -113,7 +91,7 @@ sub _calc_next_label_pos {
$pdf->Add($label_a->draw_guide_box) if $layout->get_attr('guidebox');
my $label_a_text = $label_a->create_label();
_print_text($pdf, $label_a_text);
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($template, $pdf, $row_count, $col_count, $llx, $lly);
my $label_b = C4::Labels::Label->new(
batch_id => $batch_id,
item_number => $item->{'item_number'},
Expand All @@ -136,7 +114,7 @@ sub _calc_next_label_pos {
);
$pdf->Add($label_b->draw_guide_box) if $layout->get_attr('guidebox');
my $label_b_text = $label_b->create_label();
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($template, $pdf, $row_count, $col_count, $llx, $lly);
next LABEL_ITEMS;
}
else {
Expand Down Expand Up @@ -164,7 +142,7 @@ sub _calc_next_label_pos {
$pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
my $label_text = $label->create_label();
_print_text($pdf, $label_text) if $label_text;
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($template, $pdf, $row_count, $col_count, $llx, $lly);
next LABEL_ITEMS;
}

Expand All @@ -183,6 +161,28 @@ sub _print_text {
}
}

sub _calc_next_label_pos {
my ($template, $pdf, $row_count, $col_count, $llx, $lly) = @_;
if ($col_count lt $template->get_attr('cols')) {
$llx = ($llx + $template->get_attr('label_width') + $template->get_attr('col_gap'));
$col_count++;
}
else {
$llx = $template->get_attr('left_margin');
if ($row_count eq $template->get_attr('rows')) {
$pdf->Page();
$lly = ($template->get_attr('page_height') - $template->get_attr('top_margin') - $template->get_attr('label_height'));
$row_count = 1;
}
else {
$lly = ($lly - $template->get_attr('row_gap') - $template->get_attr('label_height'));
$row_count++;
}
$col_count = 1;
}
return ($row_count, $col_count, $llx, $lly);
}

=head1 NAME
labels/label-create-pdf.pl - A script for creating a pdf export of labels and label batches in Koha
Expand Down

0 comments on commit 89f93fa

Please sign in to comment.