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

(-)a/C4/Biblio.pm (+7 lines)
Lines 2413-2418 sub _koha_marc_update_bib_ids { Link Here
2413
    } else {
2413
    } else {
2414
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2414
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2415
    }
2415
    }
2416
2417
    # update the control number (001) in MARC
2418
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
2419
        unless($record->field('001')){
2420
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
2421
        }
2422
    }
2416
}
2423
}
2417
2424
2418
=head2 _koha_marc_update_biblioitem_cn_sort
2425
=head2 _koha_marc_update_biblioitem_cn_sort
(-)a/cataloguing/addbiblio.pl (-1 / +5 lines)
Lines 807-813 if ( $biblio && !$breedingid ) { Link Here
807
if ($breedingid) {
807
if ($breedingid) {
808
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
808
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
809
}
809
}
810
810
if ( $record && $op eq 'duplicate' &&
811
     C4::Context->preference('autoControlNumber') eq 'biblionumber' ){
812
    my @control_num = $record->field('001');
813
    $record->delete_fields(@control_num);
814
}
811
#populate hostfield if hostbiblionumber is available
815
#populate hostfield if hostbiblionumber is available
812
if ($hostbiblionumber) {
816
if ($hostbiblionumber) {
813
    my $marcflavour = C4::Context->preference("marcflavour");
817
    my $marcflavour = C4::Context->preference("marcflavour");
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 73-78 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
73
('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'),
73
('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'),
74
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
74
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
75
('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'),
75
('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'),
76
('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'),
76
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
77
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
77
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
78
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
78
('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'),
79
('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js (-2 / +3 lines)
Lines 103-117 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
103
            return _framework_kohafields[kohafield];
103
            return _framework_kohafields[kohafield];
104
        },
104
        },
105
105
106
        GetRecord: function( id, callback ) {
106
        GetRecord: function( id, remove_control_num, callback ) {
107
            $.get(
107
            $.get(
108
                '/cgi-bin/koha/svc/bib/' + id
108
                '/cgi-bin/koha/svc/bib/'+ id
109
            ).done( function( metadata ) {
109
            ).done( function( metadata ) {
110
                $.get(
110
                $.get(
111
                    '/cgi-bin/koha/svc/bib_framework/' + id
111
                    '/cgi-bin/koha/svc/bib_framework/' + id
112
                ).done( function( frameworkcode ) {
112
                ).done( function( frameworkcode ) {
113
                    var record = new MARC.Record();
113
                    var record = new MARC.Record();
114
                    record.loadMARCXML(metadata);
114
                    record.loadMARCXML(metadata);
115
                    if( remove_control_num ) { record.removeField("001"); }
115
                    record.frameworkcode = $(frameworkcode).find('frameworkcode').text();
116
                    record.frameworkcode = $(frameworkcode).find('frameworkcode').text();
116
                    initFramework( record.frameworkcode, function( error ) {
117
                    initFramework( record.frameworkcode, function( error ) {
117
                        if ( typeof error === 'undefined' ) {
118
                        if ( typeof error === 'undefined' ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-2 / +6 lines)
Lines 251-263 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
251
            saveLabel: _("Duplicate"),
251
            saveLabel: _("Duplicate"),
252
            get: function( id, callback ) {
252
            get: function( id, callback ) {
253
                if ( !id ) return false;
253
                if ( !id ) return false;
254
                var remove_control_num = [% IF Koha.Preference('autoControlNumber') == 'OFF' %] 0 [% ELSE %] 1 [% END %];
254
255
255
                KohaBackend.GetRecord( id, callback );
256
                KohaBackend.GetRecord( id, remove_control_num, callback );
256
            },
257
            },
257
            save: function( id, record, done ) {
258
            save: function( id, record, done ) {
258
                function finishCb( data ) {
259
                function finishCb( data ) {
259
                    done( { error: data.error, newRecord: data.marcxml && data.marcxml[0], newId: data.biblionumber && [ 'catalog', data.biblionumber ] } );
260
                    done( { error: data.error, newRecord: data.marcxml && data.marcxml[0], newId: data.biblionumber && [ 'catalog', data.biblionumber ] } );
260
                }
261
                }
262
                [% IF Koha.Preference('autoControlNumber') != 'OFF' %]
263
                    record.removeField("001");
264
                [% END %]
261
265
262
                KohaBackend.CreateRecord( record, finishCb );
266
                KohaBackend.CreateRecord( record, finishCb );
263
            }
267
            }
Lines 272-278 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
272
            get: function( id, callback ) {
276
            get: function( id, callback ) {
273
                if ( !id ) return false;
277
                if ( !id ) return false;
274
278
275
                KohaBackend.GetRecord( id, callback );
279
                KohaBackend.GetRecord( id, "", callback );
276
            },
280
            },
277
            save: function( id, record, done ) {
281
            save: function( id, record, done ) {
278
                function finishCb( data ) {
282
                function finishCb( data ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+6 lines)
Lines 165-170 Cataloging: Link Here
165
            - and record's last modifier name in MARC subfield
165
            - and record's last modifier name in MARC subfield
166
            - pref: MarcFieldForModifierName
166
            - pref: MarcFieldForModifierName
167
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
167
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
168
        -
169
            - Control Number (001) is
170
            - pref: autoControlNumber
171
              choices:
172
                  biblionumber: generated as biblionumber.
173
                  "OFF": not generated automatically.
168
    Display:
174
    Display:
169
        -
175
        -
170
            - 'Separate main entry and subdivisions with '
176
            - 'Separate main entry and subdivisions with '
(-)a/t/db_dependent/Biblio.t (-2 / +25 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 14;
20
use Test::More tests => 15;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
use List::MoreUtils qw( uniq );
23
use List::MoreUtils qw( uniq );
Lines 250-255 sub run_tests { Link Here
250
    # Authority tests don't interact well with Elasticsearch at the moment due to the fact that there's currently no way to
250
    # Authority tests don't interact well with Elasticsearch at the moment due to the fact that there's currently no way to
251
    # roll back ES index changes.
251
    # roll back ES index changes.
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
253
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
253
254
254
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
255
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
255
256
Lines 823-828 subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { Link Here
823
    );
824
    );
824
};
825
};
825
826
827
subtest 'autoControlNumber tests' => sub {
828
    plan tests => 3;
829
830
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
831
832
    my $record = MARC::Record->new();
833
    my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
834
    $record = GetMarcBiblio({biblionumber => $biblionumber});
835
    is($record->field('001'), undef, '001 not set when pref is off');
836
837
    t::lib::Mocks::mock_preference('autoControlNumber', 'biblionumber');
838
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
839
    $record = GetMarcBiblio({biblionumber => $biblionumber});
840
    is($record->field('001')->as_string(), $biblionumber, '001 set to biblionumber when pref set and field is blank');
841
842
    $record->field('001')->update('Not biblionumber');
843
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
844
    $record = GetMarcBiblio({biblionumber => $biblionumber});
845
    is($record->field('001')->as_string(), 'Not biblionumber', '001 not set to biblionumber when pref set and field exists');
846
847
};
848
849
826
# Cleanup
850
# Cleanup
827
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
851
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
828
$schema->storage->txn_rollback;
852
$schema->storage->txn_rollback;
829
- 

Return to bug 27981