MT2582: Fix user deletion without permission
[koha.git] / serials / claims.pl
blobaf0143d6d0d4709472415efce5d20f78b7252eae
1 #!/usr/bin/perl
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
8 # version.
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.
18 use strict;
19 use warnings;
20 use CGI;
21 use C4::Auth;
22 use C4::Serials;
23 use C4::Acquisition;
24 use C4::Output;
25 use C4::Bookseller;
26 use C4::Context;
27 use C4::Letters;
28 my $input = CGI->new;
30 my $serialid = $input->param('serialid');
31 my $op = $input->param('op');
32 my $claimletter = $input->param('claimletter');
33 my $supplierid = $input->param('supplierid');
34 my $suppliername = $input->param('suppliername');
35 my $order = $input->param('order');
36 my $supplierlist = GetSuppliersWithLateIssues();
37 if ($supplierid) {
38 foreach my $s ( @{$supplierlist} ) {
39 if ($s->{id} == $supplierid ) {
40 $s->{selected} = 1;
41 last;
46 # open template first (security & userenv set here)
47 my ($template, $loggedinuser, $cookie)
48 = get_template_and_user({template_name => 'serials/claims.tmpl',
49 query => $input,
50 type => 'intranet',
51 authnotrequired => 0,
52 flagsrequired => {serials => 1},
53 debug => 1,
54 });
57 my $letters = GetLetters('claimissues');
58 my @letters;
59 foreach (keys %{$letters}){
60 push @letters ,{code=>$_,name=> $letters->{$_}};
63 my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
64 my @missingissues;
65 my @supplierinfo;
66 if ($supplierid) {
67 @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
68 @supplierinfo=GetBookSeller($supplierid);
71 my $preview=0;
72 if($op && $op eq 'preview'){
73 $preview = 1;
74 } else {
75 my @serialnums=$input->param('serialid');
76 if (@serialnums) { # i.e. they have been flagged to generate claims
77 SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
78 my $cntupdate=UpdateClaimdateIssues(\@serialnums);
79 ### $cntupdate SHOULD be equal to scalar(@$serialnums)
82 $template->param('letters'=>\@letters,'letter'=>$letter);
83 $template->param(
84 order =>$order,
85 supplier_loop => $supplierlist,
86 phone => $supplierinfo[0]->{phone},
87 booksellerfax => $supplierinfo[0]->{booksellerfax},
88 bookselleremail => $supplierinfo[0]->{bookselleremail},
89 preview => $preview,
90 missingissues => \@missingissues,
91 supplierid => $supplierid,
92 claimletter => $claimletter,
93 supplierloop => \@supplierinfo,
94 dateformat => C4::Context->preference("dateformat"),
95 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
97 output_html_with_http_headers $input, $cookie, $template->output;