[Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week]

Kyle Hall kyle.m.hall at gmail.com
Tue Aug 21 14:50:19 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Kyle Hall <kylemhall>	07/08/21 12:50:19

Modified files:
	C4/Circulation : Circ2.pm 

Log message:
	Added function getIssuingRule

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.87.2.14.2.32&r2=1.87.2.14.2.33

Patches:
Index: Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Attic/Circ2.pm,v
retrieving revision 1.87.2.14.2.32
retrieving revision 1.87.2.14.2.33
diff -u -b -r1.87.2.14.2.32 -r1.87.2.14.2.33
--- Circ2.pm	18 May 2007 14:20:21 -0000	1.87.2.14.2.32
+++ Circ2.pm	21 Aug 2007 12:50:19 -0000	1.87.2.14.2.33
@@ -3,7 +3,7 @@
 
 package C4::Circulation::Circ2;
 
-# $Id: Circ2.pm,v 1.87.2.14.2.32 2007/05/18 14:20:21 kylemhall Exp $
+# $Id: Circ2.pm,v 1.87.2.14.2.33 2007/08/21 12:50:19 kylemhall Exp $
 
 #package to deal with Returns
 #written 3/11/99 by olwen at katipo.co.nz
@@ -75,7 +75,7 @@
 @EXPORT = qw(&getpatroninformation
 	&currentissues &getissues &getiteminformation &renewstatus &renewbook
 	&canbookbeissued &issuebook &returnbook &find_reserves &transferbook &decode
-	&calc_charges &listitemsforinventory &itemseen &fixdate);
+	&calc_charges &listitemsforinventory &itemseen &fixdate, &getIssuingRule);
 
 # &getbranches &getprinters &getbranch &getprinter => moved to C4::Koha.pm
 
@@ -2021,6 +2021,72 @@
     return ($date, $invalidduedate);
 }
 
+sub getIssuingRule {
+    ## access results through $result->{'columnname'}
+    my ( $categorycode, $itemtype, $branchcode ) = @_;
+
+    my $dbh = C4::Context->dbh;
+
+    my $sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?');
+
+    ## check for perfect match
+    $sth->execute($categorycode, $itemtype, $branchcode);
+    my $result;
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for branchcode=*
+    $sth->execute($categorycode, $itemtype, "");
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for itemtype=*
+    $sth->execute($categorycode, "*", $branchcode);
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for borrower categorycode=*
+    $sth->execute("*", $itemtype, $branchcode);
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for itemtype=* AND categorycode=*
+    $sth->execute("*", "*", $branchcode);
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for categorycode=* AND branchcode=*
+    $sth->execute("*", $itemtype, "");
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for itemtype=* AND branchcode=*
+    $sth->execute($categorycode, "*", "");
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+
+    ## check for all = *
+    $sth->execute("*", "*", "");
+    $result = $sth->fetchrow_hashref;
+    if (defined($result)) {
+        return $result;
+    }
+    return;
+
 1;
 __END__
 





More information about the Koha-cvs mailing list