</ul>
</div>
<div class="btn-group">
- <a href="/cgi-bin/koha/tools/additional-contents.pl?op=del&ids=[% c.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
+ <a href="#" class="delete_news btn btn-default btn-xs" data-idnew="[% c.idnew | html %]"><i class="fa fa-trash"></i> Delete</a>
</div>
</td>
</tr>
[% END %]
</tbody>
</table>
- <input type="hidden" name="op" value="del" />
+ <input type="hidden" name="op" value="delete_confirmed" />
+ <input type="hidden" name="category" value="[% category | html %]" />
<fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
</form>
+ <form action="/cgi-bin/koha/tools/additional-contents.pl" method="post" id="delete_single">
+ <input type="hidden" id="del_op" name="op" value="delete_confirmed" />
+ <input type="hidden" id="del_category" name="category" value="[% category | html %]" />
+ <input type="hidden" id="del_ids" name="ids" />
+ </form>
[% ELSE %]
<div class="dialog message">There are no additional contents.</div>
[% END %]
"sPaginationType": "full_numbers"
}));
- $(".delete_news").on("click", function(){
- return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
+ $("#del_form").on("click", ".delete_news", function(e){
+ e.preventDefault();
+ if( confirmDelete( _("Are you sure you want to delete this content? This cannot be undone.") ) ){
+ $("#del_ids").val( $(this).data("idnew") );
+ $("#delete_single").submit();
+ }
});
$("#del_form").on("submit",function(){
if ( Checkbox() ) {
- return confirmDelete( _("Are you sure you want to delete the selected news?") );
+ return confirmDelete( _("Are you sure you want to delete the selected content?") );
} else {
- alert(_("Please select a news item to delete."));
+ alert(_("Please select content to delete."));
return false;
}
});
elsif ( $op eq 'delete_confirmed' ) {
my @ids = $cgi->multi_param('ids');
my $deleted =
- eval { Koha::AdditionalContents->search( { idnew => @ids } )->delete; };
+ map { Koha::AdditionalContents->find($_)->delete() } @ids;
if ( $@ or not $deleted ) {
push @messages, { type => 'error', code => 'error_on_delete' };