#!/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} .= ""; my @characters = split(//, $value ); my $charnum = 1; my $wordnum = 1; my $i = 1; foreach my $char ( @characters ) { if ( $char ne ' ' ) { $data->{$key} .= "$char"; } else { $data->{$key} .= "$char"; $wordnum++; $charnum = 1; } $charnum++; $i++; } $data->{$key} .= ""; } 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;