#package to deal with Returns
#written 3/11/99 by olwen@katipo.co.nz
-# $Id$
# Copyright 2000-2002 Katipo Communications
#
$sth = $dbh->prepare($query);
$sth->execute;
my $borrower = $sth->fetchrow_hashref;
+ my $amount = checkaccount($env, $borrowernumber, $dbh);
+ $borrower->{'amountoutstanding'} = $amount;
my $flags = patronflags($env, $borrower, $dbh);
+ my $accessflagshash;
+
+ $sth=$dbh->prepare("select bit,flag from userflags");
+ $sth->execute;
+ while (my ($bit, $flag) = $sth->fetchrow) {
+ if ($borrower->{'flags'} & 2**$bit) {
+ $accessflagshash->{$flag}=1;
+ }
+ }
$sth->finish;
$borrower->{'flags'}=$flags;
- return($borrower, $flags);
+ return ($borrower, $flags, $accessflagshash);
}
=item decode
last SWITCH;
}
if ($iteminformation->{'notforloan'} == 1) {
- $rejected="Reference item: not for loan.";
+ $rejected="Item not for loan.";
last SWITCH;
}
if ($iteminformation->{'wthdrawn'} == 1) {
$rejected="Restricted item.";
last SWITCH;
}
-
- # See who, if anyone, currently has this book.
+ if ($iteminformation->{'itemtype'} eq 'REF') {
+ $rejected="Reference item: Not for loan.";
+ last SWITCH;
+ }
my ($currentborrower) = currentborrower($iteminformation->{'itemnumber'});
if ($currentborrower eq $patroninformation->{'borrowernumber'}) {
# Already issued to current borrower. Ask whether the loan should
# find reserves.....
my ($resfound, $resrec) = CheckReserves($iteminformation->{'itemnumber'});
if ($resfound) {
+ my $tobrcd = ReserveWaiting($resrec->{'itemnumber'}, $resrec->{'borrowernumber'});
$resrec->{'ResFound'} = $resfound;
$messages->{'ResFound'} = $resrec;
}
my ($borrower) = @_;
my $dbh = C4::Context->dbh;
my $borrowernumber = $borrower->{'borrowernumber'};
- my $brn =$dbh->quote($borrowernumber);
my %currentissues;
- my $select = "select issues.timestamp, issues.date_due, items.biblionumber,
- items.barcode, biblio.title, biblio.author, biblioitems.dewey,
- biblioitems.subclass
- from issues,items,biblioitems,biblio
- where issues.borrowernumber = $brn
- and issues.itemnumber = items.itemnumber
- and items.biblionumber = biblio.biblionumber
- and items.biblioitemnumber = biblioitems.biblioitemnumber
- and issues.returndate is null
- order by issues.date_due";
-# warn $select;
+ my $select = "SELECT issues.timestamp AS timestamp,
+ issues.date_due AS date_due,
+ items.biblionumber AS biblionumber,
+ items.itemnumber AS itemnumber,
+ items.barcode AS barcode,
+ biblio.title AS title,
+ biblio.author AS author,
+ biblioitems.dewey AS dewey,
+ itemtypes.description AS itemtype,
+ biblioitems.subclass AS subclass
+ FROM issues,items,biblioitems,biblio, itemtypes
+ WHERE issues.borrowernumber = ?
+ AND issues.itemnumber = items.itemnumber
+ AND items.biblionumber = biblio.biblionumber
+ AND items.biblioitemnumber = biblioitems.biblioitemnumber
+ AND itemtypes.itemtype = biblioitems.itemtype
+ AND issues.returndate IS NULL
+ ORDER BY issues.date_due";
+# print $select;
my $sth=$dbh->prepare($select);
- $sth->execute;
+ $sth->execute($borrowernumber);
my $counter = 0;
while (my $data = $sth->fetchrow_hashref) {
$data->{'dewey'} =~ s/0*$//;
#take borrower number
#check accounts and list amounts owing
my ($env,$bornumber,$dbh,$date)=@_;
- my $select="Select sum(amountoutstanding) from accountlines where
- borrowernumber=$bornumber and amountoutstanding<>0";
+ my $select="SELECT SUM(amountoutstanding) AS total
+ FROM accountlines
+ WHERE borrowernumber = $bornumber
+ AND amountoutstanding<>0";
if ($date ne ''){
- $select.=" and date < '$date'";
+ $select.=" AND date < '$date'";
}
# print $select;
my $sth=$dbh->prepare($select);
$sth->execute;
- my $total=0;
- while (my $data=$sth->fetchrow_hashref){
- $total += $data->{'sum(amountoutstanding)'};
- }
+ my $data=$sth->fetchrow_hashref;
+ my $total = $data->{'total'};
$sth->finish;
# output(1,2,"borrower owes $total");
#if ($total > 0){
}
$sth1->finish;
# close FILE;
- return ($charge);
+ return ($charge, $itemtype);
}
# FIXME - A virtually identical function appears in
use C4::Circulation::Circ2;
use C4::Output;
use C4::Reserves2;
+use C4::Auth;
###############################################
# constants
# Getting state
my $query=new CGI;
+my ($loggedinuser, $sessioncookie, $sessionID) = checkauth($query);
my $branch = $query->param("branch");
($branch) || ($branch=$query->cookie('branch')) ;
($printer) || ($printer=$query->cookie('printer')) ;
+($branches->{$branch}) || ($branch=(keys %$branches)[0]);
+($printers->{$printer}) || ($printer=(keys %$printers)[0]);
+
my $request=$query->param('request');
# set up the branchselect options....
my $tobranchoptions;
foreach my $br (keys %$branches) {
-# FIXME - Dunno what this line was supposed to do, but "CU" never
-# appears anywhere else, so this was preventing this code from
-# working, by creating an empty <select> block later on.
-# (next) unless $branches->{$br}->{'CU'};
+ (next) unless $branches->{$br}->{'CU'};
my $selected='';
($selected='selected') if ($br eq $tobranchcd);
$tobranchoptions.="<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
#######################################################################################
# Make the page .....
-print $query->header;
+print $query->header(-cookie=>$sessioncookie);
print startpage;
#print startmenu('circulation');
my @inp=startmenu('circulation');
($branch) || ($branch=$query->cookie('branch'));
($printer) || ($printer=$query->cookie('printer'));
+($branches->{$branch}) || ($branch=(keys %$branches)[0]);
+($printers->{$printer}) || ($printer=(keys %$printers)[0]);
+
+
# is you force a selection....
my $oldbranch = $branch;
my $oldprinter = $printer;
my $printeroptions;
foreach (keys %$branches) {
(next) unless ($_);
- # FIXME - What is this "IS" field? I suspect it's a leftover from
- # some previous iteration of the code, and means "this is a branch
- # that does issues". But it never gets set, so no branches ever
- # get selected, and the user can't choose a branch.
- # FIXME - Also, shouldn't librarians be able to select any branch,
- # not just ones that handle issues?
-# (next) unless ($branches->{$_}->{'IS'});
+ (next) unless ($branches->{$_}->{'IS'});
$branchcount++;
my $selected='';
($selected='selected') if ($_ eq $oldbranch);
EOF
} else {
my ($printer) = keys %$printers;
-}
+ $printerform.="Printer: ".$printers->{$printer}->{printername};
+}
if ($branchcount>1) {
$branchform=<<"EOF";
EOF
} else {
my ($branch) = keys %$branches;
-}
+ $branchform.= "Branch: ".$branches->{$branch}->{branchname};
+}