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 613-618 sub handle_checkout { Link Here
613
        }
613
        }
614
    }
614
    }
615
615
616
    $resp .= $item->build_additional_item_fields_string( $server ) if $item;
617
616
    if ( $protocol_version >= 2 ) {
618
    if ( $protocol_version >= 2 ) {
617
619
618
        # Financials : return irrespective of ok status
620
        # Financials : return irrespective of ok status
Lines 680-685 sub handle_checkin { Link Here
680
    if ($item) {
682
    if ($item) {
681
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
683
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
682
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
684
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
685
        $resp .= $item->build_additional_item_fields_string( $server );
683
    }
686
    }
684
687
685
    if ( $protocol_version >= 2 ) {
688
    if ( $protocol_version >= 2 ) {
Lines 1232-1237 sub handle_item_information { Link Here
1232
1235
1233
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server );
1236
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server );
1234
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
1237
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
1238
1239
        $resp .= $item->build_additional_item_fields_string( $server );
1235
    }
1240
    }
1236
1241
1237
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1242
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
(-)a/etc/SIPconfig.xml (+1 lines)
Lines 63-68 Link Here
63
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
63
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
64
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
64
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
65
          <patron_attribute field="XY" code="CODE" />
65
          <patron_attribute field="XY" code="CODE" />
66
          <item_field field="ZY" code="permanent_location" />
66
          <syspref_overrides>
67
          <syspref_overrides>
67
              <AllFinesNeedOverride>0</AllFinesNeedOverride>
68
              <AllFinesNeedOverride>0</AllFinesNeedOverride>
68
          </syspref_overrides>
69
          </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 => 6;
24
use Test::More tests => 7;
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 167-172 subtest 'Lastseen response' => sub { Link Here
167
    $schema->storage->txn_rollback;
167
    $schema->storage->txn_rollback;
168
168
169
};
169
};
170
171
subtest "Test build_additional_item_fields_string" => sub {
172
    my $schema = Koha::Database->new->schema;
173
    $schema->storage->txn_begin;
174
175
    plan tests => 2;
176
177
    my $builder = t::lib::TestBuilder->new();
178
179
    my $item = $builder->build( { source => 'Item' } );
180
    my $ils_item = C4::SIP::ILS::Item->new( $item->{barcode} );
181
182
    my $server = {};
183
    $server->{account}->{item_field}->{code} = 'itemnumber';
184
    $server->{account}->{item_field}->{field} = 'XY';
185
    my $attribute_string = $ils_item->build_additional_item_fields_string( $server );
186
    is( $attribute_string, "XY$item->{itemnumber}|", 'Attribute field generated correctly with single param' );
187
188
    $server = {};
189
    $server->{account}->{item_field}->[0]->{code} = 'itemnumber';
190
    $server->{account}->{item_field}->[0]->{field} = 'XY';
191
    $server->{account}->{item_field}->[1]->{code} = 'biblionumber';
192
    $server->{account}->{item_field}->[1]->{field} = 'YZ';
193
    $attribute_string = $ils_item->build_additional_item_fields_string( $server );
194
    is( $attribute_string, "XY$item->{itemnumber}|YZ$item->{biblionumber}|", 'Attribute field generated correctly with multiple params' );
195
196
    $schema->storage->txn_rollback;
197
};
198
170
# Here is room for some more subtests
199
# Here is room for some more subtests
171
200
172
# END of main code
201
# END of main code
173
- 

Return to bug 24165