4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # 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 Magistere de l'Eglise
31 2204 -- Cerf -- Lectio divina
32 2204 -- Cerf -- Lire la Bible
33 2204 -- Cerf -- Pour lire
34 2204 -- Cerf -- Sources chretiennes
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
58 sub plugin_parameters {
59 my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
63 sub plugin_javascript {
64 my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
65 my $function_name = $field_number;
67 <script type=\"text/javascript\">
68 function Focus$function_name(subfield_managed) {
72 function Blur$function_name(subfield_managed) {
76 function Clic$function_name(index) {
77 // find the 010a value and the 210c. it will be used in the popup to find possibles collections
81 var inputs = document.getElementsByTagName('input');
83 for(var i=0 , len=inputs.length ; i \< len ; i++ ){
84 if(inputs[i].id.match(/^tag_010_subfield_a_.*/)){
85 isbn_found = inputs[i].value;
87 if(inputs[i].id.match(/^tag_210_subfield_c_.*/)){
88 editor_found = inputs[i].value;
90 if(editor_found && isbn_found){
95 defaultvalue = document.getElementById(\"$field_number\").value;
96 window.open(\"../cataloguing/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');
102 return ( $function_name, $res );
107 my $index = $input->param('index');
108 my $result = $input->param('result');
109 my $editor_found = $input->param('editor_found');
110 my $isbn_found = $input->param('isbn_found');
111 my $dbh = C4::Context->dbh;
112 my $authoritysep = C4::Context->preference("authoritysep");
113 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
116 "cataloguing/value_builder/unimarc_field_225a.tmpl",
119 authnotrequired => 0,
120 flagsrequired => { editcatalogue => 1 },
125 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
126 # if there is an isbn, complete search
129 my $sth = $dbh->prepare(
130 "SELECT auth_subfield_table.authid,subfieldvalue
131 FROM auth_subfield_table
132 LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
133 WHERE authtypecode='EDITORS'
140 "SELECT subfieldvalue
141 FROM auth_subfield_table
145 ORDER BY subfieldvalue"
147 my @splited = split //, $isbn_found;
148 my $isbn_rebuild = '';
149 foreach my $x (@splited) {
151 $sth->execute($isbn_rebuild);
152 my ($authid) = $sth->fetchrow;
153 $sth2->execute($authid);
154 while ( my ($line) = $sth2->fetchrow ) {
155 push @collections, $line;
160 my $sth = $dbh->prepare(
161 "SELECT auth_subfield_table.authid,subfieldvalue
162 FROM auth_subfield_table
163 LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
164 WHERE authtypecode='EDITORS'
171 "SELECT subfieldvalue
172 FROM auth_subfield_table
176 ORDER BY subfieldvalue"
178 $sth->execute($editor_found);
179 my ($authid) = $sth->fetchrow;
180 $sth2->execute($authid);
181 while ( my ($line) = $sth2->fetchrow ) {
182 push @collections, $line;
186 # my @collections = ["test"];
187 my $collection = CGI::scrolling_list(
189 -values => \@collections,
190 -default => "$result",
196 collection => $collection
198 output_html_with_http_headers $input, $cookie, $template->output;