Sub renamed & GPL Licence added.
[koha.git] / acqui / lateorders.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
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.
9 #
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.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 # $Id$
19
20 use strict;
21 use CGI;
22 use C4::Acquisition;
23 use C4::Auth;
24 use C4::Koha;
25 use C4::Output;
26 use C4::Interface::CGI::Output;
27 use C4::Context;
28 use HTML::Template;
29
30 my $query = new CGI;
31 my ($template, $loggedinuser, $cookie)
32 = get_template_and_user({template_name => "acqui/lateorders.tmpl",
33                                 query => $query,
34                                 type => "intranet",
35                                 authnotrequired => 0,
36                                 flagsrequired => {acquisition => 1},
37                                 debug => 1,
38                                 });
39 # my $title = $query->param('title');
40 # my $ISSN = $query->param('ISSN');
41 # my @subscriptions = GetSubscriptions($title,$ISSN);
42
43 my $supplierid = $query->param('supplierid');
44 my $delay = $query->param('delay');
45 my $branch = $query->param('branch');
46
47 $delay =($delay?$delay:30);
48
49 my %supplierlist = getsupplierlistwithlateorders($delay,$branch);
50 my @select_supplier;
51 push @select_supplier,"";
52 foreach my $supplierid (keys %supplierlist){
53         push @select_supplier, $supplierid;
54 }
55 my $CGIsupplier=CGI::scrolling_list( -name     => 'supplierid',
56                         -values   => \@select_supplier,
57                         -default  => $supplierid,
58                         -labels   => \%supplierlist,
59                         -size     => 1,
60                         -tabindex=>'',
61                         -multiple => 0 );
62
63 $template->param(Supplier=>$supplierlist{$supplierid}) if ($supplierid);
64
65 my $branches = getbranches;
66 my @branchloop;
67 foreach my $thisbranch (sort keys %$branches) {
68         my %row =(value => $thisbranch,
69                                 branchname => $branches->{$thisbranch}->{'branchname'},
70                         );
71         push @branchloop, \%row;
72 }
73 my $CGIbranch=CGI::scrolling_list( -name     => 'branch',
74                                 -values   => \@select_branches,
75                                 -labels   => \%select_branches,
76                                 -size     => 1,
77                                 -tabindex=>'',
78                                 -multiple => 0 );
79
80 my ($count, @lateorders) = getlateorders($delay,$supplierid,$branch);
81 my $total;
82 foreach my $lateorder (@lateorders){
83         $total+=$lateorder->{subtotal};
84 }
85 $template->param(delay=>$delay) if ($delay);
86 $template->param(
87         branchloop => \@branchloop,
88         CGIsupplier => $CGIsupplier,
89         lateorders => \@lateorders,
90         total=>$total,
91         intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
92         );
93 output_html_with_http_headers $query, $cookie, $template->output;