3 # Copyright 2012 Koha Team
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
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
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 this script is the search page for serials
40 my $title = $query->param('title_filter') || '';
42 my $ISSN = $query->param('ISSN_filter') || '';
43 my $EAN = $query->param('EAN_filter') || '';
44 my $publisher = $query->param('publisher_filter') || '';
45 utf8::decode($publisher);
46 my $bookseller = $query->param('bookseller_filter') || '';
47 utf8::decode($bookseller);
48 my $biblionumber = $query->param('biblionumber') || '';
49 my $branch = $query->param('branch_filter') || '';
50 my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials");
51 my $searched = $query->param('searched') || 0;
52 my @subscriptionids = $query ->param('subscriptionid');
53 my $op = $query->param('op');
55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57 template_name => "serials/serials-search.tmpl",
61 flagsrequired => { serials => '*' },
66 if ( $op and $op eq "close" ) {
67 for my $subscriptionid ( @subscriptionids ) {
68 C4::Serials::CloseSubscription( $subscriptionid );
70 } elsif ( $op and $op eq "reopen" ) {
71 for my $subscriptionid ( @subscriptionids ) {
72 C4::Serials::ReopenSubscription( $subscriptionid );
78 @subscriptions = SearchSubscriptions(
80 biblionumber => $biblionumber,
84 publisher => $publisher,
85 bookseller => $bookseller,
91 # to toggle between create or edit routing list options
93 for my $subscription ( @subscriptions) {
94 $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} );
95 $subscription->{branchname} = GetBranchName ( $subscription->{branchcode} );
99 my (@openedsubscriptions, @closedsubscriptions);
100 for my $sub ( @subscriptions ) {
101 unless ( $sub->{closed} ) {
102 push @openedsubscriptions, $sub;
104 push @closedsubscriptions, $sub;
108 my $branches = GetBranches();
110 foreach (sort keys %$branches){
112 $selected = 1 if( defined $branch and $branch eq $_ );
113 push @branches_loop, {
115 branchname => $branches->{$_}->{'branchname'},
116 selected => $selected,
121 openedsubscriptions => \@openedsubscriptions,
122 closedsubscriptions => \@closedsubscriptions,
123 total => @openedsubscriptions + @closedsubscriptions,
124 title_filter => $title,
125 ISSN_filter => $ISSN,
127 publisher_filter => $publisher,
128 bookseller_filter => $bookseller,
129 branch_filter => $branch,
130 branches_loop => \@branches_loop,
131 done_searched => $searched,
133 marcflavour => (uc(C4::Context->preference("marcflavour")))
136 output_html_with_http_headers $query, $cookie, $template->output;