[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Circulation.pm
From: |
Bruno Toumi |
Subject: |
[Koha-cvs] koha/C4 Circulation.pm |
Date: |
Thu, 10 May 2007 15:56:53 +0000 |
CVSROOT: /cvsroot/koha
Module name: koha
Changes by: Bruno Toumi <btoumi> 07/05/10 15:56:53
Modified files:
C4 : Circulation.pm
Log message:
add control of 'return date' if it 's a special or repeatable holidays
, and return a right return date
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation.pm?cvsroot=koha&r1=1.22&r2=1.23
Patches:
Index: Circulation.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- Circulation.pm 25 Apr 2007 14:09:10 -0000 1.22
+++ Circulation.pm 10 May 2007 15:56:53 -0000 1.23
@@ -17,7 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: Circulation.pm,v 1.22 2007/04/25 14:09:10 hdl Exp $
+# $Id: Circulation.pm,v 1.23 2007/05/10 15:56:53 btoumi Exp $
use strict;
require Exporter;
@@ -43,7 +43,7 @@
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.22 $' =~ /\d+/g; shift(@v).".".join(
"_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.23 $' =~ /\d+/g; shift(@v).".".join(
"_", map { sprintf "%03d", $_ } @v ); };
=head1 NAME
@@ -990,7 +990,7 @@
if ($date) {
$dateduef = $date;
}
-
+
$dateduef=CheckValidDatedue($dateduef,$iteminformation->{'itemnumber'},$env->{'branchcode'});
# if ReturnBeforeExpiry ON the datedue can't be after borrower
expirydate
if ( C4::Context->preference('ReturnBeforeExpiry')
&& $dateduef gt $borrower->{dateexpiry} )
@@ -1922,6 +1922,85 @@
}
+=head2 CheckValidDatedue
+
+$newdatedue = CheckValidDatedue($date_due,$itemnumber,$branchcode);
+this function return a new date due after checked if it's a repeatable or
special holiday
+C<$date_due> = returndate calculate with no day check
+C<$itemnumber> = itemnumber
+C<$branchcode> = localisation of issue
+=cut
+sub CheckValidDatedue{
+my ($date_due,$itemnumber,$branchcode)address@hidden;
+my @datedue=split('-',$date_due);
+my $years=$datedue[0];
+my $month=$datedue[1];
+my $day=$datedue[2];
+my $dow;
+for (my $i=0;$i<2;$i++){
+ $dow=Day_of_Week($years,$month,$day);
+ ($dow=0) if ($dow>6);
+ my $result=CheckRepeatableHolidays($itemnumber,$dow,$branchcode);
+ my
$countspecial=CheckSpecialHolidays($years,$month,$day,$itemnumber,$branchcode);
+ if (($result ne '0') or ($countspecial ne '0') ){
+ $i=0;
+ (($years,$month,$day) = Add_Delta_Days($years,$month,$day,
1))if ($i ne '1');
+ }
+ }
+my $newdatedue=$years."-".$month."-".$day;
+return $newdatedue;
+}
+=head2 CheckRepeatableHolidays
+
+$countrepeatable = CheckRepeatableHoliday($itemnumber,$week_day,$branchcode);
+this function check if the date due is a repeatable holiday
+C<$date_due> = returndate calculate with no day check
+C<$itemnumber> = itemnumber
+C<$branchcode> = localisation of issue
+
+=cut
+
+sub CheckRepeatableHolidays{
+my($itemnumber,$week_day,$branchcode)address@hidden;
+my $dbh = C4::Context->dbh;
+my $query = qq|SELECT count(*)
+ FROM repeatable_holidays
+ WHERE branchcode=?
+ AND weekday=?|;
+my $sth = $dbh->prepare($query);
+$sth->execute($branchcode,$week_day);
+my $result=$sth->fetchrow;
+$sth->finish;
+return $result;
+}
+
+
+=head2 CheckSpecialHolidays
+
+$countspecial =
CheckSpecialHolidays($years,$month,$day,$itemnumber,$branchcode);
+this function check if the date is a special holiday
+C<$years> = the years of datedue
+C<$month> = the month of datedue
+C<$day> = the day of datedue
+C<$itemnumber> = itemnumber
+C<$branchcode> = localisation of issue
+=cut
+sub CheckSpecialHolidays{
+my ($years,$month,$day,$itemnumber,$branchcode) = @_;
+my $dbh = C4::Context->dbh;
+my $query=qq|SELECT count(*)
+ FROM `special_holidays`
+ WHERE year=?
+ AND month=?
+ AND day=?
+ AND branchcode=?
+ |;
+my $sth = $dbh->prepare($query);
+$sth->execute($years,$month,$day,$branchcode);
+my $countspecial=$sth->fetchrow ;
+$sth->finish;
+return $countspecial;
+}
1;
- [Koha-cvs] koha/C4 Circulation.pm,
Bruno Toumi <=