[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 23:42:39 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Mason James <sushi> 07/05/15 23:42:39
Modified files:
C4/Circulation : Circ2.pm
Log message:
adding updated renewbook() sub from katipo too, has holidays loan
calc-ing, and uses issuingrules syspref too
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.26&r2=1.87.2.14.2.27
Patches:
Index: Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Attic/Circ2.pm,v
retrieving revision 1.87.2.14.2.26
retrieving revision 1.87.2.14.2.27
diff -u -b -r1.87.2.14.2.26 -r1.87.2.14.2.27
--- Circ2.pm 15 May 2007 21:38:12 -0000 1.87.2.14.2.26
+++ Circ2.pm 15 May 2007 23:42:39 -0000 1.87.2.14.2.27
@@ -3,7 +3,7 @@
package C4::Circulation::Circ2;
-# $Id: Circ2.pm,v 1.87.2.14.2.26 2007/05/15 21:38:12 sushi Exp $
+# $Id: Circ2.pm,v 1.87.2.14.2.27 2007/05/15 23:42:39 sushi Exp $
#package to deal with Returns
#written 3/11/99 by address@hidden
@@ -1781,40 +1781,53 @@
=cut
sub renewbook {
- # mark book as renewed
+# mark book as renewed
my ($env,$bornum,$itemno,$datedue)address@hidden;
my $dbh = C4::Context->dbh;
- # If the due date wasn't specified, calculate it by adding the
- # book's loan length to today's date.
+# If the due date wasn't specified, calculate it by adding the
+# book's loan length to today's date.
if ($datedue eq "" ) {
- #debug_msg($env, "getting date");
my $iteminformation = getiteminformation($env, $itemno,0);
my $borrower = getpatroninformation($env,$bornum,0);
- my $loanlength =
getLoanLength($borrower->{'categorycode'},$iteminformation->{'itemtype'},$borrower->{'branchcode'});
- my ($due_year, $due_month, $due_day) =
Add_Delta_DHMS(Today_and_Now(), $loanlength,0,0,0);
- $datedue = "$due_year-$due_month-$due_day";
- #$datedue = UnixDate(DateCalc("today","$loanlength
days"),"%Y-%m-%d");
+ my $calendar_branch;
+ if ((C4::Context->preference("useHolidaysRules") eq 'CircBranch' ||
+ C4::Context->preference("useIssuingRules") eq 'CircBranch') &&
$env->{'branchcode'} ) {
+ $calendar_branch = $env->{'branchcode'};
+ }
+ else { # if no valid env{'branchcode'} is passes use borrowers
branchcode instead
+ $calendar_branch = $borrower->{'branchcode'};
}
- # Find the issues record for this book
+ my $loanlength =
getLoanLength($borrower->{'categorycode'},$iteminformation->{'itemtype'},$calendar_branch);
+ my @datearr = localtime();
+
+# calc date-due using loan-length and holidays.
+ $datedue = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
+ my $calendar = C4::Calendar->new(branchcode => $calendar_branch);
+ my ($yeardue, $monthdue, $daydue) = split /-/, $datedue;
+ ($daydue, $monthdue, $yeardue) = $calendar->addDate($daydue,
$monthdue, $yeardue, $loanlength);
+ $datedue = "$yeardue-".sprintf ("%0.2d", $monthdue)."-".
sprintf("%0.2d",$daydue);
+ }
+
+# Find the issues record for this book
my $sth=$dbh->prepare("select * from issues where borrowernumber=? and
itemnumber=? and returndate is null");
$sth->execute($bornum,$itemno);
my $issuedata=$sth->fetchrow_hashref;
$sth->finish;
- # Update the issues record to have the new due date, and a new count
- # of how many times it has been renewed.
+# Update the issues record to have the new due date, and a new count
+# of how many times it has been renewed.
my $renews = $issuedata->{'renewals'} +1;
$sth=$dbh->prepare("update issues set date_due = ?, renewals = ?
where borrowernumber=? and itemnumber=? and returndate is
null");
$sth->execute($datedue,$renews,$bornum,$itemno);
$sth->finish;
- # Log the renewal
- UpdateStats($env,$env->{'branchcode'},'renew','','',$itemno,'',$bornum);
+# Log the renewal
+ UpdateStats($env,$env->{'branchcode'},'renew','','',$itemno);
- # Charge a new rental fee, if applicable?
+# Charge a new rental fee, if applicable?
my ($charge,$type)=calc_charges($env, $itemno, $bornum);
if ($charge > 0){
my $accountno=getnextacctno($env,$bornum,$dbh);
@@ -1823,14 +1836,18 @@
values
(?,?,now(),?,?,?,?,?)");
$sth->execute($bornum,$accountno,$charge,"Renewal of Rental
Item $item->{'title'} $item->{'barcode'}",'Rent',$charge,$itemno);
$sth->finish;
- # print $account;
+# print $account;
}
- # return();
+# return();
}
+
+
+
+
=item calc_charges
($charge, $item_type) = &calc_charges($env, $itemnumber, $borrowernumber);
- [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, 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/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