@@ -, +, @@
---
cataloguing/value_builder/marc21_field_006.pl | 107 +-
cataloguing/value_builder/marc21_field_008.pl | 141 ++-
installer/data/mysql/de-DE/mandatory/sysprefs.sql | 1 +
installer/data/mysql/en/mandatory/sysprefs.sql | 1 +
.../1-Obligatoire/unimarc_standard_systemprefs.sql | 2 +
installer/data/mysql/it-IT/necessari/sysprefs.sql | 1 +
installer/data/mysql/pl-PL/mandatory/sysprefs.sql | 1 +
...m_preferences_full_optimal_for_install_only.sql | 1 +
...m_preferences_full_optimal_for_install_only.sql | 1 +
installer/data/mysql/updatedatabase.pl | 8 +
.../intranet-tmpl/prog/en/js/xmlControlfield.js | 341 +++++
.../en/modules/admin/preferences/cataloguing.pref | 6 +
.../value_builder/marc21_field_006.tmpl | 157 ++-
.../cataloguing/value_builder/marc21_field_006.xml | 795 ++++++++++++
.../value_builder/marc21_field_008.tmpl | 533 +++++----
.../cataloguing/value_builder/marc21_field_008.xml | 1298 ++++++++++++++++++++
.../cataloguing/value_builder/marc21_field_CF.xsd | 83 ++
17 files changed, 3097 insertions(+), 380 deletions(-)
mode change 100644 => 100755 installer/data/mysql/de-DE/mandatory/sysprefs.sql
mode change 100644 => 100755 installer/data/mysql/en/mandatory/sysprefs.sql
mode change 100644 => 100755 installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
mode change 100644 => 100755 installer/data/mysql/it-IT/necessari/sysprefs.sql
mode change 100644 => 100755 installer/data/mysql/pl-PL/mandatory/sysprefs.sql
mode change 100644 => 100755 installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
mode change 100644 => 100755 installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
create mode 100755 koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js
mode change 100644 => 100755 koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
mode change 100644 => 100755 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tmpl
create mode 100755 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.xml
mode change 100644 => 100755 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl
create mode 100755 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.xml
create mode 100755 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_CF.xsd
mode change 100644 => 100755 kohaversion.pl
--- a/cataloguing/value_builder/marc21_field_006.pl
+++ a/cataloguing/value_builder/marc21_field_006.pl
@@ -26,6 +26,8 @@ use C4::Context;
use C4::Search;
use C4::Output;
+use XML::LibXML;
+
=head1 DESCRIPTION
plugin_parameters : other parameters added when the plugin is called by the dopop function
@@ -82,46 +84,71 @@ sub plugin {
);
$result = "a|||||r|||| 00| 0 " unless $result;
- # $result = "a r 00 0 " unless $result;
- my $f0 = substr($result, 0, 1);
- my $f014 = substr($result, 1, 4);
- my $f5 = substr($result, 5, 1);
- my $f6 = substr($result, 6, 1);
- my $f710 = substr($result, 7, 4);
- my $f11 = substr($result, 11, 1);
- my $f12 = substr($result, 12, 1);
- my $f13 = substr($result, 13, 1);
- my $f14 = substr($result, 14, 1);
- my $f15 = substr($result, 15, 1);
- my $f16 = substr($result, 16, 1);
- my $f17 = substr($result, 17, 1);
-
- $template->param(
- index => $index,
- f0 => $f0,
- "f0$f0" => $f0,
- f014 => $f014,
- "f014$f014" => $f014,
- f5 => $f5,
- "f5$f5" => $f5,
- f6 => $f6,
- "f6$f6" => $f6,
- f710 => $f710,
- "f710$f710" => $f710,
- f11 => $f11,
- "f11$f11" => $f11,
- f12 => $f12,
- "f12$f12" => $f12,
- f13 => $f13,
- "f13$f13" => $f13,
- f14 => $f14,
- "f14$f14" => $f14,
- f15 => $f15,
- "f15$f15" => $f15,
- f16 => $f16,
- "f16$f16" => $f16,
- f17 => $f17,
- "f17$f17" => $f17,
+ # Check whether we want to use Type of Material display with xml
+ my $viewMaterialTypesMode = C4::Context->preference("TypeOfMaterialsView_006_008");
+ # Check if the xml, xsd exists and is validated
+ if ($viewMaterialTypesMode) {
+ my $dir = C4::Context->config('intrahtdocs') . '/prog/' . $template->param('lang') . '/modules/cataloguing/value_builder/';
+ if (-r $dir . 'marc21_field_006.xml') {
+ my $doc = XML::LibXML->new->parse_file($dir . 'marc21_field_006.xml');
+ if (-r $dir . 'marc21_field_CF.xsd') {
+ my $xmlschema = XML::LibXML::Schema->new(location => $dir . 'marc21_field_CF.xsd');
+ eval {
+ $xmlschema->validate( $doc );
+ };
+ $viewMaterialTypesMode = 0 if ($@);
+ }
+ } else {
+ $viewMaterialTypesMode = 0;
+ }
+ }
+ unless ($viewMaterialTypesMode) {
+ # $result = "a r 00 0 " unless $result;
+ my $f0 = substr($result, 0, 1);
+ my $f014 = substr($result, 1, 4);
+ my $f5 = substr($result, 5, 1);
+ my $f6 = substr($result, 6, 1);
+ my $f710 = substr($result, 7, 4);
+ my $f11 = substr($result, 11, 1);
+ my $f12 = substr($result, 12, 1);
+ my $f13 = substr($result, 13, 1);
+ my $f14 = substr($result, 14, 1);
+ my $f15 = substr($result, 15, 1);
+ my $f16 = substr($result, 16, 1);
+ my $f17 = substr($result, 17, 1);
+
+ $template->param(
+ f0 => $f0,
+ "f0$f0" => $f0,
+ f014 => $f014,
+ "f014$f014" => $f014,
+ f5 => $f5,
+ "f5$f5" => $f5,
+ f6 => $f6,
+ "f6$f6" => $f6,
+ f710 => $f710,
+ "f710$f710" => $f710,
+ f11 => $f11,
+ "f11$f11" => $f11,
+ f12 => $f12,
+ "f12$f12" => $f12,
+ f13 => $f13,
+ "f13$f13" => $f13,
+ f14 => $f14,
+ "f14$f14" => $f14,
+ f15 => $f15,
+ "f15$f15" => $f15,
+ f16 => $f16,
+ "f16$f16" => $f16,
+ f17 => $f17,
+ "f17$f17" => $f17,
+ );
+ } else {
+ $template->param(tagfield => '006');
+ }
+ $template->param(index => $index,
+ result => $result,
+ viewMaterialTypesMode => $viewMaterialTypesMode,
);
output_html_with_http_headers $input, $cookie, $template->output;
}
--- a/cataloguing/value_builder/marc21_field_008.pl
+++ a/cataloguing/value_builder/marc21_field_008.pl
@@ -26,6 +26,8 @@ use C4::Context;
use C4::Search;
use C4::Output;
+use XML::LibXML;
+
=head1 DESCRIPTION
plugin_parameters : other parameters added when the plugin is called by the dopop function
@@ -96,65 +98,90 @@ sub plugin {
# $result = " t xxu 00 0 eng d" unless $result;
$result = "$dateentered" . "t xxu||||| |||| 00| 0 eng d" unless $result;
- my $f1 = substr($result, 0, 6);
- my $f6 = substr($result, 6, 1);
- my $f710 = substr($result, 7, 4);
- my $f1114 = substr($result, 11, 4);
- my $f1517 = substr($result, 15, 3);
- my $f1821 = substr($result, 18, 4);
- my $f22 = substr($result, 22, 1);
- my $f23 = substr($result, 23, 1);
- my $f2427 = substr($result, 24, 4);
- my $f28 = substr($result, 28, 1);
- my $f29 = substr($result, 29, 1);
- my $f30 = substr($result, 30, 1);
- my $f31 = substr($result, 31, 1);
- my $f33 = substr($result, 33, 1);
- my $f34 = substr($result, 34, 1);
- my $f3537 = substr($result, 35, 3);
- my $f38 = substr($result, 38, 1);
- my $f39 = substr($result, 39, 1);
-
- # bug 2563
- $f710 = "" if ($f710 =~ /^\s*$/);
- $f1114 = "" if ($f1114 =~ /^\s*$/);
-
- if ((!$f1) || ($f1 =~ m/ /)) {
- $f1 = $dateentered;
+ # Check whether we want to use Type of Material display with xml
+ my $viewMaterialTypesMode = C4::Context->preference("TypeOfMaterialsView_006_008");
+ # Check if the xml, xsd exists and is validated
+ if ($viewMaterialTypesMode) {
+ my $dir = C4::Context->config('intrahtdocs') . '/prog/' . $template->param('lang') . '/modules/cataloguing/value_builder/';
+ if (-r $dir . 'marc21_field_008.xml') {
+ my $doc = XML::LibXML->new->parse_file($dir . 'marc21_field_008.xml');
+ if (-r $dir . 'marc21_field_CF.xsd') {
+ my $xmlschema = XML::LibXML::Schema->new(location => $dir . 'marc21_field_CF.xsd');
+ eval {
+ $xmlschema->validate( $doc );
+ };
+ $viewMaterialTypesMode = 0 if ($@);
+ }
+ } else {
+ $viewMaterialTypesMode = 0;
+ }
}
+ unless ($viewMaterialTypesMode) {
+ my $f1 = substr($result, 0, 6);
+ my $f6 = substr($result, 6, 1);
+ my $f710 = substr($result, 7, 4);
+ my $f1114 = substr($result, 11, 4);
+ my $f1517 = substr($result, 15, 3);
+ my $f1821 = substr($result, 18, 4);
+ my $f22 = substr($result, 22, 1);
+ my $f23 = substr($result, 23, 1);
+ my $f2427 = substr($result, 24, 4);
+ my $f28 = substr($result, 28, 1);
+ my $f29 = substr($result, 29, 1);
+ my $f30 = substr($result, 30, 1);
+ my $f31 = substr($result, 31, 1);
+ my $f33 = substr($result, 33, 1);
+ my $f34 = substr($result, 34, 1);
+ my $f3537 = substr($result, 35, 3);
+ my $f38 = substr($result, 38, 1);
+ my $f39 = substr($result, 39, 1);
+
+ # bug 2563
+ $f710 = "" if ($f710 =~ /^\s*$/);
+ $f1114 = "" if ($f1114 =~ /^\s*$/);
+
+ if ((!$f1) || ($f1 =~ m/ /)) {
+ $f1 = $dateentered;
+ }
- $template->param(
- index => $index,
- f1 => $f1,
- f6 => $f6,
- "f6$f6" => $f6,
- f710 => $f710,
- f1114 => $f1114,
- f1517 => $f1517,
- f1821 => $f1821,
- f22 => $f22,
- "f22$f22" => $f22,
- f23 => $f23,
- "f23$f23" => $f23,
- f2427 => $f2427,
- "f24$f2427" => $f2427,
- f28 => $f28,
- "f28$f28" => $f28,
- f29 => $f29,
- "f29$f29" => $f29,
- f30 => $f30,
- "f30$f30" => $f30,
- f31 => $f31,
- "f31$f31" => $f31,
- f33 => $f33,
- "f33$f33" => $f33,
- f34 => $f34,
- "f34$f34" => $f34,
- f3537 => $f3537,
- f38 => $f38,
- "f38$f38" => $f38,
- f39 => $f39,
- "f39$f39" => $f39,
+ $template->param(
+ f1 => $f1,
+ f6 => $f6,
+ "f6$f6" => $f6,
+ f710 => $f710,
+ f1114 => $f1114,
+ f1517 => $f1517,
+ f1821 => $f1821,
+ f22 => $f22,
+ "f22$f22" => $f22,
+ f23 => $f23,
+ "f23$f23" => $f23,
+ f2427 => $f2427,
+ "f24$f2427" => $f2427,
+ f28 => $f28,
+ "f28$f28" => $f28,
+ f29 => $f29,
+ "f29$f29" => $f29,
+ f30 => $f30,
+ "f30$f30" => $f30,
+ f31 => $f31,
+ "f31$f31" => $f31,
+ f33 => $f33,
+ "f33$f33" => $f33,
+ f34 => $f34,
+ "f34$f34" => $f34,
+ f3537 => $f3537,
+ f38 => $f38,
+ "f38$f38" => $f38,
+ f39 => $f39,
+ "f39$f39" => $f39,
+ );
+ } else {
+ $template->param(tagfield => '008');
+ }
+ $template->param(index => $index,
+ result => $result,
+ viewMaterialTypesMode => $viewMaterialTypesMode,
);
output_html_with_http_headers $input, $cookie, $template->output;
}
--- a/installer/data/mysql/de-DE/mandatory/sysprefs.sql
+++ a/installer/data/mysql/de-DE/mandatory/sysprefs.sql
@@ -287,3 +287,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ a/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -287,3 +287,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -287,5 +287,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShelfBrowserUsesLocation','1','Use the item location when finding items for the shelf browser.','1','YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesHomeBranch','1','Use the item home branch when finding items for the shelf browser.','1','YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
+<<<<<<< HEAD:installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/it-IT/necessari/sysprefs.sql
+++ a/installer/data/mysql/it-IT/necessari/sysprefs.sql
@@ -274,3 +274,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql
+++ a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql
@@ -286,3 +286,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
+++ a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
@@ -341,3 +341,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
+++ a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
@@ -366,3 +366,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo');
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -4022,6 +4022,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion($DBversion);
};
+$DBversion = '3.03.00.XXX'; #FIXME
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ # 006/008 plugins show Type of Materials and change fields form to view the allowed values for the different positions
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TypeOfMaterialsView_006_008','0','Display Type of Materials for plugin of fields 006 and 008 when cataloguing','','YesNo')");
+ print "Upgrade to $DBversion done (006/008 plugins show Type of Materials positions selection)\n";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
--- a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js
+++ a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js
@@ -0,0 +1,341 @@
+
+
+// Add an option to a select form field
+function add_option(select, text, value, selected)
+{
+ var option = document.createElement('option');
+ option.text = text;
+ option.value = value;
+ if (selected) option.selected = true;
+ try {
+ select.add(option, null);
+ }
+ catch(ex) {
+ select.add(option);
+ }
+}//add_option
+
+
+// Return the value of a parameter from the url
+function returnValueParam(param)
+{
+ var params = location.search.substr(1);
+ var arr = params.split("&");
+ var pattern = param + "=";
+ for (var i=0; i < arr.length; i++) {
+ if (arr[i].indexOf(pattern) == 0) {
+ return unescape(arr[i].substr(pattern.length));
+ }
+ }
+ return "";
+}//returnValueParam
+
+
+// Return a value from a position on the result string
+function returnValuePosFromResult(result, pos)
+{
+ var index;
+ if ((index = pos.indexOf("-")) > 0) {
+ var ini = parseInt(pos.substring(0, index) ,10);
+ var end = parseInt(pos.substr(index + 1) ,10);
+ return result.substring(ini, end + 1);
+ } else {
+ return result.substr(pos, 1);
+ }
+}//returnValuePosFromResult
+
+
+// Build string from form fields
+function returnResultFromValues(form)
+{
+ var resultStr = form.result.value;
+ var pos;
+ var value;
+ for (var i=0; i < form.elements.length; i++) {
+ var pattern = new RegExp("f[0-9]+(?:[0-9]+)?");
+ if (pattern.test(form.elements[i].name)) {
+ pos = form.elements[i].name.substr(1);
+ value = (pos.indexOf("-") > 0)?form.elements[i].value:form.elements[i].options[form.elements[i].selectedIndex].value;
+ resultStr = changePosResult(pos, value, resultStr);
+ }
+ }
+ return resultStr;
+}//returnResultFromValues
+
+
+// Build/modify result string for a position and a value
+function changePosResult(pos, value, resultStr)
+{
+ var index;
+ var result = "";
+ if ((index = pos.indexOf("-")) > 0) {
+ var ini = parseInt(pos.substring(0, index) ,10);
+ var end = parseInt(pos.substr(index + 1) ,10);
+ var roffset = (1 + end - ini)- value.length;
+ if (roffset > 0) for (var i=0; i < roffset; i++) value += " ";
+ if (ini == 0)
+ result = value + resultStr.substr(end + 1);
+ else {
+ result = resultStr.substring(0, ini) + value;
+ if (end < resultStr.length)
+ result += resultStr.substr(end + 1);
+ }
+ } else {
+ var ini = parseInt(pos, 10);
+ if (ini == 0)
+ result = value + resultStr.substr(1);
+ else {
+ result = resultStr.substring(0, ini) + value;
+ if (ini < resultStr.length)
+ result += resultStr.substr(ini + 1);
+ }
+ }
+ result = result.replace(/#/g, " ");
+ return result;
+}//changePosResult
+
+
+// Display the result string on a table indicating positions and coloring them if wrong or selected
+function renderResult(tr_result, result)
+{
+ if (tr_result) {
+ var td;
+ if (tr_result.cells.length != result.length) {
+ for (var i = tr_result.cells.length - 1; i >= 0; i--)
+ tr_result.deleteCell(i);
+ for (var i=0; i < result.length; i++) {
+ value = result.charAt(i);
+ td = tr_result.insertCell(tr_result.cells.length);
+ }
+ }
+ var value;
+ var ini = -1;
+ var end = -1;
+ var args = renderResult.arguments;
+ if (args.length > 2) {
+ var index;
+ if ((index = args[2].indexOf("-")) > 0) {
+ ini = parseInt(args[2].substring(0, index) ,10);
+ end = parseInt(args[2].substr(index + 1) ,10);
+ } else ini = parseInt(args[2], 10);
+ }
+ for (var i=0; i < result.length; i++) {
+ value = result.charAt(i);
+ td = tr_result.cells[i];
+ if (td.style.backgroundColor != "yellow") td.style.backgroundColor = "white";
+ td.innerHTML = (value == " ")?" ":value;
+ td.title = "Pos " + i + ". Value: \"" + value + "\"";
+ if (ini >= 0) {
+ if (end > 0) {
+ if (ini <= i && i <= end) td.style.backgroundColor = "#cccccc";
+ } else if (i == ini) td.style.backgroundColor = "#cccccc";
+ } else {
+ var pos = (i < 10)?'0' + i:i + '';
+ var obj;
+ if ((obj = document.getElementById('f' + pos)) != null) {
+ var found = false;
+ for (var j=0; j < obj.options.length && !found; j++)
+ if (obj.options[j].value == value) found = true;
+ if (!found) {
+ td.style.backgroundColor = "yellow";
+ td.title = "Pos " + i + ". Bad Value: \"" + value + "\"";
+ }
+ }
+ }
+ }//for
+ }
+}//renderResult
+
+
+// Change displaying of result in the page
+function changeH4Result(form, h4_result, tr_result, pos, value)
+{
+ var resultStr = form.result.value;
+ var result = changePosResult(pos, value, resultStr);
+ renderResult(tr_result, result, pos);
+ h4_result.innerHTML = result;
+ form.result.value = result;
+}//changeH4Result
+
+
+
+// Class to read the xml and render the type of material
+(function()
+{
+
+ xmlControlField = function(tagfield, form_id, select, table, h4_result, tr_result, idMaterial)
+ {
+ this.tagfield = tagfield;
+ this.idMaterial = idMaterial;
+ this.form_id = form_id;
+ this.form = document.getElementById(form_id);
+ this.select = select;
+ this.table = table;
+ this.h4_result = h4_result;
+ this.tr_result = tr_result;
+ };//xmlControlField
+
+
+ xmlControlField.prototype =
+ {
+ tagfield: "",
+ idMaterial: "",
+ root: null,
+ form_id: "",
+ form: null,
+ select: null,
+ table: null,
+ h4_result: "",
+ tr_result: "",
+
+
+ setIdMaterial: function(idMaterial)
+ {
+ this.idMaterial = idMaterial;
+ },//setIdMaterial
+
+ loadXmlValues: function()
+ {
+ var xmlhttp;
+ try {
+ if (window.XMLHttpRequest) {
+ xmlhttp = new XMLHttpRequest();
+ if (xmlhttp.overrideMimeType) {
+ xmlhttp.overrideMimeType('text/xml');
+ }
+ } else if (window.ActiveXObject) {
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") || new ActiveXObject("Msxml2.XMLHTTP");
+ }
+ xmlhttp.open("GET", "/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_" + this.tagfield + ".xml", false);
+ xmlhttp.send(null);
+ this.xmlDoc = xmlhttp.responseXML;
+ if (this.xmlDoc) this.renderTemplate();
+ } catch (e) {
+ //alert(e);
+ }
+ },//loadXmlValues
+
+
+ renderTemplate: function()
+ {
+ this.root = this.xmlDoc.documentElement;
+ if (this.root.nodeName == "Tagfield" && this.root.nodeType == 1 && this.root.hasChildNodes()) {
+ var tag = this.root.attributes.getNamedItem("tag").nodeValue;
+ var nodeMaterial = this.root.getElementsByTagName('Material');
+ if (nodeMaterial != null && nodeMaterial.length > 0) {
+ if (this.idMaterial == "") this.idMaterial = nodeMaterial[0].attributes.getNamedItem("id").nodeValue;
+ this.renderSelectMaterial(nodeMaterial);
+ this.renderPositions(nodeMaterial, (this.form.result.value != "")?this.form.result.value:returnValueParam("result"));
+ }
+ }
+ },//renderTemplate
+
+
+ renderSelectMaterial: function(nodeMaterial)
+ {
+ if (this.select != null && nodeMaterial != null && nodeMaterial.length > 0) {
+ if (this.select.options.length <= 1) {
+ var id;
+ var name;
+ var arrSort = new Array();
+ var arrEquiv = new Array();
+ for (var i=0; i < nodeMaterial.length; i++) {
+ id = nodeMaterial[i].attributes.getNamedItem("id").nodeValue;
+ name = nodeMaterial[i].attributes.getNamedItem("name").nodeValue;
+ arrEquiv[id] = i;
+ arrSort.push(id);
+ }
+ arrSort.sort();
+ var j;
+ for (var i=0; i < arrSort.length; i++) {
+ j = arrEquiv[arrSort[i]];
+ add_option(this.select, arrSort[i] + " - " + nodeMaterial[j].attributes.getNamedItem("name").nodeValue, arrSort[i], (this.idMaterial != "" && arrSort[i] == this.idMaterial)?true:false);
+ }
+ } else if (this.idMaterial != "") {
+ for (var i=0; i < this.select.options.length; i++) {
+ if (this.select.options[i].value == this.idMaterial) this.select.options[i].selected = true;
+ }
+ }
+ }
+ },//renderSelectMaterial
+
+
+ renderPositions: function(nodeMaterial, result)
+ {
+ var materialNode;
+ try {
+ var resultXPath = this.xmlDoc.evaluate("//a:Material[@id='" + this.idMaterial + "']", this.xmlDoc.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
+ materialNode = resultXPath.singleNodeValue;
+ } catch (e) {
+ for (var i=0; i < nodeMaterial.length; i++) {
+ if (this.idMaterial == nodeMaterial[i].attributes.getNamedItem("id").nodeValue) {
+ materialNode = nodeMaterial[i];
+ break;
+ }
+ }
+ }
+ if (this.table != null) {
+ var tbody = this.table.tBodies[0];
+ if (tbody.rows.length > 0)
+ for (var i = tbody.rows.length - 1; i >= 1; i--)
+ tbody.deleteRow(i);
+ if (materialNode != undefined && materialNode != null && materialNode.nodeType == 1 && materialNode.hasChildNodes()) {
+ var nodePos = materialNode.firstChild;
+ var tr;
+ var td;
+ var title;
+ var pos;
+ var value;
+ var strInnerHTML = "";
+ var selected;
+ var index;
+ var url;
+ while (nodePos != null) {
+ if (nodePos.nodeType == 1 && nodePos.nodeName == "Position") {
+ tr = tbody.insertRow(tbody.rows.length);
+ td = tr.insertCell(tr.cells.length);
+ pos = nodePos.attributes.getNamedItem("pos").nodeValue;
+ title = ((nodePos.getAttributeNode("description") || nodePos.hasAttribute("description")) && nodePos.getAttribute("description") != "")?nodePos.attributes.getNamedItem("description").nodeValue:nodePos.attributes.getNamedItem("name").nodeValue;
+ try {
+ url = ((nodePos.getAttributeNode("url") || nodePos.hasAttribute("url")) && nodePos.getAttribute("url") != "" && nodePos.getAttribute("urltext") != "")?" " + nodePos.attributes.getNamedItem("urltext").nodeValue + "":"";
+ } catch (e) { url = "";}
+ td.innerHTML = "";
+ td = tr.insertCell(tr.cells.length);
+ value = returnValuePosFromResult(result, pos);
+ if ((index = pos.indexOf("-")) > 0) {
+ var ini = parseInt(pos.substring(0, index) ,10);
+ var end = parseInt(pos.substr(index + 1) ,10);
+ value = value.replace(/ /g, "#");
+ strInnerHTML = "";
+ } else {
+ strInnerHTML = "";
+ }
+ //alert(strInnerHTML);
+ td.innerHTML = strInnerHTML;
+ }
+ nodePos = nodePos.nextSibling;
+ }
+ }
+ }
+ }//renderPositions
+ };
+
+})();
+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
@@ -118,4 +118,10 @@ Cataloging:
yes: Hide
no: "Don't hide"
- items marked as suppressed from OPAC search results. Note that you must have the Suppress
index set up in Zebra and at least one suppressed item, or your searches will be broken.
+ -
+ - pref: TypeOfMaterialsView_006_008
+ choices:
+ yes: "Don't hide"
+ no: Hide
+ - 006/008 plugins show Type of Materials and change fields form to view the allowed values for the different positions.
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tmpl
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tmpl
@@ -1,14 +1,67 @@