From ecd59ad4dd8a61e071babc051c7222e3a6b42e52 Mon Sep 17 00:00:00 2001 From: charles Date: Thu, 23 Apr 2015 11:25:56 -0400 Subject: [PATCH] Bug 12747 - Add extra column in Z3950 search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch permits to add an extra column in Z3950 search result. The system preference AdditionalFieldsInZ3950ResultSearch maps which MARC field/subfields are displayed in the column. Testing: I Apply the patch II Run updatedatabase.pl ACQUISITIONS 0) Enter a field/subfield in the AdditionalFieldsInZ3950ResultSearch 1) Create a new basket or use an existing one 2) In -Add order to basket-, click "From an external source" 3) Select some search targets and enter a subject heading ex. house 4) Click Search bouton 5) Validate "Additional fields" column with the field/subfield value. CATALOGUING 0) shares same syspref as above 1) Go to cataloguing, click New from z3950 2) fill to result in a successful search 3) validate column Addition Fields sponsored by the CCSR ( http://www.ccsr.qc.ca ) Tested with both patches together, followed test plan, works as expected Signed-off-by: Marc Véron --- C4/Breeding.pm | 39 ++++++++++++++++++++++ ...47-additional_fields_in_Z3950_search_result.sql | 1 + installer/data/mysql/sysprefs.sql | 2 ++ .../prog/en/modules/acqui/z3950_search.tt | 13 ++++++++ .../en/modules/admin/preferences/cataloguing.pref | 4 +++ .../prog/en/modules/cataloguing/z3950_search.tt | 13 ++++++++ 6 files changed, 72 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql diff --git a/C4/Breeding.pm b/C4/Breeding.pm index ee14c81..e4848d1 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -220,6 +220,19 @@ sub Z3950Search { $oConnection[$_]->destroy(); } + @servers = (); + foreach my $id (@id) { + push @servers, {id => $id}; + } + + my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch'); + $pref_addnumber =~ s/\s+//g; + if ($pref_addnumber){ + $template->param( + additionalFields => '1', + ); + } + $template->param( breeding_loop => \@breeding_loop, servers => \@servers, @@ -338,6 +351,32 @@ sub _add_rowdata { } $row->{date}//= $row->{date2}; $row->{isbn}=_isbn_replace($row->{isbn}); + + my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch'); + $pref_addnumber =~ s/\s+//g; + my @addnumber_array = split /;/, $pref_addnumber; + my @addnumberfields; + foreach (@addnumber_array) { + my $length = length($_); + my $adTag = substr($_, 0, 3); + my $row_field = 'field_'.$adTag; + if ($record->field($adTag)) { + my $field = $record->field($adTag); + my $fieldContent=''; + if ($length > 3){ + my $adSubfield; + for (my $i=0; $i<$length-3; $i++){ + $adSubfield = substr($_, 3+$i, 1); + $fieldContent = $fieldContent.$field->subfield($adSubfield).' '; + } + push(@addnumberfields, $_); + $row->{$_} = $fieldContent; + } + } + } + + $row->{'addnumberfields'} = \@addnumberfields; + return $row; } diff --git a/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql b/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql new file mode 100644 index 0000000..2a6013f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql @@ -0,0 +1 @@ +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdditionalFieldsInZ3950ResultSearch', '', 'NULL', 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ef83c3d..51d5363 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -7,6 +7,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), ('AddressFormat','us','','Choose format to display postal addresses', 'Choice'), +('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'), +('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'), ('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'), ('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option. Example: eng|fre|ita','Textarea'), ('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt index e7e8fff..21f258f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt @@ -130,6 +130,9 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Author ISBN LCCN + [% IF additionalFields %] + Additional fields + [% END %] Preview   @@ -142,6 +145,16 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : [% breeding_loo.author %] [% breeding_loo.isbn %] [% breeding_loo.lccn %] + [% IF additionalFields %] + +
+ [% FOREACH addnumberfield IN breeding_loo.addnumberfields %] +
[% addnumberfield %]:
+
[% breeding_loo.$addnumberfield %]
+ [% END %] +
+ + [% END %] MARCCard Order diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 1aeadf9..60b0fad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -225,6 +225,10 @@ Cataloging: no: "don't" - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records. Note that this preference has no effect if UseQueryParser is on. - + - Determines the MARC field/subfields + - pref: AdditionalFieldsInZ3950ResultSearch + - "are displayed in 'Additional fields' column in the result of a search Z3950 (use semicolon as delimiter ex: 082ab;090ab)" + - - When matching on ISSN with the record import tool, - pref: AggressiveMatchOnISSN choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt index c7bc15a..2865ac9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt @@ -143,6 +143,9 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Edition ISBN LCCN + [% IF additionalFields %] + Additional fields + [% END %] MARC Card   @@ -158,6 +161,16 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : [% breeding_loo.edition %] [% breeding_loo.isbn %] [% breeding_loo.lccn %] + [% IF additionalFields %] + +
+ [% FOREACH addnumberfield IN breeding_loo.addnumberfields %] +
[% addnumberfield %]:
+
[% breeding_loo.$addnumberfield %]
+ [% END %] +
+ + [% END %] MARC Card Import -- 1.9.1