+$template->param( lang_list => \@lang_list,
+ branchcode => $branchcode );
+
+my $op = $cgi->param('op') // '';
+
+if ( $op eq 'add_form' ) {
+ $template->param( add_form => 1 );
+ if ($id) {
+ if($new_detail->{lang} eq "slip"){ $template->param( slip => 1); }
+ $template->param(
+ op => 'edit',
+ id => $new_detail->{'idnew'}
+ );
+ $template->{VARS}->{'new_detail'} = $new_detail;
+ }
+ else {
+ $template->param( op => 'add' );
+ }
+}
+elsif ( $op eq 'add' ) {
+ if ($title) {
+ add_opac_new(
+ {
+ title => $title,
+ content => $content,
+ lang => $lang,
+ expirationdate => $expirationdate,
+ timestamp => $timestamp,
+ number => $number,
+ branchcode => $branchcode,
+ borrowernumber => $borrowernumber,
+ }
+ );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
+ }
+ else {
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=title_missing");
+ }
+}
+elsif ( $op eq 'edit' ) {
+ upd_opac_new(
+ {
+ idnew => $id,
+ title => $title,
+ content => $content,
+ lang => $lang,
+ expirationdate => $expirationdate,
+ timestamp => $timestamp,
+ number => $number,
+ branchcode => $branchcode,
+ }
+ );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
+}
+elsif ( $op eq 'del' ) {
+ my @ids = $cgi->multi_param('ids');
+ del_opac_new( join ",", @ids );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");