Add a UNIMARC to Dublin Core XSL
[koha.git] / serials / claims.pl
blobb0a1e123c6ee8acc5ed2e7a574d2f658b2bb3831
1 #!/usr/bin/perl
3 use strict;
4 use CGI;
5 use C4::Auth;
6 use C4::Serials;
7 use C4::Acquisition;
8 use C4::Output;
9 use C4::Bookseller;
10 use C4::Context;
11 use C4::Letters;
13 my $input = new CGI;
15 my $serialid = $input->param('serialid');
16 my $op = $input->param('op');
17 my $claimletter = $input->param('claimletter');
18 my $supplierid = $input->param('supplierid');
19 my $order = $input->param('order');
20 my %supplierlist = GetSuppliersWithLateIssues;
21 my @select_supplier;
23 # open template first (security & userenv set here)
24 my ($template, $loggedinuser, $cookie)
25 = get_template_and_user({template_name => "serials/claims.tmpl",
26 query => $input,
27 type => "intranet",
28 authnotrequired => 0,
29 flagsrequired => {serials => 1},
30 debug => 1,
31 });
33 foreach my $supplierid (sort {$supplierlist{$a} cmp $supplierlist{$b} } keys %supplierlist){
34 my ($count, @dummy) = GetLateOrMissingIssues($supplierid,"",$order);
35 my $counting = $count;
36 $supplierlist{$supplierid} = $supplierlist{$supplierid}." ($counting)";
37 push @select_supplier, $supplierid
40 my $letters = GetLetters("claimissues");
41 my @letters;
42 foreach (keys %$letters){
43 push @letters ,{code=>$_,name=> $letters->{$_}};
46 my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
47 my ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order) if $supplierid;
49 my $CGIsupplier=CGI::scrolling_list( -name => 'supplierid',
50 -id => 'supplierid',
51 -values => \@select_supplier,
52 -default => $supplierid,
53 -labels => \%supplierlist,
54 -size => 1,
55 -multiple => 0 );
57 my ($singlesupplier,@supplierinfo);
58 if($supplierid){
59 (@supplierinfo)=GetBookSeller($supplierid);
60 } else { # set up supplierid for the claim links out of main table if all suppliers is chosen
61 for(my $i=0; $i<@missingissues;$i++){
62 $missingissues[$i]->{'supplierid'} = getsupplierbyserialid($missingissues[$i]->{'serialid'});
66 my $preview=0;
67 if($op eq 'preview'){
68 $preview = 1;
71 if ($op eq "send_alert"){
72 my @serialnums=$input->param("serialid");
73 SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
74 my $cntupdate=UpdateClaimdateIssues(\@serialnums);
75 ### $cntupdate SHOULD be equal to scalar(@$serialnums)
78 $template->param('letters'=>\@letters,'letter'=>$letter);
79 $template->param(
80 order =>$order,
81 CGIsupplier => $CGIsupplier,
82 phone => $supplierinfo[0]->{phone},
83 booksellerfax => $supplierinfo[0]->{booksellerfax},
84 bookselleremail => $supplierinfo[0]->{bookselleremail},
85 preview => $preview,
86 missingissues => \@missingissues,
87 supplierid => $supplierid,
88 claimletter => $claimletter,
89 singlesupplier => $singlesupplier,
90 supplierloop => \@supplierinfo,
91 dateformat => C4::Context->preference("dateformat"),
93 output_html_with_http_headers $input, $cookie, $template->output;