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

(-)a/Koha/Recall.pm (-1 / +9 lines)
Lines 358-364 sub set_waiting { Link Here
358
        },
358
        },
359
    );
359
    );
360
360
361
    C4::Message->enqueue($letter, $self->patron, 'email');
361
    my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $self->patron_id, message_name => 'Recall_Waiting' });
362
    while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) {
363
        if ( $transport eq 'email' ){
364
            C4::Message->enqueue($letter, $self->patron, 'email');
365
        }
366
        if ( $transport eq 'sms' ){
367
            C4::Message->enqueue($letter, $self->patron, 'sms');
368
        }
369
    }
362
370
363
    return $self;
371
    return $self;
364
}
372
}
(-)a/Koha/Recalls.pm (-1 / +10 lines)
Lines 167-173 sub add_recall { Link Here
167
            },
167
            },
168
        );
168
        );
169
169
170
        C4::Message->enqueue( $letter, $checkout->patron, 'email' );
170
        my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $checkout->borrowernumber, message_name => 'Recall_Requested' });
171
172
        while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) {
173
            if ( $transport eq 'email' ){
174
                C4::Message->enqueue( $letter, $checkout->patron, 'email' );
175
            }
176
            if ( $transport eq 'sms' ){
177
                C4::Message->enqueue( $letter, $checkout->patron, 'sms' );
178
            }
179
        }
171
180
172
        $item = Koha::Items->find( $itemnumber );
181
        $item = Koha::Items->find( $itemnumber );
173
        # add to statistics table
182
        # add to statistics table
(-)a/installer/data/mysql/atomicupdate/bug_23781-recalls_message_attributes.pl (+12 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23781",
5
    description => "Adding message attributes for recalls: Recall_Waiting, Recall_Requested",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{ INSERT IGNORE INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (12, 'Recall_Waiting', 0), (13, 'Recall_Requested', 0) });
11
    },
12
};
(-)a/installer/data/mysql/atomicupdate/bug_23781-recalls_message_transports.pl (+12 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23781",
5
    description => "Adding message transports for recalls notices",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{ INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code, branchcode) VALUES (12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (12, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (13, "email", 0, "circulation", "RETURN_RECALLED_ITEM", null), (13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM", null) });
11
    },
12
};
(-)a/installer/data/mysql/atomicupdate/bug_23781-recalls_sms_notices.pl (+24 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23781",
5
    description => "Add recalls SMS notices: RETURN_RECALLED_ITEM, PICKUP_RECALLED_ITEM",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES ('circulation','RETURN_RECALLED_ITEM','','Notification to return a recalled item','0','Notification to return a recalled item','Date: <<today>>
11
12
<<borrowers.firstname>> <<borrowers.surname>>,
13
14
A recall has been placed on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>). The due date has been updated, and is now <<issues.date_due>>. Please return the item before the due date.
15
16
Thank you!','sms'), ('circulation','PICKUP_RECALLED_ITEM','','Recalled item awaiting pickup','0','Recalled item awaiting pickup','Date: <<today>>
17
18
<<borrowers.firstname>> <<borrowers.surname>>,
19
20
A recall that you requested on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>) is now ready for you to pick up at <<recalls.branchcode>>. Please pick up your item by <<recalls.expirationdate>>.
21
22
Thank you!','sms') });
23
    },
24
};
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (+35 lines)
Lines 2278-2283 tables: Link Here
2278
            - ""
2278
            - ""
2279
            - "Thank you!"
2279
            - "Thank you!"
2280
2280
2281
        - module: circulation
2282
          code: RETURN_RECALLED_ITEM
2283
          branchcode: ""
2284
          name: "Notification to return a recalled item"
2285
          is_html: 0
2286
          title: "Notification to return a recalled item"
2287
          message_transport_type: sms
2288
          lang: default
2289
          content:
2290
            - "Date: <<today>>"
2291
            - ""
2292
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
2293
            - ""
2294
            - "A recall has been placed on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>). The due date has been updated, and is now <<issues.date_due>>. Please return the item before the due date."
2295
            - ""
2296
            - "Thank you!"
2297
2298
        - module: circulation
2299
          code: PICKUP_RECALLED_ITEM
2300
          branchcode: ""
2301
          name: "Recalled item awaiting pickup"
2302
          is_html: 0
2303
          title: "Recalled item awaiting pickup"
2304
          message_transport_type: sms
2305
          lang: default
2306
          content:
2307
            - "Date: <<today>>"
2308
            - ""
2309
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
2310
            - ""
2311
            - "A recall that you requested on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>) is now ready for you to pick up at <<recalls.branchcode>>. Please pick up your item by <<recalls.expirationdate>>."
2312
            - ""
2313
            - "Thank you!"
2314
2315
2281
        - module: circulation
2316
        - module: circulation
2282
          code: RECALL_REQUESTER_DET
2317
          code: RECALL_REQUESTER_DET
2283
          branchcode: ""
2318
          branchcode: ""
(-)a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql (-2 / +3 lines)
Lines 10-14 values Link Here
10
(8, 'Ill_unavailable', 0),
10
(8, 'Ill_unavailable', 0),
11
(9, 'Auto_Renewals', 0),
11
(9, 'Auto_Renewals', 0),
12
(10, 'Hold_Reminder', 0),
12
(10, 'Hold_Reminder', 0),
13
(11, 'Ill_update', 0);
13
(11, 'Ill_update', 0),
14
14
(12, 'Recall_Waiting', 0),
15
(13, 'Recall_Requested', 0);
(-)a/installer/data/mysql/mandatory/sample_notices_message_transports.sql (-1 / +5 lines)
Lines 44-47 values Link Here
44
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'),
44
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'),
45
(11, 'email', 0, 'ill', 'ILL_REQUEST_UPDATE'),
45
(11, 'email', 0, 'ill', 'ILL_REQUEST_UPDATE'),
46
(11, 'sms',   0, 'ill', 'ILL_REQUEST_UPDATE'),
46
(11, 'sms',   0, 'ill', 'ILL_REQUEST_UPDATE'),
47
(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE');
47
(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE'),
48
(12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM"),
49
(12, "sms",   0, "circulation", "PICKUP_RECALLED_ITEM"),
50
(13, "email", 0, "circulation", "RETURN_RECALLED_ITEM"),
51
(13, "sms",   0, "circulation", "RETURN_RECALLED_ITEM");
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc (+2 lines)
Lines 34-39 Link Here
34
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
34
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
35
          [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
35
          [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
36
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
36
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
37
          [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span>
38
          [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span>
37
          [% ELSE %]<span>Unknown</span>
39
          [% ELSE %]<span>Unknown</span>
38
          [% END %]
40
          [% END %]
39
      </td>
41
      </td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt (+2 lines)
Lines 76-81 Link Here
76
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
76
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
77
                                                [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
77
                                                [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
78
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
78
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
79
                                                [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span>
80
                                                [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span>
79
                                                [% ELSE %]<span>Unknown</span> [% END %]</td>
81
                                                [% ELSE %]<span>Unknown</span> [% END %]</td>
80
                                            [% IF ( messaging_preference.takes_days ) %]
82
                                            [% IF ( messaging_preference.takes_days ) %]
81
                                                <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS" aria-label="Choose how many days in advance you wish to receive notice">
83
                                                <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS" aria-label="Choose how many days in advance you wish to receive notice">
(-)a/t/db_dependent/Koha/Recall.t (+6 lines)
Lines 126-131 $expected_expirationdate = dt_from_string->add({ days => 3 }); Link Here
126
$expirationdate = $recall2->calc_expirationdate;
126
$expirationdate = $recall2->calc_expirationdate;
127
is( t::lib::Dates::compare( $expirationdate, $expected_expirationdate ), 0, "Expiration date calculated based on circulation rules" );
127
is( t::lib::Dates::compare( $expirationdate, $expected_expirationdate ), 0, "Expiration date calculated based on circulation rules" );
128
128
129
C4::Members::Messaging::SetMessagingPreference({
130
    borrowernumber => $patron1->borrowernumber,
131
    message_attribute_id => 12, # Recall_Waiting
132
    message_transport_types => [ qw( email sms ) ],
133
});
134
129
$recall2->set_waiting({ expirationdate => $expirationdate });
135
$recall2->set_waiting({ expirationdate => $expirationdate });
130
is( $recall2->waiting, 1, "Recall is waiting" );
136
is( $recall2->waiting, 1, "Recall is waiting" );
131
137
(-)a/t/db_dependent/Koha/Recalls.t (-2 / +7 lines)
Lines 68-73 Koha::CirculationRules->set_rules({ Link Here
68
C4::Circulation::AddIssue( $patron3, $item1->barcode );
68
C4::Circulation::AddIssue( $patron3, $item1->barcode );
69
C4::Circulation::AddIssue( $patron3, $item2->barcode );
69
C4::Circulation::AddIssue( $patron3, $item2->barcode );
70
70
71
C4::Members::Messaging::SetMessagingPreference({
72
    borrowernumber => $patron3->borrowernumber,
73
    message_attribute_id => 13, # Recall_Requested
74
    message_transport_types => [ qw( email sms ) ],
75
});
76
71
my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
77
my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
72
    patron => undef,
78
    patron => undef,
73
    biblio => $biblio1,
79
    biblio => $biblio1,
Lines 147-153 is( Link Here
147
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
153
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
148
154
149
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
155
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
150
is( $messages_count, 3, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
156
is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
151
157
152
my $message = Koha::Recalls->move_recall;
158
my $message = Koha::Recalls->move_recall;
153
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
159
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
154
- 

Return to bug 23781