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

(-)a/C4/Reserves.pm (-10 / +27 lines)
Lines 1889-1911 sub _koha_notify_reserve { Link Here
1889
    );
1889
    );
1890
1890
1891
    my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message.
1891
    my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message.
1892
    my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_TESTING};
1892
    my $send_notification = sub {
1893
    my $send_notification = sub {
1893
        my ( $mtt, $letter_code ) = (@_);
1894
        my ( $mtt, $letter_code, $wants_digest ) = (@_);
1894
        return unless defined $letter_code;
1895
        return unless defined $letter_code;
1895
        $letter_params{letter_code} = $letter_code;
1896
        $letter_params{letter_code}            = $letter_code;
1896
        $letter_params{message_transport_type} = $mtt;
1897
        $letter_params{message_transport_type} = $mtt;
1897
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params );
1898
        my $letter = C4::Letters::GetPreparedLetter(%letter_params);
1898
        unless ($letter) {
1899
        unless ($letter) {
1899
            warn "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module";
1900
            warn "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module";
1900
            return;
1901
            return;
1901
        }
1902
        }
1902
1903
1903
        C4::Letters::EnqueueLetter( {
1904
        unless ($wants_digest) {
1904
            letter => $letter,
1905
            C4::Letters::EnqueueLetter(
1905
            borrowernumber => $borrowernumber,
1906
                {
1906
            from_address => $from_email_address,
1907
                    letter                 => $letter,
1907
            message_transport_type => $mtt,
1908
                    borrowernumber         => $borrowernumber,
1908
        } );
1909
                    from_address           => $from_email_address,
1910
                    message_transport_type => $mtt,
1911
                }
1912
            );
1913
        } else {
1914
            C4::Context->dbh->do(q|LOCK TABLE message_queue READ|)  unless $do_not_lock;
1915
            C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock;
1916
            my $message = C4::Message->find_last_message( $patron->unblessed, $letter_code, $mtt );
1917
            unless ($message) {
1918
                C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
1919
                C4::Message->enqueue( $letter, $patron, $mtt );
1920
            } else {
1921
                $message->append($letter);
1922
                $message->update;
1923
            }
1924
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
1925
        }
1909
    };
1926
    };
1910
1927
1911
    while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
1928
    while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
Lines 1916-1922 sub _koha_notify_reserve { Link Here
1916
            or ( $mtt eq 'phone' and not $patron->phone ) # No phone number to call
1933
            or ( $mtt eq 'phone' and not $patron->phone ) # No phone number to call
1917
        );
1934
        );
1918
1935
1919
        &$send_notification($mtt, $letter_code);
1936
        &$send_notification($mtt, $letter_code, $messagingprefs->{wants_digest});
1920
        $notification_sent++;
1937
        $notification_sent++;
1921
    }
1938
    }
1922
    #Making sure that a print notification is sent if no other transport types can be utilized.
1939
    #Making sure that a print notification is sent if no other transport types can be utilized.
(-)a/installer/data/mysql/atomicupdate/bug_8838.pl (+37 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "8838",
5
    description => "Add digest option for HOLD notice",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{
11
            INSERT INTO `letter` VALUES (NULL,'reserves','HOLDDGST','','Hold available for pickup (digest)',0,'Hold(s) available for pickup','You have one or more holds available for pickup:\r\n----\r\nTitle: [% hold.biblio.title %]\r\nAuthor: [% hold.biblio.author %]\r\nCopy: [% hold.item.copynumber %]\r\nLocation: [% hold.branch.branchname %]\r\nWaiting since: [% hold.waitingdate %]:\r\n[% hold.branch.branchaddress1 %]\r\n[% hold.branch.branchaddress2 %]\r\n[% hold.branch.branchaddress3 %]\r\n[% hold.branch.branchcity %] [% hold.branch.branchzip %]\r\n----','email','default','2023-08-29 18:42:15');
12
        });
13
14
        $dbh->do(q{
15
            INSERT INTO message_transports VALUES
16
            ( 4, "email", 1, "reserves", "HOLDDGST", "" ),
17
            ( 4, "sms", 1, "reserves", "HOLDDGST", "" ),
18
            ( 4, "phone", 1, "reserves", "HOLDDGST", "");
19
        });
20
21
        # Print useful stuff here
22
        # tables
23
        say $out "Added new table 'XXX'";
24
        say $out "Added column 'XXX.YYY'";
25
26
        # sysprefs
27
        say $out "Added new system preference 'XXX'";
28
        say $out "Updated system preference 'XXX'";
29
        say $out "Removed system preference 'XXX'";
30
31
        # permissions
32
        say $out "Added new permission 'XXX'";
33
34
        # letters
35
        say $out "Added new letter 'XXX' (TRANSPORT)";
36
    },
37
};
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (-1 / +23 lines)
Lines 1771-1776 tables: Link Here
1771
            - "<<branches.branchaddress3>>"
1771
            - "<<branches.branchaddress3>>"
1772
            - "<<branches.branchcity>> <<branches.branchzip>>"
1772
            - "<<branches.branchcity>> <<branches.branchzip>>"
1773
1773
1774
        - module: reserves
1775
          code: HOLDDGST
1776
          branchcode: ""
1777
          name: "Hold(s) available for pickup"
1778
          is_html: 0
1779
          title: "Hold(s) available for pickup"
1780
          message_transport_type: email
1781
          lang: default
1782
          content:
1783
            - "You have one or more holds available for pickup:"
1784
            - "----"
1785
            - "Title: [% hold.biblio.title %]"
1786
            - "Author: [% hold.biblio.author %]"
1787
            - "Copy: [% hold.item.copynumber %]"
1788
            - "Waiting since: [% hold.waitingdate %]"
1789
            - "Waitng at: [% hold.branch.branchname %]"
1790
            - "[% hold.branch.branchaddress1 %]"
1791
            - "[% hold.branch.branchaddress2 %]"
1792
            - "[% hold.branch.branchaddress3 %]"
1793
            - "[% hold.branch.branchcity %] [% hold.branch.branchzip %]"
1794
            - "----"
1795
            - "Thank you!"
1796
1774
        - module: reserves
1797
        - module: reserves
1775
          code: HOLD
1798
          code: HOLD
1776
          branchcode: ""
1799
          branchcode: ""
1777
- 

Return to bug 8838