perltidy before next commit.
[koha.git] / acqui / order.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to show suppliers and orders
6 #written by chris@katipo.co.nz 23/2/2000
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use strict;
27 use C4::Auth;
28 use C4::Biblio;
29 use C4::Output;
30 use CGI;
31 use C4::Interface::CGI::Output;
32 use C4::Database;
33 use HTML::Template;
34 use C4::Acquisition;
35 use C4::Date;
36
37 my $query=new CGI;
38 my ($template, $loggedinuser, $cookie)
39     = get_template_and_user({template_name => "acqui/order.tmpl",
40                              query => $query,
41                              type => "intranet",
42                              authnotrequired => 0,
43                              flagsrequired => {acquisition => 1},
44                              debug => 1,
45                              });
46
47 my $supplier=$query->param('supplier');
48 my ($count,@suppliers)=bookseller($supplier);
49
50 # check if we have to "close" a basket before building page
51 my $op = $query->param('op');
52 my $basket = $query->param('basket');
53 if ($op eq 'close') {
54         closebasket($basket);
55 }
56
57 #build result page
58 my $toggle=0;
59 my @loop_suppliers;
60 for (my $i=0; $i<$count; $i++) {
61         my ($ordcount,$orders)=getorders($suppliers[$i]->{'id'});
62         my %line;
63         if ($toggle==0){
64                 $line{even}=1;
65                 $toggle=1;
66         } else {
67                 $line{even}=0;
68                 $toggle=0;
69         }
70         $line{supplierid} =$suppliers[$i]->{'id'};
71         $line{name} = $suppliers[$i]->{'name'};
72         $line{active} = $suppliers[$i]->{'active'};
73         my @loop_basket;
74         for (my $i2=0;$i2<$ordcount;$i2++){
75                 my %inner_line;
76                 $inner_line{basketno} =$orders->[$i2]->{'basketno'};
77                 $inner_line{total} =$orders->[$i2]->{'count(*)'};
78                 $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
79                 $inner_line{surname} = $orders->[$i2]->{'firstname'};
80                 $inner_line{firstname} = $orders->[$i2]->{'surname'};
81                 $inner_line{creationdate} = format_date($orders->[$i2]->{'creationdate'});
82                 $inner_line{closedate} = format_date($orders->[$i2]->{'closedate'});
83                 push @loop_basket, \%inner_line;
84         }
85         $line{loop_basket} = \@loop_basket;
86         push @loop_suppliers, \%line;
87 }
88 $template->param(loop_suppliers => \@loop_suppliers,
89                                                 supplier => $supplier,
90                                                 count => $count);
91
92 output_html_with_http_headers $query, $cookie, $template->output;