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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2744-2750 sub SendCirculationAlert { Link Here
2744
        }
2744
        }
2745
    ) or return;
2745
    ) or return;
2746
2746
2747
    my @transports = @{ $borrower_preferences->{transports} };
2747
    my @transports = keys %{ $borrower_preferences->{transports} };
2748
    # warn "no transports" unless @transports;
2748
    # warn "no transports" unless @transports;
2749
    for (@transports) {
2749
    for (@transports) {
2750
        # warn "transport: $_";
2750
        # 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/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 1839-1849 sub _koha_notify_reserve { Link Here
1839
    my $messagingprefs;
1839
    my $messagingprefs;
1840
    if ( $to_address || $borrower->{'smsalertnumber'} ) {
1840
    if ( $to_address || $borrower->{'smsalertnumber'} ) {
1841
        $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } );
1841
        $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } );
1842
1843
        return if ( !defined( $messagingprefs->{'letter_code'} ) );
1844
        $letter_code = $messagingprefs->{'letter_code'};
1845
    } else {
1842
    } else {
1846
        $letter_code = 'HOLD_PRINT';
1847
        $print_mode = 1;
1843
        $print_mode = 1;
1848
    }
1844
    }
1849
1845
Lines 1859-1867 sub _koha_notify_reserve { Link Here
1859
1855
1860
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1856
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1861
1857
1862
    my $letter =  C4::Letters::GetPreparedLetter (
1858
    my %letter_params = (
1863
        module => 'reserves',
1859
        module => 'reserves',
1864
        letter_code => $letter_code,
1865
        branchcode => $reserve->{branchcode},
1860
        branchcode => $reserve->{branchcode},
1866
        tables => {
1861
        tables => {
1867
            'branches'  => $branch_details,
1862
            'branches'  => $branch_details,
Lines 1871-1881 sub _koha_notify_reserve { Link Here
1871
            'items', $reserve->{'itemnumber'},
1866
            'items', $reserve->{'itemnumber'},
1872
        },
1867
        },
1873
        substitute => { today => C4::Dates->new()->output() },
1868
        substitute => { today => C4::Dates->new()->output() },
1874
    ) or die "Could not find a letter called '$letter_code' in the 'reserves' module";
1869
    );
1875
1876
1870
1877
1871
1878
    if ( $print_mode ) {
1872
    if ( $print_mode ) {
1873
        $letter_params{ 'letter_code' } = 'HOLD_PRINT';
1874
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1875
1879
        C4::Letters::EnqueueLetter( {
1876
        C4::Letters::EnqueueLetter( {
1880
            letter => $letter,
1877
            letter => $letter,
1881
            borrowernumber => $borrowernumber,
1878
            borrowernumber => $borrowernumber,
Lines 1885-1892 sub _koha_notify_reserve { Link Here
1885
        return;
1882
        return;
1886
    }
1883
    }
1887
1884
1888
    if ( grep { $_ eq 'email' } @{$messagingprefs->{transports}} ) {
1885
    if ( $to_address && defined $messagingprefs->{transports}->{'email'} ) {
1889
        # aka, 'email' in ->{'transports'}
1886
        $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'email'};
1887
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1888
1890
        C4::Letters::EnqueueLetter(
1889
        C4::Letters::EnqueueLetter(
1891
            {   letter                 => $letter,
1890
            {   letter                 => $letter,
1892
                borrowernumber         => $borrowernumber,
1891
                borrowernumber         => $borrowernumber,
Lines 1896-1902 sub _koha_notify_reserve { Link Here
1896
        );
1895
        );
1897
    }
1896
    }
1898
1897
1899
    if ( grep { $_ eq 'sms' } @{$messagingprefs->{transports}} ) {
1898
    if ( $borrower->{'smsalertnumber'} && defined $messagingprefs->{transports}->{'sms'} ) {
1899
        $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'sms'};
1900
        my $letter =  C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module";
1901
1900
        C4::Letters::EnqueueLetter(
1902
        C4::Letters::EnqueueLetter(
1901
            {   letter                 => $letter,
1903
            {   letter                 => $letter,
1902
                borrowernumber         => $borrowernumber,
1904
                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