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

(-)a/C4/Circulation.pm (-3 / +15 lines)
Lines 3535-3545 sub AnonymizeItemIssueHistory { Link Here
3535
            'me.itemnumber'     => $itemnumber,
3535
            'me.itemnumber'     => $itemnumber,
3536
            'me.borrowernumber' => { '!=' => $a },
3536
            'me.borrowernumber' => { '!=' => $a },
3537
        },
3537
        },
3538
        { prefetch => 'borrower', order_by => { -desc => 'returndate' } }
3538
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3539
    );
3539
    );
3540
3540
3541
    my $oi = $old_issues_rs->next();
3541
    my $oi;
3542
    if ( $oi->borrower()->privacy() == 2 ) {
3542
    if ( C4::Context->preference('StoreLastBorrower') ) {
3543
3544
        # If storing last borrower, skip the latest old_issue for this item
3545
        $old_issues_rs->next();
3546
        $oi = $old_issues_rs->next();
3547
    }
3548
    else {
3549
3550
        # If *not* storing last borrower, use the latest old_issue for this item
3551
        $oi = $old_issues_rs->next();
3552
    }
3553
3554
    if ( $oi && $oi->borrower()->privacy() == 2 ) {
3543
        $oi->set_column( 'borrowernumber', $a );
3555
        $oi->set_column( 'borrowernumber', $a );
3544
        $oi->update();
3556
        $oi->update();
3545
    }
3557
    }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 360-365 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
360
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
360
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
361
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
361
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
362
('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'),
362
('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'),
363
('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'),
363
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
364
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
364
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
365
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
365
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
366
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 8052-8057 if(CheckVersion($DBversion)) { Link Here
8052
    SetVersion($DBversion);
8052
    SetVersion($DBversion);
8053
}
8053
}
8054
8054
8055
$DBversion = "3.13.00.XXX";
8056
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8057
   $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo')");
8058
8059
   print "Upgrade to $DBversion done (Bug 9011 - Add the ability to store the last patron to return an item)\n";
8060
   SetVersion ($DBversion);
8061
}
8062
8055
=head1 FUNCTIONS
8063
=head1 FUNCTIONS
8056
8064
8057
=head2 TableExists($table)
8065
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 563-568 OPAC: Link Here
563
                  track: "Track"
563
                  track: "Track"
564
                  no: "Don't track"
564
                  no: "Don't track"
565
            - links that patrons click on
565
            - links that patrons click on
566
        -
567
            - pref: StoreLastBorrower
568
              default: 0
569
              choices:
570
                  yes: Store
571
                  no: "Don't store"
572
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
566
573
567
    Shelf Browser:
574
    Shelf Browser:
568
        -
575
        -
(-)a/t/db_dependent/Circulation_anonymization.t (-3 / +17 lines)
Lines 6-12 use C4::Context; Link Here
6
use C4::Circulation;
6
use C4::Circulation;
7
use Koha::Database;
7
use Koha::Database;
8
8
9
use Test::More tests => 4;
9
use Test::More tests => 6;
10
10
11
BEGIN {
11
BEGIN {
12
    use_ok('C4::Circulation');
12
    use_ok('C4::Circulation');
Lines 132-137 my $userenv = C4::Context->userenv Link Here
132
132
133
#Begin Tests
133
#Begin Tests
134
134
135
C4::Context->set_preference( 'StoreLastBorrower', 0 );
136
135
AddIssue( $borrower_1, 'barcode_1' );
137
AddIssue( $borrower_1, 'barcode_1' );
136
AddReturn('barcode_1');
138
AddReturn('barcode_1');
137
my $old_issue =
139
my $old_issue =
Lines 141-153 ok( $old_issue->borrower()->borrowernumber() == $anonymous_patron->borrowernumbe Link Here
141
143
142
my $next_issue_id = $old_issue->issue_id() + 1;
144
my $next_issue_id = $old_issue->issue_id() + 1;
143
145
144
145
AddIssue( $borrower_2, 'barcode_1' );
146
AddIssue( $borrower_2, 'barcode_1' );
146
AddReturn('barcode_1');
147
AddReturn('barcode_1');
147
$old_issue =
148
$old_issue =
148
  $schema->resultset('OldIssue')->find( $next_issue_id );
149
  $schema->resultset('OldIssue')->find( $next_issue_id );
149
ok( $old_issue->borrower()->borrowernumber() == $borrower2->borrowernumber(), "Patron with privacy of 1 not anonymized" );
150
ok( $old_issue->borrower()->borrowernumber() == $borrower2->borrowernumber(), "Patron with privacy of 1 not anonymized" );
150
151
152
C4::Context->set_preference( 'StoreLastBorrower', 1 );
153
154
$next_issue_id = $old_issue->issue_id() + 1;
155
156
AddIssue( $borrower_1, 'barcode_1' );
157
AddReturn('barcode_1');
158
$old_issue =
159
  $schema->resultset('OldIssue')->find( $next_issue_id );
160
ok( $old_issue->borrower()->borrowernumber() == $borrower1->borrowernumber(), "Patron with privacy of 2 not anonymized with StoreLastBorrower enabled" );
161
AddIssue( $borrower_2, 'barcode_1' );
162
AddReturn('barcode_1');
163
$old_issue =
164
  $schema->resultset('OldIssue')->find( $next_issue_id );
165
ok( $old_issue->borrower()->borrowernumber() == $anonymous_patron->borrowernumber(), "Patron with privacy of 2 anonymized after next return with StoreLastBorrower enabled" );
151
166
152
#End transaction
167
#End transaction
153
$dbh->rollback;
168
$dbh->rollback;
154
- 

Return to bug 9011