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

(-)a/C4/Biblio.pm (+21 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 $incrementalCN=C4::Context->preference('incrementalControlNumber');
284
            my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = ? WHERE variable = 'incrementalControlNumber'});
285
            $sth->execute($incrementalCN+1);
286
            $sth->finish();
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
(-)a/cataloguing/value_builder/marc21_field_001.pl (+69 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
function Blur$function_name(subfield_managed) {
52
    return 1;
53
}
54
function Focus$function_name(subfield_managed) {
55
    $focusline
56
}
57
function Clic$function_name(index) {
58
    return 1;
59
}
60
//]]>
61
</script>
62
";
63
64
    #return to caller via global hash
65
    $building_plugin->{function}= $function_name;
66
    $building_plugin->{javascript}= $res;
67
}
68
69
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 (+25 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{
7017
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');
7018
}
7019
    );
7020
    $dbh->do(
7021
        q{
7022
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number (controlnumber) of the next bibliographic record.',NULL,'');
7023
}
7024
    );
7025
    if (C4::Context->preference("marcflavour") eq 'MARC21') {
7026
        $dbh->do(
7027
            q{
7028
UPDATE marc_subfield_structure SET value_builder = 'marc21_field_001.pl' WHERE tagfield = '001' AND tagsubfield = '@'
7029
AND (value_builder = '' OR value_builder IS NULL);
7030
            }
7031
        );
7032
    }
7033
    print
7034
"Upgrade to $DBversion done (Bug 9921 - Make it possible to force 001 = biblionumber)\n";
7035
    SetVersion($DBversion);
7036
}
7037
7013
=head1 FUNCTIONS
7038
=head1 FUNCTIONS
7014
7039
7015
=head2 TableExists($table)
7040
=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