From c654b9205c0fee4dc33241c973d608c374bc9fe7 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Wed, 7 Mar 2012 20:35:59 +1300 Subject: [PATCH] Bug 4222 - allow nonpublicnote to be a mapped DB column Content-Type: text/plain; charset="UTF-8" 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. --- catalogue/detail.pl | 11 ++++++++++- catalogue/moredetail.pl | 1 + circ/returns.pl | 1 + installer/data/mysql/kohastructure.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/modules/catalogue/detail.tt | 2 ++ .../prog/en/modules/catalogue/moredetail.tt | 1 + .../prog/en/modules/circ/circulation.tt | 8 ++++---- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 1 + 9 files changed, 30 insertions(+), 5 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index be4fd9a..fdb9de3 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -245,6 +245,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|
|g; + $itemfields{$f} = 1; + } + } + # item has a host number if its biblio number does not match the current bib if ($item->{biblionumber} ne $biblionumber){ $item->{hostbiblionumber} = $item->{biblionumber}; @@ -260,6 +267,7 @@ foreach my $item (@items) { if ($item->{'materials'} ne ''){ $materials_flag = 1; } + push @itemloop, $item; } @@ -278,7 +286,8 @@ $template->param( itemdata_uri => $itemfields{uri}, itemdata_copynumber => $itemfields{copynumber}, volinfo => $itemfields{enumchron}, - itemdata_itemnotes => $itemfields{itemnotes}, + itemdata_itemnotes => $itemfields{itemnotes}, + itemdata_nonpublicnote => $itemfields{nonpublicnote}, z3950_search_params => C4::Search::z3950_search_args($dat), holdcount => $holdcount, hostrecords => $hostrecords, diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index ca7d13c..c112371 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -183,6 +183,7 @@ foreach my $item (@items){ } } + $item->{nonpublicnote} =~ s|\n|
|g if $item->{nonpublicnote}; } $template->param(count => $data->{'count'}, subscriptionsnumber => $subscriptionsnumber, diff --git a/circ/returns.pl b/circ/returns.pl index bd60d42..17d09e1 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -588,6 +588,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { $ri{itemcallnumber} = $biblio->{'itemcallnumber'}; $ri{itemtype} = $biblio->{'itemtype'}; $ri{itemnote} = $biblio->{'itemnotes'}; + $ri{nonpublicnote} = $biblio->{'nonpublicnote'}; $ri{ccode} = $biblio->{'ccode'}; $ri{itemnumber} = $biblio->{'itemnumber'}; $ri{barcode} = $bar_code; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 54498c3..1bb3059 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -765,6 +765,7 @@ CREATE TABLE `deleteditems` ( `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x) + `nonpublicnote` mediumtext default NULL, `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b) `paidfor` mediumtext, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered @@ -1032,6 +1033,7 @@ CREATE TABLE `items` ( -- holdings/item information `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x) + `nonpublicnote` mediumtext default NULL, `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b) `paidfor` mediumtext, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9cd4b14..0124e28 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5336,6 +5336,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = '3.09.00.XXX'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE items ADD COLUMN nonpublicnote MEDIUMTEXT AFTER itemnotes"); + $dbh->do("ALTER TABLE deleteditems ADD COLUMN nonpublicnote MEDIUMTEXT AFTER itemnotes"); + $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. If you have mapped your items to a MARC field other than 952 (system default), please check your Koha to MARC mapping for items.nonpublicnote)\n"; +} + =head1 FUNCTIONS =head2 TableExists($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 c92a891..8738761 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -281,6 +281,7 @@ function verify_images() { [% IF ( itemdata_copynumber ) %]Copy no.[% END %] [% IF materials %]Materials specified[% END %] [% IF ( itemdata_itemnotes ) %]Public notes[% END %] + [% IF itemdata_nonpublicnote %]Non-public note[% END %] [% IF ( SpineLabelShowPrintOnBibDetails ) %]Spine label[% END %] [% IF ( hostrecords ) %]Host records[% END %] [% IF ( analyze ) %]Used in[% END %] @@ -405,6 +406,7 @@ function verify_images() { [% itemloo.materials %] [% END %] [% IF ( itemdata_itemnotes ) %]
[% itemloo.itemnotes %]
[% END %] + [% IF itemdata_nonpublicnote %][% itemloo.nonpublicnote %][% END %] [% IF ( SpineLabelShowPrintOnBibDetails ) %] Print label [% 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 afd2a6d..6eece76 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -206,6 +206,7 @@ [% IF ( ITEM_DAT.card2 ) %]
  • Previous borrower: [% ITEM_DAT.card2 %] 
  • [% END %] [% IF ( ITEM_DAT.paidfor ) %]
  • Paid for?: [% ITEM_DAT.paidfor %] 
  • [% END %] [% IF ( ITEM_DAT.enumchron ) %]
  • Serial enumeration: [% ITEM_DAT.enumchron %] 
  • [% END %] + [% IF ( ITEM_DAT.nonpublicnote ) %]
  • Non-public note: [% ITEM_DAT.nonpublicnote %] 
  • [% END %]
  • Public note: [% IF ( CAN_user_editcatalogue_edit_items ) %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 6877737..6428aa8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -726,7 +726,7 @@ No patron matched [% message %] [% IF ( todayissue.od ) %][% ELSE %][% END %] [% todayissue.dd %] - [% todayissue.title |html %][% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- [% todayissue.itemnotes %][% END %] [% todayissue.barcode %] + [% todayissue.title |html %][% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- [% todayissue.itemnotes %][% END %][% IF ( todayissue.nonpublicnote ) %]- [% todayissue.nonpublicnote %][% END %] [% todayissue.barcode %] [% UNLESS ( noItemTypeImages ) %] [% IF ( todayissue.itemtype_image ) %][% END %][% END %][% todayissue.itemtype %] [% todayissue.checkoutdate %] [% IF ( todayissue.multiple_borrowers ) %][% todayissue.firstname %] [% todayissue.surname %][% END %] @@ -799,7 +799,7 @@ No patron matched [% message %] [% IF ( previssue.od ) %][% ELSE %][% END %] [% previssue.dd %] - [% previssue.title |html %][% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] [% previssue.barcode %] + [% previssue.title |html %][% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %][% IF ( previssue.nonpublicnote ) %]- [% previssue.nonpublicnote %][% END %] [% previssue.barcode %] [% previssue.itemtype %] @@ -907,7 +907,7 @@ No patron matched [% message %] [% END %] [% IF ( relissue.overdue ) %][% ELSE %][% END %] [% relissue.dd %] - [% relissue.title |html %][% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- [% relissue.itemnotes %][% END %] [% relissue.barcode %] + [% relissue.title |html %][% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- [% relissue.itemnotes %][% END %][% IF ( relissue.nonpublicnote ) %]- [% relissue.nonpublicnote %][% END %] [% relissue.barcode %] [% UNLESS ( noItemTypeImages ) %] [% IF ( relissue.itemtype_image ) %][% END %][% END %][% relissue.itemtype %] [% relissue.displaydate %] [% relissue.issuingbranchname %] @@ -928,7 +928,7 @@ No patron matched [% message %] [% IF ( relprevissue.overdue ) %][% ELSE %][% END %] [% relprevissue.dd %] - [% relprevissue.title |html %][% IF ( relprevissue.author ) %], by [% relprevissue.author %][% END %] [% IF ( relprevissue.itemnotes ) %]- [% relprevissue.itemnotes %][% END %] [% relprevissue.barcode %] + [% relprevissue.title |html %][% IF ( relprevissue.author ) %], by [% relprevissue.author %][% END %] [% IF ( relprevissue.itemnotes ) %]- [% relprevissue.itemnotes %][% END %][% IF ( relprevissue.nonpublicnote ) %] - [% relprevissue.nonpublicnote %][% END %] [% relprevissue.barcode %] [% UNLESS noItemTypeImages %][% IF relprevissue.itemtype_image %][% END %][% END %][% relprevissue.itemtype %] [% relprevissue.displaydate %] [% relprevissue.issuingbranchname %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 835724f..c8327d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -453,6 +453,7 @@ $(document).ready(function () { [% ELSE %]Not checked out[% END %] [% IF ( riloo.bornote ) %][% riloo.bornote %]
    [% END %] [% IF ( riloo.itemnote ) %][% riloo.itemnote %][% END %] + [% IF ( riloo.nonpublicnote ) %][% riloo.nonpublicnote %][% END %] [% END %] -- 1.7.2.5