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

(-)a/C4/Circulation.pm (-2 / +14 lines)
Lines 3791-3798 sub AnonymizeItemIssueHistory { Link Here
3791
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3791
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3792
    );
3792
    );
3793
3793
3794
    my $oi = $old_issues_rs->next();
3794
    my $oi;
3795
    if ( $oi->borrower()->privacy() == 2 ) {
3795
    if ( C4::Context->preference('StoreLastBorrower') ) {
3796
3797
        # If storing last borrower, skip the latest old_issue for this item
3798
        $old_issues_rs->next();
3799
        $oi = $old_issues_rs->next();
3800
    }
3801
    else {
3802
3803
        # If *not* storing last borrower, use the latest old_issue for this item
3804
        $oi = $old_issues_rs->next();
3805
    }
3806
3807
    if ( $oi && $oi->borrower()->privacy() == 2 ) {
3796
        $oi->set_column( 'borrowernumber', $a );
3808
        $oi->set_column( 'borrowernumber', $a );
3797
        $oi->update();
3809
        $oi->update();
3798
    }
3810
    }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 378-383 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
378
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
378
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
379
('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'),
379
('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'),
380
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
380
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
381
('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'),
381
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
382
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
382
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
383
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
383
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
384
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 8800-8805 if ( CheckVersion($DBversion) ) { Link Here
8800
    SetVersion($DBversion);
8800
    SetVersion($DBversion);
8801
}
8801
}
8802
8802
8803
$DBversion = "3.17.00.XXX";
8804
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8805
   $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')");
8806
8807
   print "Upgrade to $DBversion done (Bug 9011 - Add the ability to store the last patron to return an item)\n";
8808
}
8809
8803
=head1 FUNCTIONS
8810
=head1 FUNCTIONS
8804
8811
8805
=head2 TableExists($table)
8812
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 592-597 OPAC: Link Here
592
                  track: "Track"
592
                  track: "Track"
593
                  no: "Don't track"
593
                  no: "Don't track"
594
            - links that patrons click on
594
            - links that patrons click on
595
        -
596
            - pref: StoreLastBorrower
597
              default: 0
598
              choices:
599
                  yes: Store
600
                  no: "Don't store"
601
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
595
602
596
    Shelf Browser:
603
    Shelf Browser:
597
        -
604
        -
(-)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 6473