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

(-)a/C4/Circulation.pm (-2 / +14 lines)
Lines 3788-3795 sub AnonymizeItemIssueHistory { Link Here
3788
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3788
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3789
    );
3789
    );
3790
3790
3791
    my $oi = $old_issues_rs->next();
3791
    my $oi;
3792
    if ( $oi->borrower()->privacy() == 2 ) {
3792
    if ( C4::Context->preference('StoreLastBorrower') ) {
3793
3794
        # If storing last borrower, skip the latest old_issue for this item
3795
        $old_issues_rs->next();
3796
        $oi = $old_issues_rs->next();
3797
    }
3798
    else {
3799
3800
        # If *not* storing last borrower, use the latest old_issue for this item
3801
        $oi = $old_issues_rs->next();
3802
    }
3803
3804
    if ( $oi && $oi->borrower()->privacy() == 2 ) {
3793
        $oi->set_column( 'borrowernumber', $a );
3805
        $oi->set_column( 'borrowernumber', $a );
3794
        $oi->update();
3806
        $oi->update();
3795
    }
3807
    }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 374-379 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
374
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
374
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
375
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
375
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
376
('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'),
376
('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'),
377
('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'),
377
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
378
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
378
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
379
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
379
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
380
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 8613-8618 if ( CheckVersion($DBversion) ) { Link Here
8613
    SetVersion($DBversion);
8613
    SetVersion($DBversion);
8614
}
8614
}
8615
8615
8616
$DBversion = "3.13.00.XXX";
8617
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8618
   $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')");
8619
8620
   print "Upgrade to $DBversion done (Bug 9011 - Add the ability to store the last patron to return an item)\n";
8621
   SetVersion ($DBversion);
8622
}
8623
8616
=head1 FUNCTIONS
8624
=head1 FUNCTIONS
8617
8625
8618
=head2 TableExists($table)
8626
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 589-594 OPAC: Link Here
589
                  track: "Track"
589
                  track: "Track"
590
                  no: "Don't track"
590
                  no: "Don't track"
591
            - links that patrons click on
591
            - links that patrons click on
592
        -
593
            - pref: StoreLastBorrower
594
              default: 0
595
              choices:
596
                  yes: Store
597
                  no: "Don't store"
598
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
592
599
593
    Shelf Browser:
600
    Shelf Browser:
594
        -
601
        -
(-)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