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

(-)a/Koha/Item/Transfer.pm (-1 / +33 lines)
Lines 17-23 package Koha::Item::Transfer; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use JSON qw(to_json);
21
20
use C4::Items qw( CartToShelf ModDateLastSeen );
22
use C4::Items qw( CartToShelf ModDateLastSeen );
23
use C4::Log   qw( logaction );
21
24
22
use Koha::Database;
25
use Koha::Database;
23
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
Lines 31-40 Koha::Item::Transfer - Koha Item Transfer Object class Link Here
31
34
32
=head1 API
35
=head1 API
33
36
34
=head2 Class Methods
37
=head2 Class methods
38
39
=head3 store
40
41
Overloaded I<store> method.
35
42
36
=cut
43
=cut
37
44
45
sub store {
46
    my ($self) = @_;
47
48
    $self->_result->result_source->schema->txn_do(
49
        sub {
50
            my $action = $self->in_storage ? 'UPDATE' : 'CREATE';
51
52
            $self = $self->SUPER::store;
53
            $self->discard_changes;
54
55
            logaction(
56
                "TRANSFERS",
57
                $action,
58
                $self->itemnumber,
59
                to_json(
60
                    $self->TO_JSON,
61
                    { utf8 => 1, pretty => 1, canonical => 1, }
62
                )
63
            ) if C4::Context->preference("TransfersLog");
64
        }
65
    );
66
67
    return $self;
68
}
69
38
=head3 item
70
=head3 item
39
71
40
  my $item = $transfer->item;
72
  my $item = $transfer->item;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/action-logs.inc (+2 lines)
Lines 40-45 Link Here
40
        <span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %]<i class="log-disabled fa-solid fa-triangle-exclamation" title="Log not enabled" data-log="RecallsLog"></i>[% END %]
40
        <span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %]<i class="log-disabled fa-solid fa-triangle-exclamation" title="Log not enabled" data-log="RecallsLog"></i>[% END %]
41
    [% CASE 'SUGGESTION' %]
41
    [% CASE 'SUGGESTION' %]
42
        <span>Suggestions</span>[% UNLESS Koha.Preference('SuggestionsLog') %]<i class="log-disabled fa-solid fa-triangle-exclamation" title="Log not enabled" data-log="SuggestionsLog"></i>[% END %]
42
        <span>Suggestions</span>[% UNLESS Koha.Preference('SuggestionsLog') %]<i class="log-disabled fa-solid fa-triangle-exclamation" title="Log not enabled" data-log="SuggestionsLog"></i>[% END %]
43
    [% CASE 'TRANSFERS' %]
44
        <span>Transfers</span>[% UNLESS Koha.Preference('TransfersLog') %]<i class="log-disabled fa-solid fa-triangle-exclamation" title="Log not enabled" data-log="TransfersLog"></i>[% END %]
43
    [% CASE %]
45
    [% CASE %]
44
        [% module | html %]
46
        [% module | html %]
45
    [% END %]
47
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt (-1 / +1 lines)
Lines 123-129 Link Here
123
                            [% ELSE %]
123
                            [% ELSE %]
124
                                <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value="" /> All</label>
124
                                <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value="" /> All</label>
125
                            [% END %]
125
                            [% END %]
126
                            [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION' ] %]
126
                            [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION', 'TRANSFERS' ] %]
127
                                [% IF modules.grep(modx).size %]
127
                                [% IF modules.grep(modx).size %]
128
                                    <label for="module[% modx | html %]" class="viewlog"
128
                                    <label for="module[% modx | html %]" class="viewlog"
129
                                        ><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked" /> [% PROCESS translate_log_module module=modx %]</label
129
                                        ><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked" /> [% PROCESS translate_log_module module=modx %]</label
(-)a/t/db_dependent/Koha/Item.t (-3 / +29 lines)
Lines 887-894 subtest 'pickup_locations() tests' => sub { Link Here
887
    $schema->storage->txn_rollback;
887
    $schema->storage->txn_rollback;
888
};
888
};
889
889
890
subtest 'request_transfer' => sub {
890
subtest 'request_transfer() tests' => sub {
891
    plan tests => 14;
891
892
    plan tests => 18;
893
892
    $schema->storage->txn_begin;
894
    $schema->storage->txn_begin;
893
895
894
    my $library1 = $builder->build_object( { class => 'Koha::Libraries' } );
896
    my $library1 = $builder->build_object( { class => 'Koha::Libraries' } );
Lines 910-920 subtest 'request_transfer' => sub { Link Here
910
        'Exception thrown if `to` parameter is missing';
912
        'Exception thrown if `to` parameter is missing';
911
913
912
    # Successful request
914
    # Successful request
915
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
916
917
    $schema->resultset('ActionLog')->search()->delete();
913
    my $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } );
918
    my $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } );
914
    is(
919
    is(
915
        ref($transfer), 'Koha::Item::Transfer',
920
        ref($transfer), 'Koha::Item::Transfer',
916
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
921
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
917
    );
922
    );
923
    is( $schema->resultset('ActionLog')->count(), 0, 'False value for TransfersLog does not trigger logging' );
924
    $transfer->delete;
925
926
    t::lib::Mocks::mock_preference( 'TransfersLog', 1 );
927
928
    $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } );
929
    is(
930
        ref($transfer), 'Koha::Item::Transfer',
931
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
932
    );
933
    is( $schema->resultset('ActionLog')->count(), 1, 'True value for TransfersLog does trigger logging' );
934
    $transfer->delete;
935
936
    t::lib::Mocks::mock_preference( 'TransfersLog', 0 );
937
938
    # Successful request
939
    $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } );
940
    is(
941
        ref($transfer), 'Koha::Item::Transfer',
942
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
943
    );
944
918
    my $original_transfer = $transfer->get_from_storage;
945
    my $original_transfer = $transfer->get_from_storage;
919
946
920
    # Transfer already in progress
947
    # Transfer already in progress
921
- 

Return to bug 32034