Fixed wrong path for tab file.
[koha.git] / overdue.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use strict;
23 use C4::Context;
24 use C4::Output;
25 use CGI;
26 use HTML::Template;
27 use C4::Auth;
28
29 my $input = new CGI;
30 my $type=$input->param('type');
31
32 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
33
34 my ($template, $loggedinuser, $cookie)
35       = get_template_and_user({template_name => "overdue.tmpl",
36                                          query => $input,
37                                          type => "intranet",
38                                          authnotrequired => 0,
39                                          flagsrequired => {borrowers => 1},
40                                          debug => 1,
41                                          });
42 my $duedate;
43 my $bornum;
44 my $itemnum;
45 my $data1;
46 my $data2;
47 my $data3;
48 my $name;
49 my $phone;
50 my $email;
51 my $biblionumber;
52 my $title;
53 my $author;
54 my @datearr = localtime(time());
55 my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
56
57 my $dbh = C4::Context->dbh;
58
59 my $sth=$dbh->prepare("select date_due,borrowernumber,itemnumber from issues where isnull(returndate) && date_due<? order by date_due,borrowernumber");
60 $sth->execute($todaysdate);
61
62 my @overduedata;
63 while (my $data=$sth->fetchrow_hashref) {
64   $duedate=$data->{'date_due'};
65   $bornum=$data->{'borrowernumber'};
66   $itemnum=$data->{'itemnumber'};
67
68   my $sth1=$dbh->prepare("select concat(firstname,' ',surname),phone,emailaddress from borrowers where borrowernumber=?");
69   $sth1->execute($bornum);
70   $data1=$sth1->fetchrow_hashref;
71   $name=$data1->{'concat(firstname,\' \',surname)'};
72   $phone=$data1->{'phone'};
73   $email=$data1->{'emailaddress'};
74   $sth1->finish;
75
76   my $sth2=$dbh->prepare("select biblionumber from items where itemnumber=?");
77   $sth2->execute($itemnum);
78   $data2=$sth2->fetchrow_hashref;
79   $biblionumber=$data2->{'biblionumber'};
80   $sth2->finish;
81
82   my $sth3=$dbh->prepare("select title,author from biblio where biblionumber=?");
83   $sth3->execute($biblionumber);
84   $data3=$sth3->fetchrow_hashref;
85   $title=$data3->{'title'};
86   $author=$data3->{'author'};
87   $sth3->finish;
88   push (@overduedata, { duedate      => $duedate,
89                         bornum       => $bornum,
90                         itemnum      => $itemnum,
91                         name         => $name,
92                         phone        => $phone,
93                         email        => $email,
94                         biblionumber => $biblionumber,
95                         title        => $title,
96                         author       => $author });
97
98 }
99
100 $sth->finish;
101
102 $template->param(               todaysdate        => $todaysdate,
103                 overdueloop       => \@overduedata );
104
105 print "Content-Type: text/html\n\n", $template->output;