refining barcode plugin, two new options
[koha-ffzg.git] / cataloguing / value_builder / marc21_field_008_authorities.pl
index c5d61b2..68fbf03 100755 (executable)
@@ -33,8 +33,7 @@ plugin_parameters : other parameters added when the plugin is called by the dopo
 
 =cut
 # find today's date
-my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
-                                                               localtime(time);
+my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 $year = substr($year,1,2);
 $mon +=1;
 my $date = "$year-$mon-$mday";
@@ -53,9 +52,11 @@ return "";
 
 sub plugin_javascript {
 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
-my $function_name= "100".(int(rand(100000))+1);
+my $function_name= $field_number;
 my $res="
-<script>
+<script type=\"text/javascript\">
+//<![CDATA[
+
 function Focus$function_name(subfield_managed) {
 return 1;
 }
@@ -65,10 +66,11 @@ function Blur$function_name(subfield_managed) {
 }
 
 function Clic$function_name(i) {
-       defaultvalue=document.forms[0].field_value[i].value;
-       newin=window.open(\"plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=\"+i+\"&result=\"+defaultvalue,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes');
+       defaultvalue=document.getElementById(\"$field_number\").value;
+       newin=window.open(\"plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=$field_number&result=\"+defaultvalue,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes');
 
 }
+//]]>
 </script>
 ";
 
@@ -83,7 +85,7 @@ my ($input) = @_;
        my $dbh = C4::Context->dbh;
 
 my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "value_builder/marc21_field_008_authorities.tmpl",
+    = get_template_and_user({template_name => "cataloguing/value_builder/marc21_field_008_authorities.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
@@ -142,7 +144,7 @@ my ($template, $loggedinuser, $cookie)
                                                        f39 => $f39,
                                                        "f39$f39" => $f39,
                                        );
-       print $input->header(-cookie => $cookie),$template->output;
+        output_html_with_http_headers $input, $cookie, $template->output;
 }
 
 1;