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 848-853 sub CanBookBeIssued { Link Here
848
        }
849
        }
849
    }
850
    }
850
851
852
    # If patron uses checkPrevIssue or inherits it, check for previous
853
    # issue of item to patron.
854
    my $checkPrevIssueOverride = WantsCheckPrevIssue( $borrower );
855
    if ( ( $checkPrevIssueOverride eq 'yes' )
856
         or ( $checkPrevIssueOverride eq 'inherit'
857
              and C4::Context->preference("checkPrevIssue") ) )
858
    {
859
        $needsconfirmation{PREVISSUE} = 1
860
          if CheckPrevIssue( $borrower->{borrowernumber},
861
                             $item->{biblionumber} );
862
    }
863
851
    #
864
    #
852
    # ITEM CHECKING
865
    # ITEM CHECKING
853
    #
866
    #
(-)a/Koha/Borrower/CheckPrevIssue.pm (+126 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 $CheckPrevIssueByBrw = $borrower->{checkprevissue};
48
    if ( $CheckPrevIssueByBrw eq 'inherit' ) {
49
        return _WantsCheckPrevIssueByCat( $borrower->{borrowernumber} );
50
    } else {
51
        return $CheckPrevIssueByBrw;
52
    }
53
}
54
55
=head2 _WantsCheckPrevIssueByCat
56
57
    ($CheckPrevIssueByCatOverride) = _WantsCheckPrevIssueByCat( $borrowernumber );
58
59
Returns 'yes', 'no' or 'inherit' depending on whether the patron
60
in this category should be reminded when items to be loaned have already been
61
loaned to this borrower.
62
63
=cut
64
65
sub _WantsCheckPrevIssueByCat {
66
    my ( $borrowernumber ) = @_;
67
    my $dbh = C4::Context->dbh;
68
    my $query = '
69
SELECT categories.checkprevissue
70
FROM borrowers
71
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode
72
WHERE borrowers.borrowernumber = ?
73
';
74
    my $sth;
75
    if ($borrowernumber) {
76
        $sth = $dbh->prepare($query);
77
        $sth->execute($borrowernumber);
78
    } else {
79
        return;
80
    }
81
    return ${$sth->fetchrow_arrayref()}[0];
82
}
83
84
=head2 CheckPrevIssue
85
86
    ($PrevIssue) = CheckPrevIssue( $borrowernumber, $biblionumber );
87
88
Return 1 if $BIBLIONUMBER has previously been issued to
89
$BORROWERNUMBER, 0 otherwise.
90
91
=cut
92
93
sub CheckPrevIssue {
94
    my ( $borrowernumber, $biblionumber ) = @_;
95
    my $dbh       = C4::Context->dbh;
96
    my $previssue = 0;
97
    my $query_items = 'select itemnumber from items where biblionumber=?';
98
    my $sth_items = $dbh->prepare($query_items);
99
    $sth_items->execute($biblionumber);
100
101
    my $query_issues = '
102
select count(itemnumber) from old_issues
103
where borrowernumber=? and itemnumber=?
104
';
105
    my $sth_issues   = $dbh->prepare($query_issues);
106
107
    while ( my @row = $sth_items->fetchrow_array() ) {
108
        $sth_issues->execute( $borrowernumber, $row[0] );
109
        while ( my @matches = $sth_issues->fetchrow_array() ) {
110
            if ( $matches[0] > 0 ) {
111
                $previssue = 1;
112
                last;
113
            }
114
        }
115
        last if $previssue;
116
    }
117
    return $previssue;
118
}
119
120
1;
121
122
=head2 AUTHOR
123
124
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
125
126
=cut
(-)a/admin/categorie.pl (-5 / +9 lines)
Lines 159-164 if ( $op eq 'add_form' ) { Link Here
159
          $data->{'BlockExpiredPatronOpacActions'},
159
          $data->{'BlockExpiredPatronOpacActions'},
160
        TalkingTechItivaPhone =>
160
        TalkingTechItivaPhone =>
161
          C4::Context->preference("TalkingTechItivaPhoneNotification"),
161
          C4::Context->preference("TalkingTechItivaPhoneNotification"),
162
        checkprevissue => $data->{'checkprevissue'},
162
    );
163
    );
163
164
164
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
165
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
Lines 199-205 elsif ( $op eq 'add_validate' ) { Link Here
199
                    overduenoticerequired=?,
200
                    overduenoticerequired=?,
200
                    category_type=?,
201
                    category_type=?,
201
                    BlockExpiredPatronOpacActions=?,
202
                    BlockExpiredPatronOpacActions=?,
202
                    default_privacy=?
203
                    default_privacy=?,
204
                    checkprevissue=?
203
                WHERE categorycode=?"
205
                WHERE categorycode=?"
204
        );
206
        );
205
        $sth->execute(
207
        $sth->execute(
Lines 210-216 elsif ( $op eq 'add_validate' ) { Link Here
210
                'reservefee',            'hidelostitems',
212
                'reservefee',            'hidelostitems',
211
                'overduenoticerequired', 'category_type',
213
                'overduenoticerequired', 'category_type',
212
                'block_expired',         'default_privacy',
214
                'block_expired',         'default_privacy',
213
                'categorycode'
215
                'checkprevissue',        'categorycode'
214
            )
216
            )
215
        );
217
        );
216
        my @branches = $input->param("branches");
218
        my @branches = $input->param("branches");
Lines 246-254 elsif ( $op eq 'add_validate' ) { Link Here
246
                overduenoticerequired,
248
                overduenoticerequired,
247
                category_type,
249
                category_type,
248
                BlockExpiredPatronOpacActions,
250
                BlockExpiredPatronOpacActions,
249
                default_privacy
251
                default_privacy,
252
                checkprevissue
250
            )
253
            )
251
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" );
254
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)" );
252
        $sth->execute(
255
        $sth->execute(
253
            map { $input->param($_) } (
256
            map { $input->param($_) } (
254
                'categorycode',    'description',
257
                'categorycode',    'description',
Lines 257-263 elsif ( $op eq 'add_validate' ) { Link Here
257
                'enrolmentfee',    'reservefee',
260
                'enrolmentfee',    'reservefee',
258
                'hidelostitems',   'overduenoticerequired',
261
                'hidelostitems',   'overduenoticerequired',
259
                'category_type',   'block_expired',
262
                'category_type',   'block_expired',
260
                'default_privacy',
263
                'default_privacy', 'checkprevissue'
261
            )
264
            )
262
        );
265
        );
263
        $sth->finish;
266
        $sth->finish;
Lines 354-359 else { # DEFAULT Link Here
354
            enrolmentfee =>
357
            enrolmentfee =>
355
              sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ),
358
              sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ),
356
            "type_" . $results->[$i]{'category_type'} => 1,
359
            "type_" . $results->[$i]{'category_type'} => 1,
360
            checkprevissue => $results->[$i]{'checkprevissue'},
357
        );
361
        );
358
362
359
        if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
363
        if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
(-)a/installer/data/mysql/kohastructure.sql (+2 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
  `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'.
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 468-473 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
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)
469
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
470
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
470
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
471
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
472
  `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'.
471
  PRIMARY KEY  (`categorycode`),
473
  PRIMARY KEY  (`categorycode`),
472
  UNIQUE KEY `categorycode` (`categorycode`)
474
  UNIQUE KEY `categorycode` (`categorycode`)
473
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
475
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 82-87 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
82
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
82
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
83
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
83
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
84
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
84
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
85
('CheckPrevIssue','0','','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','YesNo'),
85
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
86
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
86
('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'),
87
('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'),
87
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
88
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 8603-8608 if ( CheckVersion($DBversion) ) { Link Here
8603
    SetVersion($DBversion);
8603
    SetVersion($DBversion);
8604
}
8604
}
8605
8605
8606
$DBversion = "3.17.00.XXX";
8607
if ( CheckVersion($DBversion) ) {
8608
    $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')");
8609
    $dbh->do("ALTER TABLE categories ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit')");
8610
    $dbh->do("ALTER TABLE borrowers ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit')");
8611
    print "Upgrade to $DBversion done (Bug 6906: show 'Borrower has previously issued \$ITEM' alert on checkout)\n";
8612
    SetVersion ($DBversion);
8613
}
8614
8606
=head1 FUNCTIONS
8615
=head1 FUNCTIONS
8607
8616
8608
=head2 TableExists($table)
8617
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (+37 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 281-286 Link Here
281
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
297
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
282
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
298
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
283
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
299
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
300
    <tr>
301
        <th scope="row">Check previous loans: </th>
302
        <td>
303
            [% IF ( checkprevissue == 'yes' ) %]
304
            Yes
305
            [% ELSIF ( checkprevissue == 'no' ) %]
306
            No
307
            [% ELSE %]
308
            Inherit
309
            [% END %]
310
        </td>
311
    </tr>
284
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
312
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
285
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
313
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
286
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
314
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
Lines 337-342 Link Here
337
			<th scope="col">Age required</th>
365
			<th scope="col">Age required</th>
338
			<th scope="col">Upper age limit</th>
366
			<th scope="col">Upper age limit</th>
339
			<th scope="col">Enrollment fee</th>
367
			<th scope="col">Enrollment fee</th>
368
            <th scope="col">Check previous loans</th>
340
			<th scope="col">Overdue</th>
369
			<th scope="col">Overdue</th>
341
            <th scope="col">Lost items</th>
370
            <th scope="col">Lost items</th>
342
 			<th scope="col">Hold fee</th>
371
 			<th scope="col">Hold fee</th>
Lines 375-380 Link Here
375
                        <td>[% loo.dateofbirthrequired %] years</td>
404
                        <td>[% loo.dateofbirthrequired %] years</td>
376
			<td>[% loo.upperagelimit %] years</td>
405
			<td>[% loo.upperagelimit %] years</td>
377
                        <td>[% loo.enrolmentfee %]</td>
406
                        <td>[% loo.enrolmentfee %]</td>
407
                        <td>[% IF ( loo.checkprevissue == 'yes' ) %]
408
                              Yes
409
                            [% ELSIF ( loo.checkprevissue == 'no' ) %]
410
                              No
411
                            [% ELSE %]
412
                              Inherit
413
                            [% END %]
414
                        </td>
378
                        <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
415
                        <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
379
                        <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
416
                        <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
380
                        <td>[% loo.reservefee %]</td>
417
                        <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: CheckPrevIssue
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 229-234 $(document).ready(function() { Link Here
229
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
229
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
230
[% END %]
230
[% END %]
231
231
232
[% IF PREVISSUE %]
233
    <li>This item has previously been issued to this patron.  Check out anyway?</li>
234
[% END %]
235
232
[% IF BIBLIO_ALREADY_ISSUED %]
236
[% IF BIBLIO_ALREADY_ISSUED %]
233
  <li>
237
  <li>
234
    Patron has already checked out another item from this record.
238
    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 974-980 Link Here
974
    [% IF ( mandatorysort2 ) %]<span class="required">Required</span>[% END %]
974
    [% IF ( mandatorysort2 ) %]<span class="required">Required</span>[% END %]
975
    </li>
975
    </li>
976
        [% END %]
976
        [% END %]
977
	</ol>
977
    <li><label for="checkprevissue">Check for previous issues: </label>
978
      <select name="checkprevissue" id="checkprevissue">
979
      [% IF ( checkprevissue == 'yes' ) %]
980
        <option value="yes" selected="selected">Yes and override patron category default.</option>
981
        <option value="no">No and override patron category default.</option>
982
        <option value="inherit">Inherit from patron category default.</option>
983
      [% ELSIF (checkprevissue == 'no' ) %]
984
        <option value="yes">Yes and override patron category default.</option>
985
        <option value="no" selected="selected">No and override patron category default.</option>
986
        <option value="inherit">Inherit from patron category default.</option>
987
      [% ELSE %]
988
        <option value="yes">Yes and override patron category default.</option>
989
        <option value="no">No and override patron category default.</option>
990
        <option value="inherit" selected="selected">Inherit from patron category default.</option>
991
      [% END %]
992
    </select>
993
   </li>
994
  </ol>
978
  </fieldset>
995
  </fieldset>
979
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
996
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
980
	<fieldset class="rows" id="memberentry_subscription">
997
	<fieldset class="rows" id="memberentry_subscription">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+9 lines)
Lines 350-355 function validate1(date) { Link Here
350
    </li>
350
    </li>
351
    [% IF ( borrowernotes ) %]<li><span class="label">Circulation note: </span>[% borrowernotes %]</li>[% END %]
351
    [% IF ( borrowernotes ) %]<li><span class="label">Circulation note: </span>[% borrowernotes %]</li>[% END %]
352
    [% IF ( opacnote ) %]<li><span class="label">OPAC note:</span>[% opacnote %]</li>[% END %]
352
    [% IF ( opacnote ) %]<li><span class="label">OPAC note:</span>[% opacnote %]</li>[% END %]
353
    <li><span class="label">Check previous loans: </span>
354
      [% IF ( checkprevissue == 'yes' ) %]
355
        Yes
356
      [% ELSIF ( checkprevissue == 'no' ) %]
357
        No
358
      [% ELSE %]
359
        Inherited
360
      [% END %]
361
    </li>
353
	</ol>
362
	</ol>
354
	</div>
363
	</div>
355
 </div>
364
 </div>
(-)a/t/CheckPrevIssue.t (-1 / +114 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          = '
44
SELECT categories.checkprevissue
45
FROM borrowers
46
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode
47
WHERE borrowers.borrowernumber = ?
48
';
49
50
# Test if, as brw inherits, result is simply passed from
51
# _WantsCheckPrevIssueByCat back through WantsCheckPrevIssue.
52
my %brw = (
53
   checkprevissue => 'inherit',
54
   borrowernumber => '101',
55
);
56
57
$dbh->{mock_add_resultset} =
58
  {
59
   sql          => $sql,
60
   bound_params => [ '101' ],
61
   results      => [ [ 'categories.checkprevissue' ], [ 'pass_thru' ] ],
62
  };
63
64
is( WantsCheckPrevIssue(\%brw), 'pass_thru',
65
    $name . ": Return value \"pass_thru\"." );
66
67
# Test if, if brw does not inherit, WantsCheckPrevIssue simply returns
68
# its contents.
69
%brw = (
70
   checkprevissue => 'brw_pass_thru',
71
   borrowernumber => '101',
72
);
73
74
is( WantsCheckPrevIssue(\%brw), 'brw_pass_thru',
75
    $name . ": Return value \"$brw{checkprevissue}\"." );
76
77
clean_vars();
78
79
## CheckPrevIssue
80
$name      = 'CheckPrevIssue';
81
$sql       = 'select itemnumber from items where biblionumber=?';
82
$sql2      = '
83
select count(itemnumber) from old_issues
84
where borrowernumber=? and itemnumber=?
85
';
86
@keys      = qw< borrowernumber biblionumber itemnumber >;
87
@values    = qw< 101 3576 5043 >;
88
89
# 1) Prepop items with itemnumber for result
90
$dbh->{mock_add_resultset} = {
91
    sql          => $sql,
92
    bound_params => $keys[1],
93
    results      => [ [ ( $keys[2] ) ], [ ( $values[2] ) ] ],
94
   };
95
# 2) Test if never issued before (expect 0)
96
is( CheckPrevIssue( $keys[0], $keys[1] ), 0,
97
    $name . ': Return value "no matches".' );
98
# 3) Prepop old_issues with itemnumber and borrowernumber
99
$dbh->{mock_add_resultset} = {
100
    sql          => $sql2,
101
    bound_params => [ $keys[0], $keys[2] ],
102
    results      => [
103
                     [ ( $keys[0], $keys[2] ) ],
104
                     [ ( $values[0], $values[2] ) ],
105
                     [ ( $values[0], $values[2] ) ],
106
                     [ ( $values[0], $values[2] ) ],
107
                     [ ( $values[0], $values[2] ) ],
108
                    ],
109
   };
110
# 4) Test if issued before (e.g. 7 times — expect 1)
111
is( CheckPrevIssue( $keys[0], $keys[1] ), 1,
112
    $name . ': Return value "> 0 matches".' );
113
114
clean_vars();

Return to bug 6906