Koha/labels/spinelabel-print.pl
Kyle M Hall 6860310e96 Quick Spine Label Printer
This is a small tool for quickly printing spine labels using dedicated label printers.
It is located in the Tools page as Quick Spine Label Creator.
The system preference SpineLabelFormat defines which fields will be displayed.
The pref SpineLabelAutoPrint will make the print dialog pop up automatically.
The CSS file spinelabel.css controls all presentation for the labels.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2009-08-01 10:47:13 -04:00

73 lines
1.7 KiB
Perl
Executable file

#!/usr/bin/perl
use warnings;
use strict;
use CGI;
use C4::Auth;
use C4::Output;
use HTML::Template::Pro;
my $scheme = C4::Context->preference('SpineLabelFormat');
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "labels/spinelabel-print.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $barcode = $query->param('barcode');
my $dbh = C4::Context->dbh;
my $sth;
my $item;
my $sql = "SELECT * FROM biblio, biblioitems, items
WHERE biblio.biblionumber = items.biblionumber
AND biblioitems.biblioitemnumber = items.biblioitemnumber
AND items.barcode = ?";
$sth = $dbh->prepare( $sql );
$sth->execute( $barcode );
$item = $sth->fetchrow_hashref;
my $body;
my $data;
while ( my ($key, $value ) = each(%$item) ) {
$data->{$key} .= "<span class='field' id='$key'>";
my @characters = split(//, $value );
my $charnum = 1;
my $wordnum = 1;
my $i = 1;
foreach my $char ( @characters ) {
if ( $char ne ' ' ) {
$data->{$key} .= "<span class='character word$wordnum character$charnum' id='$key$i'>$char</span>";
} else {
$data->{$key} .= "<span class='space character$charnum' id='$key$i'>$char</span>";
$wordnum++;
$charnum = 1;
}
$charnum++;
$i++;
}
$data->{$key} .= "</span>";
}
while ( my ($key, $value ) = each(%$data) ) {
$scheme =~ s/<$key>/$value/g;
}
$body = $scheme;
$template->param( autoprint => C4::Context->preference("SpineLabelAutoPrint") );
$template->param( content => $body );
output_html_with_http_headers $query, $cookie, $template->output;