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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
27 this script is the search page for serials
35 use C4::Koha qw( GetAuthorisedValues );
38 use Koha::AdditionalField;
41 use Koha::SharedContent;
44 my $title = $query->param('title_filter') || '';
45 my $ISSN = $query->param('ISSN_filter') || '';
46 my $EAN = $query->param('EAN_filter') || '';
47 my $callnumber = $query->param('callnumber_filter') || '';
48 my $publisher = $query->param('publisher_filter') || '';
49 my $bookseller = $query->param('bookseller_filter') || '';
50 my $biblionumber = $query->param('biblionumber') || '';
51 my $branch = $query->param('branch_filter') || '';
52 my $location = $query->param('location_filter') || '';
53 my $expiration_date = $query->param('expiration_date_filter') || '';
54 my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials");
55 my $searched = $query->param('searched') || 0;
56 my $mana = $query->param('mana') || 0;
57 my @subscriptionids = $query->multi_param('subscriptionid');
58 my $op = $query->param('op');
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62 template_name => "serials/serials-search.tt",
66 flagsrequired => { serials => '*' },
71 if ( $op and $op eq "close" ) {
72 for my $subscriptionid ( @subscriptionids ) {
73 C4::Serials::CloseSubscription( $subscriptionid );
75 } elsif ( $op and $op eq "reopen" ) {
76 for my $subscriptionid ( @subscriptionids ) {
77 C4::Serials::ReopenSubscription( $subscriptionid );
82 my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription', searchable => 1 } );
83 my $additional_field_filters = Koha::AdditionalField->get_filters_from_query( {
84 tablename => 'subscription',
88 my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
93 my $result = Koha::SharedContent::search_entities("subscription",{
97 publisher => $publisher
99 $mana_statuscode = $result->{code};
100 @subscriptions = @{ $result->{data} };
103 @subscriptions = SearchSubscriptions(
105 biblionumber => $biblionumber,
109 callnumber => $callnumber,
110 publisher => $publisher,
111 bookseller => $bookseller,
113 additional_fields => $additional_field_filters,
114 location => $location,
115 expiration_date => $expiration_date_dt,
122 subscriptions => \@subscriptions,
123 statuscode => $mana_statuscode,
124 total => scalar @subscriptions,
125 title_filter => $title,
126 ISSN_filter => $ISSN,
128 callnumber_filter => $callnumber,
129 publisher_filter => $publisher,
130 bookseller_filter => $bookseller,
131 branch_filter => $branch,
132 location_filter => $location,
133 expiration_date_filter => $expiration_date_dt,
134 done_searched => $searched,
136 additional_field_filters => $additional_field_filters,
137 additional_fields_for_subscription => $additional_fields,
138 marcflavour => (uc(C4::Context->preference("marcflavour"))),
145 # to toggle between create or edit routing list options
147 for my $subscription ( @subscriptions) {
148 $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} );
152 my (@openedsubscriptions, @closedsubscriptions);
153 for my $sub ( @subscriptions ) {
154 unless ( $sub->{closed} ) {
155 push @openedsubscriptions, $sub
156 unless $sub->{cannotdisplay};
158 push @closedsubscriptions, $sub
159 unless $sub->{cannotdisplay};
163 my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } );
165 foreach my $b ( @branches ) {
167 $selected = 1 if( defined $branch and $branch eq $b->branchcode );
168 push @branches_loop, {
169 branchcode => $b->branchcode,
170 branchname => $b->branchname,
171 selected => $selected,
176 openedsubscriptions => \@openedsubscriptions,
177 closedsubscriptions => \@closedsubscriptions,
178 total => @openedsubscriptions + @closedsubscriptions,
179 title_filter => $title,
180 ISSN_filter => $ISSN,
182 callnumber_filter => $callnumber,
183 publisher_filter => $publisher,
184 bookseller_filter => $bookseller,
185 branch_filter => $branch,
186 location_filter => $location,
187 expiration_date_filter => $expiration_date_dt,
188 branches_loop => \@branches_loop,
189 done_searched => $searched,
191 additional_field_filters => Koha::AdditionalField->get_filters_as_values( $additional_field_filters ),
192 additional_fields_for_subscription => $additional_fields,
193 marcflavour => (uc(C4::Context->preference("marcflavour"))),
197 output_html_with_http_headers $query, $cookie, $template->output;