3 # Parts Copyright 2010 Biblibre
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>.
28 use C4
::Koha
qw( GetAuthorisedValues );
30 use Koha
::AdditionalFields
;
31 use Koha
::CsvProfiles
;
35 my $serialid = $input->param('serialid');
36 my $op = $input->param('op');
37 my $claimletter = $input->param('claimletter');
38 my $supplierid = $input->param('supplierid');
39 my $suppliername = $input->param('suppliername');
41 # open template first (security & userenv set here)
42 my ($template, $loggedinuser, $cookie)
43 = get_template_and_user
({template_name
=> 'serials/claims.tt',
47 flagsrequired
=> {serials
=> 'claim_serials'},
51 # supplierlist is returned in name order
52 my $supplierlist = GetSuppliersWithLateIssues
();
53 for my $s (@
{$supplierlist} ) {
54 $s->{count
} = scalar GetLateOrMissingIssues
($s->{id
});
55 if ($supplierid && $s->{id
} == $supplierid) {
60 my $additional_fields = Koha
::AdditionalFields
->search( { tablename
=> 'subscription', searchable
=> 1 } );
62 my @serialnums=$input->multi_param('serialid');
63 if (@serialnums) { # i.e. they have been flagged to generate claims
66 $err = SendAlerts
('claimissues',\
@serialnums,$input->param("letter_code"));
67 if ( not ref $err or not exists $err->{error
} ) {
68 C4
::Serials
::updateClaim
( \
@serialnums );
72 $template->param(error_claim
=> $@
);
73 } elsif ( ref $err and exists $err->{error
} ) {
74 if ( $err->{error
} eq "no_email" ) {
75 $template->param( error_claim
=> 'no_vendor_email' );
76 } elsif ( $err->{error
} =~ m
|Bad
or missing From address
| ) {
77 $template->param( error_claim
=> 'bad_or_missing_sender' );
80 $template->param( info_claim
=> 1 );
84 my $letters = GetLetters
({ module
=> 'claimissues' });
88 @missingissues = GetLateOrMissingIssues
($supplierid);
89 foreach my $issue (@missingissues) {
90 $issue->{cannot_claim
} = 1
91 unless C4
::Serials
::can_claim_subscription
($issue);
96 suploop
=> $supplierlist,
97 missingissues
=> \
@missingissues,
98 supplierid
=> $supplierid,
99 claimletter
=> $claimletter,
100 additional_fields_for_subscription
=> $additional_fields,
101 csv_profiles
=> [ Koha
::CsvProfiles
->search({ type
=> 'sql', used_for
=> 'late_issues' }) ],
103 (uc(C4
::Context
->preference("marcflavour"))) => 1
105 output_html_with_http_headers
$input, $cookie, $template->output;