25 |
use CGI; |
use CGI; |
26 |
use HTML::Template; |
use HTML::Template; |
27 |
use C4::Auth; |
use C4::Auth; |
28 |
|
use C4::Koha; |
29 |
|
use C4::Acquisition; |
30 |
|
|
31 |
my $input = new CGI; |
my $input = new CGI; |
32 |
my $type=$input->param('type'); |
my $type=$input->param('type'); |
33 |
my $order=$input->param('order'); |
my $order=$input->param('order'); |
34 |
|
my $bornamefilter=$input->param('borname'); |
35 |
|
my $borcatfilter=$input->param('borcat'); |
36 |
|
my $itemtypefilter=$input->param('itemtype'); |
37 |
|
my $borflagsfilter=$input->param('borflags'); |
38 |
|
my $branchfilter=$input->param('branch'); |
39 |
|
my $showall=$input->param('showall'); |
40 |
|
warn "shoall :".$showall; |
41 |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
42 |
|
|
43 |
my ($template, $loggedinuser, $cookie) |
my ($template, $loggedinuser, $cookie) |
48 |
flagsrequired => {borrowers => 1}, |
flagsrequired => {borrowers => 1}, |
49 |
debug => 1, |
debug => 1, |
50 |
}); |
}); |
51 |
|
my $dbh = C4::Context->dbh; |
52 |
|
my $req; |
53 |
|
$req = $dbh->prepare( "select categorycode, description from categories order by description"); |
54 |
|
$req->execute; |
55 |
|
my %select_catcode; |
56 |
|
my @select_catcode; |
57 |
|
push @select_catcode,""; |
58 |
|
$select_catcode{""} = ""; |
59 |
|
while (my ($catcode, $description) =$req->fetchrow) { |
60 |
|
push @select_catcode, $catcode; |
61 |
|
$select_catcode{$catcode} = $description |
62 |
|
} |
63 |
|
my $CGIcatcode=CGI::scrolling_list( -name => 'borcat', |
64 |
|
-id => 'borcat', |
65 |
|
-values => \@select_catcode, |
66 |
|
-labels => \%select_catcode, |
67 |
|
-size => 1, |
68 |
|
-multiple => 0 ); |
69 |
|
$req = $dbh->prepare( "select itemtype, description from itemtypes order by description"); |
70 |
|
$req->execute; |
71 |
|
my %select_itemtype; |
72 |
|
my @select_itemtype; |
73 |
|
push @select_itemtype,""; |
74 |
|
$select_itemtype{""} = ""; |
75 |
|
while (my ($itemtype, $description) =$req->fetchrow) { |
76 |
|
push @select_itemtype, $itemtype; |
77 |
|
$select_itemtype{$itemtype} = $description |
78 |
|
} |
79 |
|
my $CGIitemtype=CGI::scrolling_list( -name => 'itemtype', |
80 |
|
-id => 'itemtype', |
81 |
|
-values => \@select_itemtype, |
82 |
|
-labels => \%select_itemtype, |
83 |
|
-size => 1, |
84 |
|
-multiple => 0 ); |
85 |
|
my @branches; |
86 |
|
my @select_branch; |
87 |
|
my %select_branches; |
88 |
|
my ($count2,@branches)=branches(); |
89 |
|
push @select_branch,""; |
90 |
|
$select_branches{''}=''; |
91 |
|
for (my $i=0;$i<$count2;$i++){ |
92 |
|
push @select_branch, $branches[$i]->{'branchcode'};# |
93 |
|
$select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'}; |
94 |
|
} |
95 |
|
my $CGIbranch=CGI::scrolling_list( -name => 'branch', |
96 |
|
-values => \@select_branch, |
97 |
|
-labels => \%select_branches, |
98 |
|
-size => 1, |
99 |
|
-multiple => 0 ); |
100 |
|
my @selectflags; |
101 |
|
push @selectflags, " ";# |
102 |
|
push @selectflags,"gonenoaddress";# |
103 |
|
push @selectflags,"debarred";# |
104 |
|
push @selectflags,"lost";# |
105 |
|
my $CGIflags=CGI::scrolling_list( -name => 'borflags', |
106 |
|
-id =>'borflags', |
107 |
|
-values => \@selectflags, |
108 |
|
# -labels => \%selectflags, |
109 |
|
-size => 1, |
110 |
|
-multiple => 0 ); |
111 |
|
$template->param(CGIcatcodes => $CGIcatcode, |
112 |
|
CGIitemtypes => $CGIitemtype, |
113 |
|
CGIbranches => $CGIbranch, |
114 |
|
CGIflags => $CGIflags, |
115 |
|
borname => $bornamefilter, |
116 |
|
showall => $showall); |
117 |
|
|
118 |
my $duedate; |
my $duedate; |
119 |
my $bornum; |
my $bornum; |
120 |
my $itemnum; |
my $itemnum; |
131 |
my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); |
my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); |
132 |
|
|
133 |
my $dbh = C4::Context->dbh; |
my $dbh = C4::Context->dbh; |
134 |
my $strsth="select date_due,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,itemnumber from issues, borrowers where isnull(returndate) && date_due<'".$todaysdate."' && issues.borrowernumber=borrowers.borrowernumber order by date_due,borrower "; |
my $strsth="select date_due,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,issues.itemnumber, biblio.title, biblio.author from issues, borrowers,items,biblioitems, biblio where isnull(returndate) "; |
135 |
$strsth="select date_due,concat(firstname,' ',surname) as borrower, phone, emailaddress,itemnumber from issues, borrowers where isnull(returndate) && date_due<'".$todaysdate."' && issues.borrowernumber=borrowers.borrowernumber order by borrower,date_due " if ($order eq "borrower"); |
$strsth.= " && date_due<'".$todaysdate."' " unless ($showall); |
136 |
|
$strsth.= " && issues.borrowernumber=borrowers.borrowernumber && issues.itemnumber=items.itemnumber && biblioitems.biblioitemnumber=items.itemnumber && biblio.biblionumber=items.biblionumber "; |
137 |
|
$strsth.=" && (borrowers.firstname like '".$bornamefilter."%' or borrowers.surname like '".$bornamefilter."%' or borrowers.cardnumber like '".$bornamefilter."%')" if($bornamefilter) ; |
138 |
|
$strsth.=" && borrowers.categorycode = '".$borcatfilter."' " if($borcatfilter) ; |
139 |
|
$strsth.=" && biblioitems.itemtype = '".$itemtypefilter."' " if($itemtypefilter) ; |
140 |
|
$strsth.=" && borrowers.flags = '".$borflagsfilter."' " if ($borflagsfilter ne " ") ; |
141 |
|
$strsth.=" && issues.issuingbranch = '".$branchfilter."' " if($branchfilter) ; |
142 |
|
# my $bornamefilter=$input->param('borname'); |
143 |
|
# my $borcatfilter=$input->param('borcat'); |
144 |
|
# my $itemtypefilter=$input->param('itemtype'); |
145 |
|
# my $borflagsfilter=$input->param('borflags'); |
146 |
|
# my $branchfilter=$input->param('branch'); |
147 |
|
|
148 |
|
if ($order eq "borrower"){ |
149 |
|
$strsth.=" order by borrower,date_due " ; |
150 |
|
} else { |
151 |
|
$strsth.=" order by date_due,borrower "; |
152 |
|
} |
153 |
my $sth=$dbh->prepare($strsth); |
my $sth=$dbh->prepare($strsth); |
154 |
warn "".$strsth; |
warn "".$strsth; |
155 |
$sth->execute(); |
$sth->execute(); |
163 |
$phone=$data->{'phone'}; |
$phone=$data->{'phone'}; |
164 |
$email=$data->{'emailaddress'}; |
$email=$data->{'emailaddress'}; |
165 |
|
|
166 |
my $sth2=$dbh->prepare("select biblionumber from items where itemnumber=?"); |
$title=$data->{'title'}; |
167 |
$sth2->execute($itemnum); |
$author=$data->{'author'}; |
|
$data2=$sth2->fetchrow_hashref; |
|
|
$biblionumber=$data2->{'biblionumber'}; |
|
|
$sth2->finish; |
|
|
|
|
|
my $sth3=$dbh->prepare("select title,author from biblio where biblionumber=?"); |
|
|
$sth3->execute($biblionumber); |
|
|
$data3=$sth3->fetchrow_hashref; |
|
|
$title=$data3->{'title'}; |
|
|
$author=$data3->{'author'}; |
|
|
$sth3->finish; |
|
168 |
push (@overduedata, { duedate => $duedate, |
push (@overduedata, { duedate => $duedate, |
169 |
bornum => $bornum, |
bornum => $bornum, |
170 |
itemnum => $itemnum, |
itemnum => $itemnum, |
178 |
} |
} |
179 |
|
|
180 |
$sth->finish; |
$sth->finish; |
|
|
|
181 |
$template->param( todaysdate => $todaysdate, |
$template->param( todaysdate => $todaysdate, |
182 |
overdueloop => \@overduedata ); |
overdueloop => \@overduedata ); |
183 |
|
|