From 6860310e965bfd734501408b9897c5162a6025ff Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 10 Jul 2009 15:50:25 +0000 Subject: [PATCH] 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 --- .../data/mysql/en/mandatory/sysprefs.sql | 2 + .../unimarc_standard_systemprefs.sql | 2 + installer/data/mysql/updatedatabase.pl | 7 ++ .../intranet-tmpl/prog/en/css/spinelabel.css | 27 +++++++ .../en/modules/labels/spinelabel-home.tmpl | 24 ++++++ .../en/modules/labels/spinelabel-print.tmpl | 14 ++++ .../prog/en/modules/tools/tools-home.tmpl | 5 ++ labels/spinelabel-home.pl | 27 +++++++ labels/spinelabel-print.pl | 73 +++++++++++++++++++ 9 files changed, 181 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/css/spinelabel.css create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-home.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-print.tmpl create mode 100755 labels/spinelabel-home.pl create mode 100755 labels/spinelabel-print.pl diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index a978fad3d1..3b78ae959e 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -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', '', '', '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 .', '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'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index 424b716039..0f2cb571f8 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -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', '', '', '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 .', '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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d6ccd0a52d..aaa5a0c4da 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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', '', '', '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 .', '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 index 0000000000..f0e3ead39c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/css/spinelabel.css @@ -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 index 0000000000..c7c9879fe6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-home.tmpl @@ -0,0 +1,24 @@ +Koha › Tools › Labels + + + + + + + + +
+ +
+
+
+
+ + + +
+
+
+
+
+ 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 index 0000000000..8897435219 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/spinelabel-print.tmpl @@ -0,0 +1,14 @@ + + + Koha › Tools › Spine Labels + /css/spinelabel.css" /> + + onLoad="window.print()" + + +
+
+ + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl index 75d810400b..be817d9f78 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl @@ -24,6 +24,11 @@
Create printable labels and barcodes from catalog data and patron cards from patron data
+ +
Quick Spine Label Creator
+
Enter a barcode to generate a printable spine label
+ +
Calendar
Define days when the library is closed
diff --git a/labels/spinelabel-home.pl b/labels/spinelabel-home.pl new file mode 100755 index 0000000000..6a505c103f --- /dev/null +++ b/labels/spinelabel-home.pl @@ -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 index 0000000000..04d7935c61 --- /dev/null +++ b/labels/spinelabel-print.pl @@ -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} .= ""; + + 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; -- 2.39.5