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

(-)a/C4/Circulation.pm (+15 lines)
Lines 3903-3908 sub LostItem{ Link Here
3903
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
3903
            $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber });
3904
        }
3904
        }
3905
    }
3905
    }
3906
3907
    # SendLostHoldNotices
3908
    my $item = Koha::Items->find( $itemnumber );
3909
    if ( C4::Context->preference('SendLostHoldNotices') && defined $hold && $item->itemlost ){
3910
        my $letter = C4::Letters::GetPreparedLetter(
3911
            module => 'reserves',
3912
            letter_code => 'LOST_WAITING_HOLD',
3913
            branchcode => $hold->branchcode,
3914
            tables => {
3915
                borrowers => $hold->borrowernumber,
3916
                branches => $hold->branchcode,
3917
            },
3918
        );
3919
        C4::Message->enqueue($letter, $hold->borrower->unblessed, 'email');
3920
    }
3906
}
3921
}
3907
3922
3908
sub GetOfflineOperations {
3923
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 1545-1547 tables: Link Here
1545
            - "This item must be renewed at the library."
1545
            - "This item must be renewed at the library."
1546
            - "[% END %]"
1546
            - "[% END %]"
1547
            - "[% END %]"
1547
            - "[% END %]"
1548
1549
        - module: reserves
1550
          code: LOST_WAITING_HOLD
1551
          branchcode: ""
1552
          name: "Waiting hold marked lost"
1553
          is_html: 0
1554
          title: "Your waiting hold has been marked lost"
1555
          message_transport_type: email
1556
          lang: default
1557
          content:
1558
            - "Dear [% borrower.firstname %] [% borrowers.surname %],"
1559
            - ""
1560
            - "Your hold awaiting pickup is no longer available. The item is lost."
1561
            - ""
1562
            - "Please contact the library for more information."
1563
            - ""
1564
            - "Thank you,"
1565
            - ""
1566
            - "[% branch.branchname %]"
(-)a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql (-1 / +3 lines)
Lines 37-43 Checked in items for [% borrower.title %] [% borrower.firstname %] [% borrower.i Link Here
37
[% item.biblio.title %] <br />
37
[% item.biblio.title %] <br />
38
Barcode: [% item.barcode %] <br />
38
Barcode: [% item.barcode %] <br />
39
</p>
39
</p>
40
[% END %]", 'print');
40
[% END %]", 'print'),
41
('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost',0,'Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
42
;
41
43
42
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
44
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
43
VALUES ('suggestions','NEW_SUGGESTION','Nouvelle suggestion','Nouvelle suggestion','<h3>Suggestion en attente</h3>
45
VALUES ('suggestions','NEW_SUGGESTION','Nouvelle suggestion','Nouvelle suggestion','<h3>Suggestion en attente</h3>
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql (-1 / +3 lines)
Lines 24-30 VALUES Link Here
24
('suggestions','TO_PROCESS','Avis au propriétaire du poste budgétaire', 'Une suggestion est prête à être traitée','<<borrowers.firstname>> <<borrowers.surname>>,\n\nUne nouvelle suggestion est prête à être traitée : <<suggestions.title>> / <<suggestions.author>>.\n\nMerci,\n\n<<branches.branchname>>', 'email'),
24
('suggestions','TO_PROCESS','Avis au propriétaire du poste budgétaire', 'Une suggestion est prête à être traitée','<<borrowers.firstname>> <<borrowers.surname>>,\n\nUne nouvelle suggestion est prête à être traitée : <<suggestions.title>> / <<suggestions.author>>.\n\nMerci,\n\n<<branches.branchname>>', 'email'),
25
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
25
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
26
('members', 'DISCHARGE', 'Quitus', 'Quitus pour <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Quitus</h1>\r\n\r\nLa librairie <<borrowers.branchcode>> certifies que lecteur suivant :\r\n\r\n    <<borrowers.firstname>> <<borrowers.surname>>\r\n   Numéro de carte : <<borrowers.cardnumber>>\r\n\r\na bien retourné tous ses documents.', 'email'),
26
('members', 'DISCHARGE', 'Quitus', 'Quitus pour <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Quitus</h1>\r\n\r\nLa librairie <<borrowers.branchcode>> certifies que lecteur suivant :\r\n\r\n    <<borrowers.firstname>> <<borrowers.surname>>\r\n   Numéro de carte : <<borrowers.cardnumber>>\r\n\r\na bien retourné tous ses documents.', 'email'),
27
('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <<problem_reports.username>>\n\nProblem page: <<problem_reports.problempage>>\n\nTitle: <<problem_reports.title>>\n\nMessage: <<problem_reports.content>>','email');
27
('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <<problem_reports.username>>\n\nProblem page: <<problem_reports.problempage>>\n\nTitle: <<problem_reports.title>>\n\nMessage: <<problem_reports.content>>','email'),
28
('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
29
;
28
30
29
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
31
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
30
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Suggestion pendin    g approval</h3>
32
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Suggestion pendin    g approval</h3>
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql (-1 / +3 lines)
Lines 44-50 VALUES ('circulation','ODUE','Purring','Purring på dokument','<<borrowers.first Link Here
44
('suggestions','TO_PROCESS','Notify fund owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.author>>.\n\nThank you,\n\n<<branches.branchname>>', 'email'),
44
('suggestions','TO_PROCESS','Notify fund owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.author>>.\n\nThank you,\n\n<<branches.branchname>>', 'email'),
45
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
45
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
46
('members', 'DISCHARGE', 'Discharge', 'Discharge for <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Discharge</h1>\r\n\r\nThe library <<borrowers.branchcode>> certifies that the following borrower :\r\n\r\n    <<borrowers.firstname>> <<borrowers.surname>>\r\n   Cardnumber : <<borrowers.cardnumber>>\r\n\r\nreturned all his documents.', 'email'),
46
('members', 'DISCHARGE', 'Discharge', 'Discharge for <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Discharge</h1>\r\n\r\nThe library <<borrowers.branchcode>> certifies that the following borrower :\r\n\r\n    <<borrowers.firstname>> <<borrowers.surname>>\r\n   Cardnumber : <<borrowers.cardnumber>>\r\n\r\nreturned all his documents.', 'email'),
47
('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <<problem_reports.username>>\n\nProblem page: <<problem_reports.problempage>>\n\nTitle: <<problem_reports.title>>\n\nMessage: <<problem_reports.content>>','email');
47
('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <<problem_reports.username>>\n\nProblem page: <<problem_reports.problempage>>\n\nTitle: <<problem_reports.title>>\n\nMessage: <<problem_reports.content>>','email'),
48
('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
49
;
48
50
49
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
51
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
50
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Suggestion pendin    g approval</h3>
52
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Suggestion pendin    g approval</h3>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 666-671 Circulation: Link Here
666
                  no: "Don't revert"
666
                  no: "Don't revert"
667
            - waiting status of a hold if the allocated item is marked as Lost.
667
            - waiting status of a hold if the allocated item is marked as Lost.
668
        -
668
        -
669
            - pref: SendLostHoldNotices
670
              choices:
671
                  yes: Send
672
                  no: "Don't send"
673
            - a notice to a borrower if their reserved and waiting item is marked as Lost.
674
        -
669
            - In the staff interface, split the holds queue into separate tables by
675
            - In the staff interface, split the holds queue into separate tables by
670
            - pref: HoldsSplitQueue
676
            - pref: HoldsSplitQueue
671
              choices:
677
              choices:
(-)a/t/db_dependent/Reserves.t (-3 / +20 lines)
Lines 1334-1346 subtest 'ModReserveAffect logging' => sub { Link Here
1334
1334
1335
subtest 'Waiting item is marked as lost' => sub {
1335
subtest 'Waiting item is marked as lost' => sub {
1336
1336
1337
    plan tests => 15;
1337
    plan tests => 17;
1338
1338
1339
    # Set up data
1339
    # Set up data
1340
    my $biblio = $builder->build_sample_biblio();
1340
    my $biblio = $builder->build_sample_biblio();
1341
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1341
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1342
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1342
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1343
1343
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 );
1344
    $dbh->do(q|DELETE FROM message_queue|);
1344
    ## TEST 1: BIBLIO-LEVEL HOLD
1345
    ## TEST 1: BIBLIO-LEVEL HOLD
1345
1346
1346
    # place biblio-level hold
1347
    # place biblio-level hold
Lines 1351-1356 subtest 'Waiting item is marked as lost' => sub { Link Here
1351
    });
1352
    });
1352
    my $hold = Koha::Holds->find( $reserve_id );
1353
    my $hold = Koha::Holds->find( $reserve_id );
1353
1354
1355
    $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 %]") });
1356
1354
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1357
    is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
1355
1358
1356
    # set hold as waiting and assign item
1359
    # set hold as waiting and assign item
Lines 1418-1424 subtest 'Waiting item is marked as lost' => sub { Link Here
1418
    $hold->cancel;
1421
    $hold->cancel;
1419
    $item->itemlost( 0 );
1422
    $item->itemlost( 0 );
1420
1423
1424
    my $message_count = $dbh->selectall_arrayref(q{
1425
        SELECT COUNT(*)
1426
        FROM message_queue
1427
        WHERE letter_code = 'LOST_WAITING_HOLD'
1428
    });
1429
    is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' );
1430
1421
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1431
    # TEST 3: ITEM-LEVEL HOLD, CANCEL
1432
    t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 );
1422
1433
1423
    # place item-level hold
1434
    # place item-level hold
1424
    $reserve_id = AddReserve({
1435
    $reserve_id = AddReserve({
Lines 1452-1457 subtest 'Waiting item is marked as lost' => sub { Link Here
1452
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1463
    C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 });
1453
    $hold = Koha::Holds->find( $reserve_id );
1464
    $hold = Koha::Holds->find( $reserve_id );
1454
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1465
    is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' );
1466
1467
    $message_count = $dbh->selectall_arrayref(q{
1468
        SELECT COUNT(*)
1469
        FROM message_queue
1470
        WHERE letter_code = 'LOST_WAITING_HOLD'
1471
    });
1472
    is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' );
1455
};
1473
};
1456
1474
1457
sub count_hold_print_messages {
1475
sub count_hold_print_messages {
1458
- 

Return to bug 20844