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

(-)a/C4/Circulation.pm (+17 lines)
Lines 3684-3689 sub LostItem{ Link Here
3684
         DeleteTransfer($itemnumber);
3684
         DeleteTransfer($itemnumber);
3685
    }
3685
    }
3686
3686
3687
    my ( $restype, $res ) = C4::Reserves::CheckReserves( $itemnumber );
3688
    my $LostItemLevelHold;
3689
    if ( $restype eq "Waiting" || $restype eq "Reserved" ) {
3690
        if ( $res->{originalholdtype} eq "B" ) {
3691
            #originalholdtype equalling "B" means this is a bib level hold
3692
            C4::Reserves::RevertWaitingStatus({itemnumber => $itemnumber});
3693
3694
            #If the LostBibLevelHoldsRevert syspref is enabled then revert the allocated reserve back to an unallocated bib-level hold
3695
            if ( C4::Context->preference('LostBibLevelHoldsRevert')) {
3696
                C4::Reserves::RevertItemLevelHoldToBibLevelHold({ reserveid => $res->{reserve_id} });
3697
            }
3698
        } else {
3699
            #Otherwise originalholdtype equals "I" and is an item level hold
3700
            $LostItemLevelHold = 1;
3701
        }
3702
    }
3703
    return $LostItemLevelHold;
3687
}
3704
}
3688
3705
3689
sub GetOfflineOperations {
3706
sub GetOfflineOperations {
(-)a/C4/Reserves.pm (-22 / +87 lines)
Lines 130-135 BEGIN { Link Here
130
        &AlterPriority
130
        &AlterPriority
131
        &ToggleLowestPriority
131
        &ToggleLowestPriority
132
132
133
        &RevertWaitingStatus
134
        &RevertItemLevelHoldToBibLevelHold
133
        &ReserveSlip
135
        &ReserveSlip
134
        &ToggleSuspend
136
        &ToggleSuspend
135
        &SuspendAll
137
        &SuspendAll
Lines 198-220 sub AddReserve { Link Here
198
    # Don't add itemtype limit if specific item is selected
200
    # Don't add itemtype limit if specific item is selected
199
    $itemtype = undef if $checkitem;
201
    $itemtype = undef if $checkitem;
200
202
201
    # updates take place here
203
    # Create reserves with with originalholdtype="B" if biblio level hold and "I" if item level hold
202
    my $hold = Koha::Hold->new(
204
    my $hold;
203
        {
205
    if (!($checkitem)) {
204
            borrowernumber => $borrowernumber,
206
        # updates take place here
205
            biblionumber   => $biblionumber,
207
        $hold = Koha::Hold->new(
206
            reservedate    => $resdate,
208
         {
207
            branchcode     => $branch,
209
           borrowernumber => $borrowernumber,
208
            priority       => $priority,
210
           biblionumber   => $biblionumber,
209
            reservenotes   => $notes,
211
           reservedate    => $resdate,
210
            itemnumber     => $checkitem,
212
           branchcode     => $branch,
211
            found          => $found,
213
           priority       => $priority,
212
            waitingdate    => $waitingdate,
214
           reservenotes   => $notes,
213
            expirationdate => $expdate,
215
           itemnumber     => $checkitem,
214
            itemtype       => $itemtype,
216
           found          => $found,
215
        }
217
           waitingdate    => $waitingdate,
216
    )->store();
218
           expirationdate => $expdate,
217
    $hold->set_waiting() if $found eq 'W';
219
           itemtype       => $itemtype,
220
           originalholdtype => 'B',
221
         }
222
        )->store();
223
        $hold->set_waiting() if $found eq 'W';
224
    } else {
225
        # updates take place here
226
        $hold = Koha::Hold->new(
227
         {
228
          borrowernumber => $borrowernumber,
229
          biblionumber   => $biblionumber,
230
          reservedate    => $resdate,
231
          branchcode     => $branch,
232
          priority       => $priority,
233
          reservenotes   => $notes,
234
          itemnumber     => $checkitem,
235
          found          => $found,
236
          waitingdate    => $waitingdate,
237
          expirationdate => $expdate,
238
          itemtype       => $itemtype,
239
          originalholdtype  => 'I',
240
         }
241
        )->store();
242
        $hold->set_waiting() if $found eq 'W';
243
    }
218
244
219
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
245
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
220
        if C4::Context->preference('HoldsLog');
246
        if C4::Context->preference('HoldsLog');
Lines 1405-1415 sub _FixPriority { Link Here
1405
        $hold = Koha::Holds->find( $reserve_id );
1431
        $hold = Koha::Holds->find( $reserve_id );
1406
        return unless $hold;
1432
        return unless $hold;
1407
    }
1433
    }
1408
1409
    unless ( $biblionumber ) { # FIXME This is a very weird API
1434
    unless ( $biblionumber ) { # FIXME This is a very weird API
1410
        $biblionumber = $hold->biblionumber;
1435
        $biblionumber = $hold->biblionumber;
1411
    }
1436
    }
1412
1413
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1437
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1414
        $hold->cancel;
1438
        $hold->cancel;
1415
    }
1439
    }
Lines 1521-1527 sub _Findgroupreserve { Link Here
1521
               biblioitems.biblioitemnumber AS biblioitemnumber,
1545
               biblioitems.biblioitemnumber AS biblioitemnumber,
1522
               reserves.itemnumber          AS itemnumber,
1546
               reserves.itemnumber          AS itemnumber,
1523
               reserves.reserve_id          AS reserve_id,
1547
               reserves.reserve_id          AS reserve_id,
1524
               reserves.itemtype            AS itemtype
1548
               reserves.itemtype            AS itemtype,
1549
               reserves.originalholdtype    AS originalholdtype
1525
        FROM reserves
1550
        FROM reserves
1526
        JOIN biblioitems USING (biblionumber)
1551
        JOIN biblioitems USING (biblionumber)
1527
        JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber)
1552
        JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber)
Lines 1556-1562 sub _Findgroupreserve { Link Here
1556
               biblioitems.biblioitemnumber AS biblioitemnumber,
1581
               biblioitems.biblioitemnumber AS biblioitemnumber,
1557
               reserves.itemnumber          AS itemnumber,
1582
               reserves.itemnumber          AS itemnumber,
1558
               reserves.reserve_id          AS reserve_id,
1583
               reserves.reserve_id          AS reserve_id,
1559
               reserves.itemtype            AS itemtype
1584
               reserves.itemtype            AS itemtype,
1585
               reserves.originalholdtype    AS originalholdtype
1560
        FROM reserves
1586
        FROM reserves
1561
        JOIN biblioitems USING (biblionumber)
1587
        JOIN biblioitems USING (biblionumber)
1562
        JOIN hold_fill_targets USING (biblionumber, borrowernumber)
1588
        JOIN hold_fill_targets USING (biblionumber, borrowernumber)
Lines 1590-1596 sub _Findgroupreserve { Link Here
1590
               reserves.timestamp                  AS timestamp,
1616
               reserves.timestamp                  AS timestamp,
1591
               reserves.itemnumber                 AS itemnumber,
1617
               reserves.itemnumber                 AS itemnumber,
1592
               reserves.reserve_id                 AS reserve_id,
1618
               reserves.reserve_id                 AS reserve_id,
1593
               reserves.itemtype                   AS itemtype
1619
               reserves.itemtype                   AS itemtype,
1620
               reserves.originalholdtype           AS originalholdtype
1594
        FROM reserves
1621
        FROM reserves
1595
        WHERE reserves.biblionumber = ?
1622
        WHERE reserves.biblionumber = ?
1596
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1623
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
Lines 1910-1915 sub RevertWaitingStatus { Link Here
1910
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1937
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1911
}
1938
}
1912
1939
1940
1941
=head2 RevertItemLevelHoldToBibLevelHold
1942
1943
  RevertItemLevelHoldToBibLevelHold({ reserveid => $reserveid });
1944
1945
  Reverts a item level hold (which was originally a bib-level hold, which is determined by the value of reserves.originalholdtype) back to a bib-level hold.
1946
1947
=cut
1948
1949
sub RevertItemLevelHoldToBibLevelHold {
1950
    my ( $params ) = @_;
1951
    my $reserve_id = $params->{'reserveid'};
1952
1953
    return unless ( $reserve_id );
1954
    my $dbh = C4::Context->dbh;
1955
1956
    #Get the waiting reserve we want to revert
1957
    my $query = "
1958
        SELECT * FROM reserves
1959
        WHERE reserve_id = ?
1960
        AND itemnumber IS NOT NULL
1961
    ";
1962
     my $sth = $dbh->prepare( $query );
1963
     $sth->execute( $reserve_id );
1964
     my $reserve = $sth->fetchrow_hashref();
1965
1966
     ## Set the itemnumber to 'NULL'
1967
     $query = "
1968
         UPDATE reserves
1969
         SET
1970
         itemnumber = NULL
1971
         WHERE
1972
         reserve_id =  ?
1973
     ";
1974
     $sth = $dbh->prepare( $query );
1975
     $sth->execute( $reserve_id );
1976
}
1977
1913
=head2 ReserveSlip
1978
=head2 ReserveSlip
1914
1979
1915
ReserveSlip(
1980
ReserveSlip(
(-)a/Koha/Schema/Result/OldReserve.pm (-2 / +10 lines)
Lines 137-142 __PACKAGE__->table("old_reserves"); Link Here
137
  is_nullable: 1
137
  is_nullable: 1
138
  size: 10
138
  size: 10
139
139
140
=head2 originalholdtype
141
142
  data_type: 'varchar'
143
  is_nullable: 1
144
  size: 1
145
140
=cut
146
=cut
141
147
142
__PACKAGE__->add_columns(
148
__PACKAGE__->add_columns(
Lines 192-197 __PACKAGE__->add_columns( Link Here
192
  },
198
  },
193
  "itemtype",
199
  "itemtype",
194
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
200
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
201
  "originalholdtype",
202
  { data_type => "varchar", is_nullable => 1, size => 1 },
195
);
203
);
196
204
197
=head1 PRIMARY KEY
205
=head1 PRIMARY KEY
Lines 289-296 __PACKAGE__->belongs_to( Link Here
289
);
297
);
290
298
291
299
292
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
300
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-02 09:48:38
293
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ynb6NtiTN8ZZur2YCvxlNg
301
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cc4o9r7wLXapCJJ3WfDy4g
294
302
295
303
296
# You can replace this text with custom content, and it will be preserved on regeneration
304
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/Koha/Schema/Result/Reserve.pm (-2 / +10 lines)
Lines 141-146 __PACKAGE__->table("reserves"); Link Here
141
  is_nullable: 1
141
  is_nullable: 1
142
  size: 10
142
  size: 10
143
143
144
=head2 originalholdtype
145
146
  data_type: 'varchar'
147
  is_nullable: 1
148
  size: 1
149
144
=cut
150
=cut
145
151
146
__PACKAGE__->add_columns(
152
__PACKAGE__->add_columns(
Lines 206-211 __PACKAGE__->add_columns( Link Here
206
  },
212
  },
207
  "itemtype",
213
  "itemtype",
208
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
214
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
215
  "originalholdtype",
216
  { data_type => "varchar", is_nullable => 1, size => 1 },
209
);
217
);
210
218
211
=head1 PRIMARY KEY
219
=head1 PRIMARY KEY
Lines 313-320 __PACKAGE__->belongs_to( Link Here
313
);
321
);
314
322
315
323
316
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
324
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-25 12:05:26
317
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2GCET9quFpUvzuN7MUWZNw
325
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YIZXhPQwRJXrzYkdmVQH7Q
318
326
319
__PACKAGE__->belongs_to(
327
__PACKAGE__->belongs_to(
320
  "item",
328
  "item",
(-)a/catalogue/moredetail.pl (+7 lines)
Lines 71-76 my $itemnumber = $query->param('itemnumber'); Link Here
71
my $data = &GetBiblioData($biblionumber);
71
my $data = &GetBiblioData($biblionumber);
72
my $dewey = $data->{'dewey'};
72
my $dewey = $data->{'dewey'};
73
my $showallitems = $query->param('showallitems');
73
my $showallitems = $query->param('showallitems');
74
my $lostitemlevelhold = $query->param('LostItemLevelHold');
75
my $lostitemnumber = $query->param('lostitemnumber');
76
my $itemlost = $query->param('itemlost');
77
78
if ($lostitemlevelhold && $itemlost) {
79
    $template->param(LostItemLevelHold => $lostitemlevelhold, itemlost => $itemlost, lostitemnumber => $lostitemnumber, biblionumber => $biblionumber);
80
}
74
81
75
#coping with subscriptions
82
#coping with subscriptions
76
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
83
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
(-)a/catalogue/updateitem.pl (-2 / +21 lines)
Lines 26-31 use C4::Items; Link Here
26
use C4::Output;
26
use C4::Output;
27
use C4::Circulation;
27
use C4::Circulation;
28
use C4::Reserves;
28
use C4::Reserves;
29
use Data::Dumper;
29
30
30
my $cgi= new CGI;
31
my $cgi= new CGI;
31
32
Lines 39-44 my $itemnotes=$cgi->param('itemnotes'); Link Here
39
my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic');
40
my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic');
40
my $withdrawn=$cgi->param('withdrawn');
41
my $withdrawn=$cgi->param('withdrawn');
41
my $damaged=$cgi->param('damaged');
42
my $damaged=$cgi->param('damaged');
43
my $cancelhold = $cgi->param('CancelHold');
44
my $retainhold = $cgi->param('RetainHold');
42
45
43
my $confirm=$cgi->param('confirm');
46
my $confirm=$cgi->param('confirm');
44
my $dbh = C4::Context->dbh;
47
my $dbh = C4::Context->dbh;
Lines 53-60 for ($damaged,$itemlost,$withdrawn) { Link Here
53
    }
56
    }
54
}
57
}
55
58
59
if ($cancelhold) {
60
    my ($restype, $res ) = C4::Reserves::CheckReserves( $itemnumber );
61
    my $hold = Koha::Holds->find($res->{reserve_id});
62
    $hold->cancel;
63
}
64
65
#Assigning variables for use in cancelling item level holds when item marked as 'Lost'
66
my $LostItemLevelHold;
67
my $originalitemnumber = $itemnumber;
68
56
# modify MARC item if input differs from items table.
69
# modify MARC item if input differs from items table.
57
my $item_changes = {};
70
my $item_changes = {};
71
58
if (defined $itemnotes_nonpublic) { # i.e., itemnotes_nonpublic parameter passed from form
72
if (defined $itemnotes_nonpublic) { # i.e., itemnotes_nonpublic parameter passed from form
59
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
73
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
60
    if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
74
    if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
Lines 79-85 elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form Link Here
79
}
93
}
80
94
81
ModItem($item_changes, $biblionumber, $itemnumber);
95
ModItem($item_changes, $biblionumber, $itemnumber);
96
$LostItemLevelHold = LostItem($itemnumber, 'moredetail') if $itemlost;
97
98
if ( $LostItemLevelHold) {
99
    print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&LostItemLevelHold=$LostItemLevelHold&itemlost=$itemlost&lostitemnumber=$itemnumber#item$itemnumber");
100
} else {
101
    print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
102
}
82
103
83
LostItem($itemnumber, 'moredetail') if $itemlost;
84
104
85
print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
(-)a/cataloguing/additem.pl (-3 / +31 lines)
Lines 40-46 use C4::Search; Link Here
40
use Storable qw(thaw freeze);
40
use Storable qw(thaw freeze);
41
use URI::Escape;
41
use URI::Escape;
42
use C4::Members;
42
use C4::Members;
43
43
use Data::Dumper;
44
use MARC::File::XML;
44
use MARC::File::XML;
45
use URI::Escape;
45
use URI::Escape;
46
46
Lines 385-393 my $fa_barcode = $input->param('barcode'); Link Here
385
my $fa_branch             = $input->param('branch');
385
my $fa_branch             = $input->param('branch');
386
my $fa_stickyduedate      = $input->param('stickyduedate');
386
my $fa_stickyduedate      = $input->param('stickyduedate');
387
my $fa_duedatespec        = $input->param('duedatespec');
387
my $fa_duedatespec        = $input->param('duedatespec');
388
388
my $cancelhold            = $input->param('CancelHold');
389
my $retainhold            = $input->param('RetainHold');
389
my $frameworkcode = &GetFrameworkCode($biblionumber);
390
my $frameworkcode = &GetFrameworkCode($biblionumber);
390
391
392
if ($cancelhold || $retainhold) {
393
    $op ='';
394
}
395
396
#Assigning variables for use in cancelling item level holds when item marked as 'Lost'
397
my $LostItemLevelHold;
398
my $originalitemnumber = $itemnumber;
399
391
# Defining which userflag is needing according to the framework currently used
400
# Defining which userflag is needing according to the framework currently used
392
my $userflags;
401
my $userflags;
393
if (defined $input->param('frameworkcode')) {
402
if (defined $input->param('frameworkcode')) {
Lines 692-697 if ($op eq "additem") { Link Here
692
    # check that the barcode don't exist already
701
    # check that the barcode don't exist already
693
    my $addedolditem = TransformMarcToKoha($itemtosave);
702
    my $addedolditem = TransformMarcToKoha($itemtosave);
694
    my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
703
    my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
704
    my $lostitemnumber;
695
    if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
705
    if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
696
        push @errors,"barcode_not_unique";
706
        push @errors,"barcode_not_unique";
697
    } else {
707
    } else {
Lines 700-708 if ($op eq "additem") { Link Here
700
        $itemnumber = q{};
710
        $itemnumber = q{};
701
        my $olditemlost = $item->{itemlost};
711
        my $olditemlost = $item->{itemlost};
702
        my $newitemlost = $newitem->{itemlost};
712
        my $newitemlost = $newitem->{itemlost};
703
        LostItem( $item->{itemnumber}, 'additem' )
713
        $LostItemLevelHold = LostItem( $item->{itemnumber}, 'additem' )
704
            if $newitemlost && $newitemlost ge '1' && !$olditemlost;
714
            if $newitemlost && $newitemlost ge '1' && !$olditemlost;
705
    }
715
    }
716
717
    if ($LostItemLevelHold) {
718
        $lostitemnumber = $originalitemnumber;
719
    }
720
    $template->param( LostItemLevelHold  => $LostItemLevelHold, lostitemnumber => $lostitemnumber );
706
    $nextop="additem";
721
    $nextop="additem";
707
} elsif ($op eq "delinkitem"){
722
} elsif ($op eq "delinkitem"){
708
    my $analyticfield = '773';
723
    my $analyticfield = '773';
Lines 720-725 if ($op eq "additem") { Link Here
720
	my $modbibresult = ModBiblio($record, $biblionumber,'');
735
	my $modbibresult = ModBiblio($record, $biblionumber,'');
721
}
736
}
722
737
738
if ($cancelhold) {
739
    my ( $restype, $res ) = C4::Reserves::CheckReserves( $originalitemnumber );
740
    my $hold = Koha::Holds->find($res->{reserve_id});
741
    $hold->cancel;
742
}
743
723
#
744
#
724
#-------------------------------------------------------------------------------
745
#-------------------------------------------------------------------------------
725
# build screen with existing items. and "new" one
746
# build screen with existing items. and "new" one
Lines 905-910 foreach my $tag ( keys %{$tagslib}){ Link Here
905
926
906
my $item = Koha::Items->find($itemnumber); # We certainly want to fetch it earlier
927
my $item = Koha::Items->find($itemnumber); # We certainly want to fetch it earlier
907
928
929
#If you are trying to mark an item as lost which has an item level hold on it return $originalitemnumber
930
if ($LostItemLevelHold) {
931
    $template->param( itemnumber => $originalitemnumber);
932
} else {
933
    $template->param( itemnumber => $itemnumber );
934
}
935
908
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
936
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
909
$template->param(
937
$template->param(
910
    biblionumber => $biblionumber,
938
    biblionumber => $biblionumber,
(-)a/installer/data/mysql/atomicupdate/bug_20844-added-holdtype-field-to-reserves.sql (+3 lines)
Line 0 Link Here
1
ALTER TABLE reserves ADD originalholdtype VARCHAR(1);
2
ALTER TABLE old_reserves ADD originalholdtype VARCHAR(1);
3
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('LostBibLevelHoldsRevert', 1, 'Enable|Disable', 'If the item which has an allocated hold on it which was originally a bib-level hold then when the item is marked as lost revert the hold to a bib-level hold', 'YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 595-600 Circulation: Link Here
595
            - pref: ReservesMaxPickUpDelay
595
            - pref: ReservesMaxPickUpDelay
596
              class: integer
596
              class: integer
597
            - days.
597
            - days.
598
        -
599
            - If the item which has an allocated hold on it which was originally a bib-level hold is marked as lost then revert the hold to a bib-level hold
600
            - pref: LostBibLevelHoldsRevert
601
              choices:
602
                  yes: "Enable"
603
                  no: "Disable"
598
        -
604
        -
599
            - pref: LostItemCancelOutstandingTransfers
605
            - pref: LostItemCancelOutstandingTransfers
600
              choices:
606
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-2 / +17 lines)
Lines 42-55 Link Here
42
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblionumber | uri %]&amp;showallitems=1">Show all items</a>[% END %]</li>
42
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblionumber | uri %]&amp;showallitems=1">Show all items</a>[% END %]</li>
43
    </ol>
43
    </ol>
44
44
45
45
    <br clear="all" />
46
    <br clear="all" />
46
    [% IF ( ONLY_ONE ) %]
47
    [% IF ( ONLY_ONE ) %]
47
        <div class="dialog message">You are only viewing one item.  <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblionumber | uri %]&amp;bi=[% biblioitemnumber | uri %]#item[% itemnumber | uri %]">View All</a></div>
48
        <div class="dialog message">You are only viewing one item.  <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblionumber | uri %]&amp;bi=[% biblioitemnumber | uri %]#item[% itemnumber | uri %]">View All</a></div>
48
    [% END %]
49
    [% END %]
50
49
    [% FOREACH ITEM_DAT IN ITEM_DATA %]
51
    [% FOREACH ITEM_DAT IN ITEM_DATA %]
50
    <div class="yui-g">
52
    <div class="yui-g">
51
        <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %]  [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %]</h3>
53
         <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %]  [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %]</h3>
52
        <div class="listgroup"><h4>Item information [% IF ( CAN_user_editcatalogue_edit_catalogue ) %][% UNLESS ( ITEM_DAT.nomod ) %]
54
        [% IF ((ITEM_DAT.itemnumber == lostitemnumber) && (LostItemLevelHold)) %]
55
        <div class="alert alert-warning">
56
            <form id="DeallocateLostItemLevelHold" method="post" action="updateitem.pl" name="DeallocateLostItemLevelHold">
57
                <input type="hidden" name="biblionumber" value="[% biblionumber | html %]"/>
58
                <input type="hidden" name="itemnumber" value="[% lostitemnumber | html %]"/>
59
                <input type="hidden" name="itemlost" value="[% itemlost | html %]"/>
60
                This item has an item-level hold on it:
61
                <input type="submit" name="RetainHold" value="Retain Hold"/>
62
                <input type="submit" name="CancelHold" value="Cancel Hold"/>
63
            </form>
64
        </div>
65
    [% END %]
66
67
    <div class="listgroup"><h4>Item information [% IF ( CAN_user_editcatalogue_edit_catalogue ) %][% UNLESS ( ITEM_DAT.nomod ) %]
53
         [% IF ( CAN_user_editcatalogue_edit_items ) %]
68
         [% IF ( CAN_user_editcatalogue_edit_items ) %]
54
         <a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% ITEM_DAT.biblionumber | uri %]&amp;itemnumber=[% ITEM_DAT.itemnumber | uri %]">[Edit Item]</a>
69
         <a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% ITEM_DAT.biblionumber | uri %]&amp;itemnumber=[% ITEM_DAT.itemnumber | uri %]">[Edit Item]</a>
55
         [% END %]
70
         [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (+14 lines)
Lines 258-263 function confirm_deletion() { Link Here
258
    [% ELSE %]
258
    [% ELSE %]
259
        <h2 id="edititem">Edit Item #[% itemnumber | html %][% IF ( barcode ) %] / Barcode [% barcode | html %][% END %]</h2>
259
        <h2 id="edititem">Edit Item #[% itemnumber | html %][% IF ( barcode ) %] / Barcode [% barcode | html %][% END %]</h2>
260
    [% END %]
260
    [% END %]
261
262
263
    [% IF (LostItemLevelHold) %]
264
        <div class="alert alert-warning">
265
            <form id="DeallocateLostItemLevelHold" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="DeallocateLostItemLevelHold">
266
                <input type="hidden" id="itemnumber" name="itemnumber" value="[% lostitemnumber | html %]"/>
267
                This item has an item-level hold on it:
268
                <input type="submit" name="RetainHold" value="Retain Hold"/>
269
                <input type="submit" name="CancelHold" value="Cancel hold"/>
270
            </form>
271
        </div>
272
    [% END %]
273
274
261
	<fieldset class="rows">
275
	<fieldset class="rows">
262
	<ol>
276
	<ol>
263
        [% FOREACH ite IN item %]
277
        [% FOREACH ite IN item %]
(-)a/t/db_dependent/Holds/RevertWaitingStatus.t (-2 / +63 lines)
Lines 16-22 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::More tests => 3;
19
use Test::More tests => 12;
20
use MARC::Record;
20
use MARC::Record;
21
21
22
use Koha::Libraries;
22
use Koha::Libraries;
Lines 109-114 ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' ); Link Here
109
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
109
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
110
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
110
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
111
111
112
#Bug 20844
113
#Test reverting the waiting status of holds when the reserved items are set to lost
114
115
#Create bib-level hold and test what happens when the item an allocated bib-level hold is allocated on is lost when the LostBibLevelHoldsRevert syspref is enabled
116
my $hold_id = C4::Reserves::AddReserve(
117
    $branchcode,
118
    4,
119
    $biblionumber,
120
    my $bibitems   = q{},
121
    my $priority,
122
    my $resdate,
123
    my $expdate,
124
    my $notes = q{},
125
    $title,
126
    my $checkitem,
127
    my $found,
128
);
129
130
my $hold = Koha::Holds->find($hold_id);
131
is( $hold->originalholdtype, 'B', 'Holds originalholdtype is "B" which is correct' );
132
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's an allocated bib-level hold on $itemnumber and has status is 'W'
133
$hold = Koha::Holds->find($hold_id);
134
is( $hold->found, 'W', 'Hold status is "W" (waiting) which is correct' );
135
is( $hold->itemnumber, $itemnumber, 'Bib-level hold is allocated and has an itemnumber' );
136
t::lib::Mocks::mock_preference( 'LostBibLevelHoldsRevert', 1 );
137
138
if (C4::Context->preference('LostBibLevelHoldsRevert') ) {
139
    #When item is set to lost revert hold to bib-level (i.e. remove the itemnumber in hold record) and change reserves.found to ''
140
    RevertWaitingStatus({ itemnumber => $itemnumber });
141
    RevertItemLevelHoldToBibLevelHold({ reserveid => $hold_id });
142
}
143
$hold = Koha::Holds->find($hold_id);
144
is( $hold->found, undef, 'reserve.found reverted to undef now item is lost' );
145
is( $hold->itemnumber, undef, 'Hold reverted back to unallocated bib level hold' );
146
147
#Create item-level hold and test what happens when the reserved item is set to lost
148
$hold_id = C4::Reserves::AddReserve(
149
     $branchcode,
150
     4,
151
     $biblionumber,
152
     $bibitems   = q{},
153
     $priority,
154
     $resdate,
155
     $expdate,
156
     $notes = q{},
157
     $title,
158
     $itemnumber,
159
     $found,
160
);
161
162
$hold = Koha::Holds->find($hold_id);
163
is( $hold->itemnumber, $itemnumber, 'This is an item-level hold' );
164
165
is( $hold->originalholdtype, 'I', 'Holds originalholdtype is correct' );
166
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's a waiting item-level hold with a reserves.found value of 'W'
167
$hold = Koha::Holds->find($hold_id);
168
is( $hold->found, 'W', 'Hold status is waiting' );
169
170
RevertWaitingStatus({ itemnumber => $itemnumber });
171
$hold = Koha::Holds->find($hold_id);
172
is( $hold->found, undef, 'Reserves found value is reverted to undef as the reserved item has been lost' );
173
112
$schema->storage->txn_rollback;
174
$schema->storage->txn_rollback;
113
175
114
# Helper method to set up a Biblio.
176
# Helper method to set up a Biblio.
115
- 

Return to bug 20844