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
24 This plugin is used to map isbn/editor with collection.
26 in thesaurus, a category named EDITORS
27 in this category, datas must be entered like following :
28 isbn separator editor separator collection.
30 2204 -- Cerf -- Cogitatio fidei
31 2204 -- Cerf -- Le Magistere de l'Eglise
32 2204 -- Cerf -- Lectio divina
33 2204 -- Cerf -- Lire la Bible
34 2204 -- Cerf -- Pour lire
35 2204 -- Cerf -- Sources chretiennes
37 when the user clic on ... on 225a line, the popup shows the list of collections from the selected editor
38 if the biblio has no isbn, then the search if done on editor only
39 If the biblio ha an isbn, the search is done on isbn and editor. It's faster.
55 plugin_parameters : other parameters added when the plugin is called by the dopop function
59 sub plugin_parameters {
60 my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
64 sub plugin_javascript {
65 my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
66 my $function_name = $field_number;
68 <script type=\"text/javascript\">
69 function Focus$function_name(subfield_managed) {
73 function Blur$function_name(subfield_managed) {
77 function Clic$function_name(index) {
78 // find the 010a value and the 210c. it will be used in the popup to find possibles collections
82 var re1 = /'tag_010_subfield_a_.*'/;
83 var re2 = /'tag_210_subfield_c_.*'/;
85 var inputs = document.getElementsByTagName('input');
87 for(var i=0 , len=inputs.length ; i \< len ; i++ ){
88 if(inputs[i].id.match(re1)){
89 isbn_found = inputs[i].value;
91 if(inputs[i].id.match(re2)){
92 editor_found = inputs[i].value;
94 if(editor_found && isbn_found){
99 defaultvalue = document.getElementById(\"$field_number\").value;
100 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');
106 return ( $function_name, $res );
111 my $index = $input->param('index');
112 my $result = $input->param('result');
113 my $editor_found = $input->param('editor_found');
114 my $isbn_found = $input->param('isbn_found');
115 my $dbh = C4::Context->dbh;
116 my $authoritysep = C4::Context->preference("authoritysep");
117 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
120 "cataloguing/value_builder/unimarc_field_225a.tmpl",
123 authnotrequired => 0,
124 flagsrequired => { editcatalogue => 1 },
129 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
130 # if there is an isbn, complete search
133 my $sth = $dbh->prepare(
134 "SELECT auth_subfield_table.authid,subfieldvalue
135 FROM auth_subfield_table
136 LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
137 WHERE authtypecode='EDITORS'
144 "SELECT subfieldvalue
145 FROM auth_subfield_table
149 ORDER BY subfieldvalue"
151 my @splited = split //, $isbn_found;
152 my $isbn_rebuild = '';
153 foreach my $x (@splited) {
155 $sth->execute($isbn_rebuild);
156 my ($authid) = $sth->fetchrow;
157 $sth2->execute($authid);
158 while ( my ($line) = $sth2->fetchrow ) {
159 push @collections, $line;
164 my $sth = $dbh->prepare(
165 "SELECT auth_subfield_table.authid,subfieldvalue
166 FROM auth_subfield_table
167 LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
168 WHERE authtypecode='EDITORS'
175 "SELECT subfieldvalue
176 FROM auth_subfield_table
180 ORDER BY subfieldvalue"
182 $sth->execute($editor_found);
183 my ($authid) = $sth->fetchrow;
184 $sth2->execute($authid);
185 while ( my ($line) = $sth2->fetchrow ) {
186 push @collections, $line;
190 # my @collections = ["test"];
191 my $collection = CGI::scrolling_list(
193 -values => \@collections,
194 -default => "$result",
200 collection => $collection
202 output_html_with_http_headers $input, $cookie, $template->output;