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

(-)a/C4/SIP/ILS/Item.pm (+32 lines)
Lines 14-19 use Carp; Link Here
14
use Template;
14
use Template;
15
15
16
use C4::SIP::ILS::Transaction;
16
use C4::SIP::ILS::Transaction;
17
use C4::SIP::Sip qw(add_field);
17
18
18
use C4::Debug;
19
use C4::Debug;
19
use C4::Context;
20
use C4::Context;
Lines 87-92 sub new { Link Here
87
    $self->{'collection_code'} = $item->ccode;
88
    $self->{'collection_code'} = $item->ccode;
88
    $self->{  'call_number'  } = $item->itemcallnumber;
89
    $self->{  'call_number'  } = $item->itemcallnumber;
89
90
91
    $self->{object} = $item;
92
90
    my $it = $item->effective_itemtype;
93
    my $it = $item->effective_itemtype;
91
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
94
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
92
    $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
95
    $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
Lines 387-392 sub fill_reserve { Link Here
387
    }
390
    }
388
    return ModReserveFill($hold);
391
    return ModReserveFill($hold);
389
}
392
}
393
394
=head2 build_additional_item_fields_string
395
396
This method builds the part of the sip message for additional item fields
397
to send in the item related message responses
398
399
=cut
400
401
sub build_additional_item_fields_string {
402
    my ( $self, $server ) = @_;
403
404
    my $string = q{};
405
406
    if ( $server->{account}->{item_field} ) {
407
        my @fields_to_send =
408
          ref $server->{account}->{item_field} eq "ARRAY"
409
          ? @{ $server->{account}->{item_field} }
410
          : ( $server->{account}->{item_field} );
411
412
        foreach my $f ( @fields_to_send ) {
413
            my $code = $f->{code};
414
            my $value = $self->{object}->$code;
415
            $string .= add_field( $f->{field}, $value );
416
        }
417
    }
418
419
    return $string;
420
}
421
390
1;
422
1;
391
__END__
423
__END__
392
424
(-)a/C4/SIP/Sip/MsgType.pm (+5 lines)
Lines 607-612 sub handle_checkout { Link Here
607
        }
607
        }
608
    }
608
    }
609
609
610
    $resp .= $item->build_additional_item_fields_string( $server ) if $item;
611
610
    if ( $protocol_version >= 2 ) {
612
    if ( $protocol_version >= 2 ) {
611
613
612
        # Financials : return irrespective of ok status
614
        # Financials : return irrespective of ok status
Lines 674-679 sub handle_checkin { Link Here
674
    if ($item) {
676
    if ($item) {
675
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
677
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
676
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
678
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
679
        $resp .= $item->build_additional_item_fields_string( $server );
677
    }
680
    }
678
681
679
    if ( $protocol_version >= 2 ) {
682
    if ( $protocol_version >= 2 ) {
Lines 1181-1186 sub handle_item_information { Link Here
1181
1184
1182
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server, $server );
1185
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server, $server );
1183
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
1186
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
1187
1188
        $resp .= $item->build_additional_item_fields_string( $server );
1184
    }
1189
    }
1185
1190
1186
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1191
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
(-)a/etc/SIPconfig.xml (+1 lines)
Lines 62-67 Link Here
62
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
62
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
63
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
63
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
64
          <patron_attribute field="XY" code="CODE" />
64
          <patron_attribute field="XY" code="CODE" />
65
          <item_field field="ZY" code="permanent_location" />
65
          <syspref_overrides>
66
          <syspref_overrides>
66
              <AllFinesNeedOverride>0</AllFinesNeedOverride>
67
              <AllFinesNeedOverride>0</AllFinesNeedOverride>
67
          </syspref_overrides>
68
          </syspref_overrides>
(-)a/t/db_dependent/SIP/Message.t (-2 / +30 lines)
Lines 21-27 Link Here
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use Test::More tests => 4;
24
use Test::More tests => 5;
25
use Test::MockObject;
25
use Test::MockObject;
26
use Test::MockModule;
26
use Test::MockModule;
27
use Test::Warn;
27
use Test::Warn;
Lines 123-128 subtest 'Lastseen response' => sub { Link Here
123
    $schema->storage->txn_rollback;
123
    $schema->storage->txn_rollback;
124
124
125
};
125
};
126
127
subtest "Test build_additional_item_fields_string" => sub {
128
    my $schema = Koha::Database->new->schema;
129
    $schema->storage->txn_begin;
130
131
    plan tests => 2;
132
133
    my $builder = t::lib::TestBuilder->new();
134
135
    my $item = $builder->build( { source => 'Item' } );
136
    my $ils_item = C4::SIP::ILS::Item->new( $item->{barcode} );
137
138
    my $server = {};
139
    $server->{account}->{item_field}->{code} = 'itemnumber';
140
    $server->{account}->{item_field}->{field} = 'XY';
141
    my $attribute_string = $ils_item->build_additional_item_fields_string( $server );
142
    is( $attribute_string, "XY$item->{itemnumber}|", 'Attribute field generated correctly with single param' );
143
144
    $server = {};
145
    $server->{account}->{item_field}->[0]->{code} = 'itemnumber';
146
    $server->{account}->{item_field}->[0]->{field} = 'XY';
147
    $server->{account}->{item_field}->[1]->{code} = 'biblionumber';
148
    $server->{account}->{item_field}->[1]->{field} = 'YZ';
149
    $attribute_string = $ils_item->build_additional_item_fields_string( $server );
150
    is( $attribute_string, "XY$item->{itemnumber}|YZ$item->{biblionumber}|", 'Attribute field generated correctly with multiple params' );
151
152
    $schema->storage->txn_rollback;
153
};
154
126
# Here is room for some more subtests
155
# Here is room for some more subtests
127
156
128
# END of main code
157
# END of main code
129
- 

Return to bug 24165