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

(-)a/Koha/Recall.pm (-1 / +8 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} } ) {        if ( $transport eq 'email' ){
363
            C4::Message->enqueue($letter, $self->patron->unblessed, 'email');
364
        }
365
        if ( $transport eq 'sms' ){
366
            C4::Message->enqueue($letter, $self->patron->unblessed, 'sms');
367
        }
368
    }
362
369
363
    return $self;
370
    return $self;
364
}
371
}
(-)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 (7, "email", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (7, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (8, "email", 0, "circulation", "RETURN_RECALLED_ITEM", null), (8, "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 1634-1636 tables: Link Here
1634
            - "Callnumber: <<items.itemcallnumber>>"
1634
            - "Callnumber: <<items.itemcallnumber>>"
1635
            - "Waiting since: <<recalls.waitingdate>>"
1635
            - "Waiting since: <<recalls.waitingdate>>"
1636
            - "Notes: <<recalls.recallnotes>>"
1636
            - "Notes: <<recalls.recallnotes>>"
1637
1638
        - module: circulation
1639
          code: RETURN_RECALLED_ITEM
1640
          branchcode: ""
1641
          name: "Notification to return a recalled item"
1642
          is_html: 0
1643
          title: "Notification to return a recalled item"
1644
          message_transport_type: sms
1645
          lang: default
1646
          content:
1647
            - "Date: <<today>>"
1648
            - ""
1649
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1650
            - ""
1651
            - "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."
1652
            - ""
1653
            - "Thank you!"
1654
1655
        - module: circulation
1656
          code: PICKUP_RECALLED_ITEM
1657
          branchcode: ""
1658
          name: "Recalled item awaiting pickup"
1659
          is_html: 0
1660
          title: "Recalled item awaiting pickup"
1661
          message_transport_type: sms
1662
          lang: default
1663
          content:
1664
            - "Date: <<today>>"
1665
            - ""
1666
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1667
            - ""
1668
            - "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>>."
1669
            - ""
1670
            - "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 125-130 $expected_expirationdate = dt_from_string->add({ days => 3 }); Link Here
125
$expirationdate = $recall2->calc_expirationdate;
125
$expirationdate = $recall2->calc_expirationdate;
126
is( $expirationdate, $expected_expirationdate, "Expiration date calculated based on circulation rules" );
126
is( $expirationdate, $expected_expirationdate, "Expiration date calculated based on circulation rules" );
127
127
128
C4::Members::Messaging::SetMessagingPreference({
129
    borrowernumber => $patron1->borrowernumber,
130
    message_attribute_id => 11, # Recall_Waiting
131
    message_transport_types => [ qw( email sms ) ],
132
});
133
128
$recall2->set_waiting({ expirationdate => $expirationdate });
134
$recall2->set_waiting({ expirationdate => $expirationdate });
129
is( $recall2->waiting, 1, "Recall is waiting" );
135
is( $recall2->waiting, 1, "Recall is waiting" );
130
136
(-)a/t/db_dependent/Koha/Recalls.t (-2 / +7 lines)
Lines 67-72 Koha::CirculationRules->set_rules({ Link Here
67
C4::Circulation::AddIssue( $patron3->unblessed, $item1->barcode );
67
C4::Circulation::AddIssue( $patron3->unblessed, $item1->barcode );
68
C4::Circulation::AddIssue( $patron3->unblessed, $item2->barcode );
68
C4::Circulation::AddIssue( $patron3->unblessed, $item2->barcode );
69
69
70
C4::Members::Messaging::SetMessagingPreference({
71
    borrowernumber => $patron3->borrowernumber,
72
    message_attribute_id => 12, # Recall_Requested
73
    message_transport_types => [ qw( email sms ) ],
74
});
75
70
my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
76
my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
71
    patron => undef,
77
    patron => undef,
72
    biblio => $biblio1,
78
    biblio => $biblio1,
Lines 140-146 is( dt_from_string( $recall->checkout->date_due ), $expected_due_date, "Checkout Link Here
140
is( $due_date, $expected_due_date, "Due date correctly returned" );
146
is( $due_date, $expected_due_date, "Due date correctly returned" );
141
147
142
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
148
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
143
is( $messages_count, 3, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
149
is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
144
150
145
my $message = Koha::Recalls->move_recall;
151
my $message = Koha::Recalls->move_recall;
146
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
152
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
147
- 

Return to bug 23781