Bug 13904: Make unimarc_field_4XX displays usefull 200 subfield data
[koha.git] / serials / serials-search.pl
blob27ccd42af4f6ad461ed00dd1e5dd07b8c7facb9e
1 #!/usr/bin/perl
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>.
21 =head1 NAME
23 serials-search.pl
25 =head1 DESCRIPTION
27 this script is the search page for serials
29 =cut
31 use Modern::Perl;
32 use CGI qw ( -utf8 );
33 use C4::Auth;
34 use C4::Branch;
35 use C4::Context;
36 use C4::Output;
37 use C4::Serials;
39 use Koha::DateUtils;
41 my $query = new CGI;
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",
60 query => $query,
61 type => "intranet",
62 authnotrequired => 0,
63 flagsrequired => { serials => '*' },
64 debug => 1,
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;
79 my @subscriptions;
80 if ($searched){
81 @subscriptions = SearchSubscriptions(
83 biblionumber => $biblionumber,
84 title => $title,
85 issn => $ISSN,
86 ean => $EAN,
87 callnumber => $callnumber,
88 publisher => $publisher,
89 bookseller => $bookseller,
90 branch => $branch,
91 location => $location,
92 expiration_date => $expiration_date_dt,
97 # to toggle between create or edit routing list options
98 if ($routing) {
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};
109 } else {
110 push @closedsubscriptions, $sub
111 unless $sub->{cannotdisplay};
115 my $branches = GetBranches();
116 my @branches_loop;
117 foreach (sort keys %$branches){
118 my $selected = 0;
119 $selected = 1 if( defined $branch and $branch eq $_ );
120 push @branches_loop, {
121 branchcode => $_,
122 branchname => $branches->{$_}->{'branchname'},
123 selected => $selected,
128 $template->param(
129 openedsubscriptions => \@openedsubscriptions,
130 closedsubscriptions => \@closedsubscriptions,
131 total => @openedsubscriptions + @closedsubscriptions,
132 title_filter => $title,
133 ISSN_filter => $ISSN,
134 EAN_filter => $EAN,
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,
143 routing => $routing,
144 marcflavour => (uc(C4::Context->preference("marcflavour")))
147 output_html_with_http_headers $query, $cookie, $template->output;