@@ -, +, @@ --- labels/label-create-pdf.pl | 17 ++++------------- labels/label-print.pl | 6 +++--- 2 files changed, 7 insertions(+), 16 deletions(-) --- a/labels/label-create-pdf.pl +++ a/labels/label-create-pdf.pl @@ -45,7 +45,7 @@ my $start_label = $cgi->param('start_label') || 1; @item_numbers = $cgi->multi_param('item_number') if $cgi->param('item_number'); my $from = $cgi->param('from') || undef; my $to = $cgi->param('to') || undef; -my $range = $cgi->param('range') || undef; +my $barcode_length = $cgi->param('barcode_length'); my $items = undef; @@ -117,18 +117,9 @@ elsif (@item_numbers) { } @item_numbers; } elsif ($from and $to) { - for (my $i = $from; $i <= $to; $i++) { - my $compare_range = $range - length($i); - if ($compare_range == 0){ - push @{$items}, {'item_number' => $i}; - } else { - my $a = ''; - for (my $j = 1; $j <= $compare_range; $j++){ - $a .= '0'; - } - $a .= $i; - push @{$items}, {'item_number' => $a}; - } + for my $i ( $from .. $to ) { + my $padding = '0' x ( $barcode_length - length($i) ); + push @$items, { item_number => $padding . $i }; } } else { --- a/labels/label-print.pl +++ a/labels/label-print.pl @@ -55,7 +55,7 @@ my $txt_from = $cgi->param('from') || undef; my $txt_to = $cgi->param('to') || undef; my $from = int($txt_from) || undef; my $to = int($txt_to) || undef; -my $range = length($txt_from) || undef; +my $barcode_length = length($txt_from) || undef; my $layouts = undef; my $templates = undef; @@ -127,7 +127,7 @@ if ($op eq 'export') { push (@batches, {create_script => 'label-create-pdf.pl', from => $from, to => $to, - range => $range, + barcode_length => $barcode_length, template_id => $template_id, layout_id => $layout_id, start_label => $start_label, @@ -161,7 +161,7 @@ elsif ($op eq 'none') { referer => $referer, from => $from, to => $to, - range => $range, + barcode_length => $barcode_length, txt_from => $txt_from, txt_to => $txt_to ); --