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

(-)a/C4/Form/MessagingPreferences.pm (-7 / +14 lines)
Lines 54-60 the same thing in staff and OPAC. Link Here
54
54
55
=head2 handle_form_action
55
=head2 handle_form_action
56
56
57
    C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template);
57
    C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template, $insert);
58
58
59
Processes CGI parameters and updates the target patron or patron category's
59
Processes CGI parameters and updates the target patron or patron category's
60
preferences.
60
preferences.
Lines 64-80 C<$input> is the CGI query object. Link Here
64
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key 
64
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key 
65
identifying the patron or patron category whose messaging preferences are to be updated.
65
identifying the patron or patron category whose messaging preferences are to be updated.
66
66
67
C<$template> is the HTML::Template::Pro object for the response; this routine
67
C<$template> is the Template::Toolkit object for the response; this routine
68
adds a settings_updated template variable.
68
adds a settings_updated template variable.
69
69
70
=cut
70
=cut
71
71
72
sub handle_form_action {
72
sub handle_form_action {
73
    my ($query, $target_params, $template) = @_;
73
    my ($query, $target_params, $template, $insert, $categorycode) = @_;
74
    my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
74
    my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
75
76
    # TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box
75
    # TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box
77
    
76
    my $prefs_set = 0;
78
    OPTION: foreach my $option ( @$messaging_options ) {
77
    OPTION: foreach my $option ( @$messaging_options ) {
79
        my $updater = { %{ $target_params }, 
78
        my $updater = { %{ $target_params }, 
80
                        message_attribute_id    => $option->{'message_attribute_id'} };
79
                        message_attribute_id    => $option->{'message_attribute_id'} };
Lines 96-103 sub handle_form_action { Link Here
96
        }
95
        }
97
96
98
        C4::Members::Messaging::SetMessagingPreference( $updater );
97
        C4::Members::Messaging::SetMessagingPreference( $updater );
99
    }
100
98
99
	if ($query->param( $option->{'message_attribute_id'})){	    
100
	    $prefs_set = 1;
101
	}
102
    }
103
    if (! $prefs_set && $insert){
104
        # this is new borrower, and we have no preferences set, use the defaults
105
	$target_params->{categorycode} = $categorycode;
106
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults( $target_params );
107
    }
101
    # show the success message
108
    # show the success message
102
    $template->param( settings_updated => 1 );
109
    $template->param( settings_updated => 1 );
103
}
110
}
Lines 112-118 and fills the corresponding template variables. Link Here
112
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key 
119
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key 
113
identifying the patron or patron category.
120
identifying the patron or patron category.
114
121
115
C<$template> is the HTML::Template::Pro object for the response.
122
C<$template> is the Template::Toolkit object for the response.
116
123
117
=cut
124
=cut
118
125
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+3 lines)
Lines 1072-1077 Link Here
1072
    [% END %]
1072
    [% END %]
1073
    <input type="hidden" name="setting_messaging_prefs" value="1" />
1073
    <input type="hidden" name="setting_messaging_prefs" value="1" />
1074
    <legend>Patron messaging preferences</legend>
1074
    <legend>Patron messaging preferences</legend>
1075
    [% IF type_only %]
1076
        <i>If no preferences are selected, the default preferences for the category chosen will be applied on save, otherwise your selection here is saved</i>
1077
    [% END %]
1075
    [% INCLUDE 'messaging-preference-form.inc' %]
1078
    [% INCLUDE 'messaging-preference-form.inc' %]
1076
    [% IF ( SMSSendDriver ) %]
1079
    [% IF ( SMSSendDriver ) %]
1077
        <p><label for="SMSnumber">SMS number:</label> 
1080
        <p><label for="SMSnumber">SMS number:</label> 
(-)a/members/memberentry.pl (-5 / +7 lines)
Lines 105-118 $template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); Link Here
105
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
105
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
106
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
106
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
107
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
107
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
108
my $category_type = $input->param('category_type');
108
my $category_type = $input->param('category_type') || '';
109
if ($category_type){
110
    $template->{VARS}->{'type_only'} = 1;
111
}
109
my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
112
my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
110
unless ($category_type or !($categorycode)){
113
unless ($category_type or !($categorycode)){
111
    my $borrowercategory = GetBorrowercategory($categorycode);
114
    my $borrowercategory = GetBorrowercategory($categorycode);
112
    $category_type    = $borrowercategory->{'category_type'};
115
    $category_type    = $borrowercategory->{'category_type'};
113
    my $category_name = $borrowercategory->{'description'}; 
116
    my $category_name = $borrowercategory->{'description'}; 
114
    $template->param("categoryname"=>$category_name);
117
    $template->param("categoryname"=>$category_name);
115
}
118
 }
116
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
119
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
117
120
118
# if a add or modify is requested => check validity of data.
121
# if a add or modify is requested => check validity of data.
Lines 333-340 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
333
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
336
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
334
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
337
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
335
        }
338
        }
336
        if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {
339
        if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {	    
337
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
340
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'}); 
338
        }
341
        }
339
	} elsif ($op eq 'save'){ 
342
	} elsif ($op eq 'save'){ 
340
		if ($NoUpdateLogin) {
343
		if ($NoUpdateLogin) {
341
- 

Return to bug 5918