HTL mod for till reconciliation.
[koha.git] / acqui / lateorders.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5 use C4::Acquisition;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Interface::CGI::Output;
9 use C4::Context;
10 use HTML::Template;
11
12 my $query = new CGI;
13 my ($template, $loggedinuser, $cookie)
14 = get_template_and_user({template_name => "acqui/lateorders.tmpl",
15                                 query => $query,
16                                 type => "intranet",
17                                 authnotrequired => 0,
18                                 flagsrequired => {acquisition => 1},
19                                 debug => 1,
20                                 });
21 # my $title = $query->param('title');
22 # my $ISSN = $query->param('ISSN');
23 # my @subscriptions = getsubscriptions($title,$ISSN);
24
25 my $supplierid = $query->param('supplierid');
26 my $delay = $query->param('delay');
27 my $branch = $query->param('branch');
28
29 $delay =($delay?$delay:30);
30
31 my %supplierlist = getsupplierlistwithlateorders($delay,$branch);
32 my @select_supplier;
33 push @select_supplier,"";
34 foreach my $supplierid (keys %supplierlist){
35         push @select_supplier, $supplierid;
36 }
37 my $CGIsupplier=CGI::scrolling_list( -name     => 'supplierid',
38                         -values   => \@select_supplier,
39                         -default  => $supplierid,
40                         -labels   => \%supplierlist,
41                         -size     => 1,
42                         -multiple => 0 );
43
44 my @select_branches;
45 my %select_branches;
46 push @select_branches,"";
47 $select_branches{""}="";
48 my ($count, @branches) = branches(); 
49 #branches is IndependantBranches aware
50 foreach my $branch (@branches){
51         push @select_branches, $branch->{branchcode};
52         $select_branches{$branch->{branchcode}}=$branch->{branchname};
53 }
54 my $CGIbranch=CGI::scrolling_list( -name     => 'branch',
55                                 -values   => \@select_branches,
56                                 -labels   => \%select_branches,
57                                 -size     => 1,
58                                 -multiple => 0 );
59
60 my ($count, @lateorders) = getlateorders($delay,$supplierid,$branch);
61
62 $template->param(delay=>$delay) if ($delay);
63 $template->param(
64         CGIbranch => $CGIbranch,
65         CGIsupplier => $CGIsupplier,
66         lateorders => \@lateorders
67         );
68 output_html_with_http_headers $query, $cookie, $template->output;