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 122-127 subtest 'AuthenticatePatron test' => sub { Link Here
122
    $schema->storage->txn_rollback;
122
    $schema->storage->txn_rollback;
123
};
123
};
124
124
125
subtest 'GetPatronInfo test for holds' => sub {
126
    plan tests => 8;
127
128
    $schema->storage->txn_begin;
129
    $schema->resultset( 'Issue' )->delete_all;
130
    $schema->resultset( 'Reserve' )->delete_all;
131
    $schema->resultset( 'Borrower' )->delete_all;
132
    $schema->resultset( 'Category' )->delete_all;
133
    $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
134
    $schema->resultset( 'Branch' )->delete_all;
135
136
    # Configure Koha to enable ILS-DI server
137
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
138
139
    my $library = $builder->build_object({
140
        class => 'Koha::Libraries',
141
    });
142
143
    # Create new users:
144
    my $brwr = $builder->build_object( {
145
        class => 'Koha::Patrons',
146
        value  => {
147
            branchcode   => $library->branchcode,
148
        }
149
    } );
150
    my $brwr2 = $builder->build_object( {
151
        class => 'Koha::Patrons',
152
        value  => {
153
            branchcode   => $library->branchcode,
154
        }
155
    } );
156
    my $brwr3 = $builder->build_object( {
157
        class => 'Koha::Patrons',
158
        value  => {
159
            branchcode   => $library->branchcode,
160
        }
161
    } );
162
163
    my $module = Test::MockModule->new('C4::Context');
164
    $module->mock('userenv', sub { { branch => $library->branchcode } });
165
166
    # Place a loan
167
    my $biblio = $builder->build_object( { class => 'Koha::Biblios' } );
168
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
169
    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber } } );
170
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library->branchcode, itype => $itemtype->itemtype });
171
    my $issue = AddIssue($brwr, $item->barcode);
172
173
    # Prepare and send web request for IL-SDI server:
174
    my $query = new CGI;
175
    $query->param( 'service', 'GetPatronInfo' );
176
    $query->param( 'patron_id', $brwr->borrowernumber );
177
    $query->param( 'show_loans', '1' );
178
    my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
179
180
    # Check that this loan is not on hold
181
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "0", "Record is not on hold");
182
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is not on hold");
183
184
    # Place a loan
185
    # Add a hold on the biblio
186
    my $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr2->borrowernumber, biblionumber => $biblio->biblionumber });
187
188
    # Check that it is on hold on biblio level
189
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
190
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "1", "Record is on hold");
191
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is on hold");
192
193
    # Delete holds
194
    $schema->resultset( 'Reserve' )->delete_all;
195
196
    # Add a hold on the item
197
    my $itemreserve = AddReserve({
198
             branchcode => $library->branchcode,
199
             borrowernumber => $brwr2->borrowernumber,
200
             biblionumber => $biblio->biblionumber,
201
             itemnumber => $item->itemnumber
202
     });
203
204
    # When a specific item has a reserve, the item is on hold as well as the record
205
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
206
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "1", "Record is on hold");
207
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
208
209
    # Add another hold on the biblio
210
    $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr3->borrowernumber, biblionumber => $biblio->biblionumber });
211
212
    # Check that there are 2 holds on the biblio and 1 on this specific item
213
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
214
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "2", "Record is on hold twice");
215
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
216
217
    # Cleanup
218
    $schema->storage->txn_rollback;
219
220
};
125
221
126
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
222
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
127
223
128
- 

Return to bug 21284