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

(-)a/C4/SIP/ILS/Patron.pm (+31 lines)
Lines 15-20 use Carp; Link Here
15
use Sys::Syslog qw(syslog);
15
use Sys::Syslog qw(syslog);
16
use Data::Dumper;
16
use Data::Dumper;
17
17
18
use C4::SIP::Sip qw(add_field);
19
18
use C4::Debug;
20
use C4::Debug;
19
use C4::Context;
21
use C4::Context;
20
use C4::Koha;
22
use C4::Koha;
Lines 474-479 sub _get_outstanding_holds { Link Here
474
    return \@holds;
476
    return \@holds;
475
}
477
}
476
478
479
sub build_patron_attributes_string {
480
    my ( $self, $server ) = @_;
481
482
    my $string = q{};
483
484
    if ( $server->{account}->{patron_attribute} ) {
485
        my @attributes_to_send =
486
          ref $server->{account}->{patron_attribute} eq "ARRAY"
487
          ? @{ $server->{account}->{patron_attribute} }
488
          : ( $server->{account}->{patron_attribute} );
489
490
        foreach my $a ( @attributes_to_send ) {
491
            my @attributes = Koha::Patron::Attributes->search(
492
                {
493
                    borrowernumber => $self->{borrowernumber},
494
                    code           => $a->{code}
495
                }
496
            );
497
498
            foreach my $attribute ( @attributes ) {
499
                my $value = $attribute->attribute();
500
                $string .= add_field( $a->{field}, $value );
501
            }
502
        }
503
    }
504
505
    return $string;
506
}
507
477
1;
508
1;
478
__END__
509
__END__
479
510
(-)a/C4/SIP/Sip/MsgType.pm (+6 lines)
Lines 19-24 use Data::Dumper; Link Here
19
use CGI qw ( -utf8 );
19
use CGI qw ( -utf8 );
20
use C4::Auth qw(&check_api_auth);
20
use C4::Auth qw(&check_api_auth);
21
21
22
use Koha::Patron::Attributes;
23
22
use UNIVERSAL::can;
24
use UNIVERSAL::can;
23
25
24
use vars qw(@ISA @EXPORT_OK);
26
use vars qw(@ISA @EXPORT_OK);
Lines 443-448 sub build_patron_status { Link Here
443
          if ( $server->{account}->{send_patron_home_library_in_af} );
445
          if ( $server->{account}->{send_patron_home_library_in_af} );
444
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
446
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
445
447
448
        $resp .= $patron->build_patron_attributes_string( $server );
449
446
    } else {
450
    } else {
447
        # Invalid patron (cardnumber)
451
        # Invalid patron (cardnumber)
448
        # Report that the user has no privs.
452
        # Report that the user has no privs.
Lines 1001-1006 sub handle_patron_info { Link Here
1001
            $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server);
1005
            $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server);
1002
        }
1006
        }
1003
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
1007
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
1008
1009
        $resp .= $patron->build_patron_attributes_string( $server );
1004
    } else {
1010
    } else {
1005
1011
1006
        # Invalid patron ID:
1012
        # Invalid patron ID:
(-)a/etc/SIPconfig.xml (+1 lines)
Lines 56-61 Link Here
56
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >
56
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >
57
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
57
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
58
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
58
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
59
          <patron_attribute field="XY" code="CODE" />
59
      </login>
60
      </login>
60
  </accounts>
61
  </accounts>
61
62
(-)a/t/db_dependent/SIP/Patron.t (-2 / +43 lines)
Lines 4-15 Link Here
4
# This needs to be extended! Your help is appreciated..
4
# This needs to be extended! Your help is appreciated..
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 3;
7
use Test::More tests => 4;
8
8
9
use Koha::Database;
9
use Koha::Database;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
11
use t::lib::Mocks;
11
use t::lib::Mocks;
12
use C4::SIP::ILS::Patron;
12
use C4::SIP::ILS::Patron;
13
use Koha::Patron::Attributes;
13
14
14
my $schema = Koha::Database->new->schema;
15
my $schema = Koha::Database->new->schema;
15
$schema->storage->txn_begin;
16
$schema->storage->txn_begin;
Lines 72-75 subtest "OverduesBlockCirc tests" => sub { Link Here
72
73
73
};
74
};
74
75
76
subtest "Test build_patron_attribute_string" => sub {
77
78
    plan tests => 2;
79
80
    my $patron = $builder->build( { source => 'Borrower' } );
81
82
    my $attribute_type = $builder->build( { source => 'BorrowerAttributeType' } );
83
    my $attribute = Koha::Patron::Attribute->new(
84
        {
85
            borrowernumber => $patron->{borrowernumber},
86
            code           => $attribute_type->{code},
87
            attribute      => 'Test Attribute'
88
        }
89
    )->store();
90
91
    my $attribute_type2 = $builder->build( { source => 'BorrowerAttributeType' } );
92
    my $attribute2 = Koha::Patron::Attribute->new(
93
        {
94
            borrowernumber => $patron->{borrowernumber},
95
            code           => $attribute_type2->{code},
96
            attribute      => 'Another Test Attribute'
97
        }
98
    )->store();
99
100
    my $ils_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber} );
101
102
    my $server = {};
103
    $server->{account}->{patron_attribute}->{code} = $attribute->code;
104
    $server->{account}->{patron_attribute}->{field} = 'XY';
105
    my $attribute_string = $ils_patron->build_patron_attributes_string( $server );
106
    is( $attribute_string, "XYTest Attribute|", 'Attribute field generated correctly with single param' );
107
108
    $server = {};
109
    $server->{account}->{patron_attribute}->[0]->{code} = $attribute->code;
110
    $server->{account}->{patron_attribute}->[0]->{field} = 'XY';
111
    $server->{account}->{patron_attribute}->[1]->{code} = $attribute2->code;
112
    $server->{account}->{patron_attribute}->[1]->{field} = 'YZ';
113
    $attribute_string = $ils_patron->build_patron_attributes_string( $server );
114
    is( $attribute_string, "XYTest Attribute|YZAnother Test Attribute|", 'Attribute field generated correctly with multiple params' );
115
};
116
75
$schema->storage->txn_rollback;
117
$schema->storage->txn_rollback;
76
- 

Return to bug 17826