From ae751e3b1b08086ab2cc13c152bc78e044249dd1 Mon Sep 17 00:00:00 2001 From: simith Date: Mon, 11 Aug 2014 14:40:58 -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 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. sponsored by the CCSR ( http://www.ccsr.qc.ca ) --- C4/Breeding.pm | 35 ++++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++ .../prog/en/modules/acqui/z3950_search.tt | 10 +++++++ .../en/modules/admin/preferences/acquisitions.pref | 4 +++ 5 files changed, 57 insertions(+) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 03f3ed5..113d507 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -293,6 +293,15 @@ sub Z3950Search { 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, @@ -342,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/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 03a3f1e..dda96b6 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -5,6 +5,7 @@ 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'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3f1af57..c1f1688 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8603,6 +8603,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); +} + =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 99096e5..c7efcbe 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 @@ -157,6 +157,9 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Author ISBN LCCN + [% IF additionalFields %] + Additional fields + [% END %] Preview   @@ -169,6 +172,13 @@ 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/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index ac57f95..4b6baae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -57,6 +57,10 @@ Acquisitions: type: textarea - "You can use the following fields: price, quantity, budget_code, discount, sort1, sort2" - "
For example:
price: 947$a|947$c
quantity: 969$h
budget_code: 922$a" + - + - 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)" Printing: - - Use the -- 1.9.1