From 3dde9f03c93dce8ec5b12504e8a227e2f7b1baab Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Mon, 17 Sep 2018 01:06:12 +0300 Subject: [PATCH] Bug 16424: Handle framework code properly also when adding a new record Signed-off-by: Michal Denar Signed-off-by: Your Full Name --- koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js | 11 ++++++++--- svc/new_bib | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js index 49bf383..10e9337 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js @@ -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') } ); } ); }, diff --git a/svc/new_bib b/svc/new_bib index d53f405..32e6fb1 100755 --- a/svc/new_bib +++ b/svc/new_bib @@ -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) ) { -- 2.1.4