Bug 10132: Add ability to set MARC Organization Code at library level
Test plan: 0. Apply patches 1. Update database 2. Go to administration -> libraries, try to update some library and fill in some value into Marc Organization code field 3. Save this library and edit again - the code should be stored correctly 4. Go to system preferences and fill in some value into MARCOrgCode preference, note there is enhanced description mentioning the ability to set organization code on library level 5. Set active library to the one with own org code stored 6. Go to cataloguing, create new empty record and click into field 003 - there should be the code you filled for that library 7. Set active library to one withou marc org code 8. Go to cataloguing, create new empty record and click into field 003 - there should be the code from system preference 9. Go to system preferences again and set AutoCreateAuthorities to 'generate' and BiblioAddsAuthorities to 'allow' 10. Go to cataloguing and create some biblio record, fill in any author in to create its authority record, save the biblio 11. Go to authorities and find this created authority, go to details and check the fields: 003, 040$a, 040$c, 670$a - there should be used right org code 12. prove t/db_dependent/AuthoritiesMarc.t t/db_dependent/Biblio.t t/db_dependent/Koha/Libraries.t Signed-off-by: Hugo Agud <hagud@orex.es> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
e2d56c0b2b
commit
b36a0e1a59
|
|
@ -32,6 +32,7 @@ use Koha::Authorities;
|
|||
use Koha::Authority::MergeRequest;
|
||||
use Koha::Authority::Types;
|
||||
use Koha::Authority;
|
||||
use Koha::Libraries;
|
||||
use Koha::SearchEngine;
|
||||
use Koha::SearchEngine::Search;
|
||||
|
||||
|
|
@ -605,12 +606,17 @@ sub AddAuthority {
|
|||
|
||||
SetUTF8Flag($record);
|
||||
if ($format eq "MARC21") {
|
||||
my $userenv = C4::Context->userenv;
|
||||
my $library;
|
||||
if ( $userenv && $userenv->{'branch'} ) {
|
||||
$library = Koha::Libraries->find( $userenv->{'branch'} );
|
||||
}
|
||||
if (!$record->leader) {
|
||||
$record->leader($leader);
|
||||
}
|
||||
if (!$record->field('003')) {
|
||||
$record->insert_fields_ordered(
|
||||
MARC::Field->new('003',C4::Context->preference('MARCOrgCode'))
|
||||
MARC::Field->new('003', $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'))
|
||||
);
|
||||
}
|
||||
my $date=POSIX::strftime("%y%m%d",localtime);
|
||||
|
|
@ -629,8 +635,8 @@ sub AddAuthority {
|
|||
if (!$record->field('040')) {
|
||||
$record->insert_fields_ordered(
|
||||
MARC::Field->new('040','','',
|
||||
'a' => C4::Context->preference('MARCOrgCode'),
|
||||
'c' => C4::Context->preference('MARCOrgCode')
|
||||
'a' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'),
|
||||
'c' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -568,6 +568,11 @@ sub LinkBibHeadingsToAuthorities {
|
|||
# of change to a core API just before the 3.0 release.
|
||||
|
||||
if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
|
||||
my $userenv = C4::Context->userenv;
|
||||
my $library;
|
||||
if ( $userenv && $userenv->{'branch'} ) {
|
||||
$library = Koha::Libraries->find( $userenv->{'branch'} );
|
||||
}
|
||||
$marcrecordauth->insert_fields_ordered(
|
||||
MARC::Field->new(
|
||||
'667', '', '',
|
||||
|
|
@ -582,7 +587,7 @@ sub LinkBibHeadingsToAuthorities {
|
|||
$cite =~ s/[\s\,]*$//;
|
||||
$cite =
|
||||
"Work cat.: ("
|
||||
. C4::Context->preference('MARCOrgCode') . ")"
|
||||
. ( $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode') ) . ")"
|
||||
. $bib->subfield( '999', 'c' ) . ": "
|
||||
. $cite;
|
||||
$marcrecordauth->insert_fields_ordered(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ use Modern::Perl;
|
|||
|
||||
use Carp;
|
||||
|
||||
use C4::Context;
|
||||
|
||||
use Koha::Database;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
|
@ -54,6 +56,12 @@ sub add_to_categories {
|
|||
}
|
||||
}
|
||||
|
||||
sub get_effective_marcorgcode {
|
||||
my ( $self ) = @_;
|
||||
|
||||
return $self->marcorgcode || C4::Context->preference("MARCOrgCode");
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
use Modern::Perl;
|
||||
use C4::Context;
|
||||
|
||||
use Koha::Libraries;
|
||||
|
||||
my $builder = sub {
|
||||
my ( $params ) = @_;
|
||||
my $org = C4::Context->preference('MARCOrgCode');
|
||||
my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} );
|
||||
my $org = $library->get_effective_marcorgcode;
|
||||
return <<"HERE";
|
||||
<script type=\"text/javascript\">
|
||||
//<![CDATA[
|
||||
|
|
|
|||
Loading…
Reference in New Issue