Bug 9718 - Add POD and comments for Check_Userid and Generate_Userid subs
[koha.git] / serials / claims.pl
blob5434b2aea91357084c5f209d3a9c511cbbda2395
1 #!/usr/bin/perl
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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
22 use CGI;
23 use C4::Auth;
24 use C4::Serials;
25 use C4::Acquisition;
26 use C4::Output;
27 use C4::Bookseller qw( GetBookSeller );
28 use C4::Context;
29 use C4::Letters;
30 use C4::Branch; # GetBranches GetBranchesLoop
32 my $input = CGI->new;
34 my $serialid = $input->param('serialid');
35 my $op = $input->param('op');
36 my $claimletter = $input->param('claimletter');
37 my $supplierid = $input->param('supplierid');
38 my $suppliername = $input->param('suppliername');
39 my $order = $input->param('order');
41 # open template first (security & userenv set here)
42 my ($template, $loggedinuser, $cookie)
43 = get_template_and_user({template_name => 'serials/claims.tmpl',
44 query => $input,
45 type => 'intranet',
46 authnotrequired => 0,
47 flagsrequired => {serials => 'claim_serials'},
48 debug => 1,
49 });
51 # supplierlist is returned in name order
52 my $supplierlist = GetSuppliersWithLateIssues();
53 for my $s (@{$supplierlist} ) {
54 $s->{count} = scalar GetLateOrMissingIssues($s->{id}, q{}, $order);
55 if ($supplierid && $s->{id} == $supplierid) {
56 $s->{selected} = 1;
60 my $letters = GetLetters('claimissues');
61 my @letters;
62 foreach (keys %{$letters}){
63 push @letters ,{code=>$_,name=> $letters->{$_}};
66 my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
67 my @missingissues;
68 my @supplierinfo;
69 if ($supplierid) {
70 @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
71 @supplierinfo=GetBookSeller($supplierid);
74 my $branchloop = GetBranchesLoop();
75 unshift @$branchloop, {value=> 'all',name=>''};
77 my $preview=0;
78 if($op && $op eq 'preview'){
79 $preview = 1;
80 } else {
81 my @serialnums=$input->param('serialid');
82 if (@serialnums) { # i.e. they have been flagged to generate claims
83 SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
84 my $cntupdate=UpdateClaimdateIssues(\@serialnums);
85 ### $cntupdate SHOULD be equal to scalar(@$serialnums)
88 $template->param('letters'=>\@letters,'letter'=>$letter);
89 $template->param(
90 order =>$order,
91 suploop => $supplierlist,
92 phone => $supplierinfo[0]->{phone},
93 booksellerfax => $supplierinfo[0]->{booksellerfax},
94 bookselleremail => $supplierinfo[0]->{bookselleremail},
95 preview => $preview,
96 missingissues => \@missingissues,
97 supplierid => $supplierid,
98 claimletter => $claimletter,
99 supplierloop => \@supplierinfo,
100 branchloop => $branchloop,
101 (uc(C4::Context->preference("marcflavour"))) => 1
103 output_html_with_http_headers $input, $cookie, $template->output;