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

(-)a/C4/Biblio.pm (+43 lines)
Lines 283-288 sub AddBiblio { Link Here
283
            # update MARC subfield that stores biblioitems.cn_sort
283
            # update MARC subfield that stores biblioitems.cn_sort
284
            _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
284
            _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
285
285
286
            # update the control number (001) in MARC
287
            if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
288
                unless($record->field('001')){
289
                    $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
290
                }elsif($record->field('001')->data() eq 'biblionumber'){
291
                    $record->field('001')->update($biblionumber);
292
                }
293
            }elsif(C4::Context->preference('autoControlNumber') eq 'incremental'){
294
                if(!defined($record->field('001')) or (defined($record->field('001')) and $record->field('001')->data() eq 'incremental')){
295
                    my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = value+1 WHERE variable = 'incrementalControlNumber'});
296
                    $sth->execute();
297
                    $sth->finish();
298
                    my $incrementalCN=C4::Context->preference('incrementalControlNumber')-1;
299
                    unless($record->field('001')){
300
                        $record->insert_fields_ordered(MARC::Field->new('001', $incrementalCN));
301
                    }else{
302
                        $record->field('001')->update($incrementalCN);
303
                    }
304
                }
305
            }
306
307
286
            # now add the record
308
            # now add the record
287
            ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save;
309
            ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save;
288
310
Lines 376-381 sub ModBiblio { Link Here
376
    # update MARC subfield that stores biblioitems.cn_sort
398
    # update MARC subfield that stores biblioitems.cn_sort
377
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
399
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
378
400
401
    # update the control number (001) in MARC
402
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
403
        unless($record->field('001')){
404
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
405
        }elsif($record->field('001')->data() eq 'biblionumber'){
406
            $record->field('001')->update($biblionumber);
407
        }
408
    }elsif(C4::Context->preference('autoControlNumber') eq 'incremental'){
409
        if(!defined($record->field('001')) or (defined($record->field('001')) and $record->field('001')->data() eq 'incremental')){
410
            my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = value+1 WHERE variable = 'incrementalControlNumber'});
411
            $sth->execute();
412
            $sth->finish();
413
            my $incrementalCN=C4::Context->preference('incrementalControlNumber')-1;
414
            unless($record->field('001')){
415
                $record->insert_fields_ordered(MARC::Field->new('001', $incrementalCN));
416
            }else{
417
                $record->field('001')->update($incrementalCN);
418
            }
419
        }
420
    }
421
379
    # update the MARC record (that now contains biblio and items) with the new record data
422
    # update the MARC record (that now contains biblio and items) with the new record data
380
    &ModBiblioMarc( $record, $biblionumber );
423
    &ModBiblioMarc( $record, $biblionumber );
381
424
(-)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/atomicupdate/bug_9921.perl (+28 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
4
    $dbh->do(
5
        q{INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','incremental|biblionumber|OFF',
6
        'Used to autogenerate a Control Number: incremental will be of the form 1, 2, 3; biblionumber will be as biblionumber;','Choice');}
7
    );
8
    $dbh->do(
9
        q{INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number
10
        (controlnumber) of the next bibliographic record.',NULL,'');}
11
    );
12
    if (C4::Context->preference("marcflavour") eq 'MARC21') {
13
        my $sth = $dbh->prepare(
14
            q{SELECT * FROM marc_subfield_structure WHERE tagfield = '001' AND tagsubfield = '@'
15
            AND (value_builder IS NOT NULL AND value_builder != '') LIMIT 1;}
16
        );
17
        $sth->execute;
18
        unless($sth->fetchrow){
19
            $dbh->do(
20
                q{UPDATE marc_subfield_structure SET value_builder = 'marc21_field_001.pl' WHERE tagfield = '001' AND tagsubfield = '@';}
21
            );
22
            print "WARNING: Your frameworks have been updated, field 001 will filled in through marc21_field_001.pl plugin.\n";
23
        }
24
    }
25
26
    # Always end with this (adjust the bug info)
27
    NewVersion( $DBversion, 9921, "Make it possible to force 001 = biblionumbe");
28
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+2 lines)
Lines 69-74 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
69
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
69
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
70
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
70
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
71
('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'),
71
('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'),
72
('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'),
72
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
73
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
73
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
74
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
74
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
75
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
Lines 255-260 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
255
('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
256
('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
256
('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
257
('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
257
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
258
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
259
('incrementalControlNumber', '1', 'Set the number (controlnumber) of the next bibliographic record.',NULL,''),
258
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
260
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
259
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
261
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
260
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
262
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +13 lines)
Lines 158-163 Cataloging: Link Here
158
            - and record's last modifier name in MARC subfield
158
            - and record's last modifier name in MARC subfield
159
            - pref: MarcFieldForModifierName
159
            - pref: MarcFieldForModifierName
160
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
160
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
161
        -
162
            - Control Number (001) is
163
            - pref: autoControlNumber
164
              choices:
165
                  biblionumber: generated as biblionumber.
166
                  incremental: generated in the form 1, 2, 3.
167
                  "OFF": not generated automatically.
168
            - (You should fill in a value in incrementalControlNumber preference.)
169
        -
170
            - Use Control Number (001)
171
            - pref: incrementalControlNumber
172
              class: integer
173
            - as incremental number. (This requires generated in the form 1, 2, 3 in autoControlNumber preference.)
161
    Display:
174
    Display:
162
        -
175
        -
163
            - 'Separate main entry and subdivisions with '
176
            - 'Separate main entry and subdivisions with '
164
- 

Return to bug 9921