From: David Cook Date: Fri, 6 Jun 2014 04:01:17 +0000 (+1000) Subject: Bug 9093 - 008 forgetting what material type was chosen X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=e897e11c65d1a5cbeb5ca5bff5a83a41269588c1;p=koha_fer 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 Signed-off-by: Bernardo Gonzalez Kriegel Work as described, nice job. koha-qa complains for a tab char, removed on followup. Mode change on TT file (+x), removed. No other errors NOTE: It would be desirable to update LEADER values to reflect changes on 008. Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi Awesome work David. --- diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl index 6fbb3d1b3f..ab30454718 100755 --- a/cataloguing/value_builder/marc21_field_008.pl +++ b/cataloguing/value_builder/marc21_field_008.pl @@ -72,7 +72,14 @@ 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'); + //Retrieve full leader string and pass it to the 008 tag editor + var leader_value = \$(\"input[id^='tag_000']\").val(); + var leader_parameter = \"\"; + if (leader_value){ + //Only add the parameter to the URL if there is a value to add + 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 +97,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 Type 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 type using 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 material type + if ( ($material_configuration) && (ref($material_configuration) eq 'HASH') ){ + $material_configuration = $material_configuration->{$leader07}; + } + } my $dbh = C4::Context->dbh; @@ -123,6 +178,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 5bb381b632..fc2499a9da 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,10 @@ 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 type configuration is found using the leader, use that type when rendering. Otherwise, the default of BKS will be used %] + [% IF ( material_configuration ) %] + objXmlControlField.idMaterial = "[% material_configuration %]"; + [% END %] objXmlControlField.loadXmlValues(); renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result")); [% END %]