refining barcode plugin, two new options
[koha-ffzg.git] / cataloguing / value_builder / unimarc_field_210c.pl
index c971663..6230b5b 100755 (executable)
@@ -24,12 +24,11 @@ use C4::AuthoritiesMarc;
 use C4::Auth;
 use C4::Context;
 use C4::Output;
-use C4::Interface::CGI::Output;
 use CGI;
 use C4::Search;
 use MARC::Record;
 use C4::Koha;
-
+###TODO To rewrite in order to use SearchAuthorities
 
 =head1
 
@@ -57,17 +56,19 @@ 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= "210c".(int(rand(100000))+1);
+my $function_name= $field_number;
 #---- build editors list.
 #---- the editor list is built from the "EDITORS" thesaurus
 #---- this thesaurus category must be filled as follow :
 #---- 200$a for isbn
 #---- 200$b for editor
 #---- 200$c (repeated) for collections
-my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table 
+ my $sth 
+= $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table 
                         left join auth_header on auth_subfield_table.authid=auth_header.authid
                         where authtypecode='EDITORS' and tag='200' and subfieldcode='a'");
-my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='b' and authid=?");
+ my $sth2
+ = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='b' and authid=?");
 $sth->execute;
 my @editors;
 my $authoritysep = C4::Context->preference("authoritysep");
@@ -114,7 +115,7 @@ function Blur$function_name(subfield_managed) {
 }
 
 function Clic$function_name(subfield_managed) {
-    defaultvalue=escape(document.forms['f'].field_value[subfield_managed].value);
+    defaultvalue=escape(document.getElementById(\"$field_number\").value);
     newin=window.open(\"plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&index=\"+subfield_managed,\"unimarc 225a\",'width=500,height=600,toolbar=false,scrollbars=yes');
 }
 </script>
@@ -171,7 +172,7 @@ my ($input) = @_;
         # builds tag and subfield arrays
         my @tags;
     
-        my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or,
+        my ($results,$total) = SearchAuthorities( \@tags,\@and_or,
                                             \@excluding, \@operator, \@value,
                                             $startfrom*$resultsperpage, $resultsperpage,$authtypecode);# $orderby);
     
@@ -214,14 +215,13 @@ my ($input) = @_;
             $to = (($startfrom+1)*$resultsperpage);
         }
         $template->param(result => $results) if $results;
-        $template->param(index => $query->param('index'));
+        $template->param('index' => $query->param('index'));
         $template->param(startfrom=> $startfrom,
                                 displaynext=> $displaynext,
                                 displayprev=> $displayprev,
                                 resultsperpage => $resultsperpage,
                                 startfromnext => $startfrom+1,
                                 startfromprev => $startfrom-1,
-                                index => $index,
                                 total=>$total,
                                 from=>$from,
                                 to=>$to,