5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
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
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.
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
30 my $type=$input->param('type');
32 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
34 my ($template, $loggedinuser, $cookie)
35 = get_template_and_user({template_name => "overdue.tmpl",
39 flagsrequired => {borrowers => 1},
54 my @datearr = localtime(time());
55 my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
57 my $dbh = C4::Context->dbh;
59 my $query="select date_due,borrowernumber,itemnumber from issues where isnull(returndate) && date_due<'$todaysdate' order by date_due,borrowernumber";
60 my $sth=$dbh->prepare($query);
64 while (my $data=$sth->fetchrow_hashref) {
65 $duedate=$data->{'date_due'};
66 $bornum=$data->{'borrowernumber'};
67 $itemnum=$data->{'itemnumber'};
69 my $query="select concat(firstname,' ',surname),phone,emailaddress from borrowers where borrowernumber='$bornum'";
70 my $sth1=$dbh->prepare($query);
72 $data1=$sth1->fetchrow_hashref;
73 $name=$data1->{'concat(firstname,\' \',surname)'};
74 $phone=$data1->{'phone'};
75 $email=$data1->{'emailaddress'};
78 # FIXME - There's already a $query in this scope.
79 my $query="select biblionumber from items where itemnumber='$itemnum'";
80 my $sth2=$dbh->prepare($query);
82 $data2=$sth2->fetchrow_hashref;
83 $biblionumber=$data2->{'biblionumber'};
86 # FIXME - There's already a $query in this scope.
87 my $query="select title,author from biblio where biblionumber='$biblionumber'";
88 my $sth3=$dbh->prepare($query);
90 $data3=$sth3->fetchrow_hashref;
91 $title=$data3->{'title'};
92 $author=$data3->{'author'};
94 push (@overduedata, { duedate => $duedate,
100 biblionumber => $biblionumber,
102 author => $author });
108 $template->param( todaysdate => $todaysdate,
109 overdueloop => \@overduedata );
111 print "Content-Type: text/html\n\n", $template->output;