Lines 148-153
PREF: foreach my $option (@$messaging_options) {
Link Here
|
148 |
$template->param( messaging_preferences => $messaging_options ); |
148 |
$template->param( messaging_preferences => $messaging_options ); |
149 |
} |
149 |
} |
150 |
|
150 |
|
|
|
151 |
|
152 |
=head2 restore_form_values |
153 |
|
154 |
C4::Form::MessagingPreferences::restore_form_values({ borrowernumber => 51 }, $template, $input); |
155 |
|
156 |
Restores patron message preferences if error occurs while creating a patron. |
157 |
|
158 |
C<$input> is the CGI query object. |
159 |
|
160 |
C<$template> is the Template::Toolkit object for the response. |
161 |
|
162 |
=cut |
163 |
|
164 |
sub restore_form_values { |
165 |
my ( $input, $template ) = @_; |
166 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
167 |
foreach my $option (@$messaging_options) { |
168 |
$option->{ $option->{'message_name'} } = 1; |
169 |
|
170 |
my $message_attribute_id = $option->{'message_attribute_id'}; |
171 |
if ( $option->{'takes_days'} ) { |
172 |
my $selected_value = $input->param( $message_attribute_id . '-DAYS' ); |
173 |
my $days_in_advance = $selected_value ? $selected_value : 0; |
174 |
$option->{days_in_advance} = $days_in_advance; |
175 |
@{ $option->{'select_days'} } = map { |
176 |
{ |
177 |
day => $_, |
178 |
selected => $_ == $days_in_advance |
179 |
} |
180 |
} ( 0 .. MAX_DAYS_IN_ADVANCE ); |
181 |
} |
182 |
|
183 |
my $transport_type = $input->param($message_attribute_id); |
184 |
$option->{ 'transports_' . $transport_type } = 1 unless !$transport_type; |
185 |
|
186 |
if ( $option->{'has_digest'} ) { |
187 |
if ( List::Util::first { $_ == $message_attribute_id } $input->multi_param('digest') ) { |
188 |
$option->{'digest'} = 1; |
189 |
} |
190 |
} |
191 |
} |
192 |
$template->param( messaging_preferences => $messaging_options ); |
193 |
} |
194 |
|
151 |
=head1 TODO |
195 |
=head1 TODO |
152 |
|
196 |
|
153 |
=over 4 |
197 |
=over 4 |