Bugzilla – Attachment 27606 Details for
Bug 6906
Show 'Borrower has previously issued $ITEM' alert on checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6906 - show 'Borrower has previously...
Bug-6906---show-Borrower-has-previously.patch (text/plain), 29.33 KB, created by
Alex Sassmannshausen
on 2014-04-25 10:41:19 UTC
(
hide
)
Description:
Bug 6906 - show 'Borrower has previously...
Filename:
MIME Type:
Creator:
Alex Sassmannshausen
Created:
2014-04-25 10:41:19 UTC
Size:
29.33 KB
patch
obsolete
>From 3673fc9888a4f189b4ddab5861fcfbbbca72cb80 Mon Sep 17 00:00:00 2001 >From: "A. Sassmannshausen" <alex.sassmannshausen@ptfs-europe.com> >Date: Thu, 24 Apr 2014 13:57:07 +0000 >Subject: [PATCH] Bug 6906 - show 'Borrower has previously... > >New module: provide granular means to configure warnings about items >that have been issued to a particular borrower before, according to >their loan history. > >- Global syspref ('CheckPrevIssue'), set to 'No' by default, allows >- users to enable this feature library wide. >- Per category pref allow libraries to create overrides per category, > falling back on the global setting by default. >- Per borrower pref allows switching the functionality on at the level > of borrowers. Fall-back to category settings by default. > >* Koha/Borrowers/CheckPrevIssue.pm: new module. >* C4/Circulation.pm (CanBookBeIssued): introduce CheckPrevIssue check. >* koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt: Add > 'CHECKPREVISSUE' confirmation message. >* installer/data/mysql/kohastructure.sql: modify structure of > 'categories', 'borrowers'. >* installer/data/mysql/sysprefs.sql: add 'CheckPrevIssue' (exposed in > patrons.pref). >* installer/data/mysql/updatedatabase.pl: provide upgrade path. >* admin/categorie.pl: add 'checkprevissue' to sql queries; pass it to > template. >* .../admin/categorie.tt: > .../members/memberentrygen.tt: > .../members/moremember.tt: add content. >* CheckPrevIssue.t: new file with unit tests. > >Test plan: >- Apply patch. >- Run db updates from updatedatabase.pl manually. >- Verify 'CheckPrevIssue' is visible in Patrons sysprefs and can be > switched 'on' and 'off'. > + Issue previously issued items to a borrower, checking the message > appears as expected. >- Verify 'Check previous loans' setting appears on the borrower > category pages and can be modified per borrower category. > + Issue previously issued items to a borrower, checking the message > appears as expected (This setting should override the default > setting). >- Verify 'Check previous loans' setting appears on individual borrower > pages and can be modified. > + Issue previously issued items to a borrower, checking the message > appears as expected (This setting should override the category > setting and the default setting). >--- > C4/Circulation.pm | 13 ++ > Koha/Borrower/CheckPrevIssue.pm | 126 ++++++++++++++++++++ > admin/categorie.pl | 17 +-- > installer/data/mysql/kohastructure.sql | 4 +- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 9 ++ > .../prog/en/modules/admin/categorie.tt | 31 +++++ > .../prog/en/modules/admin/preferences/patrons.pref | 6 + > .../prog/en/modules/circ/circulation.tt | 4 + > .../prog/en/modules/members/memberentrygen.tt | 19 ++- > .../prog/en/modules/members/moremember.tt | 9 ++ > t/CheckPrevIssue.t | 114 ++++++++++++++++++ > 12 files changed, 344 insertions(+), 9 deletions(-) > create mode 100644 Koha/Borrower/CheckPrevIssue.pm > create mode 100755 t/CheckPrevIssue.t > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index bd9e1cc..e7509f6 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -48,6 +48,7 @@ use Data::Dumper; > use Koha::DateUtils; > use Koha::Calendar; > use Koha::Borrower::Debarments; >+use Koha::Borrower::CheckPrevIssue qw( WantsCheckPrevIssue CheckPrevIssue ); > use Carp; > use Date::Calc qw( > Today >@@ -841,6 +842,18 @@ sub CanBookBeIssued { > } > } > >+ # If patron uses checkPrevIssue or inherits it, check for previous >+ # issue of item to patron. >+ my $checkPrevIssueOverride = WantsCheckPrevIssue( $borrower ); >+ if ( ( $checkPrevIssueOverride eq 'yes' ) >+ or ( $checkPrevIssueOverride eq 'inherit' >+ and C4::Context->preference("checkPrevIssue") ) ) >+ { >+ $needsconfirmation{PREVISSUE} = 1 >+ if CheckPrevIssue( $borrower->{borrowernumber}, >+ $item->{biblionumber} ); >+ } >+ > # > # ITEM CHECKING > # >diff --git a/Koha/Borrower/CheckPrevIssue.pm b/Koha/Borrower/CheckPrevIssue.pm >new file mode 100644 >index 0000000..40276cf >--- /dev/null >+++ b/Koha/Borrower/CheckPrevIssue.pm >@@ -0,0 +1,126 @@ >+package Koha::Borrower::CheckPrevIssue; >+ >+# This file is part of Koha. >+# >+# Copyright 2014 PTFS Europe >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use C4::Context; >+ >+use parent qw( Exporter ); >+ >+our @EXPORT = qw( >+ WantsCheckPrevIssue >+ CheckPrevIssue >+); >+ >+=head1 Koha::Borrower::CheckPrevIssue >+ >+Koha::Borrower::Debarments - Manage Previous Issue preferences & searches. >+ >+=head2 WantsCheckPrevIssue >+ >+ ($CheckPrevIssueOverride) = WantsCheckPrevIssue( $borrower ); >+ >+Returns 'yes', 'no' or 'inherit' depending on whether the patron or >+patron category should be reminded when items to be loaned have >+already been loaned to this borrower. >+ >+=cut >+ >+sub WantsCheckPrevIssue { >+ my ( $borrower ) = @_; >+ my $CheckPrevIssueByBrw = $borrower->{checkprevissue}; >+ if ( $CheckPrevIssueByBrw eq 'inherit' ) { >+ return _WantsCheckPrevIssueByCat( $borrower->{borrowernumber} ); >+ } else { >+ return $CheckPrevIssueByBrw; >+ } >+} >+ >+=head2 _WantsCheckPrevIssueByCat >+ >+ ($CheckPrevIssueByCatOverride) = _WantsCheckPrevIssueByCat( $borrowernumber ); >+ >+Returns 'yes', 'no' or 'inherit' depending on whether the patron >+in this category should be reminded when items to be loaned have already been >+loaned to this borrower. >+ >+=cut >+ >+sub _WantsCheckPrevIssueByCat { >+ my ( $borrowernumber ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $query = ' >+SELECT categories.checkprevissue >+FROM borrowers >+LEFT JOIN categories ON borrowers.categorycode = categories.categorycode >+WHERE borrowers.borrowernumber = ? >+'; >+ my $sth; >+ if ($borrowernumber) { >+ $sth = $dbh->prepare($query); >+ $sth->execute($borrowernumber); >+ } else { >+ return; >+ } >+ return ${$sth->fetchrow_arrayref()}[0]; >+} >+ >+=head2 CheckPrevIssue >+ >+ ($PrevIssue) = CheckPrevIssue( $borrowernumber, $biblionumber ); >+ >+Return 1 if $BIBLIONUMBER has previously been issued to >+$BORROWERNUMBER, 0 otherwise. >+ >+=cut >+ >+sub CheckPrevIssue { >+ my ( $borrowernumber, $biblionumber ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $previssue = 0; >+ my $query_items = 'select itemnumber from items where biblionumber=?'; >+ my $sth_items = $dbh->prepare($query_items); >+ $sth_items->execute($biblionumber); >+ >+ my $query_issues = ' >+select count(itemnumber) from old_issues >+where borrowernumber=? and itemnumber=? >+'; >+ my $sth_issues = $dbh->prepare($query_issues); >+ >+ while ( my @row = $sth_items->fetchrow_array() ) { >+ $sth_issues->execute( $borrowernumber, $row[0] ); >+ while ( my @matches = $sth_issues->fetchrow_array() ) { >+ if ( $matches[0] > 0 ) { >+ $previssue = 1; >+ last; >+ } >+ } >+ last if $previssue; >+ } >+ return $previssue; >+} >+ >+1; >+ >+=head2 AUTHOR >+ >+Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> >+ >+=cut >diff --git a/admin/categorie.pl b/admin/categorie.pl >index 6ea7b5a..187c94c 100755 >--- a/admin/categorie.pl >+++ b/admin/categorie.pl >@@ -96,7 +96,7 @@ if ($op eq 'add_form') { > my @selected_branches; > if ($categorycode) { > my $dbh = C4::Context->dbh; >- my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); >+ my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissue from categories where categorycode=?"); > $sth->execute($categorycode); > $data=$sth->fetchrow_hashref; > >@@ -139,6 +139,7 @@ if ($op eq 'add_form') { > TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), > "type_".$data->{'category_type'} => 1, > branches_loop => \@branches_loop, >+ checkprevissue => $data->{'checkprevissue'}, > ); > if (C4::Context->preference('EnhancedMessagingPreferences')) { > C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); >@@ -155,8 +156,8 @@ if ($op eq 'add_form') { > } > > if ($is_a_modif) { >- my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); >- $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); >+ my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=?,checkprevissue=? WHERE categorycode=?"); >+ $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','checkprevissue','categorycode')); > my @branches = $input->param("branches"); > if ( @branches ) { > $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?"); >@@ -175,8 +176,8 @@ if ($op eq 'add_form') { > } > $sth->finish; > } else { >- my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); >- $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type')); >+ my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissue) values (?,?,?,?,?,?,?,?,?,?,?,?)"); >+ $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','checkprevissue')); > $sth->finish; > } > if (C4::Context->preference('EnhancedMessagingPreferences')) { >@@ -198,8 +199,8 @@ if ($op eq 'add_form') { > my $total = $sth->fetchrow_hashref; > $sth->finish; > $template->param(total => $total->{'total'}); >- >- my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); >+ >+ my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissue from categories where categorycode=?"); > $sth2->execute($categorycode); > my $data=$sth2->fetchrow_hashref; > $sth2->finish; >@@ -221,6 +222,7 @@ if ($op eq 'add_form') { > reservefee => sprintf("%.2f",$data->{'reservefee'} || 0), > hidelostitems => $data->{'hidelostitems'}, > category_type => $data->{'category_type'}, >+ checkprevissue => $data->{'checkprevissue'}, > ); > # END $OP eq DELETE_CONFIRM > ################## DELETE_CONFIRMED ################################## >@@ -268,6 +270,7 @@ if ($op eq 'add_form') { > category_type => $results->[$i]{'category_type'}, > "type_".$results->[$i]{'category_type'} => 1, > branches => \@selected_branches, >+ checkprevissue => $results->[$i]{'checkprevissue'}, > ); > if (C4::Context->preference('EnhancedMessagingPreferences')) { > my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index ea4f944..342873a 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -265,6 +265,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons > `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower > `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on) > `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history >+ `checkprevissue` varchar(7) NOT NULL default 'inherit', -- produce a warning for this borrower if this item has previously been issued to this borrower if 'yes', not if 'no', defer to category setting if 'inherit'. > UNIQUE KEY `cardnumber` (`cardnumber`), > PRIMARY KEY `borrowernumber` (`borrowernumber`), > KEY `categorycode` (`categorycode`), >@@ -465,7 +466,8 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr > `issuelimit` smallint(6) default NULL, -- unused in Koha > `reservefee` decimal(28,6) default NULL, -- cost to place holds > `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no) >- `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff) >+ `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff), >+ `checkprevissue` varchar(7) NOT NULL default 'inherit', -- produce a warning for this borrower category if this item has previously been issued to this borrower if 'yes', not if 'no', defer to syspref setting if 'inherit'. > PRIMARY KEY (`categorycode`), > UNIQUE KEY `categorycode` (`categorycode`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 05a0031..41dadcf 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -79,6 +79,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'), > ('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'), > ('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'), >+('CheckPrevIssue','0','','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','YesNo'), > ('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'), > ('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'), > ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 8917081..cebec5b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8202,6 +8202,15 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.15.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('CheckPrevIssue','0','','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','YesNo')"); >+ $dbh->do("ALTER TABLE categories ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit')"); >+ $dbh->do("ALTER TABLE borrowers ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit')"); >+ print "Upgrade to $DBversion done (Bug 6906: show 'Borrower has previously issued \$ITEM' alert on checkout)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >index c32094e..31f0844 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >@@ -146,6 +146,22 @@ > <li><label for="dateofbirthrequired">Age required: </label> <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% dateofbirthrequired %]" size="3" maxlength="3" /> years</li> > <li><label for="upperagelimit">Upperage limit: </label> <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% upperagelimit %]" /> years</li> > <li><label for="enrolmentfee">Enrollment fee: </label><input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% enrolmentfee %]" /></li> >+ <li><label for="checkprevissue">Check for previous issues: </label> >+ <select name="checkprevissue" id="checkprevissue"> >+ [% IF ( checkprevissue == 'yes' ) %] >+ <option value="yes" selected="selected">Yes and override system preferences.</option> >+ <option value="no">No and override system preferences.</option> >+ <option value="inherit">Inherit from system preferences.</option> >+ [% ELSIF (checkprevissue == 'no' ) %] >+ <option value="yes">Yes and override system preferences.</option> >+ <option value="no" selected="selected">No and override system preferences.</option> >+ <option value="inherit">Inherit from system preferences.</option> >+ [% ELSE %] >+ <option value="yes">Yes and override system preferences.</option> >+ <option value="no">No and override system preferences.</option> >+ <option value="inherit" selected="selected">Inherit from system preferences.</option> >+ [% END %] >+ </select></li> > <li><label for="overduenoticerequired">Overdue notice required: </label> <select name="overduenoticerequired" id="overduenoticerequired"> > [% IF ( overduenoticerequired ) %] > <option value="0">No</option> >@@ -235,6 +251,13 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr> > <tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr> > <tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr> >+ <tr><th scope="row">Check previous loans: </th><td>[% IF ( checkprevissue == 'yes' ) %] >+ Yes >+ [% ELSIF ( checkprevissue == 'no' ) %] >+ No >+ [% ELSE %] >+ Inherit >+ [% END %]</td></tr> > <tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr> > <tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr> > <tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr> >@@ -278,6 +301,7 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <th scope="col">Age required</th> > <th scope="col">Upper age limit</th> > <th scope="col">Enrollment fee</th> >+ <th scope="col">Check previous loans</th> > <th scope="col">Overdue</th> > <th scope="col">Lost items</th> > <th scope="col">Hold fee</th> >@@ -315,6 +339,13 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <td>[% loo.dateofbirthrequired %] years</td> > <td>[% loo.upperagelimit %] years</td> > <td>[% loo.enrolmentfee %]</td> >+ <td>[% IF ( loo.checkprevissue == 'yes' ) %] >+ Yes >+ [% ELSIF ( loo.checkprevissue == 'no' ) %] >+ No >+ [% ELSE %] >+ Inherit >+ [% END %]</td> > <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td> > <td>[% loo.reservefee %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 9732d1a..de7eba2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -50,6 +50,12 @@ Patrons: > class: multi > - (separate multiple choices with |) > - >+ - pref: CheckPrevIssue >+ choices: >+ yes: "Unless overridden, do" >+ no: "Unless overridden, do not" >+ - " check borrower loan history to see if the current item has been loaned before." >+ - > - pref: checkdigit > choices: > none: "Don't" >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 afdc95d..6111720 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -272,6 +272,10 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li> > [% END %] > >+[% IF PREVISSUE %] >+ <li>This item has previously been issued to this patron. Check out anyway?</li> >+[% END %] >+ > [% IF BIBLIO_ALREADY_ISSUED %] > <li> > Patron has already checked out another item from this record. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 694432e..5b768f6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -982,7 +982,24 @@ > [% END %] > </li> > [% END %] >- </ol> >+ <li><label for="checkprevissue">Check for previous issues: </label> >+ <select name="checkprevissue" id="checkprevissue"> >+ [% IF ( checkprevissue == 'yes' ) %] >+ <option value="yes" selected="selected">Yes and override patron category default.</option> >+ <option value="no">No and override patron category default.</option> >+ <option value="inherit">Inherit from patron category default.</option> >+ [% ELSIF (checkprevissue == 'no' ) %] >+ <option value="yes">Yes and override patron category default.</option> >+ <option value="no" selected="selected">No and override patron category default.</option> >+ <option value="inherit">Inherit from patron category default.</option> >+ [% ELSE %] >+ <option value="yes">Yes and override patron category default.</option> >+ <option value="no">No and override patron category default.</option> >+ <option value="inherit" selected="selected">Inherit from patron category default.</option> >+ [% END %] >+ </select> >+ </li> >+ </ol> > </fieldset> > [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] > <fieldset class="rows" id="memberentry_subscription"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 9cd6a90..07c5a41 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -384,6 +384,15 @@ function validate1(date) { > </li> > [% IF ( borrowernotes ) %]<li><span class="label">Circulation note: </span>[% borrowernotes %]</li>[% END %] > [% IF ( opacnote ) %]<li><span class="label">OPAC note:</span>[% opacnote %]</li>[% END %] >+ <li><span class="label">Check previous loans: </span> >+ [% IF ( checkprevissue == 'yes' ) %] >+ Yes >+ [% ELSIF ( checkprevissue == 'no' ) %] >+ No >+ [% ELSE %] >+ Inherited >+ [% END %] >+ </li> > </ol> > </div> > </div> >diff --git a/t/CheckPrevIssue.t b/t/CheckPrevIssue.t >new file mode 100755 >index 0000000..1cc67c6 >--- /dev/null >+++ b/t/CheckPrevIssue.t >@@ -0,0 +1,114 @@ >+#!/usr/bin/perl >+use strict; >+use warnings; >+ >+use C4::Context; >+use Test::More tests => 5; >+use Test::MockModule; >+use DBD::Mock; >+ >+use_ok('Koha::Borrower::CheckPrevIssue'); >+ >+use Koha::Borrower::CheckPrevIssue qw( WantsCheckPrevIssue CheckPrevIssue ); >+ >+# Setup mock db >+my $module_context = new Test::MockModule('C4::Context'); >+$module_context->mock( >+ '_new_dbh', >+ sub { >+ my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >+ || die "Cannot create handle: $DBI::errstr\n"; >+ return $dbh; >+ } >+); >+ >+my $dbh = C4::Context->dbh(); >+ >+# convenience variables >+my $name; >+# mock_add_resultset vars >+my ( $sql, $sql2, @bound_params, @keys, @values, %result ) = ( ); >+# mock_history_verification vars >+my ( $history, $params, $query ) = ( ); >+ >+sub clean_vars { >+ ( $name, $sql, $sql2, @bound_params, @keys, @values, %result, >+ $history, $params, $query ) = ( ); >+ $dbh->{mock_clear_history} = 1; >+} >+ >+# Tests >+## WantsCheckPrevIssue >+$name = 'WantsCheckPrevIssue'; >+$sql = ' >+SELECT categories.checkprevissue >+FROM borrowers >+LEFT JOIN categories ON borrowers.categorycode = categories.categorycode >+WHERE borrowers.borrowernumber = ? >+'; >+ >+# Test if, as brw inherits, result is simply passed from >+# _WantsCheckPrevIssueByCat back through WantsCheckPrevIssue. >+my %brw = ( >+ checkprevissue => 'inherit', >+ borrowernumber => '101', >+); >+ >+$dbh->{mock_add_resultset} = >+ { >+ sql => $sql, >+ bound_params => [ '101' ], >+ results => [ [ 'categories.checkprevissue' ], [ 'pass_thru' ] ], >+ }; >+ >+is( WantsCheckPrevIssue(\%brw), 'pass_thru', >+ $name . ": Return value \"pass_thru\"." ); >+ >+# Test if, if brw does not inherit, WantsCheckPrevIssue simply returns >+# its contents. >+%brw = ( >+ checkprevissue => 'brw_pass_thru', >+ borrowernumber => '101', >+); >+ >+is( WantsCheckPrevIssue(\%brw), 'brw_pass_thru', >+ $name . ": Return value \"$brw{checkprevissue}\"." ); >+ >+clean_vars(); >+ >+## CheckPrevIssue >+$name = 'CheckPrevIssue'; >+$sql = 'select itemnumber from items where biblionumber=?'; >+$sql2 = ' >+select count(itemnumber) from old_issues >+where borrowernumber=? and itemnumber=? >+'; >+@keys = qw< borrowernumber biblionumber itemnumber >; >+@values = qw< 101 3576 5043 >; >+ >+# 1) Prepop items with itemnumber for result >+$dbh->{mock_add_resultset} = { >+ sql => $sql, >+ bound_params => $keys[1], >+ results => [ [ ( $keys[2] ) ], [ ( $values[2] ) ] ], >+ }; >+# 2) Test if never issued before (expect 0) >+is( CheckPrevIssue( $keys[0], $keys[1] ), 0, >+ $name . ': Return value "no matches".' ); >+# 3) Prepop old_issues with itemnumber and borrowernumber >+$dbh->{mock_add_resultset} = { >+ sql => $sql2, >+ bound_params => [ $keys[0], $keys[2] ], >+ results => [ >+ [ ( $keys[0], $keys[2] ) ], >+ [ ( $values[0], $values[2] ) ], >+ [ ( $values[0], $values[2] ) ], >+ [ ( $values[0], $values[2] ) ], >+ [ ( $values[0], $values[2] ) ], >+ ], >+ }; >+# 4) Test if issued before (e.g. 7 times รข expect 1) >+is( CheckPrevIssue( $keys[0], $keys[1] ), 1, >+ $name . ': Return value "> 0 matches".' ); >+ >+clean_vars(); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6906
:
5531
|
5532
|
5533
|
27558
|
27606
|
30680
|
30681
|
50071
|
50127
|
50128
|
50243
|
50286
|
50323
|
51378
|
51393
|
52278
|
52279
|
52280
|
53104
|
53105
|
53136
|
53144
|
53145
|
53146
|
53147
|
53148