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

(-)a/C4/Circulation.pm (+15 lines)
Lines 3949-3954 sub LostItem{ Link Here
3949
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
3949
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
3950
        }
3950
        }
3951
    }
3951
    }
3952
3953
    # SendLostHoldNotices
3954
    my $item = Koha::Items->find( $itemnumber );
3955
    if ( C4::Context->preference('SendLostHoldNotices') && defined $hold && $item->itemlost ){
3956
        my $letter = C4::Letters::GetPreparedLetter(
3957
            module => 'reserves',
3958
            letter_code => 'LOST_WAITING_HOLD',
3959
            branchcode => $hold->branchcode,
3960
            tables => {
3961
                borrowers => $hold->borrowernumber,
3962
                branches => $hold->branchcode,
3963
            },
3964
        );
3965
        C4::Message->enqueue($letter, $hold->borrower->unblessed, 'email');
3966
    }
3952
}
3967
}
3953
3968
3954
sub GetOfflineOperations {
3969
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 1745-1747 tables: Link Here
1745
            - "<p>This is to confirm that someone enabled two factor authentication on your account.</p>"
1745
            - "<p>This is to confirm that someone enabled two factor authentication on your account.</p>"
1746
            - "<p>If you did not do this, someone else may be using your account. Please contact technical support.</p>"
1746
            - "<p>If you did not do this, someone else may be using your account. Please contact technical support.</p>"
1747
            - "<p>Your library</p>"
1747
            - "<p>Your library</p>"
1748
1749
        - module: reserves
1750
          code: LOST_WAITING_HOLD
1751
          branchcode: ""
1752
          name: "Waiting hold marked lost"
1753
          is_html: 0
1754
          title: "Your waiting hold has been marked lost"
1755
          message_transport_type: email
1756
          lang: default
1757
          content:
1758
            - "Dear [% borrower.firstname %] [% borrowers.surname %],"
1759
            - ""
1760
            - "Your hold awaiting pickup is no longer available. The item is lost."
1761
            - ""
1762
            - "Please contact the library for more information."
1763
            - ""
1764
            - "Thank you,"
1765
            - ""
1766
            - "[% branch.branchname %]"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 668-673 Circulation: Link Here
668
                  no: "Don't revert"
668
                  no: "Don't revert"
669
            - waiting status of a hold if the allocated item is marked as Lost.
669
            - waiting status of a hold if the allocated item is marked as Lost.
670
        -
670
        -
671
            - pref: SendLostHoldNotices
672
              choices:
673
                  yes: Send
674
                  no: "Don't send"
675
            - a notice to a borrower if their reserved and waiting item is marked as Lost.
676
        -
671
            - In the staff client, split the holds queue into separate tables by
677
            - In the staff client, split the holds queue into separate tables by
672
            - pref: HoldsSplitQueue
678
            - pref: HoldsSplitQueue
673
              choices:
679
              choices:
(-)a/t/db_dependent/Reserves.t (-3 / +20 lines)
Lines 1410-1422 subtest 'ModReserveAffect logging' => sub { Link Here
1410
1410
1411
subtest 'Waiting item is marked as lost' => sub {
1411
subtest 'Waiting item is marked as lost' => sub {
1412
1412
1413
    plan tests => 15;
1413
    plan tests => 17;
1414
1414
1415
    # Set up data
1415
    # Set up data
1416
    my $biblio = $builder->build_sample_biblio();
1416
    my $biblio = $builder->build_sample_biblio();
1417
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1417
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1418
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1418
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1419
1419
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 );
1420
    $dbh->do(q|DELETE FROM message_queue|);
1420
    ## TEST 1: BIBLIO-LEVEL HOLD
1421
    ## TEST 1: BIBLIO-LEVEL HOLD
1421
1422
1422
    # place biblio-level hold
1423
    # place biblio-level hold
Lines 1427-1432 subtest 'Waiting item is marked as lost' => sub { Link Here
1427
    });
1428
    });
1428
    my $hold = Koha::Holds->find( $reserve_id );
1429
    my $hold = Koha::Holds->find( $reserve_id );
1429
1430
1431
    $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 %]") });
1432
1430
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1433
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1431
1434
1432
    # set hold as waiting and assign item
1435
    # set hold as waiting and assign item
Lines 1494-1500 subtest 'Waiting item is marked as lost' => sub { Link Here
1494
    $hold->cancel;
1497
    $hold->cancel;
1495
    $item->itemlost( 0 );
1498
    $item->itemlost( 0 );
1496
1499
1500
    my $message_count = $dbh->selectall_arrayref(q{
1501
        SELECT COUNT(*)
1502
        FROM message_queue
1503
        WHERE letter_code = 'LOST_WAITING_HOLD'
1504
    });
1505
    is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' );
1506
1497
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1507
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1508
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 );
1498
1509
1499
    # place item-level hold
1510
    # place item-level hold
1500
    $reserve_id = AddReserve({
1511
    $reserve_id = AddReserve({
Lines 1528-1533 subtest 'Waiting item is marked as lost' => sub { Link Here
1528
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1539
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1529
    $hold = Koha::Holds->find( $reserve_id );
1540
    $hold = Koha::Holds->find( $reserve_id );
1530
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1541
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1542
1543
    $message_count = $dbh->selectall_arrayref(q{
1544
        SELECT COUNT(*)
1545
        FROM message_queue
1546
        WHERE letter_code = 'LOST_WAITING_HOLD'
1547
    });
1548
    is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' );
1531
};
1549
};
1532
1550
1533
sub count_hold_print_messages {
1551
sub count_hold_print_messages {
1534
- 

Return to bug 20844