[Koha-cvs] koha/C4 Reserves2.pm

Mason James szrj1m at yahoo.com
Wed Jun 7 01:49:26 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Mason James <sushi>	06/06/06 23:49:26

Modified files:
	C4             : Reserves2.pm 

Log message:
	Merging Katipo changes.
	Adding CalcHLTReserveFee(), and change to CreateReserve().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Reserves2.pm?cvsroot=koha&r1=1.43&r2=1.44

Patches:
Index: Reserves2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Reserves2.pm,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- Reserves2.pm	19 May 2006 17:01:03 -0000	1.43
+++ Reserves2.pm	6 Jun 2006 23:49:26 -0000	1.44
@@ -3,7 +3,7 @@
 
 package C4::Reserves2;
 
-# $Id: Reserves2.pm,v 1.43 2006/05/19 17:01:03 alaurin Exp $
+# $Id: Reserves2.pm,v 1.44 2006/06/06 23:49:26 sushi Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -27,8 +27,8 @@
 use DBI;
 use C4::Context;
 use C4::Biblio;
-
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+my $library_name = C4::Context->preference("LibraryName");
 
 # set the version for version checking
 $VERSION = 0.01;
@@ -73,6 +73,8 @@
     &OtherReserves
     GetFirstReserveDateFromItem
     GetNumberReservesFromBorrower
+
+    # fixpriority is used only used internally, and by reorder_reserve.pl
 );
 
 # make all your functions, whether exported or not;
@@ -694,7 +696,12 @@
 # XXX - POD
 sub CreateReserve {
   my ($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title,$checkitem,$found)= @_;
-  my $fee=CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
+  my $fee;
+  if($library_name =~ /Horowhenua/){
+      $fee = CalcHLTReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
+  } else {
+      $fee = CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
+  }
   my $dbh = C4::Context->dbh;
   my $const = lc substr($constraint,0,1);
   my @datearr = localtime(time);
@@ -824,6 +831,50 @@
   return $fee;
 }
 
+# The following are junior and young adult item types that should not incur a
+# reserve charge.
+#
+# Juniors: BJC, BJCN, BJF, BJK, BJM, BJN, BJP, BJSF, BJSN, DJ, DJP, FJ, JVID,
+#  VJ, VJP, PJ, TJ, TJP, VJ, VJP.
+#
+# Young adults: BYF, BYN, BYP, DY, DYP, PY, PYP, TY, TYP, VY, VYP.
+#
+# All other item types should incur a reserve charge.
+sub CalcHLTReserveFee {
+    my ($env,$borrnum,$biblionumber,$constraint,$bibitems) = @_;
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare("SELECT * FROM borrowers,categories
+                  WHERE (borrowernumber = ?)
+                    AND (borrowers.categorycode = categories.categorycode)");
+    $sth->execute($borrnum);
+    my $data = $sth->fetchrow_hashref;
+    $sth->finish();
+    my $fee = $data->{'reservefee'};
+
+    my $matchno;
+    my @nocharge = qw/BJC BJCN BJF BJK BJM BJN BJP BJSF BJSN DJ DJP FJ NJ CJ VJ VJP PJ TJ TJP BYF BYN BYP DY DYP PY PYP TY TYP VY VYP/;
+    my $sth = $dbh->prepare("SELECT * FROM biblio,biblioitems
+                     WHERE (biblio.biblionumber = ?)
+                       AND (biblio.biblionumber = biblioitems.biblionumber)");
+    $sth->execute($biblionumber);
+    my $data=$sth->fetchrow_hashref;
+    my $itemtype = $data->{'itemtype'};
+    for (my $i = 0; $i < @nocharge; $i++) {
+        if ($itemtype eq $nocharge[$i]) {
+            $matchno++;
+            last;
+        }
+    }
+
+    if($matchno>0){
+        $fee = 0;
+    }
+  warn "BOB DEBUG: Fee is $fee";
+  return $fee;
+}
+
+
+
 # XXX - Internal use
 sub getnextacctno {
   my ($env,$bornumber,$dbh)=@_;





More information about the Koha-cvs mailing list