Browse Source

Tidy-ups on reserves

master
olwen 22 years ago
parent
commit
36b0464d49
  1. 2
      C4/Accounts.pm
  2. 2
      C4/Circulation.pm
  3. 2
      C4/Circulation/Borrower.pm
  4. 25
      C4/Circulation/Issues.pm
  5. 25
      C4/Circulation/Main.pm
  6. 2
      C4/Circulation/Renewals.pm
  7. 17
      C4/Circulation/Returns.pm
  8. 22
      C4/Print.pm
  9. 6
      C4/Reserves.pm

2
C4/Accounts.pm

@ -9,6 +9,7 @@ use DBI;
use C4::Database;
use C4::Format;
use C4::Search;
use C4::Stats;
use C4::InterfaceCDK;
use C4::Interface::AccountsCDK;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -181,6 +182,7 @@ sub recordpayment{
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
UpdateStats($env,'branch','payment',$data)
# $sth->finish;
# $query = "commit";
# $sth = $dbh->prepare;

2
C4/Circulation.pm

@ -70,7 +70,7 @@ sub Start_circ{
clearscreen();
($reason,$data) = menu($env,'console','Circulation',
('Issues','Returns','Borrower Enquiries','Reserves','Log In'));
debug_msg($env,"data = $data");
#debug_msg($env,"data = $data");
} else {
$data = $donext;
}

2
C4/Circulation/Borrower.pm

@ -105,7 +105,7 @@ sub findborrower {
my $borrowers=join(' ',($borrower->{'title'},$borrower->{'firstname'},$borrower->{'surname'}));
my $odues;
($issuesallowed,$odues,$owing) = &checktraps($env,$dbh,$bornum,$borrower);
debug_msg ($env,"owing = $owing");
#debug_msg ($env,"owing = $owing");
}
#debug_msg ($env,"2 = $env->{'IssuesAllowed'}");
return ($bornum, $issuesallowed,$borrower,$reason,$owing);

25
C4/Circulation/Issues.pm

@ -201,9 +201,24 @@ sub issueitem{
}
if ($canissue == 1) {
#check reserve
my $resbor;
$resbor = &C4::Circulation::Main::checkreserve($env,$dbh,$item->{'itemnumber'});
if ($resbor ne "") {$canissue = 0;};
my ($resbor,$resrec) =
&C4::Circulation::Main::checkreserve($env,$dbh,$item->{'itemnumber'});
if ($resbor ne "") {
my $bquery = "select * from borrowers
where borrowernumber = '$resbor'";
my $btsh = $dbh->prepare($bquery);
$btsh->execute;
my $resborrower = $btsh->fetchrow_hashref;
my $msgtxt = "Res for $resborrower->{'cardnumber'},";
$msgtxt = $msgtxt." $resborrower->{'initials'} $resborrower->{'surname'}";
my $ans = msg_yn($env,$msgtxt,"Allow issue?");
if ($ans eq "N") {
# print a docket;
printreserve($env,$resrec,$resborrower,$item);
$canissue = 0;
}
$btsh->finish();
};
}
#if charge deal with it
@ -214,7 +229,7 @@ sub issueitem{
#now mark as issued
$datedue=&updateissues($env,$item->{'itemnumber'},$item->{'biblioitemnumber'},$dbh,$bornum);
#debug_msg("","date $datedue");
&UpdateStats($env,$env->{'branchcode'},'issue');
&UpdateStats($env,$env->{'branchcode'},'issue',$charge);
if ($charge > 0) {
createcharge($env,$dbh,$item->{'itemnumber'},$bornum,$charge);
}
@ -225,7 +240,7 @@ sub issueitem{
error_msg($env,"$itemnum not found - rescan");
}
$sth->finish;
debug_msg($env,"date $datedue");
#debug_msg($env,"date $datedue");
return($item,$charge,$datedue);
}

25
C4/Circulation/Main.pm

@ -141,10 +141,31 @@ sub checkreserve{
and (reserves.found is null) order by priority";
my $sth = $dbh->prepare($query);
$sth->execute();
my $resrec;
if (my $data=$sth->fetchrow_hashref) {
$resbor = $data->{'borrowernumber'};
$resrec=$data;
my $const = $data->{'constrainttype'};
if ($const eq "a") {
$resbor = $data->{'borrowernumber'};
} else {
my $found = 0;
my $cquery = "select * from reserveconstraints
where borrowernumber='$data->{'borrowernumber'}'
and reservedate='$data->{'reservedate'}'
and biblionumber='$data->{'biblionumber'}'
and biblioitemnumber=$itemnum";
my $csth = $dbh->prepare($cquery);
$csth->execute;
if (my $cdata=$csth->fetchrow_hashref) {$found = 1;}
if ($const eq 'o') {
if ($found == 1) {$resbor = $data->{'borrowernumber'};}
} else {
if ($found == 0) {$resbor = $data->{'borrowernumber'};}
}
$csth->finish();
}
}
return ($resbor);
return ($resbor,$resrec);
}
sub checkwaiting{

2
C4/Circulation/Renewals.pm

@ -158,7 +158,7 @@ sub bulkrenew {
$x++;
}
if ($x < 1) {
C4::InterfaceCDK::debug_msg($env,"no issues");
#C4::InterfaceCDK::debug_msg($env,"no issues");
return;
}
my $renews = C4::Interface::RenewalsCDK::renew_window($env,\@items,$borrower,$amount,$odues);

17
C4/Circulation/Returns.pm

@ -14,6 +14,8 @@ use C4::Format;
use C4::Scan;
use C4::Stats;
use C4::Search;
use C4::Print;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
@ -70,6 +72,7 @@ sub Returns {
my $bornum;
my $amt_owing;
my $odues;
my $issues;
# until (($reason eq "Circ") || ($reason eq "Quit")) {
until ($reason ne "") {
($reason,$item) =
@ -80,6 +83,7 @@ sub Returns {
if ($reason eq "") {
my $resp;
($resp,$bornum,$borrower,$itemno,$itemrec,$amt_owing) = checkissue($env,$dbh,$item);
($issues,$odues,$amt_owing) = borrdata2($env,$bornum);
if ($resp ne "") {
if ($resp eq "Returned") {
my $item = itemnodata($env,$dbh,$itemno);
@ -106,7 +110,7 @@ sub checkissue {
my $itemrec;
my $amt_owing;
$item = uc $item;
my $query = "select * from items,biblio
my $query = "select * from items,biblio,biblioitems
where barcode = '$item'
and (biblio.biblionumber=items.biblionumber)";
my $sth=$dbh->prepare($query);
@ -135,10 +139,17 @@ sub checkissue {
updatelastseen($env,$dbh,$itemrec->{'itemnumber'});
$reason = "Item not issued";
}
my ($resfound,$issrec) = find_reserves($env,$dbh,$itemrec->{'itemnumber'});
my ($resfound,$resrec) = find_reserves($env,$dbh,$itemrec->{'itemnumber'});
if ($resfound eq "y") {
my $mess = "Reserved for collection at branch $issrec->{'branchcode'}";
my $bquery = "select * from borrowers
where borrowernumber = '$resrec->{'borrowernumber'}'";
my $btsh = $dbh->prepare($bquery);
$btsh->execute;
my $resborrower = $bsth->fetchrow_hashref;
printreserve($env,$resrec,$resborrower,$itemrec);
my $mess = "Reserved for collection at branch $resrec->{'branchcode'}";
error_msg($env,$mess);
$bsth->finish;
}
} else {
$sth->finish;

22
C4/Print.pm

@ -10,7 +10,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&remoteprint);
@EXPORT = qw(&remoteprint &printreserve);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -58,10 +58,30 @@ sub remoteprint {
print FILE "$items->[$i]\n";
$i++;
}
print FILE "\n\n\n\n\n\n\n\n\n\n";
close FILE;
system("lpr /tmp/$file");
}
sub printreserve {
my($env,$resrec,$rbordata,$itemdata)=@_;
my $file=time;
open (FILE,">/tmp/$file");
print FILE "Collect at $resrec->{'branchcode'}\n\n";
print FILE "$rbordata->{'surname'}; $rbordata->{'firstname'}\n";
print FILE "$rbordata->{'cardnumber'}\n";
print FILE "Phone: $rbordata->{'phone'}\n";
print FILE "$rbordata->{'streetaddress'}\n";
print FILE "$rbordata->{'suburb'}\n";
print FILE "$rbordata->{'town'}\n";
print FILE "$rbordata->{'emailaddress'}\n\n";
print FILE "$itemdata->{'barcode'}\n";
print FILE "$itemdata->{'title'}\n";
print FILE "$itemdata->{'author'}";
print FILE "\n\n\n\n\n\n\n\n\n\n";
close FILE;
system("lpr /tmp/$file");
}
END { } # module clean-up code here (global destructor)

6
C4/Reserves.pm

@ -9,6 +9,7 @@ use DBI;
use C4::Database;
use C4::Format;
use C4::Accounts;
use C4::Stats;
use C4::InterfaceCDK;
use C4::Interface::ReserveentCDK;
use C4::Circulation::Main;
@ -242,7 +243,7 @@ sub CalcReserveFee {
}
$dbh->disconnect();
return $fee;
}
} # end CalcReserveFee
sub CreateReserve {
my ($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$fee) = @_;
@ -279,6 +280,7 @@ sub CreateReserve {
$i++;
}
}
UpdateStats($env,'branch','reserve',$fee);
#$dbh->commit();
#};
#if (@_) {
@ -289,7 +291,7 @@ sub CreateReserve {
#}
$dbh->disconnect();
return();
}
} # end CreateReserve

Loading…
Cancel
Save