View | Details | Raw Unified | Return to bug 12747
Collapse All | Expand All

(-)a/C4/Breeding.pm (+41 lines)
Lines 25-30 use C4::Biblio; Link Here
25
use C4::Koha;
25
use C4::Koha;
26
use C4::Charset;
26
use C4::Charset;
27
use MARC::File::USMARC;
27
use MARC::File::USMARC;
28
use MARC::Field;
28
use C4::ImportBatch;
29
use C4::ImportBatch;
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::Languages;
31
use C4::Languages;
Lines 336-341 sub _add_rowdata { Link Here
336
    }
337
    }
337
    $row->{date}//= $row->{date2};
338
    $row->{date}//= $row->{date2};
338
    $row->{isbn}=_isbn_replace($row->{isbn});
339
    $row->{isbn}=_isbn_replace($row->{isbn});
340
341
    $row = _add_custom_field_rowdata($row, $record);
342
343
    return $row;
344
}
345
346
sub _add_custom_field_rowdata
347
{
348
    my ( $row, $record ) = @_;
349
    my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
350
351
    $pref_newtags =~ s/^\s+|\s+$//g;
352
    $pref_newtags =~ s/\h+/ /g;
353
354
    my @addnumberfields;
355
356
    foreach my $field (split / /, $pref_newtags) {
357
        my ($tag, $subtags) = split(/\$/, $field);
358
359
        if ( $record->field($tag) ) {
360
            my $marcfield   = $record->field($tag);
361
362
            if ( $subtags ) {
363
                my $content = '';
364
                for my $code (split //, $subtags) {
365
                    $content .= $marcfield->subfield($code) . ' ';
366
                }
367
368
                $row->{$field} = $content;
369
            } elsif ( $tag <= 10 ) {
370
                $row->{$field} = $marcfield->data();
371
            } else {
372
                $row->{$field} = $marcfield->as_string();
373
            }
374
            push( @addnumberfields, $field );
375
        }
376
    }
377
378
    $row->{'addnumberfields'} = \@addnumberfields;
379
339
    return $row;
380
    return $row;
340
}
381
}
341
382
(-)a/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE 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');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
9
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
12
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt (-2 / +18 lines)
Lines 3-8 Link Here
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
4
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
4
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'datatables.inc' %]
7
[% USE Koha %]
8
6
<style type="text/css">
9
<style type="text/css">
7
.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;}
10
.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;}
8
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
11
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
Lines 14-20 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
14
<body id="acq_z3950_search" class="acq">
17
<body id="acq_z3950_search" class="acq">
15
[% INCLUDE 'header.inc' %]
18
[% INCLUDE 'header.inc' %]
16
[% INCLUDE 'acquisitions-search.inc' %]
19
[% INCLUDE 'acquisitions-search.inc' %]
17
20
[% INCLUDE 'z3950_search.inc' %]
18
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | uri %]">Basket [% basketno | html %]</a> &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]<a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order from external source</a> &rsaquo; Search results[% END %]</div>
21
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | uri %]">Basket [% basketno | html %]</a> &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]<a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order from external source</a> &rsaquo; Search results[% END %]</div>
19
22
20
<div class="main container-fluid">
23
<div class="main container-fluid">
Lines 99-104 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
99
        <th>Author</th>
102
        <th>Author</th>
100
        <th>ISBN</th>
103
        <th>ISBN</th>
101
        <th>LCCN</th>
104
        <th>LCCN</th>
105
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
106
        <th>Additional fields</th>
107
        [% END %]
102
        <th>Preview</th>
108
        <th>Preview</th>
103
		<th>&nbsp;</th>
109
		<th>&nbsp;</th>
104
    </tr></thead>
110
    </tr></thead>
Lines 111-116 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
111
            <td>[% breeding_loo.author %]</td>
117
            <td>[% breeding_loo.author %]</td>
112
            <td>[% breeding_loo.isbn %]</td>
118
            <td>[% breeding_loo.isbn %]</td>
113
            <td>[% breeding_loo.lccn %]</td>
119
            <td>[% breeding_loo.lccn %]</td>
120
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
121
            <td>
122
               <dl>
123
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
124
                  <dt>[% addnumberfield %]:</dt>
125
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
126
                  [% END %]
127
               </dl>
128
            </td>
129
            [% END %]
114
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
130
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
115
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
131
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
116
132
Lines 224-227 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
224
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/z3950_search_[% KOHA_VERSION %].js"></script>
240
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/z3950_search_[% KOHA_VERSION %].js"></script>
225
[% END %]
241
[% END %]
226
242
227
[% INCLUDE 'intranet-bottom.inc' %]
243
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 229-234 Cataloging: Link Here
229
                  no: "don't"
229
                  no: "don't"
230
            - 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.
230
            - 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.
231
        -
231
        -
232
            - Determines the MARC field/subfields
233
            - pref: AdditionalFieldsInZ3950ResultSearch
234
            - "are displayed in 'Additional fields' column in the result of a search Z3950 (use whitespace as delimiter ex: <code>082$ab</code> <code>090$ab</code>)"
235
        -
232
            - When matching on ISSN with the record import tool,
236
            - When matching on ISSN with the record import tool,
233
            - pref: AggressiveMatchOnISSN
237
            - pref: AggressiveMatchOnISSN
234
              choices:
238
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (-2 / +21 lines)
Lines 1-4 Link Here
1
[% SET footerjs = 1 %]
1
[% SET footerjs = 1 %]
2
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Z39.50/SRU search results</title>
4
<title>Koha &rsaquo; Z39.50/SRU search results</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 101-106 Link Here
101
        <th>ISBN</th>
102
        <th>ISBN</th>
102
        <th>LCCN</th>
103
        <th>LCCN</th>
103
        <th>Actions</th>
104
        <th>Actions</th>
105
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
106
        <th>Additional fields</th>
107
        [% END %]
108
        <th>MARC</th>
109
        <th>Card</th>
110
		<th>&nbsp;</th>
104
    </tr></thead>
111
    </tr></thead>
105
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
112
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
106
        [% IF ( breeding_loo.breedingid ) %]
113
        [% IF ( breeding_loo.breedingid ) %]
Lines 113-119 Link Here
113
            <td>[% breeding_loo.edition %]</td>
120
            <td>[% breeding_loo.edition %]</td>
114
            <td>[% breeding_loo.isbn %]</td>
121
            <td>[% breeding_loo.isbn %]</td>
115
            <td>[% breeding_loo.lccn %]</td>
122
            <td>[% breeding_loo.lccn %]</td>
116
117
            <td>
123
            <td>
118
                <div class="dropdown">
124
                <div class="dropdown">
119
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
125
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
Lines 126-131 Link Here
126
                    </ul>
132
                    </ul>
127
                </div>
133
                </div>
128
            </td>
134
            </td>
135
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
136
            <td>
137
               <dl>
138
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
139
                  <dt>[% addnumberfield %]:</dt>
140
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
141
                  [% END %]
142
               </dl>
143
            </td>
144
            [% END %]
145
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
146
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
147
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
129
        </tr>
148
        </tr>
130
        [% END %]
149
        [% END %]
131
    [% END %]</tbody>
150
    [% END %]</tbody>
Lines 245-248 Link Here
245
    [% INCLUDE 'z3950_search.inc' %]
264
    [% INCLUDE 'z3950_search.inc' %]
246
[% END %]
265
[% END %]
247
266
248
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
267
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
(-)a/t/db_dependent/Breeding.t (-2 / +43 lines)
Lines 20-28 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use FindBin;
22
use FindBin;
23
use Test::More tests => 3;
23
use Test::More tests => 4;
24
use Test::Warn;
24
use Test::Warn;
25
25
26
use C4::Context;
26
use C4::Breeding;
27
use C4::Breeding;
27
use Koha::XSLT_Handler;
28
use Koha::XSLT_Handler;
28
29
Lines 49-54 subtest '_do_xslt_proc' => sub { Link Here
49
    plan tests => 7;
50
    plan tests => 7;
50
    test_do_xslt();
51
    test_do_xslt();
51
};
52
};
53
#Group 4: testing _add_rowdata (part of Z3950Search)
54
subtest '_add_rowdata' => sub {
55
    plan tests => 4;
56
    test_add_rowdata();
57
};
52
58
53
#-------------------------------------------------------------------------------
59
#-------------------------------------------------------------------------------
54
60
Lines 186-188 sub test_do_xslt { Link Here
186
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
192
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
187
        'At least the title is the same :)' );
193
        'At least the title is the same :)' );
188
}
194
}
189
- 
195
196
sub test_add_rowdata {
197
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch','');
198
199
    my $row = {
200
       biblionumber => 0,
201
       server => "testServer",
202
       breedingid => 0,
203
   };
204
205
    my $biblio = MARC::Record->new();
206
    $biblio->append_fields(
207
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
208
    );
209
210
    my $returned_row = C4::Breeding::_add_rowdata($row,$biblio);
211
212
    is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio");
213
    is($returned_row->{addnumberfields}[0],undef,"_add_rowdata returns undef if it has no additionnal field");
214
215
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a");
216
217
    $row = {
218
       biblionumber => 0,
219
       server => "testServer",
220
       breedingid => 0,
221
   };
222
   $biblio = MARC::Record->new();
223
   $biblio->append_fields(
224
       MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
225
   );
226
   $returned_row = C4::Breeding::_add_rowdata($row,$biblio);
227
228
   is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio");
229
   is($returned_row->{addnumberfields}[0],"245\$a","_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference");
230
}

Return to bug 12747