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

(-)a/C4/ILSDI/Services.pm (+7 lines)
Lines 529-534 sub GetPatronInfo { Link Here
529
            # FIXME We should only retrieve what is needed in the template
529
            # FIXME We should only retrieve what is needed in the template
530
            my $issue = $c->unblessed_all_relateds;
530
            my $issue = $c->unblessed_all_relateds;
531
            delete $issue->{'more_subfields_xml'};
531
            delete $issue->{'more_subfields_xml'};
532
533
            # Is the item already on hold by another user?
534
            $issue->{'itemonhold'} = Koha::Holds->search({ itemnumber => $issue->{'itemnumber'} })->count;
535
536
            # Is the record (next available item) on hold by another user?
537
            $issue->{'recordonhold'} = Koha::Holds->search({ biblionumber => $issue->{'biblionumber'} })->count;
538
532
            push @checkouts, $issue
539
            push @checkouts, $issue
533
        }
540
        }
534
        $borrower->{'loans'}->{'loan'} = \@checkouts;
541
        $borrower->{'loans'}->{'loan'} = \@checkouts;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt (+4 lines)
Lines 650-655 Link Here
650
      <location>Salle de lecture</location>
650
      <location>Salle de lecture</location>
651
      <itemlost>0</itemlost>
651
      <itemlost>0</itemlost>
652
      <publicationyear>1985</publicationyear>
652
      <publicationyear>1985</publicationyear>
653
      <recordonhold>0</recordonhold>
654
      <itemonhold>0</itemonhold>
653
      <issues>1</issues>
655
      <issues>1</issues>
654
      <homebranch>BIB</homebranch>
656
      <homebranch>BIB</homebranch>
655
      <holdingbranch>BIB</holdingbranch>
657
      <holdingbranch>BIB</holdingbranch>
Lines 688-693 Link Here
688
      <location>Salle de lecture</location>
690
      <location>Salle de lecture</location>
689
      <itemlost>0</itemlost>
691
      <itemlost>0</itemlost>
690
      <publicationyear>2007</publicationyear>
692
      <publicationyear>2007</publicationyear>
693
      <recordonhold>1</recordonhold>
694
      <itemonhold>1</itemonhold>
691
      <issues>1</issues>
695
      <issues>1</issues>
692
      <homebranch>BIB</homebranch>
696
      <homebranch>BIB</homebranch>
693
      <holdingbranch>BIB</holdingbranch>
697
      <holdingbranch>BIB</holdingbranch>
(-)a/t/db_dependent/ILSDI_Services.t (-2 / +97 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
21
22
use Test::More tests => 12;
22
use Test::More tests => 13;
23
use Test::MockModule;
23
use Test::MockModule;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 123-128 subtest 'AuthenticatePatron test' => sub { Link Here
123
    $schema->storage->txn_rollback;
123
    $schema->storage->txn_rollback;
124
};
124
};
125
125
126
subtest 'GetPatronInfo test for holds' => sub {
127
    plan tests => 8;
128
129
    $schema->storage->txn_begin;
130
    $schema->resultset( 'Issue' )->delete_all;
131
    $schema->resultset( 'Reserve' )->delete_all;
132
    $schema->resultset( 'Borrower' )->delete_all;
133
    $schema->resultset( 'Category' )->delete_all;
134
    $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
135
    $schema->resultset( 'Branch' )->delete_all;
136
137
    # Configure Koha to enable ILS-DI server
138
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
139
140
    my $library = $builder->build_object({
141
        class => 'Koha::Libraries',
142
    });
143
144
    # Create new users:
145
    my $brwr = $builder->build_object( {
146
        class => 'Koha::Patrons',
147
        value  => {
148
            branchcode   => $library->branchcode,
149
        }
150
    } );
151
    my $brwr2 = $builder->build_object( {
152
        class => 'Koha::Patrons',
153
        value  => {
154
            branchcode   => $library->branchcode,
155
        }
156
    } );
157
    my $brwr3 = $builder->build_object( {
158
        class => 'Koha::Patrons',
159
        value  => {
160
            branchcode   => $library->branchcode,
161
        }
162
    } );
163
164
    my $module = Test::MockModule->new('C4::Context');
165
    $module->mock('userenv', sub { { branch => $library->branchcode } });
166
167
    # Place a loan
168
    my $biblio = $builder->build_object( { class => 'Koha::Biblios' } );
169
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
170
    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber } } );
171
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library->branchcode, itype => $itemtype->itemtype });
172
    my $issue = AddIssue($brwr, $item->barcode);
173
174
    # Prepare and send web request for IL-SDI server:
175
    my $query = new CGI;
176
    $query->param( 'service', 'GetPatronInfo' );
177
    $query->param( 'patron_id', $brwr->borrowernumber );
178
    $query->param( 'show_loans', '1' );
179
    my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
180
181
    # Check that this loan is not on hold
182
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "0", "Record is not on hold");
183
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is not on hold");
184
185
    # Place a loan
186
    # Add a hold on the biblio
187
    my $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr2->borrowernumber, biblionumber => $biblio->biblionumber });
188
189
    # Check that it is on hold on biblio level
190
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
191
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "1", "Record is on hold");
192
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is on hold");
193
194
    # Delete holds
195
    $schema->resultset( 'Reserve' )->delete_all;
196
197
    # Add a hold on the item
198
    my $itemreserve = AddReserve({
199
             branchcode => $library->branchcode,
200
             borrowernumber => $brwr2->borrowernumber,
201
             biblionumber => $biblio->biblionumber,
202
             itemnumber => $item->itemnumber
203
     });
204
205
    # When a specific item has a reserve, the item is on hold as well as the record
206
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
207
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "1", "Record is on hold");
208
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
209
210
    # Add another hold on the biblio
211
    $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr3->borrowernumber, biblionumber => $biblio->biblionumber });
212
213
    # Check that there are 2 holds on the biblio and 1 on this specific item
214
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
215
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "2", "Record is on hold twice");
216
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
217
218
    # Cleanup
219
    $schema->storage->txn_rollback;
220
221
};
126
222
127
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
223
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
128
224
129
- 

Return to bug 21284