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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2725-2731 sub SendCirculationAlert { Link Here
2725
        }
2725
        }
2726
    ) or return;
2726
    ) or return;
2727
2727
2728
    my @transports = @{ $borrower_preferences->{transports} };
2728
    my @transports = keys %{ $borrower_preferences->{transports} };
2729
    # warn "no transports" unless @transports;
2729
    # warn "no transports" unless @transports;
2730
    for (@transports) {
2730
    for (@transports) {
2731
        # warn "transport: $_";
2731
        # warn "transport: $_";
(-)a/C4/Form/MessagingPreferences.pm (-1 / +1 lines)
Lines 139-145 sub set_form_values { Link Here
139
                selected   => $_ == $days_in_advance ? 'selected="selected"' :'' } 
139
                selected   => $_ == $days_in_advance ? 'selected="selected"' :'' } 
140
            } ( 0..30 ); # FIXME: 30 is a magic number.
140
            } ( 0..30 ); # FIXME: 30 is a magic number.
141
        }
141
        }
142
        foreach my $transport ( @{$pref->{'transports'}} ) {
142
        foreach my $transport ( keys %{$pref->{'transports'}} ) {
143
            $option->{'transports_'.$transport} = 1;
143
            $option->{'transports_'.$transport} = 1;
144
        }
144
        }
145
        $option->{'digest'} = 1 if $pref->{'wants_digest'};
145
        $option->{'digest'} = 1 if $pref->{'wants_digest'};
(-)a/C4/Letters.pm (+2 lines)
Lines 670-675 sub EnqueueLetter ($) { Link Here
670
    return unless exists $params->{'borrowernumber'};
670
    return unless exists $params->{'borrowernumber'};
671
    return unless exists $params->{'message_transport_type'};
671
    return unless exists $params->{'message_transport_type'};
672
672
673
    warn "EnqueueLetter{ message_transport_type => " . $params->{'message_transport_type'} . " }";
674
673
    # If we have any attachments we should encode then into the body.
675
    # If we have any attachments we should encode then into the body.
674
    if ( $params->{'attachments'} ) {
676
    if ( $params->{'attachments'} ) {
675
        $params->{'letter'} = _add_attachments(
677
        $params->{'letter'} = _add_attachments(
(-)a/C4/Members/Messaging.pm (-3 / +3 lines)
Lines 98-106 END_SQL Link Here
98
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
98
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
99
        $return->{'wants_digest'}    = $row->{'wants_digest'}    if defined $row->{'wants_digest'};
99
        $return->{'wants_digest'}    = $row->{'wants_digest'}    if defined $row->{'wants_digest'};
100
        $return->{'letter_code'}     = $row->{'letter_code'};
100
        $return->{'letter_code'}     = $row->{'letter_code'};
101
        $transports{$row->{'message_transport_type'}} = 1;
101
        $return->{'transports'}->{ $row->{'message_transport_type'} } = $row->{'letter_code'};
102
    }
102
    }
103
    @{$return->{'transports'}} = keys %transports;
104
    return $return;
103
    return $return;
105
}
104
}
106
105
Lines 248-255 sub SetMessagingPreferencesFromDefaults { Link Here
248
        # FIXME - except for setting the borrowernumber, it really ought to be possible
247
        # FIXME - except for setting the borrowernumber, it really ought to be possible
249
        # to have the output of GetMessagingPreferences be able to be the input
248
        # to have the output of GetMessagingPreferences be able to be the input
250
        # to SetMessagingPreference
249
        # to SetMessagingPreference
250
        my @message_transport_types = keys %{ $default_pref->{transports} };
251
        $default_pref->{message_attribute_id}    = $option->{'message_attribute_id'};
251
        $default_pref->{message_attribute_id}    = $option->{'message_attribute_id'};
252
        $default_pref->{message_transport_types} = $default_pref->{transports};
252
        $default_pref->{message_transport_types} = \@message_transport_types;
253
        $default_pref->{borrowernumber}          = $params->{borrowernumber};
253
        $default_pref->{borrowernumber}          = $params->{borrowernumber};
254
        SetMessagingPreference( $default_pref );
254
        SetMessagingPreference( $default_pref );
255
    }
255
    }
(-)a/C4/Reserves.pm (-11 / +13 lines)
Lines 1717-1727 sub _koha_notify_reserve { Link Here
1717
    my $messagingprefs;
1717
    my $messagingprefs;
1718
    if ( $to_address || $borrower->{'smsalertnumber'} ) {
1718
    if ( $to_address || $borrower->{'smsalertnumber'} ) {
1719
        $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } );
1719
        $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } );
1720
1721
        return if ( !defined( $messagingprefs->{'letter_code'} ) );
1722
        $letter_code = $messagingprefs->{'letter_code'};
1723
    } else {
1720
    } else {
1724
        $letter_code = 'HOLD_PRINT';
1725
        $print_mode = 1;
1721
        $print_mode = 1;
1726
    }
1722
    }
1727
1723
Lines 1737-1745 sub _koha_notify_reserve { Link Here
1737
1733
1738
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1734
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1739
1735
1740
    my $letter =  C4::Letters::GetPreparedLetter (
1736
    my %letter_params = (
1741
        module => 'reserves',
1737
        module => 'reserves',
1742
        letter_code => $letter_code,
1743
        branchcode => $reserve->{branchcode},
1738
        branchcode => $reserve->{branchcode},
1744
        tables => {
1739
        tables => {
1745
            'branches'  => $branch_details,
1740
            'branches'  => $branch_details,
Lines 1749-1759 sub _koha_notify_reserve { Link Here
1749
            'items', $reserve->{'itemnumber'},
1744
            'items', $reserve->{'itemnumber'},
1750
        },
1745
        },
1751
        substitute => { today => C4::Dates->new()->output() },
1746
        substitute => { today => C4::Dates->new()->output() },
1752
    ) or die "Could not find a letter called '$letter_code' in the 'reserves' module";
1747
    );
1753
1754
1748
1755
1749
1756
    if ( $print_mode ) {
1750
    if ( $print_mode ) {
1751
        $letter_params{ 'letter_code' } = 'HOLD_PRINT';
1752
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1753
        
1757
        C4::Letters::EnqueueLetter( {
1754
        C4::Letters::EnqueueLetter( {
1758
            letter => $letter,
1755
            letter => $letter,
1759
            borrowernumber => $borrowernumber,
1756
            borrowernumber => $borrowernumber,
Lines 1763-1770 sub _koha_notify_reserve { Link Here
1763
        return;
1760
        return;
1764
    }
1761
    }
1765
1762
1766
    if ( grep { $_ eq 'email' } @{$messagingprefs->{transports}} ) {
1763
    if ( $to_address && defined $messagingprefs->{transports}->{'email'} ) {
1767
        # aka, 'email' in ->{'transports'}
1764
        $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'email'};
1765
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1766
1768
        C4::Letters::EnqueueLetter(
1767
        C4::Letters::EnqueueLetter(
1769
            {   letter                 => $letter,
1768
            {   letter                 => $letter,
1770
                borrowernumber         => $borrowernumber,
1769
                borrowernumber         => $borrowernumber,
Lines 1774-1780 sub _koha_notify_reserve { Link Here
1774
        );
1773
        );
1775
    }
1774
    }
1776
1775
1777
    if ( grep { $_ eq 'sms' } @{$messagingprefs->{transports}} ) {
1776
    if ( $borrower->{'smsalertnumber'} && defined $messagingprefs->{transports}->{'sms'} ) {
1777
        $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'sms'};
1778
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1779
1778
        C4::Letters::EnqueueLetter(
1780
        C4::Letters::EnqueueLetter(
1779
            {   letter                 => $letter,
1781
            {   letter                 => $letter,
1780
                borrowernumber         => $borrowernumber,
1782
                borrowernumber         => $borrowernumber,
(-)a/admin/categorie.pl (-1 / +1 lines)
Lines 250-256 sub _get_brief_messaging_prefs { Link Here
250
            message_name            => $option->{'message_name'},
250
            message_name            => $option->{'message_name'},
251
            $option->{'message_name'} => 1
251
            $option->{'message_name'} => 1
252
        };
252
        };
253
        foreach my $transport ( @{$pref->{'transports'}} ) {
253
        foreach my $transport ( keys %{$pref->{'transports'}} ) {
254
            push @{ $brief_pref->{'transports'} }, { transport => $transport };
254
            push @{ $brief_pref->{'transports'} }, { transport => $transport };
255
        }
255
        }
256
        push @$results, $brief_pref;
256
        push @$results, $brief_pref;
(-)a/misc/cronjobs/advance_notices.pl (-4 / +3 lines)
Lines 210-216 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
210
        print $letter->{'content'};
210
        print $letter->{'content'};
211
      }
211
      }
212
      else {
212
      else {
213
        foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
213
        foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
214
            C4::Letters::EnqueueLetter( { letter                 => $letter,
214
            C4::Letters::EnqueueLetter( { letter                 => $letter,
215
                                          borrowernumber         => $upcoming->{'borrowernumber'},
215
                                          borrowernumber         => $upcoming->{'borrowernumber'},
216
                                          from_address           => $from_address,
216
                                          from_address           => $from_address,
Lines 264-270 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
264
      print $letter->{'content'};
264
      print $letter->{'content'};
265
    }
265
    }
266
    else {
266
    else {
267
      foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
267
      foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
268
        C4::Letters::EnqueueLetter( { letter                 => $letter,
268
        C4::Letters::EnqueueLetter( { letter                 => $letter,
269
                                      borrowernumber         => $borrowernumber,
269
                                      borrowernumber         => $borrowernumber,
270
                                      from_address           => $from_address,
270
                                      from_address           => $from_address,
Lines 303-309 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
303
      print $letter->{'content'};
303
      print $letter->{'content'};
304
    }
304
    }
305
    else {
305
    else {
306
      foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
306
      foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
307
        C4::Letters::EnqueueLetter( { letter                 => $letter,
307
        C4::Letters::EnqueueLetter( { letter                 => $letter,
308
                                      borrowernumber         => $borrowernumber,
308
                                      borrowernumber         => $borrowernumber,
309
                                      from_address           => $from_address,
309
                                      from_address           => $from_address,
310
- 

Return to bug 4246