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);
101 my $index= $input->param('index');
102 my $result= $input->param('result');
103 my $editor_found = $input->param('editor_found');
104 my $isbn_found = $input->param('isbn_found');
105 my $dbh = C4::Context->dbh;
106 my $authoritysep = C4::Context->preference("authoritysep");
107 my ($template, $loggedinuser, $cookie)
108 = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_225a.tmpl",
111 authnotrequired => 0,
112 flagsrequired => {editcatalogue => 1},
115 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
116 # if there is an isbn, complete search
119 my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table
120 left join auth_header on auth_subfield_table.authid=auth_header.authid
121 where authtypecode='EDITORS' and tag='200' and subfieldcode='a' and subfieldvalue=?");
122 my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='c' and authid=? order by subfieldvalue");
123 my @splited = split //, $isbn_found;
125 foreach my $x (@splited) {
127 $sth->execute($isbn_rebuild);
128 my ($authid) = $sth->fetchrow;
129 $sth2->execute($authid);
130 while (my ($line)= $sth2->fetchrow) {
131 push @collections,$line;
135 my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table
136 left join auth_header on auth_subfield_table.authid=auth_header.authid
137 where authtypecode='EDITORS' and tag='200' and subfieldcode='b' and subfieldvalue=?");
138 my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='c' and authid=? order by subfieldvalue");
139 $sth->execute($editor_found);
140 my ($authid) = $sth->fetchrow;
141 $sth2->execute($authid);
142 while (my ($line)= $sth2->fetchrow) {
143 push @collections,$line;
146 # my @collections = ["test"];
147 my $collection =CGI::scrolling_list(-name=>'f1',
148 -values=> \@collections,
153 $template->param(index => $index,
154 collection => $collection);
155 print $input->header(-cookie => $cookie),$template->output;