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 4-9 Link Here
4
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
4
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
5
[% Asset.css("css/datatables.css") %]
5
[% Asset.css("css/datatables.css") %]
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'datatables.inc' %]
8
[% USE Koha %]
9
7
<style type="text/css">
10
<style type="text/css">
8
.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;}
11
.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;}
9
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
12
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
Lines 15-21 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
15
<body id="acq_z3950_search" class="acq">
18
<body id="acq_z3950_search" class="acq">
16
[% INCLUDE 'header.inc' %]
19
[% INCLUDE 'header.inc' %]
17
[% INCLUDE 'acquisitions-search.inc' %]
20
[% INCLUDE 'acquisitions-search.inc' %]
18
21
[% INCLUDE 'z3950_search.inc' %]
19
<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>
22
<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>
20
23
21
<div class="main container-fluid">
24
<div class="main container-fluid">
Lines 102-107 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
102
        <th>Author</th>
105
        <th>Author</th>
103
        <th>ISBN</th>
106
        <th>ISBN</th>
104
        <th>LCCN</th>
107
        <th>LCCN</th>
108
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
109
        <th>Additional fields</th>
110
        [% END %]
105
        <th>Preview</th>
111
        <th>Preview</th>
106
		<th>&nbsp;</th>
112
		<th>&nbsp;</th>
107
    </tr></thead>
113
    </tr></thead>
Lines 114-119 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
114
            <td>[% breeding_loo.author %]</td>
120
            <td>[% breeding_loo.author %]</td>
115
            <td>[% breeding_loo.isbn %]</td>
121
            <td>[% breeding_loo.isbn %]</td>
116
            <td>[% breeding_loo.lccn %]</td>
122
            <td>[% breeding_loo.lccn %]</td>
123
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
124
            <td>
125
               <dl>
126
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
127
                  <dt>[% addnumberfield %]:</dt>
128
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
129
                  [% END %]
130
               </dl>
131
            </td>
132
            [% END %]
117
            <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>
133
            <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>
118
            <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>
134
            <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>
119
135
Lines 227-230 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
227
    [% Asset.js("js/z3950_search.js") %]
243
    [% Asset.js("js/z3950_search.js") %]
228
[% END %]
244
[% END %]
229
245
230
[% INCLUDE 'intranet-bottom.inc' %]
246
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 246-251 Cataloging: Link Here
246
                  no: "don't"
246
                  no: "don't"
247
            - 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.
247
            - 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.
248
        -
248
        -
249
            - Determines the MARC field/subfields
250
            - pref: AdditionalFieldsInZ3950ResultSearch
251
            - "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>)"
252
        -
249
            - When matching on ISSN with the record import tool,
253
            - When matching on ISSN with the record import tool,
250
            - pref: AggressiveMatchOnISSN
254
            - pref: AggressiveMatchOnISSN
251
              choices:
255
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (-2 / +21 lines)
Lines 1-5 Link Here
1
[% USE Asset %]
1
[% USE Asset %]
2
[% SET footerjs = 1 %]
2
[% SET footerjs = 1 %]
3
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Z39.50/SRU search results</title>
5
<title>Koha &rsaquo; Z39.50/SRU search results</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 102-107 Link Here
102
        <th>ISBN</th>
103
        <th>ISBN</th>
103
        <th>LCCN</th>
104
        <th>LCCN</th>
104
        <th>Actions</th>
105
        <th>Actions</th>
106
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
107
        <th>Additional fields</th>
108
        [% END %]
109
        <th>MARC</th>
110
        <th>Card</th>
111
		<th>&nbsp;</th>
105
    </tr></thead>
112
    </tr></thead>
106
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
113
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
107
        [% IF ( breeding_loo.breedingid ) %]
114
        [% IF ( breeding_loo.breedingid ) %]
Lines 114-120 Link Here
114
            <td>[% breeding_loo.edition %]</td>
121
            <td>[% breeding_loo.edition %]</td>
115
            <td>[% breeding_loo.isbn %]</td>
122
            <td>[% breeding_loo.isbn %]</td>
116
            <td>[% breeding_loo.lccn %]</td>
123
            <td>[% breeding_loo.lccn %]</td>
117
118
            <td>
124
            <td>
119
                <div class="dropdown">
125
                <div class="dropdown">
120
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
126
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
Lines 127-132 Link Here
127
                    </ul>
133
                    </ul>
128
                </div>
134
                </div>
129
            </td>
135
            </td>
136
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
137
            <td>
138
               <dl>
139
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
140
                  <dt>[% addnumberfield %]:</dt>
141
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
142
                  [% END %]
143
               </dl>
144
            </td>
145
            [% END %]
146
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
147
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
148
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
130
        </tr>
149
        </tr>
131
        [% END %]
150
        [% END %]
132
    [% END %]</tbody>
151
    [% END %]</tbody>
Lines 246-249 Link Here
246
    [% INCLUDE 'z3950_search.inc' %]
265
    [% INCLUDE 'z3950_search.inc' %]
247
[% END %]
266
[% END %]
248
267
249
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
268
[% 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