[Koha-patches] [PATCH 1/2] Bug 4222 - allow nonpublicnote to be a mapped DB column

Jesse Weaver pianohacker at gmail.com
Fri Jun 3 03:51:40 CEST 2011


From: Robin Sheat <robin at catalyst.net.nz>

This means that it's possible (and easy) to put non-public notes
(usually 952$x) on a template, same as public notes. It creates a
mapping between the 952$x field and the new database column.

Note that when this is applied, it will only work on newly saved records.

It is possible this will need to be altered to allow for UNIMARC etc. if
they use 952 differently.

Signed-off-by: Jesse Weaver <pianohacker at gmail.com>
---
 catalogue/detail.pl                                |    8 ++++++++
 catalogue/moredetail.pl                            |    1 +
 installer/data/mysql/updatedatabase.pl             |    7 +++++++
 .../prog/en/modules/catalogue/detail.tt            |    4 +++-
 .../prog/en/modules/catalogue/moredetail.tt        |    1 +
 5 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index 03271b4..9abc3e4 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -224,6 +224,13 @@ foreach my $item (@items) {
         $item->{waitingdate} = format_date($wait_hashref->{waitingdate});
     }
 
+    foreach my $f (qw( itemnotes nonpublicnote )) {
+        if ($item->{$f}) {
+            $item->{$f} =~ s|\n|<br />|g;
+            $itemfields{$f} = 1;
+        }
+    }
+
     push @itemloop, $item;
 }
 
@@ -242,6 +249,7 @@ $template->param(
 	itemdata_copynumber => $itemfields{copynumber},
 	volinfo				=> $itemfields{enumchron},
     itemdata_itemnotes  => $itemfields{itemnotes},
+	itemdata_nonpublicnote  => $itemfields{nonpublicnote},
 	z3950_search_params	=> C4::Search::z3950_search_args($dat),
     holdcount           => $holdcount,
 	C4::Search::enabled_staff_search_views,
diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl
index d848188..364c26c 100755
--- a/catalogue/moredetail.pl
+++ b/catalogue/moredetail.pl
@@ -145,6 +145,7 @@ foreach my $item (@items){
     } else {
         $item->{'issue'}= 0;
     }
+    $item->{nonpublicnote} =~ s|\n|<br />|g if $item->{nonpublicnote};
 }
 $template->param(count => $data->{'count'},
 	subscriptionsnumber => $subscriptionsnumber,
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 52951e7..d6bc16c 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4332,6 +4332,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = '3.05.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("ALTER TABLE items ADD COLUMN nonpublicnote MEDIUMTEXT");
+    $dbh->do("UPDATE marc_subfield_structure SET kohafield='items.nonpublicnote' WHERE (kohafield IS NULL OR kohafield = '') AND tagfield='952' AND tagsubfield='x'");
+    print "Upgrade to $DBversion done (Make nonpublicnote easier to use)\n";
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
index a019733..8a57aff 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -246,7 +246,8 @@ function verify_images() {
                 [% IF ( volinfo ) %]<th>Publication Details</th>[% END %]
                 [% IF ( itemdata_uri ) %]<th>url</th>[% END %]
                 [% IF ( itemdata_copynumber ) %]<th>Copy No.</th>[% END %]
-                [% IF ( itemdata_itemnotes ) %]<th>Public notes</th>[% END %]
+                [% IF ( itemdata_itemnotes ) %]<th>Public Notes</th>[% END %]
+                [% IF ( itemdata_nonpublicnote ) %]<th>Non-public Notes</th>[% END %]
 		[% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine Label</th>[% END %]
             </tr>
             [% FOREACH itemloo IN itemloop %]
@@ -370,6 +371,7 @@ function verify_images() {
 					<td class="copynumber">[% itemloo.copynumber %]</td>
 				[% END %]
                 [% IF ( itemdata_itemnotes ) %]<td><div class="itemnotes">[% itemloo.itemnotes %]</div></td>[% END %]
+                [% IF ( itemdata_nonpublicnote ) %]<td><div class="itemnotes">[% itemloo.nonpublicnote %]</div></td>[% END %]
                 [% IF ( itemloo.type ) %]
                     <td><a href="/cgi-bin/koha/maint/catmaintain.pl?type=fixitemtype&amp;bi=[% itemloo.biblioitemnumber %]&amp;item=[% itemloo.itemtype %]">Fix Itemtype</a></td>
                 [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
index 86c8a3f..c9dac79 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
@@ -173,6 +173,7 @@
                 [% IF ( ITEM_DAT.card1 ) %]<li><span class="label">Previous Borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower1 %]">[% ITEM_DAT.card1 %]</a>&nbsp;</li>[% END %]
 		[% IF ( ITEM_DAT.card2 ) %]<li><span class="label">Previous Borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower2 %]">[% ITEM_DAT.card2 %]</a>&nbsp;</li>[% END %]
                 <li><span class="label">Paid for?:</span> [% ITEM_DAT.paidfor %]&nbsp;</li>
+                <li><span class="label">Non-public Note:<span> [% ITEM_DAT.nonpublicnote %]&nbsp;</li>
             <li><span class="label">Serial enumeration:</span> [% ITEM_DAT.enumchron %]&nbsp;</li>
             <li><span class="label">Public Note:</span>
                 [% IF ( CAN_user_editcatalogue_edit_items ) %]
-- 
1.7.4.1



More information about the Koha-patches mailing list