3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use C4::Branch; # GetBranches GetBranchesLoop
32 my $serialid = $input->param('serialid');
33 my $op = $input->param('op');
34 my $claimletter = $input->param('claimletter');
35 my $supplierid = $input->param('supplierid');
36 my $suppliername = $input->param('suppliername');
37 my $order = $input->param('order');
38 my $supplierlist = GetSuppliersWithLateIssues();
40 foreach my $s ( @{$supplierlist} ) {
41 if ($s->{id} == $supplierid ) {
48 # open template first (security & userenv set here)
49 my ($template, $loggedinuser, $cookie)
50 = get_template_and_user({template_name => 'serials/claims.tmpl',
54 flagsrequired => {serials => 'claim_serials'},
59 for my $s ( sort {$a->{name} cmp $b->{name} } @$supplierlist ) {
60 my @list = GetLateOrMissingIssues($s, "", $order);
63 count => scalar(@list),
64 selected => $s->{id} == $supplierid,
68 my $letters = GetLetters('claimissues');
70 foreach (keys %{$letters}){
71 push @letters ,{code=>$_,name=> $letters->{$_}};
74 my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
78 @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
79 @supplierinfo=GetBookSeller($supplierid);
82 my $branchloop = GetBranchesLoop();
83 unshift @$branchloop, {value=> 'all',name=>''};
86 if($op && $op eq 'preview'){
89 my @serialnums=$input->param('serialid');
90 if (@serialnums) { # i.e. they have been flagged to generate claims
91 SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
92 my $cntupdate=UpdateClaimdateIssues(\@serialnums);
93 ### $cntupdate SHOULD be equal to scalar(@$serialnums)
96 $template->param('letters'=>\@letters,'letter'=>$letter);
100 phone => $supplierinfo[0]->{phone},
101 booksellerfax => $supplierinfo[0]->{booksellerfax},
102 bookselleremail => $supplierinfo[0]->{bookselleremail},
104 missingissues => \@missingissues,
105 supplierid => $supplierid,
106 claimletter => $claimletter,
107 supplierloop => \@supplierinfo,
108 branchloop => $branchloop,
109 dateformat => C4::Context->preference("dateformat"),
110 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
112 output_html_with_http_headers $input, $cookie, $template->output;