+ elsif ($from and $to) {
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT COUNT(*) AS has_barcode FROM creator_layouts WHERE printing_type LIKE("%BAR%") AND layout_id = ?;');
+ $sth->execute($layout_id);
+ if ($sth->fetchrow_hashref->{'has_barcode'} == 0) {
+ $sth = $dbh->prepare('SELECT COUNT(*) AS existing_count FROM items WHERE CAST(barcode AS unsigned) BETWEEN ? AND ?;');
+ $sth->execute($from, $to);
+ if ($sth->fetchrow_hashref->{'existing_count'} < ($to - $from + 1)) {
+ $template->param( warn_empty_range => 1 )
+ }
+ }
+
+ push (@batches, {create_script => 'label-create-pdf.pl',
+ from => $from,
+ to => $to,
+ range => $range,
+ template_id => $template_id,
+ layout_id => $layout_id,
+ start_label => $start_label,
+ });
+ $template->param(
+ batches => \@batches,
+ referer => $referer,
+ );
+ }