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

Ian Walls ian.walls at bywatersolutions.com
Sat Nov 13 18:31:34 CET 2010


I believe that UNIMARC uses 995 as the items field, rather than 952.

This patch does not cleanly apply to master anymore; this seems to be
because of the recently-committed work on Bug 4924.  A duplicate entry for
Public Notes is found in the staff client.

I'm working on a revised version of this patch to address the above issues,
as well as to automatically update items.nonpublicnote with any pre-existing
non-public notes existing only in the MARC.

Depending on the number of biblios, this could cause the
updatedatabase.plscript to take a VERY long time to complete.  It
would also require the use
of C4::Biblio (or else rewriting the GetMarcBiblio subroutine within the
updatedatabase.pl script).  Is it worth making this part of
updatedatabase.pl, or should a separate cleanup script be written?


-Ian

On Thu, Nov 11, 2010 at 10:27 PM, Robin Sheat <robin at catalyst.net.nz> wrote:

> 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                                |    9 +++++++++
>  catalogue/moredetail.pl                            |    1 +
>  installer/data/mysql/updatedatabase.pl             |    6 ++++++
>  .../prog/en/modules/catalogue/detail.tmpl          |    4 ++++
>  .../prog/en/modules/catalogue/moredetail.tmpl      |    2 ++
>  5 files changed, 22 insertions(+), 0 deletions(-)
>
> diff --git a/catalogue/detail.pl b/catalogue/detail.pl
> index 4f6c23f..624a141 100755
> --- a/catalogue/detail.pl
> +++ b/catalogue/detail.pl
> @@ -197,6 +197,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;
>  }
>
> @@ -213,6 +220,8 @@ $template->param(
>        itemdata_uri        => $itemfields{uri},
>        itemdata_copynumber => $itemfields{copynumber},
>        volinfo                         => $itemfields{enumchron},
> +       itemdata_itemnotes  => $itemfields{itemnotes},
> +       itemdata_nonpublicnote  => $itemfields{nonpublicnote},
>        z3950_search_params     => C4::Search::z3950_search_args($dat),
>        C4::Search::enabled_staff_search_views,
>  );
> diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl
> index d790c41..95598f7 100755
> --- a/catalogue/moredetail.pl
> +++ b/catalogue/moredetail.pl
> @@ -119,6 +119,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.plb/installer/data/mysql/
> updatedatabase.pl
> index 27daa38..84d5428 100755
> --- a/installer/data/mysql/updatedatabase.pl
> +++ b/installer/data/mysql/updatedatabase.pl
> @@ -3835,6 +3835,12 @@ if (C4::Context->preference("Version") <
> TransformToNum($DBversion)) {
>     SetVersion ($DBversion);
>  }
>
> +$DBversion = '3.03.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.tmpl
> b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> index 1861028..a391744 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> @@ -211,6 +211,8 @@ function verify_images() {
>                 <th>Status</th>
>                 <th>Last seen</th>
>                 <th>Barcode</th>
> +                <!-- TMPL_IF NAME="itemdata_itemnotes" --><th>Public
> Note</th><!-- /TMPL_IF -->
> +                <!-- TMPL_IF NAME="itemdata_nonpublicnote"
> --><th>Non-public Note</th><!-- /TMPL_IF -->
>                 <!-- TMPL_IF NAME="volinfo" --><th>Publication
> Details</th><!-- /TMPL_IF -->
>                 <!-- TMPL_IF NAME="itemdata_uri" --><th>URL</th><!--
> /TMPL_IF -->
>                 <!-- TMPL_IF NAME="itemdata_copynumber" --><th>Copy
> No.</th><!-- /TMPL_IF -->
> @@ -319,6 +321,8 @@ function verify_images() {
>                     </td>
>                     <td class="datelastseen"><!-- TMPL_VAR
> NAME="datelastseen" --></td>
>                     <td><a href="/cgi-bin/koha/catalogue/
> moredetail.pl?type=<!-- TMPL_VAR NAME="type" -->&amp;itemnumber=<!--
> TMPL_VAR NAME="itemnumber" -->&amp;biblionumber=<!-- TMPL_VAR
> NAME="biblionumber" -->&amp;bi=<!-- TMPL_VAR NAME="biblioitemnumber"
> -->#item<!-- TMPL_VAR NAME="itemnumber">"><!-- TMPL_VAR NAME="barcode"
> --></a></td>
> +                    <!-- TMPL_IF NAME="itemdata_itemnotes" --><td
> class="itemnotes"><!-- TMPL_VAR NAME="itemnotes" --></td><!-- /TMPL_IF -->
> +                    <!-- TMPL_IF NAME="itemdata_nonpublicnote" --><td
> class="nonpublicnote"><!-- TMPL_VAR NAME="nonpublicnote" --></td><!--
> /TMPL_IF -->
>                                <!-- TMPL_IF NAME="volinfo" --> <td
> class="enumchron">
>                                        <!-- TMPL_IF
> NAME="itemdata_enumchron" -->
>                                                <!-- TMPL_IF
> NAME="enumchron" -->
> diff --git
> a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl
> b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl
> index 55ca81f..f2a939b 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl
> @@ -166,6 +166,8 @@
>                 <!-- TMPL_IF NAME="card1" --><li><span
> class="label">Previous Borrower:</span> <a href="/cgi-bin/koha/circ/
> circulation.pl?borrowernumber=<!-- TMPL_VAR NAME="borrower1" -->"><!--
> TMPL_VAR NAME="card1" --></a>&nbsp;</li><!-- /TMPL_IF -->
>                <!-- TMPL_IF NAME="card2" --><li><span
> class="label">Previous Borrower:</span> <a href="/cgi-bin/koha/circ/
> circulation.pl?borrowernumber=<!-- TMPL_VAR NAME="borrower2" -->"><!--
> TMPL_VAR NAME="card2" --></a>&nbsp;</li><!-- /TMPL_IF -->
>                 <li><span class="label">Paid for?:</span> <!-- TMPL_VAR
> NAME="paidfor" -->&nbsp;</li>
> +                <li><span class="label">Non-public Note:</span>
> +                    <!-- TMPL_VAR NAME="nonpublicnote" -->&nbsp;</li>
>             <li><span class="label">Public Note:</span>
>                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
>               <form class="inline" action="updateitem.pl"
> method="post"><input type="hidden" name="biblionumber" value="<!-- TMPL_VAR
> Name="biblionumber" -->" />
> --
> 1.7.1
>
> _______________________________________________
> Koha-patches mailing list
> Koha-patches at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>



-- 
Ian Walls
Lead Development Specialist
ByWater Solutions
Phone # (888) 900-8944
http://bywatersolutions.com
ian.walls at bywatersolutions.com
Twitter: @sekjal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20101113/4bb1d62c/attachment-0001.htm>


More information about the Koha-patches mailing list