From 3f95f503c70571b5143bea76084f42b2f2561717 Mon Sep 17 00:00:00 2001
From: Ebin Joseph <ebin.joseph@osslabs.biz>
Date: Fri, 8 Jun 2012 15:11:50 +0530
Subject: [PATCH] Display barcode on OPAC detail page

---
 installer/data/mysql/sysprefs.sql                  |    1 +
 installer/data/mysql/updatedatabase.pl             |    7 +++++++
 .../prog/en/modules/admin/preferences/opac.pref    |    7 +++++++
 koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt |    2 ++
 opac/opac-detail.pl                                |    1 +
 5 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 2ffe2df..9fa3382 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -328,6 +328,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowBarcodeCatalogDetail','0','items barcode in catalog detail page ','','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('BorrowerUnwantedField','','Name the fields you don\'t need to store for a patron\'s account',NULL,'free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','1',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL);
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index dbbdee3..06ddbea 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5308,6 +5308,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.09.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACShowBarcodeCatalogDetail','0','items barcode in catalog detail page ','','YesNo')");
+    print "Upgrade to $DBversion done (Add syspref OPACShowBarcodeCatalogDetail)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
index e4ea15b..d5a14b5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -50,6 +50,13 @@ OPAC:
                   no: "don't"
             - open the website in a new window.
         -
+            - pref: OPACShowBarcodeCatalogDetail
+              default: 0
+              choices:
+                  yes: Show
+                  no: "Don't show"
+            - items barcode in catalog detail page
+        -
             - pref: hidelostitems
               choices:
                   yes: "Don't show"
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
index 3c45aff..56396cb 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
@@ -718,6 +718,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
             <th id="item_status">Status</th>
             [% IF ( itemdata_itemnotes ) %]<th id="item_notes">Notes</th>[% END %]
             <th id="item_datedue">Date due</th>
+			[% IF ( OPACShowBarcodeCatalogDetail ) %]<th>Barcode</th>[% END %]
         [% IF holds_count.defined %]
             <th>Item holds</th>
         [% ELSIF show_priority %]
@@ -747,6 +748,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 		<td>[% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td>
 		[% IF ( itemdata_itemnotes ) %]<td>[% ITEM_RESULT.itemnotes %]</td>[% END %]
 		<td>[% ITEM_RESULT.datedue | $KohaDates %]</td>
+		[% IF ( OPACShowBarcodeCatalogDetail ) %]<td>[% ITEM_RESULT.barcode %]</td> [% END %]
         [% IF holds_count.defined || show_priority %]
         <td>
             [% IF holds_count.defined %] [% ITEM_RESULT.holds_count %] [% END %]
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 0014c27..e2bb585 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -390,6 +390,7 @@ $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
 
 
 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); 
+$template->param('OPACShowBarcodeCatalogDetail' => C4::Context->preference("OPACShowBarcodeCatalogDetail") );
 # change back when ive fixed request.pl
 my @all_items = GetItemsInfo( $biblionumber );
 
-- 
1.7.1