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

(-)a/C4/Circulation.pm (+15 lines)
Lines 4123-4128 sub LostItem{ Link Here
4123
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
4123
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
4124
        }
4124
        }
4125
    }
4125
    }
4126
4127
    # SendLostHoldNotices
4128
    my $item = Koha::Items->find( $itemnumber );
4129
    if ( C4::Context->preference('SendLostHoldNotices') && defined $hold && $item->itemlost ){
4130
        my $letter = C4::Letters::GetPreparedLetter(
4131
            module => 'reserves',
4132
            letter_code => 'LOST_WAITING_HOLD',
4133
            branchcode => $hold->branchcode,
4134
            tables => {
4135
                borrowers => $hold->borrowernumber,
4136
                branches => $hold->branchcode,
4137
            },
4138
        );
4139
        C4::Message->enqueue($letter, $hold->borrower->unblessed, 'email');
4140
    }
4126
}
4141
}
4127
4142
4128
sub GetOfflineOperations {
4143
sub GetOfflineOperations {
(-)a/catalogue/updateitem.pl (+2 lines)
Lines 48-53 if ( defined $cancelhold ){ Link Here
48
} elsif ( defined $reverthold ){
48
} elsif ( defined $reverthold ){
49
    $cancelhold = 0;
49
    $cancelhold = 0;
50
    LostItem($itemnumber, 'moredetail', 0, { cancel_reserve => $cancelhold });
50
    LostItem($itemnumber, 'moredetail', 0, { cancel_reserve => $cancelhold });
51
} else {
52
    $cancelhold = undef;
51
}
53
}
52
if ( defined $redirecturl ){
54
if ( defined $redirecturl ){
53
    print $cgi->redirect( $redirecturl . $biblionumber );
55
    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 2467-2469 tables: Link Here
2467
            - "Your hold on [% hold.biblio.title %] ([% hold.biblio.id %]) has been confirmed."
2467
            - "Your hold on [% hold.biblio.title %] ([% hold.biblio.id %]) has been confirmed."
2468
            - "You will be notified by the library when your item is available for pickup."
2468
            - "You will be notified by the library when your item is available for pickup."
2469
            - "Thank you!"
2469
            - "Thank you!"
2470
2471
        - module: reserves
2472
          code: LOST_WAITING_HOLD
2473
          branchcode: ""
2474
          name: "Waiting hold marked lost"
2475
          is_html: 0
2476
          title: "Your waiting hold has been marked lost"
2477
          message_transport_type: email
2478
          lang: default
2479
          content:
2480
            - "Dear [% borrower.firstname %] [% borrowers.surname %],"
2481
            - ""
2482
            - "Your hold awaiting pickup is no longer available. The item is lost."
2483
            - ""
2484
            - "Please contact the library for more information."
2485
            - ""
2486
            - "Thank you,"
2487
            - ""
2488
            - "[% branch.branchname %]"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 688-693 Circulation: Link Here
688
                  1: Revert
688
                  1: Revert
689
                  0: "Don't revert"
689
                  0: "Don't revert"
690
            - waiting status of a hold if the allocated item is marked as Lost.
690
            - waiting status of a hold if the allocated item is marked as Lost.
691
        -
692
            - pref: SendLostHoldNotices
693
              choices:
694
                  yes: Send
695
                  no: "Don't send"
696
            - a notice to a borrower if their reserved and waiting item is marked as Lost.
691
        -
697
        -
692
            - In the staff interface, split the holds queue into separate tables by
698
            - In the staff interface, split the holds queue into separate tables by
693
            - pref: HoldsSplitQueue
699
            - pref: HoldsSplitQueue
(-)a/t/db_dependent/Reserves.t (-3 / +20 lines)
Lines 1407-1419 subtest 'ModReserveAffect logging' => sub { Link Here
1407
1407
1408
subtest 'Waiting item is marked as lost' => sub {
1408
subtest 'Waiting item is marked as lost' => sub {
1409
1409
1410
    plan tests => 15;
1410
    plan tests => 17;
1411
1411
1412
    # Set up data
1412
    # Set up data
1413
    my $biblio = $builder->build_sample_biblio();
1413
    my $biblio = $builder->build_sample_biblio();
1414
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1414
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1415
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1415
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1416
1416
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 );
1417
    $dbh->do(q|DELETE FROM message_queue|);
1417
    ## TEST 1: BIBLIO-LEVEL HOLD
1418
    ## TEST 1: BIBLIO-LEVEL HOLD
1418
1419
1419
    # place biblio-level hold
1420
    # place biblio-level hold
Lines 1424-1429 subtest 'Waiting item is marked as lost' => sub { Link Here
1424
    });
1425
    });
1425
    my $hold = Koha::Holds->find( $reserve_id );
1426
    my $hold = Koha::Holds->find( $reserve_id );
1426
1427
1428
    $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 %]") });
1429
1427
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1430
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1428
1431
1429
    # set hold as waiting and assign item
1432
    # set hold as waiting and assign item
Lines 1491-1497 subtest 'Waiting item is marked as lost' => sub { Link Here
1491
    $hold->cancel;
1494
    $hold->cancel;
1492
    $item->itemlost( 0 );
1495
    $item->itemlost( 0 );
1493
1496
1497
    my $message_count = $dbh->selectall_arrayref(q{
1498
        SELECT COUNT(*)
1499
        FROM message_queue
1500
        WHERE letter_code = 'LOST_WAITING_HOLD'
1501
    });
1502
    is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' );
1503
1494
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1504
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1505
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 );
1495
1506
1496
    # place item-level hold
1507
    # place item-level hold
1497
    $reserve_id = AddReserve({
1508
    $reserve_id = AddReserve({
Lines 1525-1530 subtest 'Waiting item is marked as lost' => sub { Link Here
1525
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1536
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1526
    $hold = Koha::Holds->find( $reserve_id );
1537
    $hold = Koha::Holds->find( $reserve_id );
1527
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1538
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1539
1540
    $message_count = $dbh->selectall_arrayref(q{
1541
        SELECT COUNT(*)
1542
        FROM message_queue
1543
        WHERE letter_code = 'LOST_WAITING_HOLD'
1544
    });
1545
    is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' );
1528
};
1546
};
1529
1547
1530
sub count_hold_print_messages {
1548
sub count_hold_print_messages {
1531
- 

Return to bug 20844