5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
23 This plugin is used to map isbn/editor with collection.
25 in thesaurus, a category named EDITORS
26 in this category, datas must be entered like following :
27 isbn separator editor separator collection.
29 2204 -- Cerf -- Cogitatio fidei
30 2204 -- Cerf -- Le Magistère de l'Eglise
31 2204 -- Cerf -- Lectio divina
32 2204 -- Cerf -- Lire la Bible
33 2204 -- Cerf -- Pour lire
34 2204 -- Cerf -- Sources chrétiennes
36 when the user clic on ... on 225a line, the popup shows the list of collections from the selected editor
37 if the biblio has no isbn, then the search if done on editor only
38 If the biblio ha an isbn, the search is done on isbn and editor. It's faster.
54 plugin_parameters : other parameters added when the plugin is called by the dopop function
57 sub plugin_parameters {
58 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
62 sub plugin_javascript {
63 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
64 my $function_name= "100".(int(rand(100000))+1);
67 function Focus$function_name(subfield_managed) {
71 function Blur$function_name(subfield_managed) {
75 function Clic$function_name(index) {
76 // find the 010a value and the 210c. it will be used in the popup to find possibles collections
78 for (i=0 ; i<document.f.field_value.length ; i++) {
79 if (document.f.tag[i].value == '010' && document.f.subfield[i].value == 'a') {
80 isbn_found=document.f.field_value[i].value;
84 for (i=0 ; i<document.f.field_value.length ; i++) {
85 if (document.f.tag[i].value == '210' && document.f.subfield[i].value == 'c') {
86 editor_found=document.f.field_value[i].value;
90 defaultvalue=document.f.field_value[index].value;
91 newin=window.open(\"../plugin_launcher.pl?plugin_name=unimarc_field_225a.pl&index=\"+index+\"&result=\"+defaultvalue+\"&isbn_found=\"+isbn_found+\"&editor_found=\"+editor_found,\"unimarc 225a\",'width=500,height=200,toolbar=false,scrollbars=no');
97 return ($function_name,$res);
103 # my $input = new CGI;
104 my $index= $input->param('index');
105 my $result= $input->param('result');
106 my $editor_found = $input->param('editor_found');
107 my $isbn_found = $input->param('isbn_found');
108 my $dbh = C4::Context->dbh;
109 my $authoritysep = C4::Context->preference("authoritysep");
110 my ($template, $loggedinuser, $cookie)
111 = get_template_and_user({template_name => "value_builder/unimarc_field_225a.tmpl",
114 authnotrequired => 0,
115 flagsrequired => {parameters => 1},
118 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
119 # if there is an isbn, complete search
121 my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table
122 left join auth_header on auth_subfield_table.authid=auth_header.authid
123 where authtypecode='EDITORS' and tag='200' and subfieldcode='a' and subfieldvalue=?");
124 my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='c' and authid=? order by subfieldvalue");
125 my @splited = split //, $isbn_found;
127 foreach my $x (@splited) {
129 $sth->execute($isbn_rebuild);
130 my ($authid) = $sth->fetchrow;
131 $sth2->execute($authid);
132 while (my ($line)= $sth2->fetchrow) {
133 push @collections,$line;
136 # my @collections = ["test"];
137 my $collection =CGI::scrolling_list(-name=>'f1',
138 -values=> \@collections,
143 $template->param(index => $index,
144 collection => $collection);
145 print $input->header(-cookie => $cookie),$template->output;