[Koha-cvs] koha/C4/Circulation Circ2.pm
Robert Lyon
bob at katipo.co.nz
Wed Jun 7 03:38:15 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Changes by: Robert Lyon <bob_lyon> 06/06/07 01:38:15
Modified files:
C4/Circulation : Circ2.pm
Log message:
Merging Katipo changes...
Fixing bug with defined() - when used on array or hash will check if memory
is allocated rather than if is empty/not empty
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&r1=1.105&r2=1.106
Patches:
Index: Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- Circ2.pm 6 Jun 2006 12:26:57 -0000 1.105
+++ Circ2.pm 7 Jun 2006 01:38:14 -0000 1.106
@@ -3,7 +3,7 @@
package C4::Circulation::Circ2;
-# $Id: Circ2.pm,v 1.105 2006/06/06 12:26:57 alaurin Exp $
+# $Id: Circ2.pm,v 1.106 2006/06/07 01:38:14 bob_lyon Exp $
#package to deal with Returns
#written 3/11/99 by olwen at katipo.co.nz
@@ -662,67 +662,103 @@
$sth->execute($cat_borrower, $type, $branch_borrower);
my $result = $sth->fetchrow_hashref;
# warn "==>".$result->{maxissueqty};
- if (defined($result)) {
+
+ # Currently, using defined($result) ie on an entire hash reports whether memory
+ # for that aggregate has ever been allocated. As $result is used all over the place
+ # it would rarely return as undefined.
+ if (defined($result->{maxissueqty})) {
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
my $alreadyissued = $sth2->fetchrow;
- return ("a $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("a $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
# check for branch=*
$sth->execute($cat_borrower, $type, "");
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
my $alreadyissued = $sth2->fetchrow;
- return ("b $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("b $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
# check for itemtype=*
$sth->execute($cat_borrower, "*", $branch_borrower);
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth3->execute($borrower->{'borrowernumber'});
my ($alreadyissued) = $sth3->fetchrow;
- warn "HERE : $alreadyissued / ($result->{maxissueqty} for $borrower->{'borrowernumber'}";
- return ("c $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+# warn "HERE : $alreadyissued / ($result->{maxissueqty} for $borrower->{'borrowernumber'}";
+ return ("c $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
- #check for borrowertype=*
+ # check for borrowertype=*
$sth->execute("*", $type, $branch_borrower);
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
my $alreadyissued = $sth2->fetchrow;
- return ("d $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("d $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
$sth->execute("*", "*", $branch_borrower);
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth3->execute($borrower->{'borrowernumber'});
my $alreadyissued = $sth3->fetchrow;
- return ("e $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("e $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
$sth->execute("*", $type, "");
$result = $sth->fetchrow_hashref;
- if (defined($result) && $result->{maxissueqty}>=0) {
+ if (defined($result->{maxissueqty}) && $result->{maxissueqty}>=0) {
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
my $alreadyissued = $sth2->fetchrow;
- return ("f $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("f $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
$sth->execute($cat_borrower, "*", "");
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
my $alreadyissued = $sth2->fetchrow;
- return ("g $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("g $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
$sth->execute("*", "*", "");
$result = $sth->fetchrow_hashref;
- if (defined($result)) {
+ if (defined($result->{maxissueqty})) {
$sth3->execute($borrower->{'borrowernumber'});
my $alreadyissued = $sth3->fetchrow;
- return ("h $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
+ if ($result->{'maxissueqty'} <= $alreadyissued){
+ return ("h $alreadyissued / ".($result->{maxissueqty}+0));
+ } else {
+ return;
+ }
}
return;
}
More information about the Koha-cvs
mailing list