From 1ac854a0a8596f2193354aad21460553a11708e7 Mon Sep 17 00:00:00 2001 From: Blou Date: Mon, 13 Apr 2015 17:15:01 -0400 Subject: [PATCH] Bug 12747 Add extra column in Z3950 search result 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 ) --- C4/Breeding.pm | 39 ++++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 +++++ .../prog/en/modules/acqui/z3950_search.tt | 13 ++++++++ .../en/modules/admin/preferences/cataloguing.pref | 5 +++ .../prog/en/modules/cataloguing/z3950_search.tt | 13 ++++++++ 6 files changed, 80 insertions(+) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index b5a4717..dcabdac 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -222,6 +222,19 @@ sub Z3950Search { $oConnection[$_]->destroy(); } + my @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, @@ -340,6 +353,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/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 878214f..43f6f43 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -6,6 +6,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'), ('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'), +('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/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 338246c..5857fda 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10025,6 +10025,13 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("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');"); + print "Upgrade to $DBversion done (Bug 12474 - Add extra column in Z3950 search result)\n"; + SetVersion($DBversion); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. @@ -10038,6 +10045,7 @@ while ( my $file = readdir $dirh ) { my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1; } + =head1 FUNCTIONS =head2 TableExists($table) 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 9b89e91..046e402 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 @@ -168,6 +168,9 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Author ISBN LCCN + [% IF additionalFields %] + Additional fields + [% END %] Preview   @@ -180,6 +183,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 bc35aad..d8036bd 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 @@ -215,3 +215,8 @@ Cataloging: yes: "do" 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)" + 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 79e8015..1ef8ed1 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 @@ -185,6 +185,9 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Edition ISBN LCCN + [% IF additionalFields %] + Additional fields + [% END %] MARC Card   @@ -200,6 +203,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 -- 2.1.0