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

(-)a/C4/Circulation.pm (+10 lines)
Lines 50-55 use Koha::Calendar; Link Here
50
use Koha::Items;
50
use Koha::Items;
51
use Koha::Patrons;
51
use Koha::Patrons;
52
use Koha::Patron::Debarments;
52
use Koha::Patron::Debarments;
53
use Koha::Patron::CheckPrevIssue qw(WantsCheckPrevIssue CheckPrevIssue);
53
use Koha::Database;
54
use Koha::Database;
54
use Koha::Libraries;
55
use Koha::Libraries;
55
use Koha::Holds;
56
use Koha::Holds;
Lines 909-914 sub CanBookBeIssued { Link Here
909
    }
910
    }
910
911
911
    #
912
    #
913
    # CHECKPREVISSUE: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
914
    #
915
    my $wantsCheckPrevIssue = WantsCheckPrevIssue(
916
        $borrower, C4::Context->preference("checkPrevIssue")
917
    );
918
    $needsconfirmation{PREVISSUE} = 1
919
        if ($wantsCheckPrevIssue and CheckPrevIssue($borrower, $item));
920
921
    #
912
    # ITEM CHECKING
922
    # ITEM CHECKING
913
    #
923
    #
914
    if ( $item->{'notforloan'} )
924
    if ( $item->{'notforloan'} )
(-)a/Koha/Patron/CheckPrevIssue.pm (+182 lines)
Line 0 Link Here
1
package Koha::Patron::CheckPrevIssue;
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 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
use Koha::Patron::Categories;
24
use Koha::Issues;
25
use Koha::OldIssues;
26
27
use parent qw( Exporter );
28
29
our @EXPORT = qw(
30
        WantsCheckPrevIssue
31
        CheckPrevIssue
32
);
33
34
=head1 NAME
35
36
Koha::Patron::CheckPrevIssue - Manage Previous Issue preferences & searches.
37
38
=head1 SYNOPSIS
39
40
Provide a feature to check whether a patron has previously checked out items
41
associated with a a biblio.
42
43
=head1 DESCRIPTION
44
45
CheckPrevIssue is a feature that allows administrators of a Koha instance to
46
enable a warning when items are lent to patrons when they've already borrowed
47
it in the past.
48
49
An example use case might be a housebound delivery service, where volunteers
50
pick stock for housebound patrons.  The volunteers might not have an
51
exhaustive list of books borrowed in the past, so they would benefit from
52
being warned when they are about to check out such a book to that patron.
53
54
The module introduces:
55
56
=over
57
58
=item a master syspref in the Patrons section:
59
60
=over
61
62
=item Do not
63
64
=item Unless overridden, do not
65
66
=item Unless overridden, do
67
68
=item Do
69
70
=back
71
72
=item per patron category switches:
73
74
=over
75
76
=item Inherit from system preferences.
77
78
=item Yes and try to override system preferences.
79
80
=item No and try to override system preferences.
81
82
=back
83
84
=item per patron switches
85
86
=over
87
88
=item Inherit from wider settings.
89
90
=item Yes and try to override settings.
91
92
=item No and try to override settings.
93
94
=back
95
96
=back
97
98
=head1 FUNCTIONS
99
100
=cut
101
102
=head2 WantsCheckPrevIssue
103
104
    $wantsCheckPrevIssue = WantsCheckPrevIssue($patron, $syspref);
105
106
Return 1 if Koha needs to perform PrevIssue checking, else 0.
107
108
$PATRON is used to determine patron and patron category checkPrevIssue level
109
setting.  $SYSPREF conteins the system-wide checkPrevIssue level setting.
110
111
=cut
112
113
sub WantsCheckPrevIssue {
114
    my ( $patron, $syspref ) = @_;
115
116
    # Simple cases
117
    ## Hard syspref trumps all
118
    return 1 if ($syspref eq 'hardyes');
119
    return 0 if ($syspref eq 'hardno');
120
    ## Now, patron pref trumps all
121
    my $checkPrevIssueByBrw = $patron->{checkprevissue};
122
    return 1 if ($checkPrevIssueByBrw eq 'yes');
123
    return 0 if ($checkPrevIssueByBrw eq 'no');
124
125
    # More complex: patron inherits -> determine category preference
126
    my $checkPrevIssueByCat =
127
        Koha::Patron::Categories->find($patron->{categorycode})
128
          ->checkprevissue;
129
    return 1 if ($checkPrevIssueByCat eq 'yes');
130
    return 0 if ($checkPrevIssueByCat eq 'no');
131
132
    # Finally: category preference is inherit, default to 0
133
    if ($syspref eq 'softyes') {
134
        return 1;
135
    } else {
136
        return 0;
137
    }
138
}
139
140
=head2 CheckPrevIssue
141
142
    $checkPrevIssue = CheckPrevIssue($patron, $item);
143
144
Return 1 if the bib associated with $ITEM has previously been checked out to
145
$PATRON, 0 otherwise.
146
147
=cut
148
149
sub CheckPrevIssue {
150
    my ( $patron, $item ) = @_;
151
152
    # Find all items for bib and extract item numbers.
153
    my @items = Koha::Items->search({biblionumber => $item->{biblionumber}});
154
    my @item_nos;
155
    foreach my $item (@items) {
156
        push @item_nos, $item->itemnumber;
157
    }
158
159
    # Create (old)issues search criteria
160
    my $criteria = {
161
        borrowernumber => $patron->{borrowernumber},
162
        itemnumber => \@item_nos,
163
    };
164
165
    # Check current issues table
166
    my $issues = Koha::Issues->search($criteria);
167
    return 1 if $issues->count; # 0 || N
168
169
    # Check old issues table
170
    my $old_issues = Koha::OldIssues->search($criteria);
171
    return $old_issues->count;  # 0 || N
172
}
173
174
1;
175
176
__END__
177
178
=head1 AUTHOR
179
180
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
181
182
=cut
(-)a/admin/categories.pl (+3 lines)
Lines 90-95 elsif ( $op eq 'add_validate' ) { Link Here
90
    my $overduenoticerequired = $input->param('overduenoticerequired');
90
    my $overduenoticerequired = $input->param('overduenoticerequired');
91
    my $category_type = $input->param('category_type');
91
    my $category_type = $input->param('category_type');
92
    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
92
    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
93
    my $checkPrevIssue = $input->param('checkprevissue');
93
    my $default_privacy = $input->param('default_privacy');
94
    my $default_privacy = $input->param('default_privacy');
94
    my @branches = grep { $_ ne q{} } $input->param('branches');
95
    my @branches = grep { $_ ne q{} } $input->param('branches');
95
96
Lines 113-118 elsif ( $op eq 'add_validate' ) { Link Here
113
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->category_type($category_type);
115
        $category->category_type($category_type);
115
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
116
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
117
        $category->checkprevissue($checkPrevIssue);
116
        $category->default_privacy($default_privacy);
118
        $category->default_privacy($default_privacy);
117
        eval {
119
        eval {
118
            $category->store;
120
            $category->store;
Lines 138-143 elsif ( $op eq 'add_validate' ) { Link Here
138
            overduenoticerequired => $overduenoticerequired,
140
            overduenoticerequired => $overduenoticerequired,
139
            category_type => $category_type,
141
            category_type => $category_type,
140
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
142
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
143
            checkprevissue => $checkPrevIssue,
141
            default_privacy => $default_privacy,
144
            default_privacy => $default_privacy,
142
        });
145
        });
143
        eval {
146
        eval {
(-)a/installer/data/mysql/atomicupdate/checkPrevIssue.sql (+11 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable,value,options,explanation,type)
2
VALUES('CheckPrevIssue','hardno','hardyes|softyes|softno|hardno','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','Choice');
3
4
ALTER TABLE categories
5
ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit');
6
7
ALTER TABLE borrowers
8
ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit');
9
10
ALTER TABLE deletedborrowers
11
ADD (`checkprevissue` varchar(7) NOT NULL default 'inherit');
(-)a/installer/data/mysql/kohastructure.sql (+3 lines)
Lines 266-271 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
266
  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
266
  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
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
  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
268
  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
269
  `checkprevissue` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron if this item has previously been issued to this patron if 'yes', not if 'no', defer to category setting if 'inherit'.
269
  UNIQUE KEY `cardnumber` (`cardnumber`),
270
  UNIQUE KEY `cardnumber` (`cardnumber`),
270
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
271
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
271
  KEY `categorycode` (`categorycode`),
272
  KEY `categorycode` (`categorycode`),
Lines 505-510 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
505
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
506
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
506
  `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
507
  `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
507
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
508
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
509
  `checkprevissue` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been issued to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'.
508
  PRIMARY KEY  (`categorycode`),
510
  PRIMARY KEY  (`categorycode`),
509
  UNIQUE KEY `categorycode` (`categorycode`)
511
  UNIQUE KEY `categorycode` (`categorycode`)
510
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
512
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Lines 918-923 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower Link Here
918
  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
920
  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
919
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
921
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
920
  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
922
  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
923
  `checkprevissue` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron if this item has previously been issued to this patron if 'yes', not if 'no', defer to category setting if 'inherit'.
921
  KEY borrowernumber (borrowernumber),
924
  KEY borrowernumber (borrowernumber),
922
  KEY `cardnumber` (`cardnumber`),
925
  KEY `cardnumber` (`cardnumber`),
923
  KEY `sms_provider_id` (`sms_provider_id`)
926
  KEY `sms_provider_id` (`sms_provider_id`)
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 90-95 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
90
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
90
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
91
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
91
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
92
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
92
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
93
('CheckPrevIssue','hardno','hardyes|softyes|softno|hardno','By default, for every item issued, should we warn if the patron has borrowed that item in the past?','Choice'),
93
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
94
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
94
('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'),
95
('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'),
95
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
96
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (+53 lines)
Lines 276-281 Link Here
276
                        Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
276
                        Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
277
                    </span>
277
                    </span>
278
                </li>
278
                </li>
279
                [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' )  %]
280
                  <li><label for="checkprevissue">Check for previous issues: </label>
281
                      <select name="checkprevissue" id="checkprevissue">
282
                          [% IF category.checkprevissue == 'yes' %]
283
                          <option value="yes" selected="selected">Yes and try to override system preferences</option>
284
                          <option value="no">No and try to override system preferences</option>
285
                          <option value="inherit">Inherit from system preferences</option>
286
                          [% ELSIF category.checkprevissue == 'no' %]
287
                          <option value="yes">Yes and try to override system preferences</option>
288
                          <option value="no" selected="selected">No and try to override system preferences</option>
289
                          <option value="inherit">Inherit from system preferences</option>
290
                          [% ELSE %]
291
                          <option value="yes">Yes and try to override system preferences</option>
292
                          <option value="no">No and try to override system preferences</option>
293
                          <option value="inherit" selected="selected">Inherit from system preferences</option>
294
                          [% END %]
295
                      </select>
296
                      <span>
297
                          Choose whether patrons of this category by default are reminded if they try to borrow an item they borrowed before.
298
                      </span>
299
                  </li>
300
                [% END %]
279
                <li>
301
                <li>
280
                    <label for="default_privacy">Default privacy: </label>
302
                    <label for="default_privacy">Default privacy: </label>
281
                    <select id="default_privacy" name="default_privacy">
303
                    <select id="default_privacy" name="default_privacy">
Lines 345-350 Link Here
345
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
367
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
346
                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
368
                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
347
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
369
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
370
371
                [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' ) %]
372
                  <tr>
373
                      <th scope="row">Check previous issues: </th>
374
                      <td>
375
                          [% SWITCH category.checkprevissue %]
376
                          [% CASE 'yes' %]
377
                              Yes
378
                          [% CASE 'no' %]
379
                              No
380
                          [% CASE 'inherit' %]
381
                              Inherit
382
                          [% END %]
383
                      </td>
384
                  </tr>
385
                [% END %]
348
                <tr>
386
                <tr>
349
                    <th scope="row">Default privacy: </th>
387
                    <th scope="row">Default privacy: </th>
350
                    <td>
388
                    <td>
Lines 401-406 Link Here
401
                    <th scope="col">Messaging</th>
439
                    <th scope="col">Messaging</th>
402
                    [% END %]
440
                    [% END %]
403
                    <th scope="col">Branches limitations</th>
441
                    <th scope="col">Branches limitations</th>
442
                    [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' ) %]
443
                    <th scope="col">Check previous issue?</th>
444
                    [% END %]
404
                    <th scope="col">Default privacy</th>
445
                    <th scope="col">Default privacy</th>
405
                    <th scope="col">&nbsp; </th>
446
                    <th scope="col">&nbsp; </th>
406
                    <th scope="col">&nbsp; </th>
447
                    <th scope="col">&nbsp; </th>
Lines 478-483 Link Here
478
                                No limitation
519
                                No limitation
479
                            [% END %]
520
                            [% END %]
480
                        </td>
521
                        </td>
522
                        [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' ) %]
523
                          <td>
524
                              [% SWITCH category.checkprevissue %]
525
                              [% CASE 'yes' %]
526
                              Yes
527
                              [% CASE 'no' %]
528
                              No
529
                              [% CASE 'inherit' %]
530
                              Inherit
531
                              [% END %]
532
                          </td>
533
                        [% END %]
481
                        <td>
534
                        <td>
482
                            [% SWITCH category.default_privacy %]
535
                            [% SWITCH category.default_privacy %]
483
                            [% CASE 'default' %]
536
                            [% CASE 'default' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+9 lines)
Lines 44-49 Patrons: Link Here
44
           class: multi
44
           class: multi
45
         - (separate multiple choices with |)
45
         - (separate multiple choices with |)
46
     -
46
     -
47
         - pref: CheckPrevIssue
48
           default: no
49
           choices:
50
               hardyes: "Do"
51
               softyes: "Unless overridden, do"
52
               softno: "Unless overridden, do not"
53
               hardno: "Do not"
54
         - " check borrower loan history to see if the current item has been loaned before."
55
     -
47
         - pref: checkdigit
56
         - pref: checkdigit
48
           choices:
57
           choices:
49
               none: "Don't"
58
               none: "Don't"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 308-313 $(document).ready(function() { Link Here
308
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
308
    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
309
[% END %]
309
[% END %]
310
310
311
[% IF PREVISSUE %]
312
    <li>This item has previously been checked out to this patron.  Check out anyway?</li>
313
[% END %]
314
311
[% IF BIBLIO_ALREADY_ISSUED %]
315
[% IF BIBLIO_ALREADY_ISSUED %]
312
  <li>
316
  <li>
313
    Patron has already checked out another item from this record.
317
    Patron has already checked out another item from this record.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +20 lines)
Lines 737-743 function select_user(borrowernumber, borrower) { Link Here
737
            [% END %]
737
            [% END %]
738
        </li>
738
        </li>
739
    [% END %]
739
    [% END %]
740
	</ol>
740
    [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' ) %]
741
      <li><label for="checkprevissue">Check for previous issues: </label>
742
        <select name="checkprevissue" id="checkprevissue">
743
        [% IF ( checkprevissue == 'yes' ) %]
744
          <option value="yes" selected="selected">Yes if settings allow it</option>
745
          <option value="no">No if settings allow it</option>
746
          <option value="inherit">Inherit from settings</option>
747
        [% ELSIF ( checkprevissue == 'no' ) %]
748
          <option value="yes">Yes if settings allow it</option>
749
          <option value="no" selected="selected">No if settings allow it</option>
750
          <option value="inherit">Inherit from settings</option>
751
        [% ELSE %]
752
          <option value="yes">Yes if settings allow it</option>
753
          <option value="no">No if settings allow it</option>
754
          <option value="inherit" selected="selected">Inherit from settings</option>
755
        [% END %]
756
        </select>
757
       </li>
758
     [% END %]
759
   </ol>
741
  </fieldset>
760
  </fieldset>
742
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
761
    [% UNLESS nodateenrolled &&  noopacnote && noborrowernotes %]
743
	<fieldset class="rows" id="memberentry_subscription">
762
	<fieldset class="rows" id="memberentry_subscription">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+11 lines)
Lines 400-405 function validate1(date) { Link Here
400
            <li><span class="label">Activate sync: </span>No</li>
400
            <li><span class="label">Activate sync: </span>No</li>
401
        [% END %]
401
        [% END %]
402
    [% END %]
402
    [% END %]
403
    [% IF ( Koha.Preference('CheckPrevIssue') == 'softyes' || Koha.Preference('CheckPrevIssue') == 'softno' ) %]
404
      <li><span class="label">Check previous loans: </span>
405
        [% IF ( checkprevissue == 'yes' ) %]
406
        Yes
407
        [% ELSIF ( checkprevissue == 'no' ) %]
408
        No
409
        [% ELSE %]
410
        Inherited
411
        [% END %]
412
      </li>
413
    [% END %]
403
	</ol>
414
	</ol>
404
	</div>
415
	</div>
405
 </div>
416
 </div>
(-)a/t/db_dependent/Patron/CheckPrevIssue.t (-1 / +354 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
use Modern::Perl;
3
4
use C4::Members;
5
use C4::Circulation;
6
use Koha::Patron::Categories;
7
use Koha::Patron::Category;
8
use Koha::Database;
9
use Koha::Patrons;
10
use Koha::Patron;
11
use Koha::Items;
12
use Koha::Item;
13
14
use Test::More tests => 55;
15
16
use_ok('Koha::Patron::CheckPrevIssue');
17
18
use Koha::Patron::CheckPrevIssue qw( WantsCheckPrevIssue CheckPrevIssue );
19
20
use t::lib::TestBuilder;
21
22
my $schema = Koha::Database->new->schema;
23
$schema->storage->txn_begin;
24
25
my $builder = t::lib::TestBuilder->new;
26
my $yesCatCode = $builder->build({
27
    source => 'Category',
28
    value => {
29
        categorycode => 'yesCat',
30
        checkprevissue => 'yes',
31
    },
32
});
33
34
my $noCatCode = $builder->build({
35
    source => 'Category',
36
    value => {
37
        categorycode => 'noCat',
38
        checkprevissue => 'no',
39
    },
40
});
41
42
my $inheritCatCode = $builder->build({
43
    source => 'Category',
44
    value => {
45
        categorycode => 'inheritCat',
46
        checkprevissue => 'inherit',
47
    },
48
});
49
50
# WantsCheckPrevIssue
51
52
# We expect the following result matrix:
53
#
54
# (1/0 indicates the return value of WantsCheckPrevIssue; i.e. 1 says we
55
# should check whether the item was previously issued)
56
#
57
# | System Preference | hardyes                           | softyes                           | softno                            | hardno                            |
58
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------+-----------------------------------|
59
# | Category Setting  | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   | yes       | no        | inherit   |
60
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------|
61
# | Patron Setting    | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i |
62
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
63
# | Expected Result   | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
64
65
my $mappings = [
66
    {
67
        syspref    => 'hardyes',
68
        categories => [
69
            {
70
                setting   => 'yes',
71
                borrowers => [
72
                    {setting => 'yes',     result => 1},
73
                    {setting => 'no',      result => 1},
74
                    {setting => 'inherit', result => 1},
75
                ],
76
            },
77
            {
78
                setting   => 'no',
79
                borrowers => [
80
                    {setting => 'yes',     result => 1},
81
                    {setting => 'no',      result => 1},
82
                    {setting => 'inherit', result => 1},
83
                ],
84
            },
85
            {
86
                setting   => 'inherit',
87
                borrowers => [
88
                    {setting => 'yes',     result => 1},
89
                    {setting => 'no',      result => 1},
90
                    {setting => 'inherit', result => 1},
91
                ],
92
            },
93
        ],
94
    },
95
    {
96
        syspref    => 'softyes',
97
        categories => [
98
            {
99
                setting  => 'yes',
100
                borrowers => [
101
                    {setting => 'yes',     result => 1},
102
                    {setting => 'no',      result => 0},
103
                    {setting => 'inherit', result => 1},
104
                ],
105
            },
106
            {
107
                setting  => 'no',
108
                borrowers => [
109
                    {setting => 'yes',     result => 1},
110
                    {setting => 'no',      result => 0},
111
                    {setting => 'inherit', result => 0},
112
                ],
113
            },
114
            {
115
                setting  => 'inherit',
116
                borrowers => [
117
                    {setting => 'yes',     result => 1},
118
                    {setting => 'no',      result => 0},
119
                    {setting => 'inherit', result => 1},
120
                ],
121
            },
122
        ],
123
    },
124
    {
125
        syspref    => 'softno',
126
        categories => [
127
            {
128
                setting  => 'yes',
129
                borrowers => [
130
                    {setting => 'yes',     result => 1},
131
                    {setting => 'no',      result => 0},
132
                    {setting => 'inherit', result => 1},
133
                ],
134
            },
135
            {
136
                setting  => 'no',
137
                borrowers => [
138
                    {setting => 'yes',     result => 1},
139
                    {setting => 'no',      result => 0},
140
                    {setting => 'inherit', result => 0},
141
                ],
142
            },
143
            {
144
                setting  => 'inherit',
145
                borrowers => [
146
                    {setting => 'yes',     result => 1},
147
                    {setting => 'no',      result => 0},
148
                    {setting => 'inherit', result => 0},
149
                ],
150
            },
151
        ],
152
    },
153
    {
154
        syspref    => 'hardno',
155
        categories => [
156
            {
157
                setting  => 'yes',
158
                borrowers => [
159
                    {setting => 'yes',     result => 0},
160
                    {setting => 'no',      result => 0},
161
                    {setting => 'inherit', result => 0},
162
                ],
163
            },
164
            {
165
                setting  => 'no',
166
                borrowers => [
167
                    {setting => 'yes',     result => 0},
168
                    {setting => 'no',      result => 0},
169
                    {setting => 'inherit', result => 0},
170
                ],
171
            },
172
            {
173
                setting  => 'inherit',
174
                borrowers => [
175
                    {setting => 'yes',     result => 0},
176
                    {setting => 'no',      result => 0},
177
                    {setting => 'inherit', result => 0},
178
                ],
179
            },
180
        ],
181
    },
182
];
183
184
map {
185
    my $syspref = $_->{syspref};
186
    map {
187
        my $code = $_->{setting} . 'Cat';
188
        map {
189
            my $brw = {
190
                checkprevissue => $_->{setting},
191
                categorycode => $code,
192
            };
193
            is(
194
                WantsCheckPrevIssue($brw, $syspref), $_->{result},
195
                "Predicate with syspref " . $syspref . ", cat " . $code
196
                    . ", brw " . $_->{setting}
197
              );
198
        } @{$_->{borrowers}};
199
    } @{$_->{categories}};
200
} @{$mappings};
201
202
# CheckPrevIssue
203
204
# We want to test:
205
# - DESCRIPTION [RETURNVALUE (0/1)]
206
## PreIssue (sanity checks)
207
# - Item, patron [0]
208
# - Diff item, same bib, same patron [0]
209
# - Diff item, diff bib, same patron [0]
210
# - Same item, diff patron [0]
211
# - Diff item, same bib, diff patron [0]
212
# - Diff item, diff bib, diff patron [0]
213
## PostIssue
214
# - Same item, same patron [1]
215
# - Diff item, same bib, same patron [1]
216
# - Diff item, diff bib, same patron [0]
217
# - Same item, diff patron [0]
218
# - Diff item, same bib, diff patron [0]
219
# - Diff item, diff bib, diff patron [0]
220
## PostReturn
221
# - Same item, same patron [1]
222
# - Diff item, same bib, same patron [1]
223
# - Diff item, diff bib, same patron [0]
224
# - Same item, diff patron [0]
225
# - Diff item, same bib, diff patron [0]
226
# - Diff item, diff bib, diff patron [0]
227
228
# Requirements:
229
# $patron, $different_patron, $items (same bib number), $different_item
230
my $patron = $builder->build({source => 'Borrower'});
231
my $patron_d = $builder->build({source => 'Borrower'});
232
my $item_1 = $builder->build({source => 'Item'});
233
my $item_2 = $builder->build({
234
    source => 'Item',
235
    value => { biblionumber => $item_1->{biblionumber} },
236
});
237
my $item_d = $builder->build({source => 'Item'});
238
239
## Testing Sub
240
sub test_it {
241
    my ($mapping, $stage) = @_;
242
    map {
243
        is(CheckPrevIssue(
244
            $_->{patron}, $_->{item}), $_->{result}, $stage . ": " . $_->{msg}
245
        );
246
    } @{$mapping};
247
};
248
249
## Initial Mappings
250
my $cpvmappings = [
251
    {
252
        msg => "Item, patron [0]",
253
        item => $item_1,
254
        patron => $patron,
255
        result => 0,
256
    },
257
    {
258
        msg => "Diff item, same bib, same patron [0]",
259
        item => $item_2,
260
        patron => $patron,
261
        result => 0,
262
    },
263
    {
264
        msg => "Diff item, diff bib, same patron [0]",
265
        item => $item_d,
266
        patron => $patron,
267
        result => 0,
268
    },
269
    {
270
        msg => "Same item, diff patron [0]",
271
        item => $item_1,
272
        patron => $patron_d,
273
        result => 0,
274
    },
275
    {
276
        msg => "Diff item, same bib, diff patron [0]",
277
        item => $item_2,
278
        patron => $patron_d,
279
        result => 0,
280
    },
281
    {
282
        msg => "Diff item, diff bib, diff patron [0]",
283
        item => $item_d,
284
        patron => $patron_d,
285
        result => 0,
286
    },
287
];
288
289
test_it($cpvmappings, "PreIssue");
290
291
# Issue item_1 to $patron:
292
my @USERENV = (
293
    $patron->{borrowernumber}, 'test', 'MASTERTEST', 'firstname', 'CPL',
294
    'CPL', 'email@example.org'
295
);
296
C4::Context->_new_userenv('DUMMY_SESSION_ID');
297
C4::Context->set_userenv(@USERENV);
298
BAIL_OUT("No userenv") unless C4::Context->userenv;
299
300
my $borrower = GetMember(%{{borrowernumber => $patron->{borrowernumber}}});
301
302
BAIL_OUT("Issue failed") unless AddIssue($borrower, $item_1->{barcode});
303
304
# Then test:
305
my $cpvPmappings = [
306
    {
307
        msg => "Same item, same patron [1]",
308
        item => $item_1,
309
        patron => $patron,
310
        result => 1,
311
    },
312
    {
313
        msg => "Diff item, same bib, same patron [1]",
314
        item => $item_2,
315
        patron => $patron,
316
        result => 1,
317
    },
318
    {
319
        msg => "Diff item, diff bib, same patron [0]",
320
        item => $item_d,
321
        patron => $patron,
322
        result => 0,
323
    },
324
    {
325
        msg => "Same item, diff patron [0]",
326
        item => $item_1,
327
        patron => $patron_d,
328
        result => 0,
329
    },
330
    {
331
        msg => "Diff item, same bib, diff patron [0]",
332
        item => $item_2,
333
        patron => $patron_d,
334
        result => 0,
335
    },
336
    {
337
        msg => "Diff item, diff bib, diff patron [0]",
338
        item => $item_d,
339
        patron => $patron_d,
340
        result => 0,
341
    },
342
];
343
344
test_it($cpvPmappings, "PostIssue");
345
346
# Return item_1 from patron:
347
BAIL_OUT("Return Failed") unless AddReturn($item_1->{barcode}, $patron->{branchcode});
348
349
# Then:
350
test_it($cpvPmappings, "PostReturn");
351
352
$schema->storage->txn_rollback;
353
354
1;

Return to bug 6906