3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 my $scheme = C4::Context->preference('SpineLabelFormat');
25 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
26 { template_name => "labels/spinelabel-print.tt",
30 flagsrequired => { catalogue => 1 },
35 my $barcode = $query->param('barcode');
37 my $dbh = C4::Context->dbh;
42 my $sql = "SELECT * FROM biblio, biblioitems, items
43 WHERE biblio.biblionumber = items.biblionumber
44 AND biblioitems.biblioitemnumber = items.biblioitemnumber
45 AND items.barcode = ?";
46 $sth = $dbh->prepare($sql);
47 $sth->execute($barcode);
48 $item = $sth->fetchrow_hashref;
50 unless (defined $item) {
51 $template->param( 'Barcode' => $barcode );
52 $template->param( 'BarcodeNotFound' => 1 );
55 # XXX FFZG #1059 -- dpavlin 2012-02-07 print spine labels
59 my $ip = $query->remote_addr;
61 if ( my $station = $query->param('station') ) {
63 warn "PRINTED $barcode on $station\n";
65 my $insert = $dbh->prepare(qq{
66 insert into items_print_log (barcode,itemnumber,station) values (?,?,?)
68 $insert->execute( $item->{barcode}, $item->{biblioitemnumber}, $station );
72 my $print_data = join(' ',
74 $item->{itemcallnumber},
77 print $query->redirect( 'http://printer-zebra.vbz.ffzg.hr/print.cgi?print=' . uri_escape_utf8($print_data) . '&return=' . uri_escape($query->self_url) );
87 while ( my ( $key, $value ) = each(%$item) ) {
88 $data->{$key} .= "<span class='field' id='$key'>";
90 $value = '' unless defined $value;
91 my @characters = split( //, $value );
95 foreach my $char (@characters) {
97 $data->{$key} .= "<span class='character word$wordernumber character$charnum' id='$key$i'>$char</span>";
99 $data->{$key} .= "<span class='space character$charnum' id='$key$i'>$char</span>";
107 $data->{$key} .= "</span>";
110 while ( my ( $key, $value ) = each(%$data) ) {
111 $scheme =~ s/<$key>/$value/g;
118 my $url = $query->url;
119 my $station = $query->param('station');
122 <style type="text/css">
127 border: 1px solid #aaa;
134 <form action="$url" method="get" autocomplete="off">
135 Enter another barcode:
136 <input id=focus_barcode type=text name=barcode autofocus autocomplete="off">
137 <input type=submit value="Print">
140 <h1>Last printed call number for $barcode on $station</h1>
142 <img id="printed_label" src="http://printer-zebra.vbz.ffzg.hr/$barcode.png">
144 <script type="text/javascript">
145 function formfocus() {
146 document.getElementById('focus_barcode').focus();
148 window.onload = formfocus;
155 $template->param( autoprint => C4::Context->preference("SpineLabelAutoPrint") );
156 $template->param( content => $body );
158 output_html_with_http_headers $query, $cookie, $template->output;