Bug 16424: Handle framework code properly also when adding a new record

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Ere Maijala 2018-09-17 01:06:12 +03:00 committed by Nick Clemens
parent 02a0f3185c
commit b70d2bc281
2 changed files with 10 additions and 4 deletions

View File

@ -127,16 +127,21 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
},
CreateRecord: function( record, callback ) {
var frameworkcode = record.frameworkcode;
record = record.clone();
_removeBiblionumberFields( record );
$.ajax( {
type: 'POST',
url: '/cgi-bin/koha/svc/new_bib',
url: '/cgi-bin/koha/svc/new_bib?frameworkcode=' + encodeURIComponent(frameworkcode),
data: record.toXML(),
contentType: 'text/xml'
} ).done( function( data ) {
callback( _fromXMLStruct( data ) );
var record = _fromXMLStruct( data );
if ( record.marcxml ) {
record.marcxml[0].frameworkcode = frameworkcode;
}
callback( record );
} ).fail( function( data ) {
callback( { error: _('Could not save record') } );
} );
@ -159,7 +164,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
}
callback( record );
} ).fail( function( data ) {
callback( { data: { error: data } } );
callback( { error: _('Could not save record') } );
} );
},

View File

@ -50,6 +50,7 @@ sub add_bib {
my $result = {};
my $inxml = $query->param('POSTDATA');
my $frameworkcode = $query->url_param('frameworkcode') // '';
print $query->header(-type => 'text/xml', -charset => 'utf-8');
my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21';
@ -73,7 +74,7 @@ sub add_bib {
foreach my $field ( $record->field($itemtag) ) {
$record->delete_field($field);
}
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $frameworkcode );
my $new_record = GetMarcBiblio({ biblionumber => $biblionumber });
if ( $query->url_param('items') ) {
foreach my $field ( $fullrecord->field($itemtag) ) {