Lines 49-55
foreach my $subscriptionid (@subscriptionids) {
Link Here
|
49 |
push @subscriptions, $subscription if $subscription; |
49 |
push @subscriptions, $subscription if $subscription; |
50 |
} |
50 |
} |
51 |
|
51 |
|
52 |
my @available_additional_fields = Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; |
52 |
my $available_additional_fields = Koha::AdditionalFields->search( { tablename => 'subscription' } ); |
53 |
|
53 |
|
54 |
my $batchedit = $cgi->param('batchedit'); |
54 |
my $batchedit = $cgi->param('batchedit'); |
55 |
if ($batchedit) { |
55 |
if ($batchedit) { |
Lines 65-73
if ($batchedit) {
Link Here
|
65 |
); |
65 |
); |
66 |
|
66 |
|
67 |
my $field_values = {}; |
67 |
my $field_values = {}; |
68 |
foreach my $field (@available_additional_fields) { |
68 |
|
69 |
my $value = $cgi->param( 'field_' . $field->id ); |
69 |
while ( my $available_field = $available_additional_fields->next ) { |
70 |
$field_values->{ $field->id } = $value; |
70 |
my @submitted_fields = $cgi->param( 'additional_field_' . $available_field->id ); |
|
|
71 |
|
72 |
my @submitted_fields_array; |
73 |
foreach my $submitted_field (@submitted_fields) { |
74 |
push @submitted_fields_array, $submitted_field if $submitted_field; |
75 |
} |
76 |
$field_values->{ $available_field->id } = \@submitted_fields_array; |
71 |
} |
77 |
} |
72 |
|
78 |
|
73 |
foreach my $subscription (@subscriptions) { |
79 |
foreach my $subscription (@subscriptions) { |
Lines 80-104
if ($batchedit) {
Link Here
|
80 |
} |
86 |
} |
81 |
} |
87 |
} |
82 |
|
88 |
|
83 |
my @additional_field_values; |
89 |
$subscription->add_additional_fields($field_values, 'subscription'); |
84 |
foreach my $field (@available_additional_fields) { |
|
|
85 |
my $value = $field_values->{ $field->id }; |
86 |
if ( defined $value and $value ne '' ) { |
87 |
push @additional_field_values, { |
88 |
id => $field->id, |
89 |
value => $value, |
90 |
}; |
91 |
} else { |
92 |
my $existing = $subscription->additional_field_values->search( { field_id => $field->id } )->last; |
93 |
if ( $existing && $existing->value ) { |
94 |
push @additional_field_values, { |
95 |
id => $field->id, |
96 |
value => $existing->value, |
97 |
}; |
98 |
} |
99 |
} |
100 |
} |
101 |
$subscription->set_additional_fields( \@additional_field_values ); |
102 |
|
90 |
|
103 |
$subscription->store; |
91 |
$subscription->store; |
104 |
} |
92 |
} |
Lines 109-118
if ($batchedit) {
Link Here
|
109 |
} |
97 |
} |
110 |
|
98 |
|
111 |
$template->param( |
99 |
$template->param( |
112 |
subscriptions => \@subscriptions, |
100 |
subscriptions => \@subscriptions, |
113 |
booksellers => [ Koha::Acquisition::Booksellers->search->as_list ], |
101 |
booksellers => [ Koha::Acquisition::Booksellers->search->as_list ], |
114 |
additional_fields => \@available_additional_fields, |
102 |
available_additional_fields => Koha::AdditionalFields->search( { tablename => 'subscription' } ), |
115 |
referrer => scalar $cgi->param('referrer'), |
103 |
referrer => scalar $cgi->param('referrer'), |
116 |
); |
104 |
); |
117 |
|
105 |
|
118 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
106 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
119 |
- |
|
|