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') // 1; # Page number starting at 1
68 my ($template, $loggedinuser, $cookie);
69 my $resultsperpage = $query->param('resultsperpage') // 20; # TODO hardcoded
70 my $offset = ( $startfrom - 1 ) * $resultsperpage;
72 if ($op eq "do_search") {
73 my @marclist = $query->multi_param('marclist');
74 my @and_or = $query->multi_param('and_or');
75 my @excluding = $query->multi_param('excluding');
76 my @operator = $query->multi_param('operator');
77 my @value = $query->multi_param('value');
78 my $orderby = $query->param('orderby');
80 # builds tag and subfield arrays
83 my ($results,$total) = SearchAuthorities
( \
@tags,\
@and_or,
84 \
@excluding, \
@operator, \
@value,
85 $offset, $resultsperpage,$authtypecode, $orderby);
87 # Getting the $b if it exists
89 my $authority = GetAuthority
($_->{authid
});
90 if ($authority->field('200') and $authority->subfield('200','b')) {
91 $_->{to_report
} = $authority->subfield('200','b');
95 ($template, $loggedinuser, $cookie)
96 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
100 flagsrequired
=> {editcatalogue
=> '*'},
104 # Results displayed in current page
105 my $from = $offset + 1;
106 my $to = ( $offset + $resultsperpage > $total ) ?
$total : $offset + $resultsperpage;
108 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";
110 $template->param(result
=> $results) if $results;
111 $template->param('index' => scalar $query->param('index'));
116 authtypecode
=>$authtypecode,
117 resultstring
=>$value[0],
118 pagination_bar
=> pagination_bar
(
120 getnbpages
($total, $resultsperpage),
126 ($template, $loggedinuser, $cookie)
127 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
130 authnotrequired
=> 0,
131 flagsrequired
=> {editcatalogue
=> '*'},
135 $template->param(index => $index,
136 resultstring
=> $resultstring
140 $template->param(category
=> $category);
143 output_html_with_http_headers
$query, $cookie, $template->output;