Add a UNIMARC to Dublin Core XSL
[koha.git] / serials / receipt.pl
blobb4dc9ddc6cd86a3312a2211e627ec5d84c23e4cb
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 use CGI;
23 use C4::Auth;
24 use C4::Output;
25 use C4::Context;
28 my $query = new CGI;
30 my $op = $query->param('op');
31 my $search = $query->param('titleorissn');
32 my $startfrom=$query->param('startfrom');
34 if ($op eq 'search')
36 my $total;
37 my $results;
38 my $dbh = C4::Context->dbh;
39 my @marclist = $query->param('marclist');
40 my @and_or = $query->param('and_or');
41 my @excluding = $query->param('excluding');
42 my @operator = $query->param('operator');
43 my @value = $query->param('value');
45 my $resultsperpage= $query->param('resultsperpage');
46 $resultsperpage = 19 unless $resultsperpage;
49 my $sth = $dbh->prepare("select subscriptionid, biblionumber from subscription");
50 $sth->execute();
51 my @finalsolution;
52 while (my $first_step = $sth->fetchrow_hashref)
54 my $sth2 = $dbh->prepare("select b3.title from biblioitems b2, biblio b3 where b3.biblionumber = ? and b2.biblionumber = b3.biblionumber and (b2.issn = ? or b3.title like ?)");
55 $sth2->execute($first_step->{'biblionumber'},$search, "%$search%");
56 my @answear;
57 @answear = $sth2->fetchrow_array;
58 $total = scalar @answear;
59 if ($total >= 1)
61 $first_step->{'serial'} = $answear[0];
62 push @finalsolution ,$first_step;
65 my ($template, $loggedinuser, $cookie)
66 = get_template_and_user({template_name => "serials/receipt-search-result.tmpl",
67 query => $query,
68 type => "intranet",
69 authnotrequired => 0,
70 flagsrequired => {serials => 1},
71 debug => 1,
72 });
73 $template->param(subtable => \@finalsolution, total => $total
74 ,);
76 my $displaynext=0;
77 my $displayprev=$startfrom;
78 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
79 $displaynext = 1;
82 my @field_data = ();
85 for(my $i = 0 ; $i <= $#marclist ; $i++)
87 push @field_data, { term => "marclist", val=>$marclist[$i] };
88 push @field_data, { term => "and_or", val=>$and_or[$i] };
89 push @field_data, { term => "excluding", val=>$excluding[$i] };
90 push @field_data, { term => "operator", val=>$operator[$i] };
91 push @field_data, { term => "value", val=>$value[$i] };
94 my @numbers = ();
96 if ($total>$resultsperpage)
98 for (my $i=1; $i<$total/$resultsperpage+1; $i++)
100 if ($i<16)
102 my $highlight=0;
103 ($startfrom==($i-1)) && ($highlight=1);
104 push @numbers, { number => $i,
105 highlight => $highlight ,
106 searchdata=> \@field_data,
107 startfrom => ($i-1)};
112 my $from = $startfrom*$resultsperpage+1;
113 my $to;
115 if($total < (($startfrom+1)*$resultsperpage))
117 $to = $total;
118 } else {
119 $to = (($startfrom+1)*$resultsperpage);
121 $results = \@finalsolution;
122 $template->param(result => $results) if $results;
123 $template->param(
124 startfrom=> $startfrom,
125 displaynext=> $displaynext,
126 displayprev=> $displayprev,
127 resultsperpage => $resultsperpage,
128 startfromnext => $startfrom+1,
129 startfromprev => $startfrom-1,
130 searchdata=>\@field_data,
131 total=>$total,
132 from=>$from,
133 to=>$to,
134 numbers=>\@numbers,
136 output_html_with_http_headers $query, $cookie, $template->output;
139 else{
140 my ($template, $loggedinuser, $cookie)
141 = get_template_and_user({template_name => "serials/receipt.tmpl",
142 query => $query,
143 type => "intranet",
144 authnotrequired => 0,
145 flagsrequired => {serials => 1},
146 debug => 1,
148 output_html_with_http_headers $query, $cookie, $template->output;