From 9b64445a16ff0b4319e1db87b77257af47996ad2 Mon Sep 17 00:00:00 2001 From: Mark Gavillet Date: Tue, 14 Feb 2012 16:51:31 +0000 Subject: [PATCH] Added syspref for housebound previously issued items Conflicts: C4/Circulation.pm koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt http://bugs.koha-community.org/show_bug.cgi?id=5670 --- C4/Circulation.pm | 19 ++++++++++++++ C4/Housebound.pm | 26 ++++++++++++++++++++ .../data/mysql/atomicupdate/housebound_tables.sql | 4 +++ .../prog/en/modules/circ/circulation.tt | 4 +++ 4 files changed, 53 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d74b97f..de5463b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -57,6 +57,13 @@ use Date::Calc qw( Day_of_Week Add_Delta_Days ); +use POSIX qw(strftime); +use C4::Branch; # GetBranches +use C4::Log; # logaction + +use C4::Housebound; +use Data::Dumper; + use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); BEGIN { @@ -839,6 +846,18 @@ sub CanBookBeIssued { } } +# If Housebound patron and useHouseboundCheckPrev syspref is ON check for previous issue of item to patron + if ( C4::Context->preference('useHouseboundCheckPrevious') == 1 + && $borrower->{categorycode} eq 'HB' ) + { + #$template->param(testhbpref => 'switchedon'); + my $HBprevissue = + CheckPrevIssue( $borrower->{borrowernumber}, $item->{biblionumber} ); + if ( $HBprevissue == 1 ) { + $needsconfirmation{HOUSEBOUNDPREVISSUE} = 1; + } + } + # # ITEM CHECKING # diff --git a/C4/Housebound.pm b/C4/Housebound.pm index 0734b91..28906ce 100644 --- a/C4/Housebound.pm +++ b/C4/Housebound.pm @@ -35,6 +35,7 @@ our @EXPORT = qw( DeleteHouseboundInstanceDetails GetVolunteerNameAndID GetVolunteerList + CheckPrevIssue ); =head1 NAME @@ -234,6 +235,31 @@ sub DeleteHouseboundInstanceDetails { return; } +sub CheckPrevIssue { + my ($borrowernumber,$biblionumber) = @_; + my $dbh = C4::Context->dbh; + my $query; + my $item; + my $sth; + my $previssue=0; + $sth = $dbh->prepare("select itemnumber from items where biblionumber=?"); + $sth->execute($biblionumber); + while(my @row=$sth->fetchrow_array()) + { + $query = $dbh->prepare("select count(itemnumber) from old_issues where borrowernumber=? and itemnumber=?"); + $query->execute($borrowernumber,$row[0]); + while(my @matches=$query->fetchrow_array()) + { + if ($matches[0]>0) + { + $previssue=1; + } + } + } + $sth->finish; + return $previssue; +} + 1; __END__ diff --git a/installer/data/mysql/atomicupdate/housebound_tables.sql b/installer/data/mysql/atomicupdate/housebound_tables.sql index 9dfeb0a..41418b7 100644 --- a/installer/data/mysql/atomicupdate/housebound_tables.sql +++ b/installer/data/mysql/atomicupdate/housebound_tables.sql @@ -30,5 +30,9 @@ CREATE TABLE IF NOT EXISTS `housebound_instance` ( insert into systempreferences (variable,value,options,explanation,type) values ('useHouseboundModule',1,'','If ON, use the Housebound module','YesNo'); +insert into systempreferences (variable,value,options,explanation,type) values +('useHouseboundCheckPrevious',1,'','If ON, checks if Housebound patrons have previous issued items to be checked out', +'YesNo'); + insert into categories (categorycode, description, enrolmentperiod, upperagelimit, dateofbirthrequired, category_type) values ('VOL','Housebound volunteer','99','999','1','A'); \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 2a9f6b1..7c191d2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -247,6 +247,10 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% IF HIGHHOLDS %]
  • High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?
  • [% END %] + +[% IF HOUSEBOUNDPREVISSUE %] +
  • Housebound patron has previously issued this item. Check out anyway?
  • +[% END %] [% IF HIGHHOLDS %] -- 1.7.10.4