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

(-)a/C4/ILSDI/Services.pm (-5 / +9 lines)
Lines 328-334 Parameters: Link Here
328
328
329
sub AuthenticatePatron {
329
sub AuthenticatePatron {
330
    my ($cgi) = @_;
330
    my ($cgi) = @_;
331
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') );
331
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, scalar $cgi->param('username'), scalar $cgi->param('password') );
332
    if ( $status ) {
332
    if ( $status ) {
333
        # Get the borrower
333
        # Get the borrower
334
        my $borrower = GetMember( cardnumber => $cardnumber );
334
        my $borrower = GetMember( cardnumber => $cardnumber );
Lines 377-383 sub GetPatronInfo { Link Here
377
    delete $borrower->{'password'};
377
    delete $borrower->{'password'};
378
378
379
    # Contact fields management
379
    # Contact fields management
380
    if ( $cgi->param('show_contact') eq "0" ) {
380
    my $show_contact = $cgi->param('show_contact') // '1';
381
    if ( $show_contact eq "0" ) {
381
382
382
        # Define contact fields
383
        # Define contact fields
383
        my @contactfields = (
384
        my @contactfields = (
Lines 394-400 sub GetPatronInfo { Link Here
394
    }
395
    }
395
396
396
    # Fines management
397
    # Fines management
397
    if ( $cgi->param('show_fines') eq "1" ) {
398
    my $show_fines = $cgi->param('show_fines') // '0';
399
    if ( $show_fines eq '1' ) {
398
        my @charges;
400
        my @charges;
399
        for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) {
401
        for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) {
400
            push( @charges, @charge );
402
            push( @charges, @charge );
Lines 403-409 sub GetPatronInfo { Link Here
403
    }
405
    }
404
406
405
    # Reserves management
407
    # Reserves management
406
    if ( $cgi->param('show_holds') eq "1" ) {
408
    my $show_holds = $cgi->param('show_holds') // '0';
409
    if ( $show_holds eq '1' ) {
407
410
408
        # Get borrower's reserves
411
        # Get borrower's reserves
409
        my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef );
412
        my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef );
Lines 427-433 sub GetPatronInfo { Link Here
427
    }
430
    }
428
431
429
    # Issues management
432
    # Issues management
430
    if ( $cgi->param('show_loans') eq "1" ) {
433
    my $show_loans = $cgi->param('show_loans') // '0';
434
    if ( $show_loans eq '1' ) {
431
        my $issues = GetPendingIssues($borrowernumber);
435
        my $issues = GetPendingIssues($borrowernumber);
432
        foreach my $issue ( @$issues ){
436
        foreach my $issue ( @$issues ){
433
            $issue->{'issuedate'} = $issue->{'issuedate'}->strftime('%Y-%m-%d %H:%M');
437
            $issue->{'issuedate'} = $issue->{'issuedate'}->strftime('%Y-%m-%d %H:%M');
(-)a/t/db_dependent/ILSDI_Services.t (-7 / +64 lines)
Lines 3-12 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Members qw/AddMember GetMember GetBorrowercategory/;
5
use C4::Members qw/AddMember GetMember GetBorrowercategory/;
6
use C4::Biblio qw( AddBiblio );
7
use C4::Items qw( AddItem );
8
use C4::Reserves qw( AddReserve GetReserve );
6
use Koha::Libraries;
9
use Koha::Libraries;
7
use CGI qw ( -utf8 );
10
use CGI qw ( -utf8 );
11
use MARC::Record;
8
12
9
use Test::More tests => 16;
13
use Test::More tests => 4;
10
use t::lib::Mocks;
14
use t::lib::Mocks;
11
use t::lib::TestBuilder;
15
use t::lib::TestBuilder;
12
16
Lines 48-54 unless ( Koha::Libraries->find('UT') ) { Link Here
48
my $borrowernumber = AddMember(%data);
52
my $borrowernumber = AddMember(%data);
49
my $borrower = GetMember( borrowernumber => $borrowernumber );
53
my $borrower = GetMember( borrowernumber => $borrowernumber );
50
54
51
{ # AuthenticatePatron test
55
subtest 'AuthenticatePatron' => sub {
56
    plan tests => 14;
52
57
53
    my $query = new CGI;
58
    my $query = new CGI;
54
    $query->param('username',$borrower->{'userid'});
59
    $query->param('username',$borrower->{'userid'});
Lines 89-96 my $borrower = GetMember( borrowernumber => $borrowernumber ); Link Here
89
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
94
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
90
    is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound");
95
    is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound");
91
    is($reply->{'id'}, undef, "id undef");
96
    is($reply->{'id'}, undef, "id undef");
92
97
};
93
}
94
98
95
# End transaction
99
# End transaction
96
$dbh->rollback;
100
$dbh->rollback;
Lines 109-115 $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this Link Here
109
$schema->resultset( 'Branch' )->delete_all;
113
$schema->resultset( 'Branch' )->delete_all;
110
114
111
115
112
{ # GetPatronInfo/GetBorrowerAttributes test for extended patron attributes:
116
subtest 'GetPatronInfo/GetBorrowerAttributes for extended patron attributes' => sub {
117
    plan tests => 1;
113
118
114
    # Configure Koha to enable ILS-DI server and extended attributes:
119
    # Configure Koha to enable ILS-DI server and extended attributes:
115
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
120
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
Lines 195-201 $schema->resultset( 'Branch' )->delete_all; Link Here
195
200
196
    # Check results:
201
    # Check results:
197
    is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' );
202
    is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' );
198
}
203
};
204
205
$schema->storage->txn_rollback;
206
$schema->storage->txn_begin;
207
208
subtest 'GetRecords' => sub {
209
    plan tests => 1;
210
211
    t::lib::Mocks::mock_preference('ILS-DI', 1);
212
213
    my $builder = t::lib::TestBuilder->new;
214
215
    my $branch = $builder->build({
216
        source => 'Branch',
217
        value => {
218
            branchcode => 'T_ILSDI',
219
        }
220
    });
221
222
    my $category = $builder->build({
223
        source => 'Category',
224
        value  => {
225
            category_type => 'A',
226
        }
227
    });
228
229
    # Create a new user:
230
    my $borrower = $builder->build({
231
        source => 'Borrower',
232
        value  => {
233
            categorycode => $category->{categorycode},
234
            branchcode   => $branch,
235
        }
236
    });
237
238
    my ($biblionumber) = AddBiblio(MARC::Record->new, '');
239
    my $item = {};
240
    my $itemnumber = AddItem($item, $biblionumber);
241
242
    my $reserve_id = AddReserve($branch, $borrower->{borrowernumber}, $biblionumber);
243
244
    # Prepare and send web request for IL-SDI server:
245
    my $query = new CGI;
246
    $query->param( 'service', 'GetRecords' );
247
    $query->param( 'id', $biblionumber );
248
249
    my $response = C4::ILSDI::Services::GetRecords( $query );
250
251
    my $reserve = GetReserve($reserve_id);
252
    $reserve->{rtimestamp} = $reserve->{timestamp};
253
254
    is_deeply( $response->{record}->[0]->{reserves}->{reserve}, [ $reserve ],
255
        'GetRecords /record/reserves/reserve is as expected' );
256
};
199
257
200
# Cleanup
258
# Cleanup
201
$schema->storage->txn_rollback;
259
$schema->storage->txn_rollback;
202
- 

Return to bug 16246