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 use C4::Interface::CGI::Output;
33 my $type=$input->param('type');
35 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
37 my ($template, $loggedinuser, $cookie)
38 = get_template_and_user({template_name => "reports/overdue.tmpl",
42 flagsrequired => {borrowers => 1},
59 my @datearr = localtime(time());
60 my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
61 my $dateformatted= sprintf ("%0.2d", $datearr[3]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.(1900+$datearr[5]);
62 my $dbh = C4::Context->dbh;
70 push @kohafields, "date_due","date_due";
71 push @values,$todaysdate,"0000-00-00";
72 push @relations ,"\@attr 2=1","\@attr 2=5"; ##
74 ($count,@results)=ZEBRAsearch_kohafields(\@kohafields,\@values,\@relations,$sort,\@and_or);
79 foreach my $xml(@results) {
80 my @kohafields; ## just parse the fields required
81 push @kohafields,"title","author","biblionumber","itemnumber","barcode","date_due","borrowernumber";
82 my ($biblio,@itemrecords) = XMLmarc2koha($dbh,$xml,"",@kohafields);
83 foreach my $data(@itemrecords){
84 if ($data->{'date_due'} lt $todaysdate && $data->{'date_due'} gt "0000-00-00" ){
85 $duedate=format_date($data->{'date_due'});
86 $bornum=$data->{'borrowernumber'};
87 $itemnumber=$data->{'itemnumber'};
88 $biblionumber=$data->{'biblionumber'};
89 $barcode=$data->{'barcode'};
91 my $sth1=$dbh->prepare("select concat(firstname,' ',surname),phone,emailaddress,categorycode from borrowers where borrowernumber=?");
92 $sth1->execute($bornum);
93 $data1=$sth1->fetchrow_hashref;
94 $name=$data1->{'concat(firstname,\' \',surname)'};
95 $phone=$data1->{'phone'};
96 $categorycode=$data1->{'categorycode'};
97 $email=$data1->{'emailaddress'};
104 $title=$biblio->{'title'};
105 $author=$biblio->{'author'};
106 push (@overduedata, { duedate => format_date($duedate),
108 itemnum => $itemnumber,
110 categorycode => $categorycode,
113 biblionumber => $biblionumber,
117 author => $author });
123 $template->param( dateformatted => $dateformatted, count=>$count,
124 overdueloop => \@overduedata );
126 output_html_with_http_headers $input, $cookie, $template->output;