View | Details | Raw Unified | Return to bug 6906
Collapse All | Expand All

(-)a/C4/Circulation.pm (+13 lines)
Lines 48-53 use Data::Dumper; Link Here
48
use Koha::DateUtils;
48
use Koha::DateUtils;
49
use Koha::Calendar;
49
use Koha::Calendar;
50
use Koha::Borrower::Debarments;
50
use Koha::Borrower::Debarments;
51
use Koha::Borrower::CheckPrevIssue qw( WantsCheckPrevIssue CheckPrevIssue );
51
use Carp;
52
use Carp;
52
use Date::Calc qw(
53
use Date::Calc qw(
53
  Today
54
  Today
Lines 841-846 sub CanBookBeIssued { Link Here
841
        }
842
        }
842
    }
843
    }
843
844
845
    # If patron uses checkPrevIssue or inherits it, check for previous
846
    # issue of item to patron.
847
    my $checkPrevIssueOverride = WantsCheckPrevIssue( $borrower );
848
    if ( ( $checkPrevIssueOverride eq 'yes' )
849
         or ( $checkPrevIssueOverride eq 'inherit'
850
              and C4::Context->preference("checkPrevIssueByDefault") ) )
851
    {
852
        $needsconfirmation{PREVISSUE} = 1
853
          if CheckPrevIssue( $borrower->{borrowernumber},
854
                             $item->{biblionumber} );
855
    }
856
844
    #
857
    #
845
    # ITEM CHECKING
858
    # ITEM CHECKING
846
    #
859
    #
(-)a/Koha/Borrower/CheckPrevIssue.pm (+116 lines)
Line 0 Link Here
1
package Koha::Borrower::CheckPrevIssue;
2
3
# This file is part of Koha.
4
#
5
# Copyright 2014 PTFS Europe
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use C4::Context;
23
24
use parent qw( Exporter );
25
26
our @EXPORT = qw(
27
        WantsCheckPrevIssue
28
        CheckPrevIssue
29
);
30
31
=head1 Koha::Borrower::CheckPrevIssue
32
33
Koha::Borrower::Debarments - Manage Previous Issue preferences & searches.
34
35
=head2 WantsCheckPrevIssue
36
37
    ($CheckPrevIssueOverride) = WantsCheckPrevIssue( $borrower );
38
39
Returns 'yes', 'no' or 'inherit' depending on whether the patron or
40
patron category should be reminded when items to be loaned have
41
already been loaned to this borrower.
42
43
=cut
44
45
sub WantsCheckPrevIssue {
46
    my ( $borrower ) = @_;
47
    my $CheckPrevIssueByBorrower = $borrower->{checkprevissuebyborrower};
48
    if ( $CheckPrevIssueByBorrower eq 'inherit' ) {
49
        return _WantsCheckPrevIssueByCategory( $borrower->{borrowernumber} );
50
    } else {
51
        return $CheckPrevIssueByBorrower;
52
    }
53
}
54
55
=head2 _WantsCheckPrevIssueByCategory
56
57
    ($CheckPrevIssueByCatOverride) = _WantsCheckPrevIssueByCategory( $borrowernumber );
58
59
Returns 'yes', 'no' or 'inherit' depending on whether the patron
60
category should be reminded when items to be loaned have already been
61
loaned to this borrower.
62
63
=cut
64
65
sub _WantsCheckPrevIssueByCategory {
66
    my ( $borrowernumber ) = @_;
67
    my $dbh = C4::Context->dbh;
68
    my $query;
69
    my $sth;
70
    if ($borrowernumber) {
71
        $sth = $dbh->prepare("SELECT categories.checkprevissuebycategory FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowers.borrowernumber=?");
72
        $sth->execute($borrowernumber);
73
    } else {
74
        return;
75
    }
76
    return ${$sth->fetchrow_arrayref()}[0];
77
}
78
79
=head2 CheckPrevIssue
80
81
    ($PrevIssue) = CheckPrevIssue( $borrowernumber, $biblionumber );
82
83
Return 1 if $BIBLIONUMBER has previously been issued to
84
$BORROWERNUMBER, 0 otherwise.
85
86
=cut
87
88
sub CheckPrevIssue {
89
    my ( $borrowernumber, $biblionumber ) = @_;
90
    my $dbh       = C4::Context->dbh;
91
    my $previssue = 0;
92
    my $sth =
93
      $dbh->prepare('select itemnumber from items where biblionumber=?');
94
    $sth->execute($biblionumber);
95
96
    my $query = $dbh->prepare(
97
'select count(itemnumber) from old_issues where borrowernumber=? and itemnumber=?'
98
    );
99
    while ( my @row = $sth->fetchrow_array() ) {
100
        $query->execute( $borrowernumber, $row[0] );
101
        while ( my @matches = $query->fetchrow_array() ) {
102
            if ( $matches[0] > 0 ) {
103
                $previssue = 1;
104
            }
105
        }
106
    }
107
    return $previssue;
108
}
109
110
1;
111
112
=head2 AUTHOR
113
114
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
115
116
=cut
(-)a/admin/categorie.pl (-6 / +9 lines)
Lines 96-102 if ($op eq 'add_form') { Link Here
96
    my @selected_branches;
96
    my @selected_branches;
97
	if ($categorycode) {
97
	if ($categorycode) {
98
		my $dbh = C4::Context->dbh;
98
		my $dbh = C4::Context->dbh;
99
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
99
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissuebycategory from categories where categorycode=?");
100
		$sth->execute($categorycode);
100
		$sth->execute($categorycode);
101
		$data=$sth->fetchrow_hashref;
101
		$data=$sth->fetchrow_hashref;
102
102
Lines 139-144 if ($op eq 'add_form') { Link Here
139
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
139
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
140
				"type_".$data->{'category_type'} => 1,
140
				"type_".$data->{'category_type'} => 1,
141
                branches_loop           => \@branches_loop,
141
                branches_loop           => \@branches_loop,
142
                         checkprevissue          => $data->{'checkprevissuebycategory'},
142
				);
143
				);
143
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
144
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
144
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
145
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
Lines 155-162 if ($op eq 'add_form') { Link Here
155
	}
156
	}
156
	
157
	
157
	if ($is_a_modif) {
158
	if ($is_a_modif) {
158
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
159
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=?,checkprevissuebycategory=? WHERE categorycode=?");
159
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
160
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','checkprevissue','categorycode'));
160
            my @branches = $input->param("branches");
161
            my @branches = $input->param("branches");
161
            if ( @branches ) {
162
            if ( @branches ) {
162
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
163
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
Lines 175-182 if ($op eq 'add_form') { Link Here
175
            }
176
            }
176
            $sth->finish;
177
            $sth->finish;
177
        } else {
178
        } else {
178
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
179
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissuebycategory) values (?,?,?,?,?,?,?,?,?,?,?,?)");
179
            $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type'));
180
            $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','checkprevissue'));
180
            $sth->finish;
181
            $sth->finish;
181
        }
182
        }
182
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
183
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
Lines 199-205 if ($op eq 'add_form') { Link Here
199
	$sth->finish;
200
	$sth->finish;
200
	$template->param(total => $total->{'total'});
201
	$template->param(total => $total->{'total'});
201
	
202
	
202
	my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
203
	my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,checkprevissuebycategory from categories where categorycode=?");
203
	$sth2->execute($categorycode);
204
	$sth2->execute($categorycode);
204
	my $data=$sth2->fetchrow_hashref;
205
	my $data=$sth2->fetchrow_hashref;
205
	$sth2->finish;
206
	$sth2->finish;
Lines 221-226 if ($op eq 'add_form') { Link Here
221
                                reservefee              =>  sprintf("%.2f",$data->{'reservefee'} || 0),
222
                                reservefee              =>  sprintf("%.2f",$data->{'reservefee'} || 0),
222
                                hidelostitems           => $data->{'hidelostitems'},
223
                                hidelostitems           => $data->{'hidelostitems'},
223
                                category_type           => $data->{'category_type'},
224
                                category_type           => $data->{'category_type'},
225
                                checkprevissue          => $data->{'checkprevissuebycategory'},
224
                                );
226
                                );
225
													# END $OP eq DELETE_CONFIRM
227
													# END $OP eq DELETE_CONFIRM
226
################## DELETE_CONFIRMED ##################################
228
################## DELETE_CONFIRMED ##################################
Lines 268-273 if ($op eq 'add_form') { Link Here
268
				category_type           => $results->[$i]{'category_type'},
270
				category_type           => $results->[$i]{'category_type'},
269
                "type_".$results->[$i]{'category_type'} => 1,
271
                "type_".$results->[$i]{'category_type'} => 1,
270
                branches                => \@selected_branches,
272
                branches                => \@selected_branches,
273
                        checkprevissue          => $results->[$i]{'checkprevissuebycategory'},
271
        );
274
        );
272
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
275
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
273
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
276
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 265-270 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
265
  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
265
  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
266
  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
266
  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
267
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
267
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
268
  `checkprevissuebyborrower` 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'.
268
  UNIQUE KEY `cardnumber` (`cardnumber`),
269
  UNIQUE KEY `cardnumber` (`cardnumber`),
269
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
270
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
270
  KEY `categorycode` (`categorycode`),
271
  KEY `categorycode` (`categorycode`),
Lines 465-471 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
465
  `issuelimit` smallint(6) default NULL, -- unused in Koha
466
  `issuelimit` smallint(6) default NULL, -- unused in Koha
466
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
467
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
467
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
468
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
468
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
469
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff),
470
  `checkprevissuebycategory` 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 category setting if 'inherit'.
469
  PRIMARY KEY  (`categorycode`),
471
  PRIMARY KEY  (`categorycode`),
470
  UNIQUE KEY `categorycode` (`categorycode`)
472
  UNIQUE KEY `categorycode` (`categorycode`)
471
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
473
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 79-84 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
79
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
79
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
80
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
80
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
81
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
81
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
82
('CheckPrevIssueByDefault','0','','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','YesNo'),
82
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
83
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
83
('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'),
84
('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'),
84
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
85
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 8202-8207 if ( CheckVersion($DBversion) ) { Link Here
8202
    SetVersion($DBversion);
8202
    SetVersion($DBversion);
8203
}
8203
}
8204
8204
8205
# FIXME: change $DBversion
8206
$DBversion = "3.15.00.036";
8207
if ( CheckVersion($DBversion) ) {
8208
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('CheckPrevIssueByDefault','0','','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','YesNo')");
8209
    $dbh->do("ALTER TABLE categories ADD (`checkprevissuebycategory` varchar(7) NOT NULL default 'inherit')");
8210
    $dbh->do("ALTER TABLE borrowers ADD (`checkprevissuebyborrower` varchar(7) NOT NULL default 'inherit')");
8211
    print "Upgrade to $DBversion done (Bug 6906: show 'Borrower has previously issued \$ITEM' alert on checkout)\n";
8212
    SetVersion ($DBversion);
8213
}
8214
8205
=head1 FUNCTIONS
8215
=head1 FUNCTIONS
8206
8216
8207
=head2 TableExists($table)
8217
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (+31 lines)
Lines 146-151 Link Here
146
	<li><label for="dateofbirthrequired">Age required: </label> <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% dateofbirthrequired %]" size="3" maxlength="3" /> years</li>
146
	<li><label for="dateofbirthrequired">Age required: </label> <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% dateofbirthrequired %]" size="3" maxlength="3" /> years</li>
147
	<li><label for="upperagelimit">Upperage limit: </label> <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% upperagelimit %]" /> years</li>
147
	<li><label for="upperagelimit">Upperage limit: </label> <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% upperagelimit %]" /> years</li>
148
	<li><label for="enrolmentfee">Enrollment fee: </label><input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% enrolmentfee %]" /></li>
148
	<li><label for="enrolmentfee">Enrollment fee: </label><input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% enrolmentfee %]" /></li>
149
        <li><label for="checkprevissue">Check for previous issues: </label>
150
          <select name="checkprevissue" id="checkprevissue">
151
            [% IF ( checkprevissue == 'yes' ) %]
152
              <option value="yes" selected="selected">Yes and override system preferences.</option>
153
              <option value="no">No and override system preferences.</option>
154
              <option value="inherit">Inherit from system preferences.</option>
155
            [% ELSIF (checkprevissue == 'no' ) %]
156
              <option value="yes">Yes and override system preferences.</option>
157
              <option value="no" selected="selected">No and override system preferences.</option>
158
              <option value="inherit">Inherit from system preferences.</option>
159
            [% ELSE %]
160
              <option value="yes">Yes and override system preferences.</option>
161
              <option value="no">No and override system preferences.</option>
162
              <option value="inherit" selected="selected">Inherit from system preferences.</option>
163
            [% END %]
164
          </select></li>
149
	<li><label for="overduenoticerequired">Overdue notice required: </label> <select name="overduenoticerequired" id="overduenoticerequired">
165
	<li><label for="overduenoticerequired">Overdue notice required: </label> <select name="overduenoticerequired" id="overduenoticerequired">
150
			[% IF ( overduenoticerequired ) %]
166
			[% IF ( overduenoticerequired ) %]
151
						<option value="0">No</option>
167
						<option value="0">No</option>
Lines 235-240 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
235
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
251
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
236
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
252
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
237
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
253
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
254
        <tr><th scope="row">Check previous loans: </th><td>[% IF ( checkprevissue == 'yes' ) %]
255
                                                             Yes
256
                                                           [% ELSIF ( checkprevissue == 'no' ) %]
257
                                                             No
258
                                                           [% ELSE %]
259
                                                             Inherit
260
                                                           [% END %]</td></tr>
238
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
261
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
239
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
262
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
240
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
263
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
Lines 278-283 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
278
			<th scope="col">Age required</th>
301
			<th scope="col">Age required</th>
279
			<th scope="col">Upper age limit</th>
302
			<th scope="col">Upper age limit</th>
280
			<th scope="col">Enrollment fee</th>
303
			<th scope="col">Enrollment fee</th>
304
                        <th scope="col">Check previous loans</th>
281
			<th scope="col">Overdue</th>
305
			<th scope="col">Overdue</th>
282
            <th scope="col">Lost items</th>
306
            <th scope="col">Lost items</th>
283
 			<th scope="col">Hold fee</th>
307
 			<th scope="col">Hold fee</th>
Lines 315-320 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
315
                        <td>[% loo.dateofbirthrequired %] years</td>
339
                        <td>[% loo.dateofbirthrequired %] years</td>
316
			<td>[% loo.upperagelimit %] years</td>
340
			<td>[% loo.upperagelimit %] years</td>
317
                        <td>[% loo.enrolmentfee %]</td>
341
                        <td>[% loo.enrolmentfee %]</td>
342
                        <td>[% IF ( loo.checkprevissue == 'yes' ) %]
343
                              Yes
344
                            [% ELSIF ( loo.checkprevissue == 'no' ) %]
345
                              No
346
                            [% ELSE %]
347
                              Inherit
348
                            [% END %]</td>
318
                        <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
349
                        <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
319
                        <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
350
                        <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
320
                        <td>[% loo.reservefee %]</td>
351
                        <td>[% loo.reservefee %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 50-55 Patrons: Link Here
50
           class: multi
50
           class: multi
51
         - (separate multiple choices with |)
51
         - (separate multiple choices with |)
52
     -
52
     -
53
         - pref: CheckPrevIssueByDefault
54
           choices:
55
               yes: "Unless overridden, do"
56
               no: "Unless overridden, do not"
57
         - " check borrower loan history to see if the current item has been loaned before."
58
     -
53
         - pref: checkdigit
59
         - pref: checkdigit
54
           choices:
60
           choices:
55
               none: "Don't"
61
               none: "Don't"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 272-277 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
272
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
272
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
273
[% END %]
273
[% END %]
274
274
275
[% IF PREVISSUE %]
276
    <li>This item has previously been issued to this patron.  Check out anyway?</li>
277
[% END %]
278
275
[% IF BIBLIO_ALREADY_ISSUED %]
279
[% IF BIBLIO_ALREADY_ISSUED %]
276
  <li>
280
  <li>
277
    Patron has already checked out another item from this record.
281
    Patron has already checked out another item from this record.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +18 lines)
Lines 982-988 Link Here
982
    [% END %] 
982
    [% END %] 
983
    </li>
983
    </li>
984
        [% END %]
984
        [% END %]
985
	</ol>
985
    <li><label for="checkprevissuebyborrower">Check for previous issues: </label>
986
      <select name="checkprevissuebyborrower" id="checkprevissue">
987
      [% IF ( checkprevissuebyborrower == 'yes' ) %]
988
        <option value="yes" selected="selected">Yes and override patron category default.</option>
989
        <option value="no">No and override patron category default.</option>
990
        <option value="inherit">Inherit from patron category default.</option>
991
      [% ELSIF (checkprevissuebyborrower == 'no' ) %]
992
        <option value="yes">Yes and override patron category default.</option>
993
        <option value="no" selected="selected">No and override patron category default.</option>
994
        <option value="inherit">Inherit from patron category default.</option>
995
      [% ELSE %]
996
        <option value="yes">Yes and override patron category default.</option>
997
        <option value="no">No and override patron category default.</option>
998
        <option value="inherit" selected="selected">Inherit from patron category default.</option>
999
      [% END %]
1000
    </select>
1001
   </li>
1002
  </ol>
986
  </fieldset>
1003
  </fieldset>
987
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
1004
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
988
	<fieldset class="rows" id="memberentry_subscription">
1005
	<fieldset class="rows" id="memberentry_subscription">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+9 lines)
Lines 384-389 function validate1(date) { Link Here
384
    </li>
384
    </li>
385
    [% IF ( borrowernotes ) %]<li><span class="label">Circulation note: </span>[% borrowernotes %]</li>[% END %]
385
    [% IF ( borrowernotes ) %]<li><span class="label">Circulation note: </span>[% borrowernotes %]</li>[% END %]
386
    [% IF ( opacnote ) %]<li><span class="label">OPAC note:</span>[% opacnote %]</li>[% END %]
386
    [% IF ( opacnote ) %]<li><span class="label">OPAC note:</span>[% opacnote %]</li>[% END %]
387
    <li><span class="label">Check previous loans: </span>
388
      [% IF ( checkprevissuebyborrower == 'yes' ) %]
389
        Yes
390
      [% ELSIF ( checkprevissuebyborrower == 'no' ) %]
391
        No
392
      [% ELSE %]
393
        Inherited
394
      [% END %]
395
    </li>
387
	</ol>
396
	</ol>
388
	</div>
397
	</div>
389
 </div>
398
 </div>
(-)a/t/CheckPrevIssue.t (-1 / +107 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
use strict;
3
use warnings;
4
5
use C4::Context;
6
use Test::More tests => 5;
7
use Test::MockModule;
8
use DBD::Mock;
9
10
use_ok('Koha::Borrower::CheckPrevIssue');
11
12
use Koha::Borrower::CheckPrevIssue qw( WantsCheckPrevIssue CheckPrevIssue );
13
14
# Setup mock db
15
my $module_context = new Test::MockModule('C4::Context');
16
$module_context->mock(
17
    '_new_dbh',
18
    sub {
19
        my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
20
          || die "Cannot create handle: $DBI::errstr\n";
21
        return $dbh;
22
    }
23
);
24
25
my $dbh = C4::Context->dbh();
26
27
# convenience variables
28
my $name;
29
# mock_add_resultset vars
30
my ( $sql, $sql2, @bound_params, @keys, @values, %result ) = ( );
31
# mock_history_verification vars
32
my ( $history, $params, $query ) = ( );
33
34
sub clean_vars {
35
    ( $name, $sql, $sql2, @bound_params, @keys, @values, %result,
36
      $history, $params, $query ) = ( );
37
    $dbh->{mock_clear_history} = 1;
38
}
39
40
# Tests
41
## WantsCheckPrevIssue
42
$name         = 'WantsCheckPrevIssue';
43
$sql          = 'SELECT categories.checkprevissuebycategory FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowers.borrowernumber=?';
44
45
# Test if, as brw inherits, result is simply passed from
46
# _WantsCheckPrevIssueByCategory back through WantsCheckPrevIssue.
47
my %brw = (
48
   checkprevissuebyborrower => 'inherit',
49
   borrowernumber           => '101',
50
);
51
52
$dbh->{mock_add_resultset} =
53
  {
54
   sql          => $sql,
55
   bound_params => [ '101' ],
56
   results      => [ [ 'categories.checkprevissuebycategory' ], [ 'pass_thru' ] ],
57
  };
58
59
is( WantsCheckPrevIssue(\%brw), 'pass_thru',
60
    $name . ": Return value \"pass_thru\"." );
61
62
# Test if, if brw does not inherit, WantsCheckPrevIssue simply returns
63
# its contents.
64
%brw = (
65
   checkprevissuebyborrower => 'brw_pass_thru',
66
   borrowernumber           => '101',
67
);
68
69
is( WantsCheckPrevIssue(\%brw), 'brw_pass_thru',
70
    $name . ": Return value \"$brw{checkprevissuebyborrower}\"." );
71
72
clean_vars();
73
74
## CheckPrevIssue
75
$name      = 'CheckPrevIssue';
76
$sql       = 'select itemnumber from items where biblionumber=?';
77
$sql2      = 'select count(itemnumber) from old_issues'
78
  . ' where borrowernumber=? and itemnumber=?';
79
@keys      = qw< borrowernumber biblionumber itemnumber >;
80
@values    = qw< 101 3576 5043 >;
81
82
# 1) Prepop items with itemnumber for result
83
$dbh->{mock_add_resultset} = {
84
    sql          => $sql,
85
    bound_params => $keys[1],
86
    results      => [ [ ( $keys[2] ) ], [ ( $values[2] ) ] ],
87
   };
88
# 2) Test if never issued before (expect 0)
89
is( CheckPrevIssue( $keys[0], $keys[1] ), 0,
90
    $name . ': Return value "no matches".' );
91
# 3) Prepop old_issues with itemnumber and borrowernumber
92
$dbh->{mock_add_resultset} = {
93
    sql          => $sql2,
94
    bound_params => [ $keys[0], $keys[2] ],
95
    results      => [
96
                     [ ( $keys[0], $keys[2] ) ],
97
                     [ ( $values[0], $values[2] ) ],
98
                     [ ( $values[0], $values[2] ) ],
99
                     [ ( $values[0], $values[2] ) ],
100
                     [ ( $values[0], $values[2] ) ],
101
                    ],
102
   };
103
# 4) Test if issued before (e.g. 7 times — expect 1)
104
is( CheckPrevIssue( $keys[0], $keys[1] ), 1,
105
    $name . ': Return value "> 0 matches".' );
106
107
clean_vars();

Return to bug 6906