[Koha-patches] [PATCH] Bug 7615 - Give option to use description for homebranch/holding branch in label creator instead of the branchcode

Chris Nighswonger cnighswonger at foundations.edu
Wed Feb 29 01:28:19 CET 2012


This patch adds the ability to print the name of the item's homebranch on labels

Thanks to Shane Sammons <ssammons-at-npelem.com> for the modified SQL SELECT statement.

Document Manager: The documentation will need to be updated to reflect the added field 'branchname' to the list
of available fields for label printing.

To test:

1. Create a new label layout or modify an existing one to include 'branchname'
2. Create a new label batch or using an existing one, export the batch.
3. Verify that the resulting labels contain the home branch name for the respective items.
---
 C4/Labels/Label.pm         |    7 ++++---
 labels/label-create-pdf.pl |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm
index 0aec0a6..d1ab98a 100644
--- a/C4/Labels/Label.pm
+++ b/C4/Labels/Label.pm
@@ -78,7 +78,7 @@ sub _get_label_item {
 #        FIXME This makes for a very bulky data structure; data from tables w/duplicate col names also gets overwritten.
 #        Something like this, perhaps, but this also causes problems because we need more fields sometimes.
 #        SELECT i.barcode, i.itemcallnumber, i.itype, bi.isbn, bi.issn, b.title, b.author
-    my $sth = $dbh->prepare("SELECT bi.*, i.*, b.* FROM items AS i, biblioitems AS bi ,biblio AS b WHERE itemnumber=? AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber;");
+    my $sth = $dbh->prepare("SELECT bi.*, i.*, b.*,br.* FROM items AS i, biblioitems AS bi ,biblio AS b, branches AS br WHERE itemnumber=? AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber AND i.homebranch=br.branchcode;");
     $sth->execute($item_number);
     if ($sth->err) {
         warn sprintf('Database returned the following error: %s', $sth->errstr);
@@ -185,7 +185,8 @@ sub _get_barcode_data {
         (
             @{ $kohatables->{'biblio'} },
             @{ $kohatables->{'biblioitems'} },
-            @{ $kohatables->{'items'} }
+            @{ $kohatables->{'items'} },
+            @{ $kohatables->{'branches'} }
         )
     );
     FIELD_LIST:
@@ -249,7 +250,7 @@ sub _get_barcode_data {
 sub _desc_koha_tables {
 	my $dbh = C4::Context->dbh();
 	my $kohatables;
-	for my $table ( 'biblio','biblioitems','items' ) {
+	for my $table ( 'biblio','biblioitems','items','branches' ) {
 		my $sth = $dbh->column_info(undef,undef,$table,'%');
 		while (my $info = $sth->fetchrow_hashref()){
 		        push @{$kohatables->{$table}} , $info->{'COLUMN_NAME'} ;
diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl
index 106b37d..6d32c6c 100755
--- a/labels/label-create-pdf.pl
+++ b/labels/label-create-pdf.pl
@@ -29,7 +29,7 @@ use C4::Labels 1.000000;
 
 my $cgi = new CGI;
 
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
+my ( undef, $loggedinuser, $cookie ) = get_template_and_user({
 								     template_name   => "labels/label-home.tt",
 								     query           => $cgi,
 								     type            => "intranet",
-- 
1.7.0.4



More information about the Koha-patches mailing list