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
42 my $title = $query->param('title_filter') || '';
43 my $ISSN = $query->param('ISSN_filter') || '';
44 my $EAN = $query->param('EAN_filter') || '';
45 my $callnumber = $query->param('callnumber_filter') || '';
46 my $publisher = $query->param('publisher_filter') || '';
47 my $bookseller = $query->param('bookseller_filter') || '';
48 my $biblionumber = $query->param('biblionumber') || '';
49 my $branch = $query->param('branch_filter') || '';
50 my $location = $query->param('location_filter') || '';
51 my $expiration_date = $query->param('expiration_date_filter') || '';
52 my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials");
53 my $searched = $query->param('searched') || 0;
54 my @subscriptionids = $query ->param('subscriptionid');
55 my $op = $query->param('op');
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
59 template_name => "serials/serials-search.tt",
63 flagsrequired => { serials => '*' },
68 if ( $op and $op eq "close" ) {
69 for my $subscriptionid ( @subscriptionids ) {
70 C4::Serials::CloseSubscription( $subscriptionid );
72 } elsif ( $op and $op eq "reopen" ) {
73 for my $subscriptionid ( @subscriptionids ) {
74 C4::Serials::ReopenSubscription( $subscriptionid );
78 my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
81 @subscriptions = SearchSubscriptions(
83 biblionumber => $biblionumber,
87 callnumber => $callnumber,
88 publisher => $publisher,
89 bookseller => $bookseller,
91 location => $location,
92 expiration_date => $expiration_date_dt,
97 # to toggle between create or edit routing list options
99 for my $subscription ( @subscriptions) {
100 $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} );
104 my (@openedsubscriptions, @closedsubscriptions);
105 for my $sub ( @subscriptions ) {
106 unless ( $sub->{closed} ) {
107 push @openedsubscriptions, $sub
108 unless $sub->{cannotdisplay};
110 push @closedsubscriptions, $sub
111 unless $sub->{cannotdisplay};
115 my $branches = GetBranches();
117 foreach (sort keys %$branches){
119 $selected = 1 if( defined $branch and $branch eq $_ );
120 push @branches_loop, {
122 branchname => $branches->{$_}->{'branchname'},
123 selected => $selected,
129 openedsubscriptions => \@openedsubscriptions,
130 closedsubscriptions => \@closedsubscriptions,
131 total => @openedsubscriptions + @closedsubscriptions,
132 title_filter => $title,
133 ISSN_filter => $ISSN,
135 callnumber_filter => $callnumber,
136 publisher_filter => $publisher,
137 bookseller_filter => $bookseller,
138 branch_filter => $branch,
139 locations => C4::Koha::GetAuthorisedValues('LOC', $location),
140 expiration_date_filter => $expiration_date_dt,
141 branches_loop => \@branches_loop,
142 done_searched => $searched,
144 marcflavour => (uc(C4::Context->preference("marcflavour")))
147 output_html_with_http_headers $query, $cookie, $template->output;