1 package C4::Circulation; #assumes C4/Circulation
3 #package to deal with circulation
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
23 # FIXME - This package is never used. Is it obsolete?
28 use C4::Circulation::Issues;
29 use C4::Circulation::Returns;
30 use C4::Circulation::Renewals;
31 use C4::Circulation::Borrower;
36 use vars qw($VERSION @ISA @EXPORT);
38 # set the version for version checking
42 @EXPORT = qw(&Start_circ &scanborrower);
48 &startint($env,'Circulation');
52 while ($donext ne 'Quit') {
53 if ($donext eq "Circ") {
55 ($reason,$data) = menu($env,'console','Circulation',
56 ('Issues','Returns','Borrower Enquiries','Reserves','Log In'));
57 #debug_msg($env,"data = $data");
61 if ($data eq 'Issues') {
62 $donext=Issue($env); #C4::Circulation::Issues
63 #debug_msg("","do next $donext");
64 } elsif ($data eq 'Returns') {
65 $donext=Returns($env); #C4::Circulation::Returns
66 } elsif ($data eq 'Borrower Enquiries'){
67 $donext=Borenq($env); #C4::Circulation::Borrower
68 } elsif ($data eq 'Reserves'){
69 $donext=EnterReserves($env); #C4::Reserves
70 } elsif ($data eq 'Log In') {
72 &Login($env); #C4::Security
73 &startint($env,'Circulation');
74 } elsif ($data eq 'Quit') {
77 #debug_msg($env,"donext - $donext");
83 # FIXME - This is not the same as &C4::Circulation::Main::pastitems,
84 # though the two appear to share some code.
86 #Get list of all items borrower has currently on issue
87 my ($env,$bornum,$dbh)=@_;
88 my $sth=$dbh->prepare("Select * from issues,items,biblio
89 where borrowernumber=$bornum and issues.itemnumber=items.itemnumber
90 and items.biblionumber=biblio.biblionumber
91 and returndate is null
101 while (my $data=$sth->fetchrow_hashref) {
102 my $line = "$data->{'date_due'} $data->{'title'}";
103 # $items[$i]=fmtstr($env,$line,"L29");
104 $items[$i]=fmtstr($env,$line,"L72");
107 return(\@items,\@items2);
112 #checks whether a borrower has overdue items
113 my ($env,$bornum,$dbh)=@_;
114 my $sth=$dbh->prepare("Select * from issues,items,biblio where
115 borrowernumber=$bornum and issues.itemnumber=items.itemnumber and
116 items.biblionumber=biblio.biblionumber");
120 while (my $data=$sth->fetchrow_hashref){
121 output($row,$col,$data->{'title'});
127 # FIXME - This is quite similar to &C4::Circulation::Main::previousissue
129 my ($env,$itemnum,$dbh,$bornum)=@_;
130 my $sth=$dbh->prepare("Select firstname,surname,issues.borrowernumber,cardnumber,returndate
131 from issues,borrowers where
132 issues.itemnumber='$itemnum' and
133 issues.borrowernumber=borrowers.borrowernumber and issues.returndate is
136 my $borrower=$sth->fetchrow_hashref;
138 if ($borrower->{'borrowernumber'} ne ''){
139 if ($bornum eq $borrower->{'borrowernumber'}){
141 my ($renewstatus) = &renewstatus($env,$dbh,$bornum,$itemnum);
142 my $resp = &msg_yn("Book is issued to this borrower", "Renew?");
144 &renewbook($env,$dbh,$bornum,$itemnum);
148 my $text="Issued to $borrower->{'firstname'} $borrower->{'surname'} ($borrower->{'cardnumber'})";
149 my $resp = &msg_yn($text,"Mark as returned?");
151 &returnrecord($env,$dbh,$borrower->{'borrowernumber'},$itemnum);
158 return($borrower->{'borrowernumber'});
164 # Check for reserves for biblio
165 # does not look at constraints yet
166 my ($env,$dbh,$itemnum)=@_;
168 my $query = "select * from reserves,items
169 where (items.itemnumber = '$itemnum')
170 and (items.biblionumber = reserves.biblionumber)
171 and (reserves.found is null) order by priority";
172 my $sth = $dbh->prepare($query);
174 if (my $data=$sth->fetchrow_hashref) {
175 $resbor = $data->{'borrowernumber'};
182 # check for reserves waiting
183 my ($env,$dbh,$bornum)=@_;
185 my $query = "select * from reserves
186 where (borrowernumber = '$bornum')
187 and (reserves.found='W')";
188 my $sth = $dbh->prepare($query);
190 if (my $data=$sth->fetchrow_hashref) {
191 push @itemswaiting,$data->{'itemnumber'};
193 return (\@itemswaiting);
197 # FIXME - This is identical to &C4::Circulation/Main::scanbook
199 my ($env,$interface)=@_;
201 my ($number,$reason)=dialog("Book Barcode:");
203 return ($number,$reason);
206 # FIXME - This is very similar to &C4::Circulation::Main::scanborrower
208 my ($env,$interface)=@_;
210 my ($number,$reason,$book)=&borrower_dialog($env); #C4::Interface
213 return ($number,$reason,$book);
217 END { } # module clean-up code here (global destructor)