[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week]
From: |
Mason James |
Subject: |
[Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week] |
Date: |
Tue, 15 May 2007 20:55:24 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Mason James <sushi> 07/05/15 20:55:24
Modified files:
C4/Circulation : Circ2.pm
Log message:
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.23&r2=1.87.2.14.2.24
Patches:
Index: Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Attic/Circ2.pm,v
retrieving revision 1.87.2.14.2.23
retrieving revision 1.87.2.14.2.24
diff -u -b -r1.87.2.14.2.23 -r1.87.2.14.2.24
--- Circ2.pm 15 May 2007 20:49:32 -0000 1.87.2.14.2.23
+++ Circ2.pm 15 May 2007 20:55:23 -0000 1.87.2.14.2.24
@@ -3,7 +3,7 @@
package C4::Circulation::Circ2;
-# $Id: Circ2.pm,v 1.87.2.14.2.23 2007/05/15 20:49:32 sushi Exp $
+# $Id: Circ2.pm,v 1.87.2.14.2.24 2007/05/15 20:55:23 sushi Exp $
#package to deal with Returns
#written 3/11/99 by address@hidden
@@ -869,11 +869,27 @@
#
# issuing book. We already have checked it can be issued, so, just issue it !
#
+
sub issuebook {
my ($env,$borrower,$barcode,$date,$cancelreserve) = @_;
-warn "MASON, issuebook(), startdate = $date\n";
-
my $dbh = C4::Context->dbh;
+### here too
+
+warn Dumper $env;
+
+
+# new code for holidays, if sys_pref 'useCalendarBranch' = issuing,
+# use issuing branchs' holidays rules, else is patron's branch (was default)
+ my $calendar_branch;
+ if (C4::Context->preference("useHolidayRules") eq 'CircBranch' ||
+ C4::Context->preference("useIssuingRules") eq 'CircBranch') {
+ $calendar_branch = $env->{'branchcode'};
+### in here
+ }
+ else {
+ $calendar_branch = $borrower->{'branchcode'};
+ }
+
# my ($borrower, $flags) = &getpatroninformation($env, $borrowernumber,
0);
my $iteminformation = getiteminformation($env, 0, $barcode);
# warn "B : ".$borrower->{borrowernumber}." / I :
".$iteminformation->{'itemnumber'};
@@ -882,12 +898,6 @@
#
my ($currentborrower) =
currentborrower($iteminformation->{'itemnumber'});
if ($currentborrower eq $borrower->{'borrowernumber'}) {
- my ($charge,$itemtype) = calc_charges($env,
$iteminformation->{'itemnumber'}, $borrower->{'borrowernumber'});
- if ($charge > 0) {
- createcharge($env, $dbh,
$iteminformation->{'itemnumber'}, $borrower->{'borrowernumber'}, $charge);
- $iteminformation->{'charge'} = $charge;
- }
-
#&UpdateStats($env,$env->{'branchcode'},'renew',$charge,'',$iteminformation->{'itemnumber'},$iteminformation->{'itemtype'},$borrower->{'borrowernumber'});
renewbook($env, $borrower->{'borrowernumber'},
$iteminformation->{'itemnumber'});
} else {
#
@@ -913,8 +923,12 @@
my ($resborrower,
$flags)=getpatroninformation($env, $resbor,0);
my $branches = getbranches();
my $branchname =
$branches->{$res->{'branchcode'}}->{'branchname'};
- if ($cancelreserve){
+ if ($cancelreserve) {
+ # cancel waiting reserve
CancelReserve(0, $res->{'itemnumber'},
$res->{'borrowernumber'});
+ } else {
+ # set waiting reserve to first in reserve queue as
book isn't waiting now
+ UpdateReserve(1, $res->{'biblionumber'},
$res->{'borrowernumber'}, $res->{'branchcode'});
}
} elsif ($restype eq "Reserved") {
warn "Reserved";
@@ -926,11 +940,13 @@
# cancel reserves on this item
CancelReserve(0, $res->{'itemnumber'},
$res->{'borrowernumber'});
# also cancel reserve on biblio related
to this item
- #my $st_Fbiblio = $dbh->prepare("select
biblionumber from items where itemnumber=?");
-
#$st_Fbiblio->execute($res->{'itemnumber'});
- #my $biblionumber =
$st_Fbiblio->fetchrow;
-
#CancelReserve($biblionumber,0,$res->{'borrowernumber'});
- #warn "CancelReserve
$res->{'itemnumber'}, $res->{'borrowernumber'}";
+ my $st_Fbiblio = $dbh->prepare("select biblionumber from
items where itemnumber=?");
+ $st_Fbiblio->execute($res->{'itemnumber'});
+ my $biblionumber = $st_Fbiblio->fetchrow;
+ # the following line shouldn't cancel the reserve it should
update it
+ # from rank 'waiting' to rank '1'
+ # CancelReserve($biblionumber,0,$res->{'borrowernumber'});
+ warn "CancelReserve $res->{'itemnumber'},
$res->{'borrowernumber'}";
} else {
# my $tobrcd =
ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'});
# transferbook($tobrcd,$barcode, 1);
@@ -940,36 +956,29 @@
}
# Record in the database the fact that the book was issued.
my $sth=$dbh->prepare("insert into issues (borrowernumber,
itemnumber, date_due, branchcode) values (?,?,?,?)");
- my $loanlength =
getLoanLength($borrower->{'categorycode'},$iteminformation->{'itemtype'},$borrower->{'branchcode'});
- warn "LOANLENGTH:".$loanlength;
- #my $datedue=time+($loanlength)*86400;
+ my $loanlength =
getLoanLength($borrower->{'categorycode'},$iteminformation->{'itemtype'},$calendar_branch);
my @datearr = localtime();
- my $dateduef =
(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
-
- # now calling addDate() from Calendar.pm
-
-warn "MASON, issuebook(), pre-holidays duedate = $dateduef\n";
- my $calendar = C4::Calendar->new(branchcode =>
$borrower->{'branchcode'});
- my ($yeardue, $monthdue, $daydue) = split /-/, $dateduef;
-
-
-warn "daydue, monthdue, yeardue, loanlenght = $daydue, $monthdue, $yeardue,
$loanlength\n";
- ($daydue, $monthdue, $yeardue) = $calendar->addDate($daydue,
$monthdue, $yeardue, $loanlength);
-warn "daydue, monthdue, yeardue, loanlenght = $daydue, $monthdue, $yeardue,
$loanlength\n";
-
-
-
- $dateduef = "$yeardue-". sprintf("%0.2d", $monthdue)."-".
sprintf("%0.2d",$daydue);
-warn "MASON, issuebook(), pre-holidays duedate = $dateduef\n";
-
+ my $dateduef;
+ # if a hard set date-due is pasted, then use it!
if ($date) {
+ warn "--- hard-set due-date = $date";
$dateduef=$date;
}
- # if ReturnBeforeExpiry ON the datedue can't be after borrower
expirydate
- if (C4::Context->preference('ReturnBeforeExpiry') && $dateduef
gt $borrower->{expiry}) {
- $dateduef=$borrower->{expiry};
+ # else, calc date-due using loan-length and holidays.
+ else {
+ $dateduef = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
+ my $calendar = C4::Calendar->new(branchcode => $calendar_branch);
+ my ($yeardue, $monthdue, $daydue) = split /-/, $dateduef;
+ ($daydue, $monthdue, $yeardue) = $calendar->addDate($daydue,
$monthdue, $yeardue, $loanlength);
+ $dateduef = "$yeardue-".sprintf ("%0.2d", $monthdue)."-".
sprintf("%0.2d",$daydue);
}
+
+# if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate
+# if (C4::Context->preference('ReturnBeforeExpiry') && $dateduef gt
$borrower->{expiry}) {
+# $dateduef=$borrower->{expiry};
+# }
+
$sth->execute($borrower->{'borrowernumber'},
$iteminformation->{'itemnumber'}, $dateduef, $env->{'branchcode'});
$sth->finish;
$iteminformation->{'issues'}++;
@@ -977,6 +986,7 @@
$sth->execute($iteminformation->{'issues'},$iteminformation->{'itemnumber'});
$sth->finish;
&itemseen($iteminformation->{'itemnumber'});
+ itemborrowed($iteminformation->{'itemnumber'});
# If it costs to borrow this book, charge it to the patron's
account.
my ($charge,$itemtype)=calc_charges($env,
$iteminformation->{'itemnumber'}, $borrower->{'borrowernumber'});
if ($charge > 0) {
@@ -988,6 +998,7 @@
}
}
+
=head2 getLoanLength
Get loan length for an itemtype, a borrower type and a branch
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/11
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week],
Mason James <=
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/15
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/16
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Mason James, 2007/05/16
- [Koha-cvs] koha/C4/Circulation Circ2.pm [dev_week], Kyle Hall, 2007/05/18