From e1a786287bf9d4f1d561355c477dd2a1fe249e94 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 6 Jun 2014 14:01:17 +1000 Subject: [PATCH] Bug 9093 - 008 forgetting what material type was chosen This patch adds material type checking to the MARC21 008 tag editor, based on value from the leader. That is, the 008 tag editor will choose an initial material type based on the leader 06 (and if necessary the leader 07 position) _TEST PLAN_ 1) Create a new record or open an existing bib record 2) Change position 6 from its current value (probably "a") to "c" or "e" or "g" or "m" or "p". (See the end of this message for a comprehensive list of 06 values to try.) 3) Open the 008 tag editor 4) Note that it still says BKS even though it should say "MU" or "MP" or "VM" or "CF" or "MX". 5) Apply the patch 6) Repeat steps 2 and 3. 7) Note that the 008 tag editor now shows the correct material type based on the leader. 8) For more comprehensive checking, try switching position 6 back to "a" and changing position 7 to "b" instead of "m". 9) Note that it will switch from "BKS" to "CR". 10) Fin Comprehensive mapping: Field 008/18-34 Configuration If Leader/06 = a and Leader/07 = a, c, d, or m: Books If Leader/06 = a and Leader/07 = b, i, or s: Continuing Resources If Leader/06 = t: Books If Leader/06 = c, d, i, or j: Music If Leader/06 = e, or f: Maps If Leader/06 = g, k, o, or r: Visual Materials If Leader/06 = m: Computer Files If Leader/06 = p: Mixed Materials http://www.loc.gov/marc/bibliographic/bdleader.html --- cataloguing/value_builder/marc21_field_008.pl | 56 +++++++++++++++++++- .../cataloguing/value_builder/marc21_field_008.tt | 3 + 2 files changed, 58 insertions(+), 1 deletions(-) diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl index 6fbb3d1..9eab4ab 100755 --- a/cataloguing/value_builder/marc21_field_008.pl +++ b/cataloguing/value_builder/marc21_field_008.pl @@ -72,7 +72,12 @@ function Blur$function_name(subfield_managed) { function Clic$function_name(i) { defaultvalue=document.getElementById(\"$field_number\").value; - newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008.pl&index=$field_number&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); + var leader_value = \$(\"input[id^='tag_000']\").val(); + var leader_parameter = \"\"; + if (leader_value){ + leader_parameter = \"&leader=\"+leader_value; + } + newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008.pl&index=$field_number&result=\"+defaultvalue+leader_parameter,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); } //]]> @@ -90,6 +95,54 @@ sub plugin { my ($input) = @_; my $index = $input->param('index'); my $result = $input->param('result'); + my $leader = $input->param('leader'); + + my $material_configuration; + if ($leader && length($leader) == '24') { + #MARC 21 Material Configuration + #Field 008/18-34 Configuration + #If Leader/06 = a and Leader/07 = a, c, d, or m: Books + #If Leader/06 = a and Leader/07 = b, i, or s: Continuing Resources + #If Leader/06 = t: Books + #If Leader/06 = c, d, i, or j: Music + #If Leader/06 = e, or f: Maps + #If Leader/06 = g, k, o, or r: Visual Materials + #If Leader/06 = m: Computer Files + #If Leader/06 = p: Mixed Materials + #http://www.loc.gov/marc/bibliographic/bdleader.html + my $material_configuration_mapping = { + a => { + a => 'BKS', + c => 'BKS', + d => 'BKS', + m => 'BKS', + b => 'CR', + i => 'CR', + s => 'CR', + }, + t => 'BKS', + c => 'MU', + d => 'MU', + i => 'MU', + j => 'MU', + e => 'MP', + f => 'MP', + g => 'VM', + k => 'VM', + o => 'VM', + r => 'VM', + m => 'CF', + p => 'MX', + }; + my $leader06 = substr($leader, 6, 1); + my $leader07 = substr($leader, 7, 1); + #Retrieve material configuration from the hash using marcflavour and leader06 + $material_configuration = $material_configuration_mapping->{$leader06}; + #If the value returned is a ref (i.e. leader06 is 'a'), then use leader07 to get the actual configuration + if ( ($material_configuration) && (ref($material_configuration) eq 'HASH') ){ + $material_configuration = $material_configuration->{$leader07}; + } + } my $dbh = C4::Context->dbh; @@ -123,6 +176,7 @@ sub plugin { index => $index, result => $result, errorXml => $errorXml, + material_configuration => $material_configuration, ); output_html_with_http_headers $input, $cookie, $template->output; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt index 5bb381b..626b626 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt @@ -17,6 +17,9 @@ h4_result = document.getElementById("h4_result"); tr_result = document.getElementById("tr_result"); objXmlControlField = new xmlControlField('[% tagfield %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang %]', '[% marcflavour %]'); + [% IF ( material_configuration ) %] + objXmlControlField.idMaterial = "[% material_configuration %]"; + [% END %] objXmlControlField.loadXmlValues(); renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result")); [% END %] -- 1.7.7.4