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

(-)a/C4/Members.pm (-1 / +6 lines)
Lines 452-458 sub GetMember { Link Here
452
    #FIXME interface to this routine now allows generation of a result set
452
    #FIXME interface to this routine now allows generation of a result set
453
    #so whole array should be returned but bowhere in the current code expects this
453
    #so whole array should be returned but bowhere in the current code expects this
454
    if (@{$data} ) {
454
    if (@{$data} ) {
455
        return $data->[0];
455
        my $patron = $data->[0];
456
457
        my $flags = patronflags( $patron );
458
        $patron->{flags} = $flags;
459
460
        return $patron;
456
    }
461
    }
457
462
458
    return;
463
    return;
(-)a/C4/Reserves.pm (-25 / +46 lines)
Lines 29-34 use C4::Members; Link Here
29
use C4::Items;
29
use C4::Items;
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Accounts;
31
use C4::Accounts;
32
use C4::Circulation qw(CanBookBeIssued);
32
33
33
# for _koha_notify_reserve
34
# for _koha_notify_reserve
34
use C4::Members::Messaging;
35
use C4::Members::Messaging;
Lines 41-46 use Koha::Calendar; Link Here
41
use Koha::Database;
42
use Koha::Database;
42
use Koha::Hold;
43
use Koha::Hold;
43
use Koha::Holds;
44
use Koha::Holds;
45
use Koha::Items;
44
46
45
use List::MoreUtils qw( firstidx any );
47
use List::MoreUtils qw( firstidx any );
46
use Carp;
48
use Carp;
Lines 421-439 See CanItemBeReserved() for possible return values. Link Here
421
423
422
=cut
424
=cut
423
425
424
sub CanBookBeReserved{
426
sub CanBookBeReserved {
425
    my ($borrowernumber, $biblionumber) = @_;
427
    my ( $borrowernumber, $biblionumber ) = @_;
426
428
427
    my $items = GetItemnumbersForBiblio($biblionumber);
429
    my $items = GetItemnumbersForBiblio($biblionumber);
430
428
    #get items linked via host records
431
    #get items linked via host records
429
    my @hostitems = get_hostitemnumbers_of($biblionumber);
432
    my @hostitems = get_hostitemnumbers_of($biblionumber);
430
    if (@hostitems){
433
    if (@hostitems) {
431
    push (@$items,@hostitems);
434
        push( @$items, @hostitems );
432
    }
435
    }
433
436
434
    my $canReserve;
437
    my $canReserve;
435
    foreach my $item (@$items) {
438
    foreach my $itemnumber (@$items) {
436
        $canReserve = CanItemBeReserved( $borrowernumber, $item );
439
        $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber );
437
        return 'OK' if $canReserve eq 'OK';
440
        return 'OK' if $canReserve eq 'OK';
438
    }
441
    }
439
    return $canReserve;
442
    return $canReserve;
Lines 459-465 sub CanItemBeReserved{ Link Here
459
    my $dbh             = C4::Context->dbh;
462
    my $dbh             = C4::Context->dbh;
460
    my $ruleitemtype; # itemtype of the matching issuing rule
463
    my $ruleitemtype; # itemtype of the matching issuing rule
461
    my $allowedreserves = 0;
464
    my $allowedreserves = 0;
462
            
465
463
    # we retrieve borrowers and items informations #
466
    # we retrieve borrowers and items informations #
464
    # item->{itype} will come for biblioitems if necessery
467
    # item->{itype} will come for biblioitems if necessery
465
    my $item = GetItem($itemnumber);
468
    my $item = GetItem($itemnumber);
Lines 476-482 sub CanItemBeReserved{ Link Here
476
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
479
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
477
480
478
    # we retrieve user rights on this itemtype and branchcode
481
    # we retrieve user rights on this itemtype and branchcode
479
    my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed
482
    my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed, allow_hold_if_items_available
480
                             FROM issuingrules
483
                             FROM issuingrules
481
                             WHERE (categorycode in (?,'*') )
484
                             WHERE (categorycode in (?,'*') )
482
                             AND (itemtype IN (?,'*'))
485
                             AND (itemtype IN (?,'*'))
Lines 495-502 sub CanItemBeReserved{ Link Here
495
                                LEFT JOIN borrowers USING (borrowernumber)
498
                                LEFT JOIN borrowers USING (borrowernumber)
496
                            WHERE borrowernumber = ?
499
                            WHERE borrowernumber = ?
497
                                ";
500
                                ";
498
    
501
499
    
502
500
    my $branchcode   = "";
503
    my $branchcode   = "";
501
    my $branchfield  = "reserves.branchcode";
504
    my $branchfield  = "reserves.branchcode";
502
505
Lines 507-526 sub CanItemBeReserved{ Link Here
507
        $branchfield = "borrowers.branchcode";
510
        $branchfield = "borrowers.branchcode";
508
        $branchcode = $borrower->{branchcode};
511
        $branchcode = $borrower->{branchcode};
509
    }
512
    }
510
    
513
511
    # we retrieve rights 
514
    my $allow_hold_if_items_available;
515
516
    # we retrieve rights
512
    $sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode);
517
    $sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode);
513
    if(my $rights = $sth->fetchrow_hashref()){
518
    if ( my $rights = $sth->fetchrow_hashref() ) {
514
        $ruleitemtype    = $rights->{itemtype};
519
        $ruleitemtype                  = $rights->{itemtype};
515
        $allowedreserves = $rights->{reservesallowed}; 
520
        $allowedreserves               = $rights->{reservesallowed};
516
    }else{
521
        $allow_hold_if_items_available = $rights->{allow_hold_if_items_available};
522
    }
523
    else {
517
        $ruleitemtype = '*';
524
        $ruleitemtype = '*';
518
    }
525
    }
519
526
520
    # we retrieve count
527
    # we retrieve count
521
528
522
    $querycount .= "AND $branchfield = ?";
529
    $querycount .= "AND $branchfield = ?";
523
    
530
524
    # If using item-level itypes, fall back to the record
531
    # If using item-level itypes, fall back to the record
525
    # level itemtype if the hold has no associated item
532
    # level itemtype if the hold has no associated item
526
    $querycount .=
533
    $querycount .=
Lines 530-536 sub CanItemBeReserved{ Link Here
530
      if ( $ruleitemtype ne "*" );
537
      if ( $ruleitemtype ne "*" );
531
538
532
    my $sthcount = $dbh->prepare($querycount);
539
    my $sthcount = $dbh->prepare($querycount);
533
    
540
534
    if($ruleitemtype eq "*"){
541
    if($ruleitemtype eq "*"){
535
        $sthcount->execute($borrowernumber, $branchcode);
542
        $sthcount->execute($borrowernumber, $branchcode);
536
    }else{
543
    }else{
Lines 572-577 sub CanItemBeReserved{ Link Here
572
        }
579
        }
573
    }
580
    }
574
581
582
    unless ( $allow_hold_if_items_available ) {
583
        my $item = Koha::Items->find($itemnumber);
584
        my @items = Koha::Items->search({ biblionumber => $item->biblionumber });
585
        foreach $item (@items) {
586
            my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued(
587
                $borrower, $item->barcode, my $duedate,
588
                my $inprocess,
589
                my $ignore_reserves = 1
590
            );
591
592
            return 'itemsAvailable' unless ( keys %$issuingimpossible || keys %$needsconfirmation );
593
        }
594
    }
595
575
    return 'OK';
596
    return 'OK';
576
}
597
}
577
598
Lines 744-751 sub GetReservesToBranch { Link Here
744
    my $dbh = C4::Context->dbh;
765
    my $dbh = C4::Context->dbh;
745
    my $sth = $dbh->prepare(
766
    my $sth = $dbh->prepare(
746
        "SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp
767
        "SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp
747
         FROM reserves 
768
         FROM reserves
748
         WHERE priority='0' 
769
         WHERE priority='0'
749
           AND branchcode=?"
770
           AND branchcode=?"
750
    );
771
    );
751
    $sth->execute( $frombranch );
772
    $sth->execute( $frombranch );
Lines 770-776 sub GetReservesForBranch { Link Here
770
791
771
    my $query = "
792
    my $query = "
772
        SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate
793
        SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate
773
        FROM   reserves 
794
        FROM   reserves
774
        WHERE   priority='0'
795
        WHERE   priority='0'
775
        AND found='W'
796
        AND found='W'
776
    ";
797
    ";
Lines 1389-1395 sub ModReserveMinusPriority { Link Here
1389
    my $dbh   = C4::Context->dbh;
1410
    my $dbh   = C4::Context->dbh;
1390
    my $query = "
1411
    my $query = "
1391
        UPDATE reserves
1412
        UPDATE reserves
1392
        SET    priority = 0 , itemnumber = ? 
1413
        SET    priority = 0 , itemnumber = ?
1393
        WHERE  reserve_id = ?
1414
        WHERE  reserve_id = ?
1394
    ";
1415
    ";
1395
    my $sth_upd = $dbh->prepare($query);
1416
    my $sth_upd = $dbh->prepare($query);
Lines 1604-1610 sub ToggleLowestPriority { Link Here
1604
1625
1605
    my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?");
1626
    my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?");
1606
    $sth->execute( $reserve_id );
1627
    $sth->execute( $reserve_id );
1607
    
1628
1608
    _FixPriority({ reserve_id => $reserve_id, rank => '999999' });
1629
    _FixPriority({ reserve_id => $reserve_id, rank => '999999' });
1609
}
1630
}
1610
1631
Lines 1814-1820 sub _FixPriority { Link Here
1814
            $priority[$j]->{'reserve_id'}
1835
            $priority[$j]->{'reserve_id'}
1815
        );
1836
        );
1816
    }
1837
    }
1817
    
1838
1818
    $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
1839
    $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
1819
    $sth->execute();
1840
    $sth->execute();
1820
1841
Lines 2052-2058 sub _koha_notify_reserve { Link Here
2052
    if (! $notification_sent) {
2073
    if (! $notification_sent) {
2053
        &$send_notification('print', 'HOLD');
2074
        &$send_notification('print', 'HOLD');
2054
    }
2075
    }
2055
    
2076
2056
}
2077
}
2057
2078
2058
=head2 _ShiftPriorityByDateAndPriority
2079
=head2 _ShiftPriorityByDateAndPriority
(-)a/Koha/Schema/Result/Issuingrule.pm (-2 / +10 lines)
Lines 191-196 __PACKAGE__->table("issuingrules"); Link Here
191
  is_nullable: 0
191
  is_nullable: 0
192
  size: 1
192
  size: 1
193
193
194
=head2 allow_hold_if_items_available
195
196
  data_type: 'tinyint'
197
  default_value: 1
198
  is_nullable: 0
199
194
=cut
200
=cut
195
201
196
__PACKAGE__->add_columns(
202
__PACKAGE__->add_columns(
Lines 257-262 __PACKAGE__->add_columns( Link Here
257
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
263
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
258
  "opacitemholds",
264
  "opacitemholds",
259
  { data_type => "char", default_value => "N", is_nullable => 0, size => 1 },
265
  { data_type => "char", default_value => "N", is_nullable => 0, size => 1 },
266
  "allow_hold_if_items_available",
267
  { data_type => "tinyint", default_value => 1, is_nullable => 0 },
260
);
268
);
261
269
262
=head1 PRIMARY KEY
270
=head1 PRIMARY KEY
Lines 276-283 __PACKAGE__->add_columns( Link Here
276
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
284
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
277
285
278
286
279
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-12-31 15:26:16
287
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-02 12:22:52
280
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:K/8SKpDjba5CM4+WPZtWPw
288
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:P6v2zqse5sAEUI5qHdFOHQ
281
289
282
290
283
# You can replace this text with custom content, and it will be preserved on regeneration
291
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/admin/smart-rules.pl (+2 lines)
Lines 144-149 elsif ($op eq 'add') { Link Here
144
    my $hardduedatecompare = $input->param('hardduedatecompare');
144
    my $hardduedatecompare = $input->param('hardduedatecompare');
145
    my $rentaldiscount = $input->param('rentaldiscount');
145
    my $rentaldiscount = $input->param('rentaldiscount');
146
    my $opacitemholds = $input->param('opacitemholds') || 0;
146
    my $opacitemholds = $input->param('opacitemholds') || 0;
147
    my $allow_hold_if_items_available = $input->param('allow_hold_if_items_available') || 0;
147
    my $overduefinescap = $input->param('overduefinescap') || undef;
148
    my $overduefinescap = $input->param('overduefinescap') || undef;
148
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
149
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
149
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
150
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
Lines 173-178 elsif ($op eq 'add') { Link Here
173
        onshelfholds                  => $onshelfholds,
174
        onshelfholds                  => $onshelfholds,
174
        opacitemholds                 => $opacitemholds,
175
        opacitemholds                 => $opacitemholds,
175
        overduefinescap               => $overduefinescap,
176
        overduefinescap               => $overduefinescap,
177
        allow_hold_if_items_available => $allow_hold_if_items_available,
176
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
178
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
177
    };
179
    };
178
180
(-)a/installer/data/mysql/atomicupdate/on_shelf_non_available.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE issuingrules ADD COLUMN allow_hold_if_items_available TINYINT(1) NOT NULL DEFAULT 1 AFTER opacitemholds;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1198-1203 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
1198
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
1198
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
1199
  onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
1199
  onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
1200
  opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
1200
  opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
1201
  allow_hold_if_items_available TINYINT(1) NOT NULL DEFAULT 1, -- allow holds or not if other items available
1201
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1202
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1202
  KEY `categorycode` (`categorycode`),
1203
  KEY `categorycode` (`categorycode`),
1203
  KEY `itemtype` (`itemtype`)
1204
  KEY `itemtype` (`itemtype`)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (+9 lines)
Lines 172-177 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
172
                <th>Holds allowed (count)</th>
172
                <th>Holds allowed (count)</th>
173
                <th>On shelf holds allowed</th>
173
                <th>On shelf holds allowed</th>
174
                <th>Item level holds</th>
174
                <th>Item level holds</th>
175
                <th>Allow hold if others available</th>
175
                <th>Rental discount (%)</th>
176
                <th>Rental discount (%)</th>
176
                <th colspan="2">&nbsp;</th>
177
                <th colspan="2">&nbsp;</th>
177
            </tr>
178
            </tr>
Lines 250-255 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
250
							<td>[% rule.reservesallowed %]</td>
251
							<td>[% rule.reservesallowed %]</td>
251
                                                        <td>[% IF rule.onshelfholds %]Yes[% ELSE %]No[% END %]</td>
252
                                                        <td>[% IF rule.onshelfholds %]Yes[% ELSE %]No[% END %]</td>
252
                                                        <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
253
                                                        <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
254
                                                        <td>[% IF rule.allow_hold_if_items_available %]Yes[% ELSE %]No[% END %]</td>
253
							<td>[% rule.rentaldiscount %]</td>
255
							<td>[% rule.rentaldiscount %]</td>
254
                            <td><a href="#" class="editrule">Edit</a></td>
256
                            <td><a href="#" class="editrule">Edit</a></td>
255
							<td>
257
							<td>
Lines 328-333 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
328
                            <option value="F">Force</option>
330
                            <option value="F">Force</option>
329
                        </select>
331
                        </select>
330
                    </td>
332
                    </td>
333
                    <td>
334
                        <select name="allow_hold_if_items_available" id="allow_hold_if_items_available">
335
                            <option value="0">No</option>
336
                            <option value="1" selected="selected">Yes</option>
337
                        </select>
338
                    </td>
331
                    <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
339
                    <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
332
                    <td colspan="2">
340
                    <td colspan="2">
333
                        <input type="hidden" name="branch" value="[% current_branch %]"/>
341
                        <input type="hidden" name="branch" value="[% current_branch %]"/>
Lines 359-364 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
359
                      <th>Holds allowed (count)</th>
367
                      <th>Holds allowed (count)</th>
360
                      <th>On shelf holds allowed</th>
368
                      <th>On shelf holds allowed</th>
361
                      <th>Item level holds</th>
369
                      <th>Item level holds</th>
370
                      <th>Allow hold if others available</th>
362
                      <th>Rental discount (%)</th>
371
                      <th>Rental discount (%)</th>
363
                      <th colspan="2">&nbsp;</th>
372
                      <th colspan="2">&nbsp;</th>
364
                    </tr>
373
                    </tr>
(-)a/t/db_dependent/Holds/AllowHoldIfItemsAvailable.t (-1 / +123 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use C4::Context;
6
use C4::Items;
7
use C4::Circulation;
8
use Koha::IssuingRule;
9
10
use Test::More tests => 4;
11
12
use t::lib::TestBuilder;
13
14
BEGIN {
15
    use FindBin;
16
    use lib $FindBin::Bin;
17
    use_ok('C4::Reserves');
18
}
19
20
my $schema = Koha::Database->schema;
21
$schema->storage->txn_begin;
22
my $dbh = C4::Context->dbh;
23
24
my $builder = t::lib::TestBuilder->new;
25
26
my $library1 = $builder->build({
27
    source => 'Branch',
28
});
29
30
# Now, set a userenv
31
C4::Context->_new_userenv('xxx');
32
C4::Context->set_userenv(0,0,0,'firstname','surname', $library1->{branchcode}, 'Midway Public Library', '', '', '');
33
34
my $bib_title = "Test Title";
35
36
my $borrower1 = $builder->build({
37
    source => 'Borrower',
38
    value => {
39
        categorycode => 'S',
40
        branchcode => $library1->{branchcode},
41
        dateexpiry => '3000-01-01',
42
    }
43
});
44
45
my $borrower2 = $builder->build({
46
    source => 'Borrower',
47
    value => {
48
        categorycode => 'S',
49
        branchcode => $library1->{branchcode},
50
        dateexpiry => '3000-01-01',
51
    }
52
});
53
54
# Test hold_fulfillment_policy
55
my ( $itemtype ) = @{ $dbh->selectrow_arrayref("SELECT itemtype FROM itemtypes LIMIT 1") };
56
my $borrowernumber1 = $borrower1->{borrowernumber};
57
my $borrowernumber2 = $borrower2->{borrowernumber};
58
my $library_A = $library1->{branchcode};
59
60
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
61
62
my $biblionumber = $dbh->selectrow_array("SELECT biblionumber FROM biblio WHERE title = '$bib_title'")
63
  or BAIL_OUT("Cannot find newly created biblio record");
64
65
$dbh->do("INSERT INTO biblioitems (biblionumber, marcxml, itemtype) VALUES ($biblionumber, '', '$itemtype')");
66
67
my $biblioitemnumber =
68
  $dbh->selectrow_array("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber = $biblionumber")
69
  or BAIL_OUT("Cannot find newly created biblioitems record");
70
71
$dbh->do("
72
    INSERT INTO items (barcode, biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype)
73
    VALUES ('AllowHoldIf1', $biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype')
74
");
75
76
my $itemnumber1 =
77
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber")
78
  or BAIL_OUT("Cannot find newly created item");
79
80
my $item1 = GetItem( $itemnumber1 );
81
82
$dbh->do("
83
    INSERT INTO items (barcode, biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype)
84
    VALUES ('AllowHoldIf2', $biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype')
85
");
86
87
my $itemnumber2 =
88
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber ORDER BY itemnumber DESC")
89
  or BAIL_OUT("Cannot find newly created item");
90
91
my $item2 = GetItem( $itemnumber2 );
92
93
$dbh->do("DELETE FROM issuingrules");
94
my $rule = Koha::IssuingRule->new(
95
    {
96
        categorycode => '*',
97
        itemtype     => '*',
98
        branchcode   => '*',
99
        maxissueqty  => 99,
100
        issuelength  => 7,
101
        lengthunit   => 8,
102
        reservesallowed => 99,
103
        onshelfholds => 1,
104
        allow_hold_if_items_available => 0,
105
    }
106
);
107
$rule->store();
108
109
my $can = CanItemBeReserved( $borrowernumber1, $itemnumber1);
110
is( $can, 'itemsAvailable', "Item can be held" );
111
112
AddIssue( $borrower2, $item1->{barcode} );
113
114
$can = CanItemBeReserved( $borrowernumber1, $itemnumber1);
115
is( $can, 'itemsAvailable', "Item can be held" );
116
117
AddIssue( $borrower2, $item2->{barcode} );
118
119
$can = CanItemBeReserved( $borrowernumber1, $itemnumber1);
120
is( $can, 'OK', "Item can be held" );
121
122
# Cleanup
123
$schema->storage->txn_rollback;

Return to bug 15534