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 (+35 lines)
Lines 1695-1700 tables: Link Here
1695
            - "Thank you!"
1695
            - "Thank you!"
1696
1696
1697
        - module: circulation
1697
        - module: circulation
1698
          code: RETURN_RECALLED_ITEM
1699
          branchcode: ""
1700
          name: "Notification to return a recalled item"
1701
          is_html: 0
1702
          title: "Notification to return a recalled item"
1703
          message_transport_type: sms
1704
          lang: default
1705
          content:
1706
            - "Date: <<today>>"
1707
            - ""
1708
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1709
            - ""
1710
            - "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."
1711
            - ""
1712
            - "Thank you!"
1713
1714
        - module: circulation
1715
          code: PICKUP_RECALLED_ITEM
1716
          branchcode: ""
1717
          name: "Recalled item awaiting pickup"
1718
          is_html: 0
1719
          title: "Recalled item awaiting pickup"
1720
          message_transport_type: sms
1721
          lang: default
1722
          content:
1723
            - "Date: <<today>>"
1724
            - ""
1725
            - "<<borrowers.firstname>> <<borrowers.surname>>,"
1726
            - ""
1727
            - "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>>."
1728
            - ""
1729
            - "Thank you!"
1730
1731
1732
        - module: circulation
1698
          code: RECALL_REQUESTER_DET
1733
          code: RECALL_REQUESTER_DET
1699
          branchcode: ""
1734
          branchcode: ""
1700
          name: "Details of patron who recalled item"
1735
          name: "Details of patron who recalled item"
(-)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 ) %]<span>Interlibrary loan ready</span>
30
          [% ELSIF ( messaging_preference.Ill_ready ) %]<span>Interlibrary loan ready</span>
31
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
31
          [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
32
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
32
          [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span>
33
          [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span>
34
          [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span>
33
          [% ELSE %]<span>Unknown</span>
35
          [% ELSE %]<span>Unknown</span>
34
          [% END %]
36
          [% END %]
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 ) %]<span>Interlibrary loan ready</span>
76
                                                [% ELSIF ( messaging_preference.Ill_ready ) %]<span>Interlibrary loan ready</span>
77
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span>
77
                                                [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</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">
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