} else {
C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
}
+
+ # update the control number (001) in MARC
+ if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
+ unless($record->field('001')){
+ $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
+ }
+ }
}
=head2 _koha_marc_update_biblioitem_cn_sort
if ($breedingid) {
( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
}
-
+if ( $record && $op eq 'duplicate' &&
+ C4::Context->preference('autoControlNumber') eq 'biblionumber' ){
+ my @control_num = $record->field('001');
+ $record->delete_fields(@control_num);
+}
#populate hostfield if hostbiblionumber is available
if ($hostbiblionumber) {
my $marcflavour = C4::Context->preference("marcflavour");
('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'),
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
('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'),
+('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'),
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'),
return _framework_kohafields[kohafield];
},
- GetRecord: function( id, callback ) {
+ GetRecord: function( id, remove_control_num, callback ) {
$.get(
- '/cgi-bin/koha/svc/bib/' + id
+ '/cgi-bin/koha/svc/bib/'+ id
).done( function( metadata ) {
$.get(
'/cgi-bin/koha/svc/bib_framework/' + id
).done( function( frameworkcode ) {
var record = new MARC.Record();
record.loadMARCXML(metadata);
+ if( remove_control_num ) { record.removeField("001"); }
record.frameworkcode = $(frameworkcode).find('frameworkcode').text();
initFramework( record.frameworkcode, function( error ) {
if ( typeof error === 'undefined' ) {
saveLabel: _("Duplicate"),
get: function( id, callback ) {
if ( !id ) return false;
+ var remove_control_num = [% IF Koha.Preference('autoControlNumber') == 'OFF' %] 0 [% ELSE %] 1 [% END %];
- KohaBackend.GetRecord( id, callback );
+ KohaBackend.GetRecord( id, remove_control_num, callback );
},
save: function( id, record, done ) {
function finishCb( data ) {
done( { error: data.error, newRecord: data.marcxml && data.marcxml[0], newId: data.biblionumber && [ 'catalog', data.biblionumber ] } );
}
+ [% IF Koha.Preference('autoControlNumber') != 'OFF' %]
+ record.removeField("001");
+ [% END %]
KohaBackend.CreateRecord( record, finishCb );
}
get: function( id, callback ) {
if ( !id ) return false;
- KohaBackend.GetRecord( id, callback );
+ KohaBackend.GetRecord( id, "", callback );
},
save: function( id, record, done ) {
function finishCb( data ) {
- and record's last modifier name in MARC subfield
- pref: MarcFieldForModifierName
- ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
+ -
+ - Control Number (001) is
+ - pref: autoControlNumber
+ choices:
+ biblionumber: generated as biblionumber.
+ "OFF": not generated automatically.
Display:
-
- 'Separate main entry and subdivisions with '
use Modern::Perl;
-use Test::More tests => 14;
+use Test::More tests => 15;
use Test::MockModule;
use Test::Warn;
use List::MoreUtils qw( uniq );
# Authority tests don't interact well with Elasticsearch at the moment due to the fact that there's currently no way to
# roll back ES index changes.
t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
+ t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
);
};
+subtest 'autoControlNumber tests' => sub {
+ plan tests => 3;
+
+ t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
+
+ my $record = MARC::Record->new();
+ my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
+ $record = GetMarcBiblio({biblionumber => $biblionumber});
+ is($record->field('001'), undef, '001 not set when pref is off');
+
+ t::lib::Mocks::mock_preference('autoControlNumber', 'biblionumber');
+ C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
+ $record = GetMarcBiblio({biblionumber => $biblionumber});
+ is($record->field('001')->as_string(), $biblionumber, '001 set to biblionumber when pref set and field is blank');
+
+ $record->field('001')->update('Not biblionumber');
+ C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
+ $record = GetMarcBiblio({biblionumber => $biblionumber});
+ is($record->field('001')->as_string(), 'Not biblionumber', '001 not set to biblionumber when pref set and field exists');
+
+};
+
+
# Cleanup
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
$schema->storage->txn_rollback;