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
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use C4::AuthoritiesMarc;
33 ###TODO To rewrite in order to use SearchAuthorities
37 plugin_parameters : other parameters added when the plugin is called by the dopop function
40 sub plugin_parameters {
41 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
47 plugin_javascript : the javascript function called when the user enters the subfield.
48 contain 3 javascript functions :
49 * one called when the field is entered (OnFocus). Named FocusXXX
50 * one called when the field is leaved (onBlur). Named BlurXXX
51 * one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
55 * a variable containing the 3 scripts.
56 the 3 scripts are inserted after the <input> in the html code
59 sub plugin_javascript {
60 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
61 my $function_name= $field_number;
62 #---- build editors list.
63 #---- the editor list is built from the "EDITORS" thesaurus
64 #---- this thesaurus category must be filled as follow :
66 #---- 200$b for editor
67 #---- 200$c (repeated) for collections
71 <script type=\"text/javascript\">
72 function Focus$function_name(index) {
76 function Blur$function_name(subfield_managed) {
80 function Clic$function_name(subfield_managed) {
81 defaultvalue=escape(document.getElementById(\"$field_number\").value);
82 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&index=\"+subfield_managed,\"unimarc_225a\",'width=500,height=600,toolbar=false,scrollbars=yes');
86 return ($function_name,$res);
91 plugin : the true value_builded. The screen that is open in the popup window.
98 my $op = $query->param('op');
99 my $authtypecode = $query->param('authtypecode');
100 my $index = $query->param('index');
101 my $category = $query->param('category');
102 my $resultstring = $query->param('result');
103 my $dbh = C4::Context->dbh;
105 my $startfrom=$query->param('startfrom');
106 $startfrom=0 if(!defined $startfrom);
107 my ($template, $loggedinuser, $cookie);
110 my $authtypes = getauthtypes;
112 foreach my $thisauthtype (keys %$authtypes) {
114 if ($thisauthtype eq $authtypecode) {
117 my %row =(value => $thisauthtype,
118 selected => $selected,
119 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
122 push @authtypesloop, \%row;
125 if ($op eq "do_search") {
126 my @marclist = $query->param('marclist');
127 my @and_or = $query->param('and_or');
128 my @excluding = $query->param('excluding');
129 my @operator = $query->param('operator');
130 my @value = $query->param('value');
131 my $orderby = $query->param('orderby');
133 $resultsperpage= $query->param('resultsperpage');
134 $resultsperpage = 19 if(!defined $resultsperpage);
136 # builds tag and subfield arrays
139 my ($results,$total) = SearchAuthorities( \@tags,\@and_or,
140 \@excluding, \@operator, \@value,
141 $startfrom*$resultsperpage, $resultsperpage,$authtypecode, $orderby);
143 # Getting the $b if it exists
145 my $authority = GetAuthority($_->{authid});
146 if ($authority->field('200') and $authority->subfield('200','b')) {
147 $_->{to_report} = $authority->subfield('200','b');
151 ($template, $loggedinuser, $cookie)
152 = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
155 authnotrequired => 0,
156 flagsrequired => {editcatalogue => '*'},
160 # multi page display gestion
162 my $displayprev=$startfrom;
163 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
169 if ($total>$resultsperpage) {
170 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
173 ($startfrom==($i-1)) && ($highlight=1);
174 push @numbers, { number => $i,
175 highlight => $highlight ,
176 startfrom => ($i-1)};
181 my $from = $startfrom*$resultsperpage+1;
184 if($total < (($startfrom+1)*$resultsperpage)) {
187 $to = (($startfrom+1)*$resultsperpage);
189 my $link="../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&authtypecode=EDITORS&".join("&",map {"value=".$_} @value)."&op=do_search&type=intranet&index=$index";
191 $template->param(result => $results) if $results;
192 $template->param('index' => $query->param('index'));
193 $template->param(startfrom=> $startfrom,
194 displaynext=> $displaynext,
195 displayprev=> $displayprev,
196 resultsperpage => $resultsperpage,
197 startfromnext => $startfrom+1,
198 startfromprev => $startfrom-1,
203 authtypecode =>$authtypecode,
204 resultstring =>$value[0],
205 pagination_bar => pagination_bar(
207 getnbpages($total, $resultsperpage),
213 ($template, $loggedinuser, $cookie)
214 = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
217 authnotrequired => 0,
218 flagsrequired => {editcatalogue => '*'},
222 $template->param(index => $index,
223 resultstring => $resultstring
227 $template->param(authtypesloop => \@authtypesloop);
228 $template->param(category => $category);
231 output_html_with_http_headers $query, $cookie, $template->output;