@@ -, +, @@ --- 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(+) --- a/C4/Circulation.pm +++ a/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 # --- a/C4/Housebound.pm +++ a/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__ --- a/installer/data/mysql/atomicupdate/housebound_tables.sql +++ a/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'); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/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 %] --