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->unblessed, 'email');
361
    my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $self->borrowernumber, 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->unblessed, 'email');
365
        }
366
        if ( $transport eq 'sms' ){
367
            C4::Message->enqueue($letter, $self->patron->unblessed, 'sms');
368
        }
369
    }
362
370
363
    return $self;
371
    return $self;
364
}
372
}
(-)a/Koha/Recalls.pm (-1 / +10 lines)
Lines 160-166 sub add_recall { Link Here
160
            },
160
            },
161
        );
161
        );
162
162
163
        C4::Message->enqueue( $letter, $checkout->patron->unblessed, 'email' );
163
        my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $checkout->borrowernumber, message_name => 'Recall_Requested' });
164
165
        while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) {
166
            if ( $transport eq 'email' ){
167
                C4::Message->enqueue($letter, $checkout->patron->unblessed, 'email');
168
            }
169
            if ( $transport eq 'sms' ){
170
                C4::Message->enqueue($letter, $checkout->patron->unblessed, 'sms');
171
            }
172
        }
164
173
165
        $item = Koha::Items->find( $itemnumber );
174
        $item = Koha::Items->find( $itemnumber );
166
        # add to statistics table
175
        # 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 (11, 'Recall_Waiting', 0), (12, '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 (11, "email", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (11, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (12, "email", 0, "circulation", "RETURN_RECALLED_ITEM", null), (12, "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 (+34 lines)
Lines 1635-1637 tables: Link Here
1635
            - "Callnumber: <<items.itemcallnumber>>"
1635
            - "Callnumber: <<items.itemcallnumber>>"
1636
            - "Waiting since: <<recalls.waitingdate>>"
1636
            - "Waiting since: <<recalls.waitingdate>>"
1637
            - "Notes: <<recalls.recallnotes>>"
1637
            - "Notes: <<recalls.recallnotes>>"
1638
1639
        - module: circulation
1640
          code: RETURN_RECALLED_ITEM
1641
          branchcode: ""
1642
          name: "Notification to return a recalled item"
1643
          is_html: 0
1644
          title: "Notification to return a recalled item"
1645
          message_transport_type: sms
1646
          lang: default
1647
          content:
1648
            - "Date: <<today>>"
1649
            - ""
1650
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1651
            - ""
1652
            - "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."
1653
            - ""
1654
            - "Thank you!"
1655
1656
        - module: circulation
1657
          code: PICKUP_RECALLED_ITEM
1658
          branchcode: ""
1659
          name: "Recalled item awaiting pickup"
1660
          is_html: 0
1661
          title: "Recalled item awaiting pickup"
1662
          message_transport_type: sms
1663
          lang: default
1664
          content:
1665
            - "Date: <<today>>"
1666
            - ""
1667
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1668
            - ""
1669
            - "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>>."
1670
            - ""
1671
            - "Thank you!"
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql (-1 / +15 lines)
Lines 245-251 ITEM RECALLED Link Here
245
Barcode: <<items.barcode>>
245
Barcode: <<items.barcode>>
246
Callnumber: <<items.itemcallnumber>>
246
Callnumber: <<items.itemcallnumber>>
247
Waiting since: <<recalls.waitingdate>>
247
Waiting since: <<recalls.waitingdate>>
248
Notes: <<recalls.recallnotes>>', 'print');
248
Notes: <<recalls.recallnotes>>', 'print'),
249
('circulation','RETURN_RECALLED_ITEM','','Notification to return a recalled item','0','Notification to return a recalled item','Date: <<today>>
250
251
<<borrowers.firstname>> <<borrowers.surname>>,
252
253
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.
254
255
Thank you!','sms'),
256
('circulation','PICKUP_RECALLED_ITEM','','Recalled item awaiting pickup','0','Recalled item awaiting pickup','Date: <<today>>
257
258
<<borrowers.firstname>> <<borrowers.surname>>,
259
260
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>>.
261
262
Thank you!','sms');
249
263
250
INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
264
INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
251
('circulation', 'ACCOUNT_PAYMENT', '', 'Account payment', 0, 'Account payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'),
265
('circulation', 'ACCOUNT_PAYMENT', '', 'Account payment', 0, 'Account payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'),
(-)a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql (-2 / +3 lines)
Lines 9-13 values Link Here
9
(7, 'Ill_ready', 0),
9
(7, 'Ill_ready', 0),
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
13
(11, 'Recall_Waiting', 0),
14
(12, 'Recall_Requested', 0);
(-)a/installer/data/mysql/mandatory/sample_notices_message_transports.sql (-1 / +5 lines)
Lines 38-41 values Link Here
38
(10, 'email', 0, 'circulation', 'HOLD_REMINDER'),
38
(10, 'email', 0, 'circulation', 'HOLD_REMINDER'),
39
(10, 'sms',   0, 'circulation', 'HOLD_REMINDER'),
39
(10, 'sms',   0, 'circulation', 'HOLD_REMINDER'),
40
(10, 'phone', 0, 'circulation', 'HOLD_REMINDER'),
40
(10, 'phone', 0, 'circulation', 'HOLD_REMINDER'),
41
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER');
41
(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'),
42
(11, "email", 0, "circulation", "PICKUP_RECALLED_ITEM"),
43
(11, "sms",   0, "circulation", "PICKUP_RECALLED_ITEM"),
44
(12, "email", 0, "circulation", "RETURN_RECALLED_ITEM"),
45
(12, "sms",   0, "circulation", "RETURN_RECALLED_ITEM");
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc (+2 lines)
Lines 30-35 Link Here
30
          [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready
30
          [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready
31
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable
31
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable
32
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal
32
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal
33
          [% ELSIF ( messaging_preference.Recall_Waiting ) %]Recall awaiting pickup
34
          [% ELSIF ( messaging_preference.Recall_Requested ) %]Return recalled item
33
          [% ELSE %]Unknown [% END %]</td>
35
          [% ELSE %]Unknown [% END %]</td>
34
      [% IF ( messaging_preference.takes_days ) %]
36
      [% IF ( messaging_preference.takes_days ) %]
35
      <td>
37
      <td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt (+2 lines)
Lines 76-81 Link Here
76
                                                [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready
76
                                                [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready
77
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable
77
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable
78
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal
78
                                                [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal
79
                                                [% ELSIF ( messaging_preference.Recall_Waiting ) %]Recall awaiting pickup
80
                                                [% ELSIF ( messaging_preference.Recall_Requested ) %]Return recalled item
79
                                                [% ELSE %]Unknown [% END %]</td>
81
                                                [% ELSE %]Unknown [% 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">
83
                                                <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 => 11, # 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 => 12, # 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