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.
22 #use warnings; FIXME - Bug 2505
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) {
113 my $selected = 1 if $thisauthtype eq $authtypecode;
114 my %row =(value => $thisauthtype,
115 selected => $selected,
116 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
119 push @authtypesloop, \%row;
122 if ($op eq "do_search") {
123 my @marclist = $query->param('marclist');
124 my @and_or = $query->param('and_or');
125 my @excluding = $query->param('excluding');
126 my @operator = $query->param('operator');
127 my @value = $query->param('value');
128 my $orderby = $query->param('orderby');
130 $resultsperpage= $query->param('resultsperpage');
131 $resultsperpage = 19 if(!defined $resultsperpage);
133 # builds tag and subfield arrays
136 my ($results,$total) = SearchAuthorities( \@tags,\@and_or,
137 \@excluding, \@operator, \@value,
138 $startfrom*$resultsperpage, $resultsperpage,$authtypecode, $orderby);
140 # Getting the $b if it exists
142 my $authority = GetAuthority($_->{authid});
143 if ($authority->field('200') and $authority->subfield('200','b')) {
144 $_->{to_report} = $authority->subfield('200','b');
148 ($template, $loggedinuser, $cookie)
149 = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
152 authnotrequired => 0,
153 flagsrequired => {editcatalogue => '*'},
157 # multi page display gestion
159 my $displayprev=$startfrom;
160 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
166 if ($total>$resultsperpage) {
167 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
170 ($startfrom==($i-1)) && ($highlight=1);
171 push @numbers, { number => $i,
172 highlight => $highlight ,
173 startfrom => ($i-1)};
178 my $from = $startfrom*$resultsperpage+1;
181 if($total < (($startfrom+1)*$resultsperpage)) {
184 $to = (($startfrom+1)*$resultsperpage);
186 my $link="../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&authtypecode=EDITORS&and_or=$and_or&marclist=$marclist&operator=$operator&orderby=$orderby&excluding=$excluding&".join("&",map {"value=".$_} @value)."&op=do_search&type=intranet&index=$index";
188 $template->param(result => $results) if $results;
189 $template->param('index' => $query->param('index'));
190 $template->param(startfrom=> $startfrom,
191 displaynext=> $displaynext,
192 displayprev=> $displayprev,
193 resultsperpage => $resultsperpage,
194 startfromnext => $startfrom+1,
195 startfromprev => $startfrom-1,
200 authtypecode =>$authtypecode,
201 resultstring =>$value[0],
202 pagination_bar => pagination_bar(
204 getnbpages($total, $resultsperpage),
210 ($template, $loggedinuser, $cookie)
211 = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
214 authnotrequired => 0,
215 flagsrequired => {editcatalogue => '*'},
219 $template->param(index => $index,
220 resultstring => $resultstring
224 $template->param(authtypesloop => \@authtypesloop);
225 $template->param(category => $category);
228 output_html_with_http_headers $query, $cookie, $template->output;