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

(-)a/Koha/Item/Transfer.pm (+26 lines)
Lines 17-24 package Koha::Item::Transfer; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use JSON;
20
21
21
use C4::Items qw( CartToShelf ModDateLastSeen );
22
use C4::Items qw( CartToShelf ModDateLastSeen );
23
use C4::Log qw( logaction );
22
24
23
use Koha::Database;
25
use Koha::Database;
24
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
Lines 171-176 sub cancel { Link Here
171
    return $self;
173
    return $self;
172
}
174
}
173
175
176
177
=head3 store
178
179
Transfer specific store method to log transfer createion
180
181
=cut
182
183
sub store {
184
    my ($self) = @_;
185
186
    $self->_result->result_source->schema->txn_do(
187
        sub {
188
            $self = $self->SUPER::store;
189
190
            my $action = $self->in_storage ? 'UPDATE' : 'CREATE';
191
192
            logaction( "TRANFERS", $action, $self->itemnumber,
193
                JSON->new->utf8(1)->pretty(1)->encode($self->TO_JSON) )
194
              if C4::Context->preference("TransfersLog");
195
        }
196
    );
197
    return $self;
198
}
199
174
=head3 type
200
=head3 type
175
201
176
=cut
202
=cut
(-)a/installer/data/mysql/atomicupdate/bug_32034.pl (+15 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "32034",
5
    description => "Library branch transfers should be in the action logs",
6
    up => sub {
7
        my ($args) = @_;
8
        my $dbh = $args->{dbh};
9
10
        $dbh->do( q{
11
            INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
12
            VALUES ('TransfersLog', '0', 'If enabled, log item transfer changes', '', 'YesNo')
13
        });
14
    },
15
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +2 lines)
Lines 733-741 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
733
('TraceSubjectSubdivisions','0','1','Create searches on all subdivisions for subject tracings.','YesNo'),
733
('TraceSubjectSubdivisions','0','1','Create searches on all subdivisions for subject tracings.','YesNo'),
734
('TrackClicks','0',NULL,'Track links clicked','Integer'),
734
('TrackClicks','0',NULL,'Track links clicked','Integer'),
735
('TrackLastPatronActivity','0',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron is seen','YesNo'),
735
('TrackLastPatronActivity','0',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron is seen','YesNo'),
736
('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'),
736
('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo'),
737
('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo'),
738
('TransfersLog','0',NULL,'If enabled, log item transfer changes','YesNo'),
737
('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'),
739
('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'),
738
('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'),
739
('TranslateNotices','0',NULL, 'Allow notices to be translated','YesNo'),
740
('TranslateNotices','0',NULL, 'Allow notices to be translated','YesNo'),
740
('TrapHoldsOnOrder','1',NULL,'If enabled, Koha will trap holds for on order items ( notforloan < 0 )','YesNo'),
741
('TrapHoldsOnOrder','1',NULL,'If enabled, Koha will trap holds for on order items ( notforloan < 0 )','YesNo'),
741
('TwoFactorAuthentication', 'disabled', 'enforced|enabled|disabled', 'Enables two-factor authentication', 'Choice'),
742
('TwoFactorAuthentication', 'disabled', 'enforced|enabled|disabled', 'Enables two-factor authentication', 'Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref (+6 lines)
Lines 114-119 Logging: Link Here
114
                  1: Log
114
                  1: Log
115
                  0: "Don't log"
115
                  0: "Don't log"
116
            - any actions on recalls (create, cancel, expire, fulfill).
116
            - any actions on recalls (create, cancel, expire, fulfill).
117
        -
118
            - pref: TransfersLog
119
              choices:
120
                  1: Log
121
                  0: "Don't log"
122
            - " item transfers."
117
123
118
    Debugging:
124
    Debugging:
119
        -
125
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt (-1 / +2 lines)
Lines 98-103 Link Here
98
[%        CASE 'NOTICES'      %]<span>Notices</span>[% UNLESS Koha.Preference('NoticesLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
98
[%        CASE 'NOTICES'      %]<span>Notices</span>[% UNLESS Koha.Preference('NoticesLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
99
[%        CASE 'NEWS'      %]<span>News</span>[% UNLESS Koha.Preference('NewsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
99
[%        CASE 'NEWS'      %]<span>News</span>[% UNLESS Koha.Preference('NewsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
100
[%        CASE 'RECALLS'      %]<span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
100
[%        CASE 'RECALLS'      %]<span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
101
[%        CASE 'TRANSFERS'    %]<span>Transfers</span>[% UNLESS Koha.Preference('TransfersLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
101
102
102
[%        CASE %][% module | html %]
103
[%        CASE %][% module | html %]
103
[%    END %]
104
[%    END %]
Lines 221-227 Link Here
221
                                        [% ELSE %]
222
                                        [% ELSE %]
222
                                            <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label>
223
                                            <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label>
223
                                        [% END %]
224
                                        [% END %]
224
                                        [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS' ] %]
225
                                        [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'TRANSFERS' ] %]
225
                                            [% IF modules.grep(modx).size %]
226
                                            [% IF modules.grep(modx).size %]
226
                                                <label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label>
227
                                                <label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label>
227
                                            [% ELSE %]
228
                                            [% ELSE %]
(-)a/t/db_dependent/Koha/Item.t (-3 / +20 lines)
Lines 706-712 subtest 'pickup_locations' => sub { Link Here
706
};
706
};
707
707
708
subtest 'request_transfer' => sub {
708
subtest 'request_transfer' => sub {
709
    plan tests => 13;
709
    plan tests => 17;
710
    $schema->storage->txn_begin;
710
    $schema->storage->txn_begin;
711
711
712
    my $library1 = $builder->build_object( { class => 'Koha::Libraries' } );
712
    my $library1 = $builder->build_object( { class => 'Koha::Libraries' } );
Lines 727-737 subtest 'request_transfer' => sub { Link Here
727
    'Koha::Exceptions::MissingParameter',
727
    'Koha::Exceptions::MissingParameter',
728
      'Exception thrown if `to` parameter is missing';
728
      'Exception thrown if `to` parameter is missing';
729
729
730
    # Successful request
730
    $schema->resultset('ActionLog')->search()->delete();
731
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
731
    my $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
732
    my $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
732
    is( ref($transfer), 'Koha::Item::Transfer',
733
    is( ref($transfer), 'Koha::Item::Transfer',
733
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
734
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
734
    );
735
    );
736
    is( $schema->resultset('ActionLog')->count(), 0, 'False value for TransfersLog does not trigger logging' );
737
    $transfer->delete;
738
    t::lib::Mocks::mock_preference( 'TransfersLog', 1 );
739
    $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
740
    is( ref($transfer), 'Koha::Item::Transfer',
741
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
742
    );
743
    is( $schema->resultset('ActionLog')->count(), 1, 'True value for TransfersLog does trigger logging' );
744
    $transfer->delete;
745
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
746
747
    # Successful request
748
    $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
749
    is( ref($transfer), 'Koha::Item::Transfer',
750
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
751
    );
752
735
    my $original_transfer = $transfer->get_from_storage;
753
    my $original_transfer = $transfer->get_from_storage;
736
754
737
    # Transfer already in progress
755
    # Transfer already in progress
738
- 

Return to bug 32034