Code cleaning : POD added & some functions has been changed.
[koha.git] / acqui / select-late.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::Catalogue;
28 use C4::Auth;
29 use C4::Biblio;
30 use C4::Output;
31 use CGI;
32 use C4::Interface::CGI::Output;
33 use C4::Database;
34 use HTML::Template;
35 use C4::Catalogue;
36 use C4::Context;
37 use C4::Date;
38
39 my $query=new CGI;
40 my $dbh = C4::Context->dbh;
41 my ($template, $loggedinuser, $cookie)
42     = get_template_and_user({template_name => "acqui/select-late.tmpl",
43                              query => $query,
44                              type => "intranet",
45                              authnotrequired => 0,
46                              flagsrequired => {acquisition => 1},
47                              debug => 1,
48                              });
49
50 my $supplier=$query->param('id');
51 my ($count,@suppliers)=bookseller($supplier);
52
53
54
55 my $sth = $dbh->prepare("select s.serialseq from serial s, subscription u where s.subscriptionid = u.subscriptionid and u.aqbooksellerid = ? and s.status = 2");
56
57
58  $sth->execute($supplier);
59 my  @final;
60 while (my $sol = $sth->fetchrow_hashref)
61 {
62     push @final, $sol;
63 }
64
65 $template->param(@loop_sol => \@final);
66
67 my $colour='#EEEEEE';
68 my $toggle=0;
69 my @loop_suppliers;
70 for (my $i=0; $i<$count; $i++) {
71         my ($ordcount,$orders)=getorders($suppliers[$i]->{'id'});
72         my %line;
73         if ($toggle==0){
74                 $line{color}='#EEEEEE';
75                 $toggle=1;
76         } else {
77                 $line{color}='white';
78                 $toggle=0;
79         }
80         $line{id} =$suppliers[$i]->{'id'};
81         $line{name} = $suppliers[$i]->{'name'};
82         $line{active} = $suppliers[$i]->{'active'};
83         $line{total} = $orders->[0]->{'count(*)'};
84         $line{authorisedby} = $orders->[0]->{'authorisedby'};
85         $line{entrydate} = $orders->[0]->{'entrydate'};
86         my @loop_basket;
87         for (my $i2=0;$i2<$ordcount;$i2++){
88                 my %inner_line;
89                 $inner_line{basketno} =$orders->[$i2]->{'basketno'};
90                 $inner_line{total} =$orders->[$i2]->{'count(*)'};
91                 $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
92                 $inner_line{entrydate} = format_date($orders->[$i2]->{'entrydate'});
93                 push @loop_basket, \%inner_line;
94         }
95         $line{loop_basket} = \@loop_basket;
96         push @loop_suppliers, \%line;
97 }
98 $template->param(loop_suppliers => \@loop_suppliers,
99                                                 supplier => $supplier,
100                                                 count => $count,
101                                                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
102                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
103                 IntranetNav => C4::Context->preference("IntranetNav"),
104                                                 );
105
106 output_html_with_http_headers $query, $cookie, $template->output;