Quick Spine Label Printer
authorKyle M Hall <kyle.m.hall@gmail.com>
Fri, 10 Jul 2009 15:50:25 +0000 (15:50 +0000)
committerGalen Charlton <gmcharlt@gmail.com>
Sat, 1 Aug 2009 14:47:13 +0000 (10:47 -0400)
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>
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/css/spinelabel.css [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-home.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-print.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl
labels/spinelabel-home.pl [new file with mode: 0755]
labels/spinelabel-print.pl [new file with mode: 0755]

index a978fad..3b78ae9 100644 (file)
@@ -245,3 +245,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelFormat', '<itemcallnumber><copynumber>', '', 'This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.', 'Textarea');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelAutoPrint', '0', '', 'If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.', 'YesNo');
index 424b716..0f2cb57 100644 (file)
@@ -247,3 +247,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Autoriser l''affichage MARC labellis des notices bibliographiques','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Autoriser l''affichage de la vue MARC des notices bibliographiques','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Ne pas lancer le rapport sur les retards tant qu''il n''y a pas de filtre','','YesNo');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelFormat', '<itemcallnumber><copynumber>', '', 'This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.', 'Textarea');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelAutoPrint', '0', '', 'If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.', 'YesNo');
index d6ccd0a..aaa5a0c 100755 (executable)
@@ -2480,6 +2480,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.01.00.038';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelFormat', '<itemcallnumber><copynumber>', '', 'This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.', 'Textarea')");
+    SetVersion ($DBversion);
+    print "Upgrade to $DBversion done (added SpineLabelFormat syspref)\n";
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/spinelabel.css b/koha-tmpl/intranet-tmpl/prog/en/css/spinelabel.css
new file mode 100644 (file)
index 0000000..f0e3ead
--- /dev/null
@@ -0,0 +1,27 @@
+body {
+       font-family: arial, geneva, sans-serif;
+       font-size: 12px;
+       margin: 0px 0px 0px 0px;
+}
+
+/* Line break after each field */
+.field{
+       display: block;
+}
+
+/* Line break after each space in the itemcallnumber field */
+#itemcallnumber .space {
+       display: block;
+}
+
+/* Put the copynumber on the bottom of the label */
+#copynumber {
+       position: absolute;
+       top: 75px;
+}
+
+#print_button {
+       position: absolute;
+       top: 25px;
+       left: 500px;
+}
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-home.tmpl
new file mode 100644 (file)
index 0000000..c7c9879
--- /dev/null
@@ -0,0 +1,24 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha &rsaquo; Tools &rsaquo; Labels</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Spine Labels</div>
+
+<div id="doc3" class="yui-t2">
+   
+       <div id="bd">
+               <div id="yui-main">
+                       <div class="yui-b">
+                               <form action="/cgi-bin/koha/labels/spinelabel-print.pl" method="post">
+                                       <label>Barcode: </label>
+                                       <input type="text" name="barcode" id="barcode" />
+                                       <input type="submit" value="View Spine Label" />
+                               </form>
+                       </div>
+               </div>
+       </div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-print.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-print.tmpl
new file mode 100644 (file)
index 0000000..8897435
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+       <head>
+               <title>Koha &rsaquo; Tools &rsaquo; Spine Labels</title>
+               <link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/css/spinelabel.css" />
+       </head>
+       <body <!-- TMPL_IF NAME="autoprint">onLoad="window.print()"<!-- /TMPL_IF> >
+               <span id="spinelabel" class="label">
+                       <!-- TMPL_VAR NAME="content" -->
+               </span>
+               <span id="print_button">
+                       <form><input type="button" value="Print This Label" onClick="window.print()" /></form>
+               </span>
+       </body>
+</html>
\ No newline at end of file
index 75d8104..be817d9 100644 (file)
     <dd>Create printable labels and barcodes from catalog data and patron cards from patron data</dd>
     <!-- /TMPL_IF -->
 
+    <!-- TMPL_IF NAME="CAN_user_tools_label_creator" -->
+    <dt><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick Spine Label Creator</a></dt>
+    <dd>Enter a barcode to generate a printable spine label</dd>
+    <!-- /TMPL_IF -->
+
     <!-- TMPL_IF NAME="CAN_user_tools_edit_calendar" -->
     <dt><a href="/cgi-bin/koha/tools/holidays.pl">Calendar</a></dt>
     <dd>Define days when the library is closed</dd>
diff --git a/labels/spinelabel-home.pl b/labels/spinelabel-home.pl
new file mode 100755 (executable)
index 0000000..6a505c1
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Output;
+use C4::Labels;
+use C4::Output;
+use C4::Context;
+use HTML::Template::Pro;
+
+# use Smart::Comments;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "labels/spinelabel-home.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { catalogue => 1 },
+        debug           => 1,
+    }
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/labels/spinelabel-print.pl b/labels/spinelabel-print.pl
new file mode 100755 (executable)
index 0000000..04d7935
--- /dev/null
@@ -0,0 +1,73 @@
+#!/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;