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 161-167 sub add_recall { Link Here
161
            },
161
            },
162
        );
162
        );
163
163
164
        C4::Message->enqueue( $letter, $checkout->patron, 'email' );
164
        my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $checkout->borrowernumber, message_name => 'Recall_Requested' });
165
166
        while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) {
167
            if ( $transport eq 'email' ){
168
                C4::Message->enqueue( $letter, $checkout->patron, 'email' );
169
            }
170
            if ( $transport eq 'sms' ){
171
                C4::Message->enqueue( $letter, $checkout->patron, 'sms' );
172
            }
173
        }
165
174
166
        $item = Koha::Items->find( $itemnumber );
175
        $item = Koha::Items->find( $itemnumber );
167
        # add to statistics table
176
        # 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 2213-2218 tables: Link Here
2213
            - ""
2213
            - ""
2214
            - "Thank you!"
2214
            - "Thank you!"
2215
2215
2216
        - module: circulation
2217
          code: RETURN_RECALLED_ITEM
2218
          branchcode: ""
2219
          name: "Notification to return a recalled item"
2220
          is_html: 0
2221
          title: "Notification to return a recalled item"
2222
          message_transport_type: sms
2223
          lang: default
2224
          content:
2225
            - "Date: <<today>>"
2226
            - ""
2227
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
2228
            - ""
2229
            - "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."
2230
            - ""
2231
            - "Thank you!"
2232
2233
        - module: circulation
2234
          code: PICKUP_RECALLED_ITEM
2235
          branchcode: ""
2236
          name: "Recalled item awaiting pickup"
2237
          is_html: 0
2238
          title: "Recalled item awaiting pickup"
2239
          message_transport_type: sms
2240
          lang: default
2241
          content:
2242
            - "Date: <<today>>"
2243
            - ""
2244
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
2245
            - ""
2246
            - "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>>."
2247
            - ""
2248
            - "Thank you!"
2249
2250
2216
        - module: circulation
2251
        - module: circulation
2217
          code: RECALL_REQUESTER_DET
2252
          code: RECALL_REQUESTER_DET
2218
          branchcode: ""
2253
          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 41-44 values Link Here
41
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'),
41
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'),
42
(11, 'email', 0, 'ill', 'ILL_REQUEST_UPDATE'),
42
(11, 'email', 0, 'ill', 'ILL_REQUEST_UPDATE'),
43
(11, 'sms',   0, 'ill', 'ILL_REQUEST_UPDATE'),
43
(11, 'sms',   0, 'ill', 'ILL_REQUEST_UPDATE'),
44
(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE');
44
(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE'),
45
(12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM"),
46
(12, "sms",   0, "circulation", "PICKUP_RECALLED_ITEM"),
47
(13, "email", 0, "circulation", "RETURN_RECALLED_ITEM"),
48
(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 78-83 Link Here
78
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
78
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
79
                                                [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
79
                                                [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span>
80
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
80
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
81
                                                [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span>
82
                                                [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span>
81
                                                [% ELSE %]<span>Unknown</span> [% END %]</td>
83
                                                [% ELSE %]<span>Unknown</span> [% END %]</td>
82
                                            [% IF ( messaging_preference.takes_days ) %]
84
                                            [% IF ( messaging_preference.takes_days ) %]
83
                                                <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS">
85
                                                <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS">
(-)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->unblessed, $item1->barcode );
68
C4::Circulation::AddIssue( $patron3->unblessed, $item1->barcode );
69
C4::Circulation::AddIssue( $patron3->unblessed, $item2->barcode );
69
C4::Circulation::AddIssue( $patron3->unblessed, $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 141-147 is( t::lib::Dates::compare( $recall->checkout->date_due, $expected_due_date ), 0 Link Here
141
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
147
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
142
148
143
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
149
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
144
is( $messages_count, 3, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
150
is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
145
151
146
my $message = Koha::Recalls->move_recall;
152
my $message = Koha::Recalls->move_recall;
147
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
153
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
148
- 

Return to bug 23781