|
Lines 71-78
my $input = new CGI;
Link Here
|
| 71 |
my $searchfield = $input->param('description'); |
71 |
my $searchfield = $input->param('description'); |
| 72 |
my $script_name = "/cgi-bin/koha/admin/categorie.pl"; |
72 |
my $script_name = "/cgi-bin/koha/admin/categorie.pl"; |
| 73 |
my $categorycode = $input->param('categorycode'); |
73 |
my $categorycode = $input->param('categorycode'); |
| 74 |
my $op = $input->param('op') // ''; |
74 |
my $op = $input->param('op') // 'list'; |
| 75 |
my $block_expired = $input->param("block_expired"); |
75 |
my $block_expired = $input->param("block_expired"); |
|
|
76 |
my @messages; |
| 76 |
|
77 |
|
| 77 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
78 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 78 |
{ |
79 |
{ |
|
Lines 85-96
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 85 |
} |
86 |
} |
| 86 |
); |
87 |
); |
| 87 |
|
88 |
|
| 88 |
$template->param( |
|
|
| 89 |
script_name => $script_name, |
| 90 |
categorycode => $categorycode, |
| 91 |
searchfield => $searchfield |
| 92 |
); |
| 93 |
|
| 94 |
################## ADD_FORM ################################## |
89 |
################## ADD_FORM ################################## |
| 95 |
# called by default. Used to create form to add or modify a record |
90 |
# called by default. Used to create form to add or modify a record |
| 96 |
if ( $op eq 'add_form' ) { |
91 |
if ( $op eq 'add_form' ) { |
|
Lines 171-177
if ( $op eq 'add_form' ) {
Link Here
|
| 171 |
# called by add_form, used to insert/modify data in DB |
166 |
# called by add_form, used to insert/modify data in DB |
| 172 |
} |
167 |
} |
| 173 |
elsif ( $op eq 'add_validate' ) { |
168 |
elsif ( $op eq 'add_validate' ) { |
| 174 |
$template->param( add_validate => 1 ); |
|
|
| 175 |
|
169 |
|
| 176 |
my $is_a_modif = $input->param("is_a_modif"); |
170 |
my $is_a_modif = $input->param("is_a_modif"); |
| 177 |
|
171 |
|
|
Lines 249-255
elsif ( $op eq 'add_validate' ) {
Link Here
|
| 249 |
default_privacy |
243 |
default_privacy |
| 250 |
) |
244 |
) |
| 251 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" ); |
245 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" ); |
| 252 |
$sth->execute( |
246 |
my $inserted = $sth->execute( |
| 253 |
map { $input->param($_) } ( |
247 |
map { $input->param($_) } ( |
| 254 |
'categorycode', 'description', |
248 |
'categorycode', 'description', |
| 255 |
'enrolmentperiod', 'enrolmentperioddate', |
249 |
'enrolmentperiod', 'enrolmentperioddate', |
|
Lines 260-274
elsif ( $op eq 'add_validate' ) {
Link Here
|
| 260 |
'default_privacy', |
254 |
'default_privacy', |
| 261 |
) |
255 |
) |
| 262 |
); |
256 |
); |
| 263 |
$sth->finish; |
257 |
if ( $inserted ) { |
|
|
258 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
| 259 |
} else { |
| 260 |
$searchfield = q||; |
| 261 |
push @messages, { type => 'error', code => 'error_on_insert' }; |
| 262 |
} |
| 264 |
} |
263 |
} |
| 265 |
|
264 |
|
| 266 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
265 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
| 267 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
266 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
| 268 |
{ categorycode => $input->param('categorycode') }, $template ); |
267 |
{ categorycode => $input->param('categorycode') }, $template ); |
| 269 |
} |
268 |
} |
| 270 |
print $input->redirect("/cgi-bin/koha/admin/categorie.pl"); |
269 |
|
| 271 |
exit; |
270 |
$op = 'list'; |
| 272 |
|
271 |
|
| 273 |
# END $OP eq ADD_VALIDATE |
272 |
# END $OP eq ADD_VALIDATE |
| 274 |
################## DELETE_CONFIRM ################################## |
273 |
################## DELETE_CONFIRM ################################## |
|
Lines 301-315
elsif ( $op eq 'delete_confirmed' ) {
Link Here
|
| 301 |
|
300 |
|
| 302 |
my $sth = $dbh->prepare("delete from categories where categorycode=?"); |
301 |
my $sth = $dbh->prepare("delete from categories where categorycode=?"); |
| 303 |
|
302 |
|
| 304 |
$sth->execute($categorycode); |
303 |
my $deleted = $sth->execute($categorycode); |
| 305 |
$sth->finish; |
|
|
| 306 |
|
304 |
|
| 307 |
print $input->redirect("/cgi-bin/koha/admin/categorie.pl"); |
305 |
if ( $deleted ) { |
| 308 |
exit; |
306 |
push @messages, { type => 'message', code => 'success_on_delete' }; |
|
|
307 |
} else { |
| 308 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
| 309 |
} |
| 310 |
|
| 311 |
$op = 'list'; |
| 309 |
|
312 |
|
| 310 |
# END $OP eq DELETE_CONFIRMED |
313 |
# END $OP eq DELETE_CONFIRMED |
| 311 |
} |
314 |
} |
| 312 |
else { # DEFAULT |
315 |
|
|
|
316 |
if ( $op eq 'list' ) { |
| 313 |
$template->param( else => 1 ); |
317 |
$template->param( else => 1 ); |
| 314 |
my @loop; |
318 |
my @loop; |
| 315 |
my ( $count, $results ) = StringSearch( $searchfield, 'web' ); |
319 |
my ( $count, $results ) = StringSearch( $searchfield, 'web' ); |
|
Lines 378-383
else { # DEFAULT
Link Here
|
| 378 |
$sth->finish; |
382 |
$sth->finish; |
| 379 |
|
383 |
|
| 380 |
} #---- END $OP eq DEFAULT |
384 |
} #---- END $OP eq DEFAULT |
|
|
385 |
|
| 386 |
$template->param( |
| 387 |
script_name => $script_name, |
| 388 |
categorycode => $categorycode, |
| 389 |
searchfield => $searchfield, |
| 390 |
messages => \@messages, |
| 391 |
); |
| 392 |
|
| 381 |
output_html_with_http_headers $input, $cookie, $template->output; |
393 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 382 |
|
394 |
|
| 383 |
exit 0; |
395 |
exit 0; |