1 package C4::Circulation;
5 #package to deal with circulation
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
25 # FIXME - This package is never used. Is it obsolete?
30 use C4::Circulation::Issues;
31 use C4::Circulation::Returns;
32 use C4::Circulation::Renewals;
33 use C4::Circulation::Borrower;
38 use vars qw($VERSION @ISA @EXPORT);
40 # set the version for version checking
44 @EXPORT = qw(&Start_circ &scanborrower);
50 &startint($env,'Circulation');
54 while ($donext ne 'Quit') {
55 if ($donext eq "Circ") {
57 ($reason,$data) = menu($env,'console','Circulation',
58 ('Issues','Returns','Borrower Enquiries','Reserves','Log In'));
59 #debug_msg($env,"data = $data");
63 if ($data eq 'Issues') {
64 $donext=Issue($env); #C4::Circulation::Issues
65 #debug_msg("","do next $donext");
66 } elsif ($data eq 'Returns') {
67 $donext=Returns($env); #C4::Circulation::Returns
68 } elsif ($data eq 'Borrower Enquiries'){
69 $donext=Borenq($env); #C4::Circulation::Borrower
70 } elsif ($data eq 'Reserves'){
71 $donext=EnterReserves($env); #C4::Reserves
72 } elsif ($data eq 'Log In') {
74 &Login($env); #C4::Security
75 &startint($env,'Circulation');
76 } elsif ($data eq 'Quit') {
79 #debug_msg($env,"donext - $donext");
85 # FIXME - This is not the same as &C4::Circulation::Main::pastitems,
86 # though the two appear to share some code.
88 #Get list of all items borrower has currently on issue
89 my ($env,$bornum,$dbh)=@_;
90 my $sth=$dbh->prepare("Select * from issues,items,biblio
91 where borrowernumber=$bornum and issues.itemnumber=items.itemnumber
92 and items.biblionumber=biblio.biblionumber
93 and returndate is null
103 while (my $data=$sth->fetchrow_hashref) {
104 my $line = "$data->{'date_due'} $data->{'title'}";
105 # $items[$i]=fmtstr($env,$line,"L29");
106 $items[$i]=fmtstr($env,$line,"L72");
109 return(\@items,\@items2);
114 #checks whether a borrower has overdue items
115 my ($env,$bornum,$dbh)=@_;
116 my $sth=$dbh->prepare("Select * from issues,items,biblio where
117 borrowernumber=$bornum and issues.itemnumber=items.itemnumber and
118 items.biblionumber=biblio.biblionumber");
122 while (my $data=$sth->fetchrow_hashref){
123 output($row,$col,$data->{'title'});
129 # FIXME - This is quite similar to &C4::Circulation::Main::previousissue
130 # FIXME - Never used. Obsolete, presumably.
132 my ($env,$itemnum,$dbh,$bornum)=@_;
133 my $sth=$dbh->prepare("Select firstname,surname,issues.borrowernumber,cardnumber,returndate
134 from issues,borrowers where
135 issues.itemnumber='$itemnum' and
136 issues.borrowernumber=borrowers.borrowernumber and issues.returndate is
139 my $borrower=$sth->fetchrow_hashref;
141 if ($borrower->{'borrowernumber'} ne ''){
142 if ($bornum eq $borrower->{'borrowernumber'}){
144 my ($renewstatus) = &renewstatus($env,$dbh,$bornum,$itemnum);
145 my $resp = &msg_yn("Book is issued to this borrower", "Renew?");
147 &renewbook($env,$dbh,$bornum,$itemnum);
151 my $text="Issued to $borrower->{'firstname'} $borrower->{'surname'} ($borrower->{'cardnumber'})";
152 my $resp = &msg_yn($text,"Mark as returned?");
154 &returnrecord($env,$dbh,$borrower->{'borrowernumber'},$itemnum);
161 return($borrower->{'borrowernumber'});
167 # Check for reserves for biblio
168 # does not look at constraints yet
169 my ($env,$dbh,$itemnum)=@_;
171 my $query = "select * from reserves,items
172 where (items.itemnumber = '$itemnum')
173 and (items.biblionumber = reserves.biblionumber)
174 and (reserves.found is null) order by priority";
175 my $sth = $dbh->prepare($query);
177 if (my $data=$sth->fetchrow_hashref) {
178 $resbor = $data->{'borrowernumber'};
185 # check for reserves waiting
186 my ($env,$dbh,$bornum)=@_;
188 my $query = "select * from reserves
189 where (borrowernumber = '$bornum')
190 and (reserves.found='W')";
191 my $sth = $dbh->prepare($query);
193 if (my $data=$sth->fetchrow_hashref) {
194 push @itemswaiting,$data->{'itemnumber'};
196 return (\@itemswaiting);
200 # FIXME - This is identical to &C4::Circulation/Main::scanbook
202 my ($env,$interface)=@_;
204 my ($number,$reason)=dialog("Book Barcode:");
206 return ($number,$reason);
209 # FIXME - This is very similar to &C4::Circulation::Main::scanborrower
211 my ($env,$interface)=@_;
213 my ($number,$reason,$book)=&borrower_dialog($env); #C4::Interface
214 $number= $number; # FIXME - WTF?
216 return ($number,$reason,$book);