Bug 30477: Add new UNIMARC installer translation files
[koha.git] / acqui / newordersubscription.pl
1 #!/usr/bin/perl
2
3 # Copyright 2012 BibLibre
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
16 #
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>.
19
20 use Modern::Perl;
21 use CGI qw ( -utf8 );
22 use C4::Acquisition qw( GetBasket );
23 use C4::Auth qw( get_template_and_user );
24 use C4::Context;
25 use C4::Output qw( output_html_with_http_headers );
26 use C4::Serials qw( SearchSubscriptions subscriptionCurrentlyOnOrder check_routing );
27
28 use Koha::Acquisition::Booksellers;
29
30 my $query        = CGI->new;
31 my $title        = $query->param('title_filter');
32 my $ISSN         = $query->param('ISSN_filter');
33 my $EAN          = $query->param('EAN_filter');
34 my $publisher    = $query->param('publisher_filter');
35 my $supplier     = $query->param('supplier_filter');
36 my $branch       = $query->param('branch_filter');
37 my $routing      = $query->param('routing') || C4::Context->preference("RoutingSerials");
38 my $searched     = $query->param('searched');
39 my $biblionumber = $query->param('biblionumber');
40
41 my $basketno     = $query->param('basketno');
42 my $booksellerid = $query->param('booksellerid');
43
44 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
45     {   template_name   => "acqui/newordersubscription.tt",
46         query           => $query,
47         type            => "intranet",
48         flagsrequired   => { acquisition => 'order_manage' },
49     }
50 );
51
52 my $basket = GetBasket($basketno);
53 $booksellerid = $basket->{booksellerid} unless $booksellerid;
54 my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
55
56 my @subscriptions;
57 if ($searched) {
58     @subscriptions = SearchSubscriptions({
59         title => $title,
60         issn => $ISSN,
61         ean => $EAN,
62         publisher => $publisher,
63         bookseller => $supplier,
64         branch => $branch
65     });
66 }
67
68 foreach my $sub (@subscriptions) {
69     $sub->{alreadyOnOrder} = subscriptionCurrentlyOnOrder $sub->{subscriptionid};
70
71     # to toggle between create or edit routing list options
72     if ($routing) {
73         $sub->{routingedit} = check_routing( $sub->{subscriptionid} );
74     }
75 }
76
77 $template->param(
78     subs_loop        => \@subscriptions,
79     title_filter     => $title,
80     ISSN_filter      => $ISSN,
81     EAN_filter       => $EAN,
82     publisher_filter => $publisher,
83     supplier_filter  => $supplier,
84     branch_filter    => $branch,
85     done_searched    => $searched,
86     routing          => $routing,
87     booksellerid     => $booksellerid,
88     basketno         => $basket->{basketno},
89     basketname       => $basket->{basketname},
90     booksellername   => $bookseller->name,
91 );
92 output_html_with_http_headers $query, $cookie, $template->output;