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>.
29 use C4
::Branch
; # GetBranches GetBranchesLoop
30 use C4
::Koha
qw( GetAuthorisedValues );
31 use Koha
::AdditionalField
;
32 use C4
::Csv
qw( GetCsvProfiles );
36 my $serialid = $input->param('serialid');
37 my $op = $input->param('op');
38 my $claimletter = $input->param('claimletter');
39 my $supplierid = $input->param('supplierid');
40 my $suppliername = $input->param('suppliername');
42 # open template first (security & userenv set here)
43 my ($template, $loggedinuser, $cookie)
44 = get_template_and_user
({template_name
=> 'serials/claims.tt',
48 flagsrequired
=> {serials
=> 'claim_serials'},
52 # supplierlist is returned in name order
53 my $supplierlist = GetSuppliersWithLateIssues
();
54 for my $s (@
{$supplierlist} ) {
55 $s->{count
} = scalar GetLateOrMissingIssues
($s->{id
});
56 if ($supplierid && $s->{id
} == $supplierid) {
61 my $additional_fields = Koha
::AdditionalField
->all( { tablename
=> 'subscription', searchable
=> 1 } );
62 for my $field ( @
$additional_fields ) {
63 if ( $field->{authorised_value_category
} ) {
64 $field->{authorised_value_choices
} = GetAuthorisedValues
( $field->{authorised_value_category
} );
68 my $branchloop = GetBranchesLoop
();
70 my @serialnums=$input->multi_param('serialid');
71 if (@serialnums) { # i.e. they have been flagged to generate claims
74 $err = SendAlerts
('claimissues',\
@serialnums,$input->param("letter_code"));
75 if ( not ref $err or not exists $err->{error
} ) {
76 UpdateClaimdateIssues
(\
@serialnums);
80 $template->param(error_claim
=> $@
);
81 } elsif ( ref $err and exists $err->{error
} ) {
82 if ( $err->{error
} eq "no_email" ) {
83 $template->param( error_claim
=> 'no_vendor_email' );
84 } elsif ( $err->{error
} =~ m
|Bad
or missing From address
| ) {
85 $template->param( error_claim
=> 'no_loggedin_user_email' );
88 $template->param( info_claim
=> 1 );
92 my $letters = GetLetters
({ module
=> 'claimissues' });
96 @missingissues = GetLateOrMissingIssues
($supplierid);
97 foreach my $issue (@missingissues) {
98 $issue->{cannot_claim
} = 1
99 unless C4
::Serials
::can_claim_subscription
($issue);
104 suploop
=> $supplierlist,
105 missingissues
=> \
@missingissues,
106 supplierid
=> $supplierid,
107 claimletter
=> $claimletter,
108 branchloop
=> $branchloop,
109 additional_fields_for_subscription
=> $additional_fields,
110 csv_profiles
=> C4
::Csv
::GetCsvProfiles
( "sql" ),
112 (uc(C4
::Context
->preference("marcflavour"))) => 1
114 output_html_with_http_headers
$input, $cookie, $template->output;