AddBiblio
DelBiblio
GetFrameworkCode
- GetMarcBiblio
GetMarcFromKohaField
GetMarcStructure
GetUsedMarcStructure
use Koha::BiblioFrameworks;
use Koha::DateUtils qw( dt_from_string );
+use Koha::Biblios;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::BiblioFrameworks;
+use Koha::Patrons;
use MARC::File::USMARC;
use MARC::File::XML;
# remove the - in isbn, koha store isbn without any -
if ($marc) {
my $record = MARC::Record->new_from_usmarc($marc);
+ if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
+ my @control_num = $record->field('001');
+ $record->delete_fields(@control_num);
+ }
my ($isbnfield,$isbnsubfield) = GetMarcFromKohaField( 'biblioitems.isbn' );
if ( $record->field($isbnfield) ) {
foreach my $field ( $record->field($isbnfield) ) {
sub create_input {
my ( $tag, $subfield, $value, $index_tag, $rec, $authorised_values_sth,$cgi ) = @_;
-
+
my $index_subfield = CreateKey(); # create a specifique key for each subfield
- # if there is no value provided but a default value in parameters, get it
- if ( $value eq '' ) {
+ # Apply optional framework default value when it is a new record,
+ # or when editing as new (duplicating a record),
+ # or when changing a record's framework,
+ # or when importing a record,
+ # based on the ApplyFrameworkDefaults setting.
+ # Substitute date parts, user name
+ my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults');
+ if ( $value eq '' && (
+ ( $applydefaults =~ /new/ && !$cgi->param('biblionumber') ) ||
+ ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) ||
+ ( $applydefaults =~ /changed/ && $cgi->param('changed_framework') ) ||
+ ( $applydefaults =~ /imported/ && $cgi->param('breedingid') )
+ ) ) {
$value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{};
# get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
# And <<USER>> with surname (?)
my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian");
$value=~s/<<USER>>/$username/g;
-
}
+
my $dbh = C4::Context->dbh;
# map '@' as "subfield" label for fixed fields
}
elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
# when authorities auto-creation is allowed, do not set readonly
- my $is_readonly = !C4::Context->preference("BiblioAddsAuthorities");
+ my $is_readonly = C4::Context->preference("RequireChoosingExistingAuthority");
$subfield_data{marc_value} = {
type => 'text',
}
# now, loop again to add parameter subfield that are not in the MARC::Record
- foreach my $subfield ( keys %{ $tagslib->{$tag} } )
+ foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
{
next if ( length $subfield != 1 );
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
my $breedingid = $input->param('breedingid');
my $z3950 = $input->param('z3950');
my $op = $input->param('op') // q{};
-my $mode = $input->param('mode');
+my $mode = $input->param('mode') // q{};
my $frameworkcode = $input->param('frameworkcode');
my $redirect = $input->param('redirect');
my $searchid = $input->param('searchid') // "";
}
);
+my $biblio;
if ($biblionumber){
- my $does_bib_exist = Koha::Biblios->find($biblionumber);
- if (!defined $does_bib_exist){
+ $biblio = Koha::Biblios->find($biblionumber);
+ unless ( $biblio ) {
$biblionumber = undef;
$template->param( bib_doesnt_exist => 1 );
}
$biblioitemnumber
);
-if (($biblionumber) && !($breedingid)){
- $record = GetMarcBiblio({ biblionumber => $biblionumber });
+if ( $biblio && !$breedingid ) {
+ $record = $biblio->metadata->record;
}
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");
if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
my $oldbibitemnum;
if ( $is_a_modif ) {
- ModBiblio( $record, $biblionumber, $frameworkcode );
+ my $member = Koha::Patrons->find($loggedinuser);
+ ModBiblio(
+ $record,
+ $biblionumber,
+ $frameworkcode,
+ {
+ overlay_context => {
+ source => $z3950 ? 'z39.50' : 'intranet',
+ categorycode => $member->categorycode,
+ userid => $member->userid
+ }
+ }
+ );
}
else {
( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
$template->param(
biblionumberdata => $biblionumber,
op => $op,
+ z3950 => $z3950
);
if ( $op eq "duplicate" ) {
$biblionumber = "";