@@ -, +, @@ acquisitions. Found out that there is another way of adding items, which has a different mechanism (datatables yay) of addition, so this feature enables shelving location updating in the neworderempty.pl. ------------- - TEST PLAN - ------------- --- acqui/neworderempty.pl | 11 ++- koha-tmpl/intranet-tmpl/prog/en/js/additem.js | 10 +++ .../prog/en/js/koha-to-marc-mapping-api.js | 33 +++++++++ .../prog/en/modules/acqui/neworderempty.tt | 8 ++- .../prog/en/modules/cataloguing/additem.tt | 33 +++------ svc/getAuthorisedValues.pl | 69 ------------------ svc/getShelvingLocations.pl | 81 ++++++++++++++++++++++ 7 files changed, 149 insertions(+), 96 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/koha-to-marc-mapping-api.js delete mode 100755 svc/getAuthorisedValues.pl create mode 100755 svc/getShelvingLocations.pl --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -346,6 +346,11 @@ if ( defined $subscriptionid ) { # Find the items.barcode subfield for barcode validations my (undef, $barcode_subfield) = GetMarcFromKohaField('items.barcode', ''); +#Find the Marc Subfields for changing the shelving location based on the item's homebranch. +#These are needed to target the right to update shelving locations based on the items homebranch. + var homebranchSelector = $(clone).find("div[id=subfield"+homebranchMarcSubfield+"]").find("select[name=field_value]"); + var shelvingLocationSelector = $(clone).find("div[id=subfield"+shelvingLocationMarcSubfield+"]").find("select[name=field_value]"); + + //Reload shelving location with AJAX if the "Permanent location" (homebranch) changes. + //Function is bound from koha-to-marc-mapping-api.js + $(homebranchSelector).change(function() { + reloadShelvingLocations(this.value, '', shelvingLocationSelector); + }); } }); } --- a/koha-tmpl/intranet-tmpl/prog/en/js/koha-to-marc-mapping-api.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/koha-to-marc-mapping-api.js @@ -0,0 +1,33 @@ +//Fetch the Shelving locations using AJAX +//Build the replacement HTML for the shelving location options +//Then replace the existing HTML with this. +function reloadShelvingLocations(branch, framework, selectorElement) { + + if (typeof framework == "undefined" && typeof shelvingLocationMarcField == "undefined") { + framework = "0"; //Get the default framework + } + + $.ajax({ + url: "/cgi-bin/koha/svc/getShelvingLocations.pl", + type: "POST", + dataType: 'json', + data: { 'branch' : branch, 'framework' : framework }, + success: function(data, textStatus, jqXHR) { + + var locations = data.locations; + if ( selectorElement ) { + var html_replacement = '\n'; + for (var k in locations) { + html_replacement += '\n'; + } + $(selectorElement).html( html_replacement ); + } + else { + alert("ERROR in koha-to-marc-mapping-api.js: No element given to place new shelving locations into!"); + } + }, + error: function(data, textStatus, jqXHR) { + alert("ERROR in koha-to-marc-mapping-api.js: Couldn't make a decent AJAX-call!"); + } + }); +} --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -8,9 +8,15 @@ + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -9,38 +9,20 @@ +