2 # WARNING: 4-character tab stops here
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 with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
24 subscription-bib-search.pl
28 this script search among all existing subscriptions.
35 op use to know the operation to do on this template.
36 * do_search : to search the subscription.
38 Note that if op = do_search there are some others params specific to the search :
39 marclist,and_or,excluding,operator,value
58 use C4::Interface::CGI::Output;
62 # my $type=$query->param('type');
63 my $op = $query->param('op');
64 my $dbh = C4::Context->dbh;
66 my $startfrom=$query->param('startfrom');
67 $startfrom=0 unless $startfrom;
68 my ($template, $loggedinuser, $cookie);
71 if ($op eq "do_search") {
72 my @marclist = $query->param('marclist');
73 my @and_or = $query->param('and_or');
74 my @excluding = $query->param('excluding');
75 my @operator = $query->param('operator');
76 my @value = $query->param('value');
78 $resultsperpage= $query->param('resultsperpage');
79 $resultsperpage = 19 if(!defined $resultsperpage);
80 my $orderby = $query->param('orderby');
82 # builds tag and subfield arrays
85 foreach my $marc (@marclist) {
87 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc);
89 push @tags,$dbh->quote("$tag$subfield");
91 push @tags, $dbh->quote(substr($marc,0,4));
97 my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
98 \@excluding, \@operator, \@value,
99 $startfrom*$resultsperpage, $resultsperpage,$orderby);
101 ($template, $loggedinuser, $cookie)
102 = get_template_and_user({template_name => "serials/result.tmpl",
105 authnotrequired => 0,
106 flagsrequired => {borrowers => 1},
107 flagsrequired => {catalogue => 1},
111 # multi page display gestion
113 my $displayprev=$startfrom;
114 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
121 for(my $i = 0 ; $i <= $#marclist ; $i++)
123 push @field_data, { term => "marclist", val=>$marclist[$i] };
124 push @field_data, { term => "and_or", val=>$and_or[$i] };
125 push @field_data, { term => "excluding", val=>$excluding[$i] };
126 push @field_data, { term => "operator", val=>$operator[$i] };
127 push @field_data, { term => "value", val=>$value[$i] };
132 if ($total>$resultsperpage)
134 for (my $i=1; $i<$total/$resultsperpage+1; $i++)
139 ($startfrom==($i-1)) && ($highlight=1);
140 push @numbers, { number => $i,
141 highlight => $highlight ,
142 searchdata=> \@field_data,
143 startfrom => ($i-1)};
148 my $from = $startfrom*$resultsperpage+1;
151 if($total < (($startfrom+1)*$resultsperpage))
155 $to = (($startfrom+1)*$resultsperpage);
157 $template->param(result => $results,
158 startfrom=> $startfrom,
159 displaynext=> $displaynext,
160 displayprev=> $displayprev,
161 resultsperpage => $resultsperpage,
162 startfromnext => $startfrom+1,
163 startfromprev => $startfrom-1,
164 searchdata=>\@field_data,
171 ($template, $loggedinuser, $cookie)
172 = get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
175 authnotrequired => 0,
176 flagsrequired => {catalogue => 1},
180 my %itemtypes = GetItemTypes();
181 my @values = values %itemtypes;
182 my $CGIitemtype=CGI::scrolling_list(
185 -labels => \%itemtypes,
191 CGIitemtype => $CGIitemtype,
196 output_html_with_http_headers $query, $cookie, $template->output;