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

(-)a/C4/Biblio.pm (+42 lines)
Lines 271-276 sub AddBiblio { Link Here
271
    # update MARC subfield that stores biblioitems.cn_sort
271
    # update MARC subfield that stores biblioitems.cn_sort
272
    _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
272
    _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
273
273
274
    # update the control number (001) in MARC
275
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
276
        unless($record->field('001')){
277
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
278
        }elsif($record->field('001')->data() eq 'biblionumber'){
279
            $record->field('001')->update($biblionumber);
280
        }
281
    }elsif(C4::Context->preference('autoControlNumber') eq 'incremental'){
282
        if(!defined($record->field('001')) or (defined($record->field('001')) and $record->field('001')->data() eq 'incremental')){
283
            my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = value+1 WHERE variable = 'incrementalControlNumber'});
284
            $sth->execute();
285
            $sth->finish();
286
            my $incrementalCN=C4::Context->preference('incrementalControlNumber')-1;
287
            unless($record->field('001')){
288
                $record->insert_fields_ordered(MARC::Field->new('001', $incrementalCN));
289
            }else{
290
                $record->field('001')->update($incrementalCN);
291
            }
292
        }
293
    }
294
274
    # now add the record
295
    # now add the record
275
    ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save;
296
    ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save;
276
297
Lines 343-348 sub ModBiblio { Link Here
343
364
344
    # update MARC subfield that stores biblioitems.cn_sort
365
    # update MARC subfield that stores biblioitems.cn_sort
345
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
366
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
367
    
368
    # update the control number (001) in MARC
369
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
370
        unless($record->field('001')){
371
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
372
        }elsif($record->field('001')->data() eq 'biblionumber'){
373
            $record->field('001')->update($biblionumber);
374
        }
375
    }elsif(C4::Context->preference('autoControlNumber') eq 'incremental'){
376
        if(!defined($record->field('001')) or (defined($record->field('001')) and $record->field('001')->data() eq 'incremental')){
377
            my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = value+1 WHERE variable = 'incrementalControlNumber'});
378
            $sth->execute();
379
            $sth->finish();
380
            my $incrementalCN=C4::Context->preference('incrementalControlNumber')-1;
381
            unless($record->field('001')){
382
                $record->insert_fields_ordered(MARC::Field->new('001', $incrementalCN));
383
            }else{
384
                $record->field('001')->update($incrementalCN);
385
            }
386
        }
387
    }
346
388
347
    # update the MARC record (that now contains biblio and items) with the new record data
389
    # update the MARC record (that now contains biblio and items) with the new record data
348
    &ModBiblioMarc( $record, $biblionumber, $frameworkcode );
390
    &ModBiblioMarc( $record, $biblionumber, $frameworkcode );
(-)a/cataloguing/value_builder/marc21_field_001.pl (+76 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 Spanish Ministry of Education, Culture and Sport
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use C4::Context;
23
24
# This is a new style cataloging plugin, using $building_plugin
25
26
our $building_plugin;
27
if(defined $building_plugin) {
28
    marc21_field001_plugin_javascript();
29
}
30
else { #nothing to do (no popup)
31
}
32
33
#-------------------------------------------------------------------------------
34
35
sub marc21_field001_plugin_javascript {
36
    my $field_number= $building_plugin->{subfieldid};
37
    my $function_name= $field_number;
38
39
    #depending on preference, adjust Focus function
40
    my $autoControlNumber = C4::Context->preference('autoControlNumber');
41
    my $focusline='';
42
    if( $autoControlNumber ne 'OFF' ) {
43
        $focusline= "document.getElementById(\"$field_number\").value='$autoControlNumber';\n";
44
    }
45
    $focusline.='return 1;';
46
47
    #build the actual javascript
48
    my $res = "
49
<script type=\"text/javascript\">
50
//<![CDATA[
51
oldValue = document.getElementById(\"$field_number\").value;
52
function Blur$function_name(subfield_managed) {
53
    if(oldValue != document.getElementById(\"$field_number\").value){
54
        $focusline
55
    }
56
    return 1;
57
}
58
function Focus$function_name(subfield_managed) {
59
    if(!document.getElementById(\"$field_number\").value){
60
        $focusline
61
    }
62
    return 1;
63
}
64
function Clic$function_name(index) {
65
    $focusline
66
}
67
//]]>
68
</script>
69
";
70
71
    #return to caller via global hash
72
    $building_plugin->{function}= $function_name;
73
    $building_plugin->{javascript}= $res;
74
}
75
76
1;
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 427-429 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','incremental|biblionumber|OFF','Used to autogenerate a Control Number: incremental will be of the form 1, 2, 3; biblionumber will be as biblionumber;','Choice');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number (controlnumber) of the next bibliographic record.',NULL,'');
(-)a/installer/data/mysql/updatedatabase.pl (+27 lines)
Lines 7010-7015 CREATE TABLE IF NOT EXISTS borrower_files ( Link Here
7010
    SetVersion($DBversion);
7010
    SetVersion($DBversion);
7011
}
7011
}
7012
7012
7013
$DBversion = "3.13.00.XXX";
7014
if ( CheckVersion($DBversion) ) {
7015
    $dbh->do(
7016
        q{INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','incremental|biblionumber|OFF',
7017
        'Used to autogenerate a Control Number: incremental will be of the form 1, 2, 3; biblionumber will be as biblionumber;','Choice');}
7018
    );
7019
    $dbh->do(
7020
        q{INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number
7021
        (controlnumber) of the next bibliographic record.',NULL,'');}
7022
    );
7023
    if (C4::Context->preference("marcflavour") eq 'MARC21') {
7024
        my $sth = $dbh->prepare(
7025
            q{SELECT * FROM marc_subfield_structure WHERE tagfield = '001' AND tagsubfield = '@' 
7026
            AND (value_builder IS NOT NULL AND value_builder != '') LIMIT 1;}
7027
        );
7028
        $sth->execute;
7029
        unless($sth->fetchrow){
7030
            $dbh->do(
7031
                q{UPDATE marc_subfield_structure SET value_builder = 'marc21_field_001.pl' WHERE tagfield = '001' AND tagsubfield = '@';}
7032
            );
7033
            print "WARNING: Your frameworks have been updated, field 001 will filled in through marc21_field_001.pl plugin.\n";
7034
        }
7035
    }
7036
    print "Upgrade to $DBversion done (Bug 9921 - Make it possible to force 001 = biblionumber)\n";
7037
    SetVersion($DBversion);
7038
}
7039
7013
=head1 FUNCTIONS
7040
=head1 FUNCTIONS
7014
7041
7015
=head2 TableExists($table)
7042
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +13 lines)
Lines 109-114 Cataloging: Link Here
109
            - pref: UNIMARCField100Language
109
            - pref: UNIMARCField100Language
110
              class: short
110
              class: short
111
            - as default language in the UNIMARC field 100 when creating a new record or in the field plugin.
111
            - as default language in the UNIMARC field 100 when creating a new record or in the field plugin.
112
        -
113
            - Control Number (001) is
114
            - pref: autoControlNumber
115
              choices:
116
                  biblionumber: generated as biblionumber.
117
                  incremental: generated in the form 1, 2, 3.
118
                  "OFF": not generated automatically.
119
            - (You should fill in a value in incrementalControlNumber preference.)
120
        -
121
            - Use Control Number (001)
122
            - pref: incrementalControlNumber
123
              class: integer
124
            - as incremental number. (This requires generated in the form 1, 2, 3 in autoControlNumber preference.)
112
    Display:
125
    Display:
113
        -
126
        -
114
            - 'Separate multiple displayed authors, series or subjects with '
127
            - 'Separate multiple displayed authors, series or subjects with '
115
- 

Return to bug 9921