[Koha-patches] [PATCH] Added value builder plugins for 952 g and v.

Kyle M Hall kyle.m.hall at gmail.com
Thu Oct 22 15:10:06 CEST 2009


When focused on, each will autofill the value from the other and apply the syspref ReplacementCostModifier
( adding it to g, subtracting from v ) to obtain a correct amount.
---
 cataloguing/value_builder/marc21_field_952g.pl     |   86 ++++++++++++++++++++
 cataloguing/value_builder/marc21_field_952v.pl     |   86 ++++++++++++++++++++
 installer/data/mysql/en/mandatory/sysprefs.sql     |    1 +
 .../1-Obligatoire/unimarc_standard_systemprefs.sql |    1 +
 installer/data/mysql/updatedatabase.pl             |    7 ++
 5 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100755 cataloguing/value_builder/marc21_field_952g.pl
 create mode 100755 cataloguing/value_builder/marc21_field_952v.pl

diff --git a/cataloguing/value_builder/marc21_field_952g.pl b/cataloguing/value_builder/marc21_field_952g.pl
new file mode 100755
index 0000000..02910f6
--- /dev/null
+++ b/cataloguing/value_builder/marc21_field_952g.pl
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use C4::Context;
+
+=head1
+
+plugin_parameters : other parameters added when the plugin is called by the dopop function
+
+=cut
+sub plugin_parameters {
+    # my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
+    return "";
+}
+
+=head1
+
+plugin_javascript : the javascript function called when the user enters the subfield.
+contain 3 javascript functions :
+* one called when the field is entered (OnFocus). Named FocusXXX
+* one called when the field is leaved (onBlur). Named BlurXXX
+* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
+
+returns :
+* XXX
+* a variable containing the 3 scripts.
+the 3 scripts are inserted after the <input> in the html code
+
+=cut
+sub plugin_javascript {
+    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
+    my $function_name= $field_number;
+
+    # find today's date
+    my $costMod = C4::Context->preference('ReplacementCostModifier');
+    my $res  = "
+<script type=\"text/javascript\">
+//<![CDATA[
+
+function Blur$function_name(index) {
+    var952g = document.getElementById(\"$field_number\").value;
+}
+
+function Focus$function_name(subfield_managed) {
+    if ( var952v ) {
+      document.getElementById(\"$field_number\").value = Number(var952v) - Number($costMod);
+    }
+}
+
+function Clic$function_name(subfield_managed) {
+}
+//]]>
+</script>
+";
+    return ($function_name,$res);
+}
+
+=head1
+
+plugin : the true value_builded. The screen that is open in the popup window.
+
+=cut
+
+sub plugin {
+    return "";
+}
+
+1;
diff --git a/cataloguing/value_builder/marc21_field_952v.pl b/cataloguing/value_builder/marc21_field_952v.pl
new file mode 100755
index 0000000..0ad99b4
--- /dev/null
+++ b/cataloguing/value_builder/marc21_field_952v.pl
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use C4::Context;
+
+=head1
+
+plugin_parameters : other parameters added when the plugin is called by the dopop function
+
+=cut
+sub plugin_parameters {
+    # my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
+    return "";
+}
+
+=head1
+
+plugin_javascript : the javascript function called when the user enters the subfield.
+contain 3 javascript functions :
+* one called when the field is entered (OnFocus). Named FocusXXX
+* one called when the field is leaved (onBlur). Named BlurXXX
+* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
+
+returns :
+* XXX
+* a variable containing the 3 scripts.
+the 3 scripts are inserted after the <input> in the html code
+
+=cut
+sub plugin_javascript {
+    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
+    my $function_name= $field_number;
+
+    # find today's date
+    my $costMod = C4::Context->preference('ReplacementCostModifier');
+    my $res  = "
+<script type=\"text/javascript\">
+//<![CDATA[
+
+function Blur$function_name(index) {
+    var952v = document.getElementById(\"$field_number\").value;
+}
+
+function Focus$function_name(subfield_managed) {
+    if ( var952g ) {
+      document.getElementById(\"$field_number\").value = Number(var952g) + Number($costMod);
+    }
+}
+
+function Clic$function_name(subfield_managed) {
+}
+//]]>
+</script>
+";
+    return ($function_name,$res);
+}
+
+=head1
+
+plugin : the true value_builded. The screen that is open in the popup window.
+
+=cut
+
+sub plugin {
+    return "";
+}
+
+1;
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index 6f60fa7..02b9434 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -262,3 +262,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'If ON, displays patron image when a patron uses web-based self-checkout', '', 'YesNo');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('ReplacementCostModifier', '0', '', 'If your library always adds and additional fee on in addition to the actual cost of replacing the book, enter it here. This value is used in the 952 g and v value_builder plugins.', 'Float' );
diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
index bee360a..e441faf 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -261,3 +261,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('H
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'Si activé, affiche le format, le type de public et les icônes de type en XSLT (MARC21)).', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'Si activé, affiche la photo de l''adhérent lors de l''utilisation de la console de prêt auto-contrôlé', '', 'YesNo');
+INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('ReplacementCostModifier', '0', '', 'If your library always adds and additional fee on in addition to the actual cost of replacing the book, enter it here. This value is used in the 952 g and v value_builder plugins.', 'Float' );
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 10c3451..116c189 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2675,6 +2675,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.01.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('ReplacementCostModifier', '0', '', 'If your library always adds and additional fee on in addition to the actual cost of replacing the book, enter it here. This value is used in the 952 g and v value_builder plugins.', 'Float' )");
+	print "Upgrade to $DBversion done ( Added ReplacementCostModifier system preference )\n";
+    SetVersion ($DBversion);
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
-- 
1.5.6.5




More information about the Koha-patches mailing list