|
Lines 80-85
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 80 |
|
80 |
|
| 81 |
if ($av) { |
81 |
if ($av) { |
| 82 |
$template->param( |
82 |
$template->param( |
|
|
83 |
category => Koha::AuthorisedValueCategories->find( $av->category ), |
| 83 |
category_name => $av->category, |
84 |
category_name => $av->category, |
| 84 |
av => $av, |
85 |
av => $av, |
| 85 |
imagesets => C4::Koha::getImageSets( checked => $av->imageurl ), |
86 |
imagesets => C4::Koha::getImageSets( checked => $av->imageurl ), |
|
Lines 97-105
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 97 |
); |
98 |
); |
| 98 |
|
99 |
|
| 99 |
} elsif ( $op eq 'cud-add' ) { |
100 |
} elsif ( $op eq 'cud-add' ) { |
| 100 |
my $new_authorised_value = $input->param('authorised_value'); |
101 |
my $new_authorised_value = $input->param('authorised_value'); |
| 101 |
my $new_category = $input->param('category'); |
102 |
my $parent_authorised_value_id = $input->param('parent_authorised_value_id') // ''; |
| 102 |
my $image = $input->param('image') || ''; |
103 |
my $new_category = $input->param('category'); |
|
|
104 |
my $image = $input->param('image') || ''; |
| 103 |
my $imageurl = |
105 |
my $imageurl = |
| 104 |
$image eq 'removeImage' ? '' |
106 |
$image eq 'removeImage' ? '' |
| 105 |
: ( |
107 |
: ( |
|
Lines 118-123
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 118 |
$av->lib_opac( scalar $input->param('lib_opac') || undef ); |
120 |
$av->lib_opac( scalar $input->param('lib_opac') || undef ); |
| 119 |
$av->category($new_category); |
121 |
$av->category($new_category); |
| 120 |
$av->authorised_value($new_authorised_value); |
122 |
$av->authorised_value($new_authorised_value); |
|
|
123 |
$av->parent_authorised_value_id( $parent_authorised_value_id || undef ); |
| 121 |
$av->imageurl($imageurl); |
124 |
$av->imageurl($imageurl); |
| 122 |
eval { |
125 |
eval { |
| 123 |
$av->store; |
126 |
$av->store; |
|
Lines 132-142
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 132 |
eval { |
135 |
eval { |
| 133 |
my $av = Koha::AuthorisedValue->new( |
136 |
my $av = Koha::AuthorisedValue->new( |
| 134 |
{ |
137 |
{ |
| 135 |
category => $new_category, |
138 |
category => $new_category, |
| 136 |
authorised_value => $new_authorised_value, |
139 |
authorised_value => $new_authorised_value, |
| 137 |
lib => scalar $input->param('lib') || undef, |
140 |
parent_authorised_value_id => $parent_authorised_value_id || undef, |
| 138 |
lib_opac => scalar $input->param('lib_opac') || undef, |
141 |
lib => scalar $input->param('lib') || undef, |
| 139 |
imageurl => $imageurl, |
142 |
lib_opac => scalar $input->param('lib_opac') || undef, |
|
|
143 |
imageurl => $imageurl, |
| 140 |
} |
144 |
} |
| 141 |
)->store; |
145 |
)->store; |
| 142 |
$av->replace_library_limits( \@branches ); |
146 |
$av->replace_library_limits( \@branches ); |
|
Lines 153-160
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 153 |
$op = 'list'; |
157 |
$op = 'list'; |
| 154 |
$searchfield = $new_category; |
158 |
$searchfield = $new_category; |
| 155 |
} elsif ( $op eq 'cud-add_category' ) { |
159 |
} elsif ( $op eq 'cud-add_category' ) { |
| 156 |
my $new_category = $input->param('category'); |
160 |
my $new_category = $input->param('category'); |
| 157 |
my $is_integer_only = $input->param('is_integer_only') ? 1 : 0; |
161 |
my $parent_category_name = $input->param('parent_category_name'); |
|
|
162 |
my $is_integer_only = $input->param('is_integer_only') ? 1 : 0; |
| 158 |
|
163 |
|
| 159 |
my $already_exists = Koha::AuthorisedValueCategories->find( |
164 |
my $already_exists = Koha::AuthorisedValueCategories->find( |
| 160 |
{ |
165 |
{ |
|
Lines 171-177
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 171 |
} else { # Insert |
176 |
} else { # Insert |
| 172 |
my $av = Koha::AuthorisedValueCategory->new( |
177 |
my $av = Koha::AuthorisedValueCategory->new( |
| 173 |
{ |
178 |
{ |
| 174 |
category_name => $new_category, is_integer_only => $is_integer_only, |
179 |
category_name => $new_category, |
|
|
180 |
parent_category_name => $parent_category_name, |
| 181 |
is_integer_only => $is_integer_only, |
| 175 |
} |
182 |
} |
| 176 |
); |
183 |
); |
| 177 |
|
184 |
|
|
Lines 187-198
if ( $op eq 'add_form' or $op eq 'edit_form' ) {
Link Here
|
| 187 |
|
194 |
|
| 188 |
$op = 'list'; |
195 |
$op = 'list'; |
| 189 |
} elsif ( $op eq 'cud-edit_category' ) { |
196 |
} elsif ( $op eq 'cud-edit_category' ) { |
| 190 |
my $category_name = $input->param('category'); |
197 |
my $category_name = $input->param('category'); |
| 191 |
my $is_integer_only = $input->param('is_integer_only') ? 1 : 0; |
198 |
my $parent_category_name = $input->param('parent_category_name') // ''; |
| 192 |
my $category = Koha::AuthorisedValueCategories->find($category_name); |
199 |
my $is_integer_only = $input->param('is_integer_only') ? 1 : 0; |
|
|
200 |
my $category = Koha::AuthorisedValueCategories->find($category_name); |
| 193 |
|
201 |
|
| 194 |
if ($category) { |
202 |
if ($category) { |
| 195 |
$category->is_integer_only($is_integer_only)->store; |
203 |
my $old_parent_category_name = $category->parent_category_name // ''; |
|
|
204 |
|
| 205 |
$category->parent_category_name( $parent_category_name ? $parent_category_name : undef ); |
| 206 |
$category->is_integer_only($is_integer_only); |
| 207 |
$category->store; |
| 208 |
|
| 209 |
if ( $old_parent_category_name ne $parent_category_name ) { |
| 210 |
$category->authorised_values->update( { parent_authorised_value_id => undef } ); |
| 211 |
} |
| 196 |
} else { |
212 |
} else { |
| 197 |
push @messages, { type => 'error', code => 'error_on_edit_cat' }; |
213 |
push @messages, { type => 'error', code => 'error_on_edit_cat' }; |
| 198 |
} |
214 |
} |
|
Lines 246-259
if ( $op eq 'list' ) {
Link Here
|
| 246 |
# builds value list |
262 |
# builds value list |
| 247 |
for my $av (@avs_by_category) { |
263 |
for my $av (@avs_by_category) { |
| 248 |
my %row_data; # get a fresh hash for the row data |
264 |
my %row_data; # get a fresh hash for the row data |
| 249 |
$row_data{category} = $av->category; |
265 |
$row_data{category} = $av->category; |
| 250 |
$row_data{authorised_value} = $av->authorised_value; |
266 |
$row_data{authorised_value} = $av->authorised_value; |
| 251 |
$row_data{lib} = $av->lib; |
267 |
$row_data{parent_authorised_value} = $av->parent_authorised_value; |
| 252 |
$row_data{lib_opac} = $av->lib_opac; |
268 |
$row_data{lib} = $av->lib; |
| 253 |
$row_data{image} = getitemtypeimagelocation( 'intranet', $av->imageurl ); |
269 |
$row_data{lib_opac} = $av->lib_opac; |
| 254 |
$row_data{branches} = $av->library_limits ? $av->library_limits->as_list : []; |
270 |
$row_data{image} = getitemtypeimagelocation( 'intranet', $av->imageurl ); |
| 255 |
$row_data{id} = $av->id; |
271 |
$row_data{branches} = $av->library_limits ? $av->library_limits->as_list : []; |
| 256 |
$row_data{is_integer_only} = $is_integer_only; |
272 |
$row_data{id} = $av->id; |
|
|
273 |
$row_data{is_integer_only} = $is_integer_only; |
| 257 |
push( @loop_data, \%row_data ); |
274 |
push( @loop_data, \%row_data ); |
| 258 |
} |
275 |
} |
| 259 |
|
276 |
|