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

(-)a/C4/Circulation.pm (+15 lines)
Lines 4024-4029 sub LostItem{ Link Here
4024
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
4024
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
4025
        }
4025
        }
4026
    }
4026
    }
4027
4028
    # SendLostHoldNotices
4029
    my $item = Koha::Items->find( $itemnumber );
4030
    if ( C4::Context->preference('SendLostHoldNotices') && defined $hold && $item->itemlost ){
4031
        my $letter = C4::Letters::GetPreparedLetter(
4032
            module => 'reserves',
4033
            letter_code => 'LOST_WAITING_HOLD',
4034
            branchcode => $hold->branchcode,
4035
            tables => {
4036
                borrowers => $hold->borrowernumber,
4037
                branches => $hold->branchcode,
4038
            },
4039
        );
4040
        C4::Message->enqueue($letter, $hold->borrower->unblessed, 'email');
4041
    }
4027
}
4042
}
4028
4043
4029
sub GetOfflineOperations {
4044
sub GetOfflineOperations {
(-)a/catalogue/updateitem.pl (+2 lines)
Lines 47-52 if ( defined $cancelhold ){ Link Here
47
} elsif ( defined $reverthold ){
47
} elsif ( defined $reverthold ){
48
    $cancelhold = 0;
48
    $cancelhold = 0;
49
    LostItem($itemnumber, 'moredetail', 0, { cancel_reserve => $cancelhold });
49
    LostItem($itemnumber, 'moredetail', 0, { cancel_reserve => $cancelhold });
50
} else {
51
    $cancelhold = undef;
50
}
52
}
51
if ( defined $redirecturl ){
53
if ( defined $redirecturl ){
52
    print $cgi->redirect( $redirecturl . $biblionumber );
54
    print $cgi->redirect( $redirecturl . $biblionumber );
(-)a/installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl (+6 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, message_transport_type, content) VALUES ('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost','0','Your waiting hold has been marked lost','email',"Dear [% borrower.firstname %] [% borrowers.surname %],<br><br>Your hold awaiting pickup is no longer available. The item is lost.<br><br>Please contact the library for more information.<br><br>Thank you,<br><br>[% branch.branchname %]") });
4
5
    NewVersion( $DBversion, 20844, "Add LOST_WAITING_HOLD notice");
6
}
(-)a/installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl (+6 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('SendLostHoldNotices', '0', NULL, 'Send a notice to a borrower if their reserved and waiting item is marked as lost', 'YesNo') });
4
5
    NewVersion( $DBversion, 20844, "Add SendLostHoldNotices system preference");
6
}
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (+19 lines)
Lines 2361-2363 tables: Link Here
2361
            - "[% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]"
2361
            - "[% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]"
2362
            - "[% IF ( item.location ) %], [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %][% END %][% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %][% item.barcode | html %]</li>[% END %]</ul>[% END %]"
2362
            - "[% IF ( item.location ) %], [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %][% END %][% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %][% item.barcode | html %]</li>[% END %]</ul>[% END %]"
2363
            - "<hr></li>[% END %]</ol>"
2363
            - "<hr></li>[% END %]</ol>"
2364
2365
        - module: reserves
2366
          code: LOST_WAITING_HOLD
2367
          branchcode: ""
2368
          name: "Waiting hold marked lost"
2369
          is_html: 0
2370
          title: "Your waiting hold has been marked lost"
2371
          message_transport_type: email
2372
          lang: default
2373
          content:
2374
            - "Dear [% borrower.firstname %] [% borrowers.surname %],"
2375
            - ""
2376
            - "Your hold awaiting pickup is no longer available. The item is lost."
2377
            - ""
2378
            - "Please contact the library for more information."
2379
            - ""
2380
            - "Thank you,"
2381
            - ""
2382
            - "[% branch.branchname %]"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 690-695 Circulation: Link Here
690
                  yes: Revert
690
                  yes: Revert
691
                  no: "Don't revert"
691
                  no: "Don't revert"
692
            - waiting status of a hold if the allocated item is marked as Lost.
692
            - waiting status of a hold if the allocated item is marked as Lost.
693
        -
694
            - pref: SendLostHoldNotices
695
              choices:
696
                  yes: Send
697
                  no: "Don't send"
698
            - a notice to a borrower if their reserved and waiting item is marked as Lost.
693
        -
699
        -
694
            - In the staff interface, split the holds queue into separate tables by
700
            - In the staff interface, split the holds queue into separate tables by
695
            - pref: HoldsSplitQueue
701
            - pref: HoldsSplitQueue
(-)a/t/db_dependent/Reserves.t (-3 / +20 lines)
Lines 1424-1436 subtest 'ModReserveAffect logging' => sub { Link Here
1424
1424
1425
subtest 'Waiting item is marked as lost' => sub {
1425
subtest 'Waiting item is marked as lost' => sub {
1426
1426
1427
    plan tests => 15;
1427
    plan tests => 17;
1428
1428
1429
    # Set up data
1429
    # Set up data
1430
    my $biblio = $builder->build_sample_biblio();
1430
    my $biblio = $builder->build_sample_biblio();
1431
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1431
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1432
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1432
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1433
1433
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 );
1434
    $dbh->do(q|DELETE FROM message_queue|);
1434
    ## TEST 1: BIBLIO-LEVEL HOLD
1435
    ## TEST 1: BIBLIO-LEVEL HOLD
1435
1436
1436
    # place biblio-level hold
1437
    # place biblio-level hold
Lines 1441-1446 subtest 'Waiting item is marked as lost' => sub { Link Here
1441
    });
1442
    });
1442
    my $hold = Koha::Holds->find( $reserve_id );
1443
    my $hold = Koha::Holds->find( $reserve_id );
1443
1444
1445
    $dbh->do(q{INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, message_transport_type, content) VALUES ('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost','0','Your waiting hold has been marked lost','email',"Dear [% borrower.firstname %] [% borrowers.surname %],<br><br>Your hold awaiting pickup is no longer available. The item is lost.<br><br>Please contact the library for more information.<br><br>Thank you,<br><br>[% branch.branchname %]") });
1446
1444
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1447
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1445
1448
1446
    # set hold as waiting and assign item
1449
    # set hold as waiting and assign item
Lines 1508-1514 subtest 'Waiting item is marked as lost' => sub { Link Here
1508
    $hold->cancel;
1511
    $hold->cancel;
1509
    $item->itemlost( 0 );
1512
    $item->itemlost( 0 );
1510
1513
1514
    my $message_count = $dbh->selectall_arrayref(q{
1515
        SELECT COUNT(*)
1516
        FROM message_queue
1517
        WHERE letter_code = 'LOST_WAITING_HOLD'
1518
    });
1519
    is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' );
1520
1511
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1521
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1522
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 );
1512
1523
1513
    # place item-level hold
1524
    # place item-level hold
1514
    $reserve_id = AddReserve({
1525
    $reserve_id = AddReserve({
Lines 1542-1547 subtest 'Waiting item is marked as lost' => sub { Link Here
1542
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1553
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1543
    $hold = Koha::Holds->find( $reserve_id );
1554
    $hold = Koha::Holds->find( $reserve_id );
1544
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1555
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1556
1557
    $message_count = $dbh->selectall_arrayref(q{
1558
        SELECT COUNT(*)
1559
        FROM message_queue
1560
        WHERE letter_code = 'LOST_WAITING_HOLD'
1561
    });
1562
    is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' );
1545
};
1563
};
1546
1564
1547
sub count_hold_print_messages {
1565
sub count_hold_print_messages {
1548
- 

Return to bug 20844