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
use Modern::Perl;
17
use Modern::Perl;
18
use JSON;
18
use C4::Items qw( CartToShelf ModDateLastSeen );
19
use C4::Items qw( CartToShelf ModDateLastSeen );
20
use C4::Log qw( logaction );
19
use Koha::Database;
21
use Koha::Database;
20
use Koha::DateUtils qw( dt_from_string );
22
use Koha::DateUtils qw( dt_from_string );
Lines 171-176 sub cancel { Link Here
171
    return $self;
173
    return $self;
172
}
174
}
175
176
=head3 store
177
178
Transfer specific store method to log transfer createion
179
180
=cut
181
182
sub store {
183
    my ($self) = @_;
184
185
    $self->_result->result_source->schema->txn_do(
186
        sub {
187
            $self = $self->SUPER::store;
188
189
            my $action = $self->in_storage ? 'UPDATE' : 'CREATE';
190
191
            logaction( "TRANSFERS", $action, $self->itemnumber,
192
                JSON->new->utf8(1)->pretty(1)->encode($self->TO_JSON) )
193
              if C4::Context->preference("TransfersLog");
194
        }
195
    );
196
    return $self;
197
}
198
173
=head3 type
199
=head3 type
174
=cut
200
=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
    Debugging:
123
    Debugging:
118
        -
124
        -
(-)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
[%        CASE %][% module | html %]
102
[%        CASE %][% module | html %]
102
[%    END %]
103
[%    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
subtest 'request_transfer' => sub {
707
subtest 'request_transfer' => sub {
708
    plan tests => 13;
708
    plan tests => 17;
709
    $schema->storage->txn_begin;
709
    $schema->storage->txn_begin;
710
    my $library1 = $builder->build_object( { class => 'Koha::Libraries' } );
710
    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
    # Successful request
729
    $schema->resultset('ActionLog')->search()->delete();
730
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
730
    my $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
731
    my $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
731
    is( ref($transfer), 'Koha::Item::Transfer',
732
    is( ref($transfer), 'Koha::Item::Transfer',
732
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
733
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
733
    );
734
    );
735
    is( $schema->resultset('ActionLog')->count(), 0, 'False value for TransfersLog does not trigger logging' );
736
    $transfer->delete;
737
    t::lib::Mocks::mock_preference( 'TransfersLog', 1 );
738
    $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
739
    is( ref($transfer), 'Koha::Item::Transfer',
740
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
741
    );
742
    is( $schema->resultset('ActionLog')->count(), 1, 'True value for TransfersLog does trigger logging' );
743
    $transfer->delete;
744
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
745
746
    # Successful request
747
    $transfer = $item->request_transfer({ to => $library1, reason => 'Manual' });
748
    is( ref($transfer), 'Koha::Item::Transfer',
749
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
750
    );
751
734
    my $original_transfer = $transfer->get_from_storage;
752
    my $original_transfer = $transfer->get_from_storage;
735
    # Transfer already in progress
753
    # Transfer already in progress
736
-

Return to bug 32034