From 2b1d4612112b4b6928fefb18ebccd7ee68012cd9 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Thu, 3 Apr 2014 17:40:33 +0300 Subject: [PATCH] Bug 11676 - Loading shelving locations based on stuff. For 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. Centralized the shelving location fetching code (to koha-to-marc-mapping-api.js) to have a central place to share related features. ------------- - TEST PLAN - ------------- Same as in the first patch, but this time use the neworderempty.pl-script. --- 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 diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 9fdf032..aad2195 100755 --- a/acqui/neworderempty.pl +++ b/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); + }); } }); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/koha-to-marc-mapping-api.js b/koha-tmpl/intranet-tmpl/prog/en/js/koha-to-marc-mapping-api.js new file mode 100644 index 0000000..c339abb --- /dev/null +++ b/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!"); + } + }); +} \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index 596aa07..d5cabaa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -8,9 +8,15 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index b45bbc0..062e309 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -9,38 +9,20 @@ +