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 (-42 / +31 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 146-205 subtest 'GetPatronInfo test for holds' => sub { Link Here
146
    # Configure Koha to enable ILS-DI server
146
    # Configure Koha to enable ILS-DI server
147
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
147
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
148
148
149
    # Set up a library/branch for our user to belong to:
149
    my $library = $builder->build_object({
150
    my $branchcode = 'T_ILSDI';
150
        class => 'Koha::Libraries',
151
    my $lib = $builder->build( {
151
    });
152
        source => 'Branch',
153
        value => {
154
            branchcode => $branchcode,
155
        }
156
    } );
157
158
    # Create a new category for user to belong to:
159
    my $cat = $builder->build( {
160
        source => 'Category',
161
        value  => {
162
            category_type                 => 'A',
163
            BlockExpiredPatronOpacActions => -1,
164
        }
165
    } );
166
152
167
    # Create new users:
153
    # Create new users:
168
    my $brwr = $builder->build( {
154
    my $brwr = $builder->build_object( {
169
        source => 'Borrower',
155
        class => 'Koha::Patrons',
170
        value  => {
156
        value  => {
171
            categorycode => $cat->{'categorycode'},
157
            branchcode   => $library->branchcode,
172
            branchcode   => $lib->{'branchcode'},
173
        }
158
        }
174
    } );
159
    } );
175
    my $brwr2 = $builder->build( {
160
    my $brwr2 = $builder->build_object( {
176
        source => 'Borrower',
161
        class => 'Koha::Patrons',
177
        value  => {
162
        value  => {
178
            categorycode => $cat->{'categorycode'},
163
            branchcode   => $library->branchcode,
179
            branchcode   => $lib->{'branchcode'},
180
        }
164
        }
181
    } );
165
    } );
182
    my $brwr3 = $builder->build( {
166
    my $brwr3 = $builder->build_object( {
183
        source => 'Borrower',
167
        class => 'Koha::Patrons',
184
        value  => {
168
        value  => {
185
            categorycode => $cat->{'categorycode'},
169
            branchcode   => $library->branchcode,
186
            branchcode   => $lib->{'branchcode'},
187
        }
170
        }
188
    } );
171
    } );
189
172
173
    my $module = Test::MockModule->new('C4::Context');
174
    $module->mock('userenv', sub { { branch => $library->branchcode } });
190
175
191
    # Place a loan
176
    # Place a loan
192
    my $biblio = $builder->build( { source => 'Biblio', } );
177
    my $biblio = $builder->build_object( { class => 'Koha::Biblios' } );
193
    my $item = $builder->build( { source => 'Item', value => { biblionumber => $biblio->{biblionumber}, barcode => "mybarcode"} } );
178
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
194
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
179
    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber } } );
195
    $userenv = { flags => 1, id => $brwr->{borrowernumber}, branch => 'T_ILSDI' };
180
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library->branchcode, itype => $itemtype->itemtype });
196
    my $issue = AddIssue($brwr, $item->{barcode});
181
    $userenv = { flags => 1, id => $brwr->borrowernumber, branch => $library->branchcode };
182
    my $issue = AddIssue($brwr, $item->barcode);
197
183
198
    # Prepare and send web request for IL-SDI server:
184
    # Prepare and send web request for IL-SDI server:
199
    my $query = new CGI;
185
    my $query = new CGI;
200
    $query->param( 'service', 'GetPatronInfo' );
186
    $query->param( 'service', 'GetPatronInfo' );
201
    $query->param( 'patron_id', $brwr->{'borrowernumber'} );
187
    $query->param( 'patron_id', $brwr->borrowernumber );
202
    $query->param( 'show_attributes', '0' );
203
    $query->param( 'show_loans', '1' );
188
    $query->param( 'show_loans', '1' );
204
    my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
189
    my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
205
190
Lines 207-214 subtest 'GetPatronInfo test for holds' => sub { Link Here
207
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "0", "Record is not on hold");
192
    is ( $reply->{loans}->{loan}[0]->{recordonhold}, "0", "Record is not on hold");
208
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is not on hold");
193
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is not on hold");
209
194
195
    # Place a loan
210
    # Add a hold on the biblio
196
    # Add a hold on the biblio
211
    my $biblioreserve = AddReserve($branchcode, $brwr2->{'borrowernumber'}, $biblio->{biblionumber});
197
    my $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr2->borrowernumber, biblionumber => $biblio->biblionumber });
212
198
213
    # Check that it is on hold on biblio level
199
    # Check that it is on hold on biblio level
214
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
200
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
Lines 219-226 subtest 'GetPatronInfo test for holds' => sub { Link Here
219
    $schema->resultset( 'Reserve' )->delete_all;
205
    $schema->resultset( 'Reserve' )->delete_all;
220
206
221
    # Add a hold on the item
207
    # Add a hold on the item
222
    my $itemreserve = AddReserve($branchcode, $brwr2->{'borrowernumber'}, $biblio->{biblionumber},
208
    my $itemreserve = AddReserve({
223
                                 [$biblio->{biblionumber}], undef, undef, undef, undef, undef, $item->{itemnumber});
209
             branchcode => $library->branchcode,
210
             borrowernumber => $brwr2->borrowernumber,
211
             biblionumber => $biblio->biblionumber,
212
             itemnumber => $item->itemnumber
213
     });
224
214
225
    # When a specific item has a reserve, the item is on hold as well as the record
215
    # When a specific item has a reserve, the item is on hold as well as the record
226
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
216
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
Lines 228-234 subtest 'GetPatronInfo test for holds' => sub { Link Here
228
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
218
    is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold");
229
219
230
    # Add another hold on the biblio
220
    # Add another hold on the biblio
231
    $biblioreserve = AddReserve($branchcode, $brwr3->{'borrowernumber'}, $biblio->{biblionumber});
221
    $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr3->borrowernumber, biblionumber => $biblio->biblionumber });
232
222
233
    # Check that there are 2 holds on the biblio and 1 on this specific item
223
    # Check that there are 2 holds on the biblio and 1 on this specific item
234
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
224
    $reply = C4::ILSDI::Services::GetPatronInfo( $query );
235
- 

Return to bug 21284