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
61 # my $type=$query->param('type');
62 my $op = $input->param('op');
63 my $dbh = C4::Context->dbh;
65 my $startfrom=$input->param('startfrom');
66 $startfrom=0 unless $startfrom;
67 my ($template, $loggedinuser, $cookie);
70 if ($op eq "do_search") {
71 my $query = $input->param('q');
73 $resultsperpage= $input->param('resultsperpage');
74 $resultsperpage = 19 if(!defined $resultsperpage);
76 my ($error,$marcrecords) = SimpleSearch($query);
77 my $total = scalar @$marcrecords;
80 $template->param(query_error => $error);
81 warn "error: ".$error;
82 output_html_with_http_headers $input, $cookie, $template->output;
88 for(my $i=0;$i<$total;$i++) {
90 my $marcrecord = MARC::File::USMARC::decode($marcrecords->[$i]);
91 my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
93 #build the hash for the template.
94 $resultsloop{highlight} = ($i % 2)?(1):(0);
95 $resultsloop{title} = $biblio->{'title'};
96 $resultsloop{subtitle} = $biblio->{'subtitle'};
97 $resultsloop{biblionumber} = $biblio->{'biblionumber'};
98 $resultsloop{author} = $biblio->{'author'};
99 $resultsloop{publishercode} = $biblio->{'publishercode'};
100 $resultsloop{publicationyear} = $biblio->{'publicationyear'};
102 push @results, \%resultsloop;
105 ($template, $loggedinuser, $cookie)
106 = get_template_and_user({template_name => "serials/result.tmpl",
109 authnotrequired => 0,
110 flagsrequired => {serials => 1},
111 flagsrequired => {catalogue => 1},
115 # multi page display gestion
117 my $displayprev=$startfrom;
118 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
125 if ($total>$resultsperpage)
127 for (my $i=1; $i<$total/$resultsperpage+1; $i++)
132 ($startfrom==($i-1)) && ($highlight=1);
133 push @numbers, { number => $i,
134 highlight => $highlight ,
135 searchdata=> \@results,
136 startfrom => ($i-1)};
141 my $from = $startfrom*$resultsperpage+1;
144 if($total < (($startfrom+1)*$resultsperpage))
148 $to = (($startfrom+1)*$resultsperpage);
152 resultsloop => \@results,
153 startfrom=> $startfrom,
154 displaynext=> $displaynext,
155 displayprev=> $displayprev,
156 resultsperpage => $resultsperpage,
157 startfromnext => $startfrom+1,
158 startfromprev => $startfrom-1,
164 } # end of if ($op eq "do_search")
166 ($template, $loggedinuser, $cookie)
167 = get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
170 authnotrequired => 0,
171 flagsrequired => {catalogue => 1, serials=>1},
175 my %itemtypes = GetItemTypes();
176 my @values = values %itemtypes;
177 my $CGIitemtype=CGI::scrolling_list(
180 -labels => \%itemtypes,
186 CGIitemtype => $CGIitemtype,
191 output_html_with_http_headers $input, $cookie, $template->output;