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
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use C4
::AuthoritiesMarc
;
33 ###TODO To rewrite in order to use SearchAuthorities
35 sub plugin_javascript
{
36 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
37 my $function_name= $field_number;
38 #---- build editors list.
39 #---- the editor list is built from the "EDITORS" thesaurus
40 #---- this thesaurus category must be filled as follow :
42 #---- 200$b for editor
43 #---- 200$c (repeated) for collections
47 <script type=\"text/javascript\">
48 function Clic$function_name(subfield_managed) {
49 defaultvalue=escape(document.getElementById(\"$field_number\").value);
50 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');
54 return ($function_name,$res);
60 my $op = $query->param('op');
61 my $authtypecode = $query->param('authtypecode');
62 my $index = $query->param('index');
63 my $category = $query->param('category');
64 my $resultstring = $query->param('result');
65 my $dbh = C4
::Context
->dbh;
67 my $startfrom=$query->param('startfrom');
68 $startfrom=0 if(!defined $startfrom);
69 my ($template, $loggedinuser, $cookie);
72 my $authtypes = getauthtypes
;
74 foreach my $thisauthtype (keys %$authtypes) {
76 if ($thisauthtype eq $authtypecode) {
79 my %row =(value
=> $thisauthtype,
80 selected
=> $selected,
81 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
84 push @authtypesloop, \
%row;
87 if ($op eq "do_search") {
88 my @marclist = $query->param('marclist');
89 my @and_or = $query->param('and_or');
90 my @excluding = $query->param('excluding');
91 my @operator = $query->param('operator');
92 my @value = $query->param('value');
93 my $orderby = $query->param('orderby');
95 $resultsperpage= $query->param('resultsperpage');
96 $resultsperpage = 19 if(!defined $resultsperpage);
98 # builds tag and subfield arrays
101 my ($results,$total) = SearchAuthorities
( \
@tags,\
@and_or,
102 \
@excluding, \
@operator, \
@value,
103 $startfrom*$resultsperpage, $resultsperpage,$authtypecode, $orderby);
105 # Getting the $b if it exists
107 my $authority = GetAuthority
($_->{authid
});
108 if ($authority->field('200') and $authority->subfield('200','b')) {
109 $_->{to_report
} = $authority->subfield('200','b');
113 ($template, $loggedinuser, $cookie)
114 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
117 authnotrequired
=> 0,
118 flagsrequired
=> {editcatalogue
=> '*'},
122 # multi page display gestion
124 my $displayprev=$startfrom;
125 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
131 if ($total>$resultsperpage) {
132 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
135 ($startfrom==($i-1)) && ($highlight=1);
136 push @numbers, { number
=> $i,
137 highlight
=> $highlight ,
138 startfrom
=> ($i-1)};
143 my $from = $startfrom*$resultsperpage+1;
146 if($total < (($startfrom+1)*$resultsperpage)) {
149 $to = (($startfrom+1)*$resultsperpage);
151 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";
153 $template->param(result
=> $results) if $results;
154 $template->param('index' => $query->param('index'));
155 $template->param(startfrom
=> $startfrom,
156 displaynext
=> $displaynext,
157 displayprev
=> $displayprev,
158 resultsperpage
=> $resultsperpage,
159 startfromnext
=> $startfrom+1,
160 startfromprev
=> $startfrom-1,
165 authtypecode
=>$authtypecode,
166 resultstring
=>$value[0],
167 pagination_bar
=> pagination_bar
(
169 getnbpages
($total, $resultsperpage),
175 ($template, $loggedinuser, $cookie)
176 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
179 authnotrequired
=> 0,
180 flagsrequired
=> {editcatalogue
=> '*'},
184 $template->param(index => $index,
185 resultstring
=> $resultstring
189 $template->param(authtypesloop
=> \
@authtypesloop);
190 $template->param(category
=> $category);
193 output_html_with_http_headers
$query, $cookie, $template->output;