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