Bug 36193: cud- treatment for credit_types.pl

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomas Cohen Arazi 2024-03-05 11:32:18 -03:00 committed by Katrin Fischer
parent 1415fee322
commit 9e352b83d9
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 26 additions and 5 deletions

View File

@ -99,7 +99,7 @@ elsif ( $op eq 'cud-add_validate' ) {
};
$op = 'list';
}
elsif ( $op eq 'archive' ) {
elsif ( $op eq 'cud-archive' ) {
try {
$credit_type->archived(1)->store();
push @messages, { code => 'success_on_archive', type => 'message' };
@ -110,7 +110,7 @@ elsif ( $op eq 'archive' ) {
};
$op = 'list';
}
elsif ( $op eq 'unarchive' ) {
elsif ( $op eq 'cud-unarchive' ) {
try {
$credit_type->archived(0)->store();
push @messages, { code => 'success_on_restore', type => 'message' };

View File

@ -202,11 +202,20 @@
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=add_form&amp;code=[% credit_type.code | uri %]&type=credit"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
[% END %]
[% IF !credit_type.is_system && !credit_type.archived %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=archive&amp;code=[% credit_type.code | uri %]"><i class="fa fa-archive"></i> Archive</a>
<form id="archive_[% credit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/credit_types.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-archive" />
<input type="hidden" name="code" value="[% credit_type.code | html %]" />
</form>
<a class="btn btn-default btn-xs archive_button" href="#" data-code="[% credit_type.code | html %]"><i class="fa fa-archive"></i> Archive</a>
[% END %]
[% IF !credit_type.is_system && credit_type.archived %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=unarchive&amp;code=[% credit_type.code | uri %]"><i class="fa fa-undo"></i> Restore</a>
<form id="unarchive_[% credit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/credit_types.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-unarchive" />
<input type="hidden" name="code" value="[% credit_type.code | html %]" />
</form>
<a class="btn btn-default btn-xs unarchive_button" href="#" data-code="[% credit_type.code | html %]"><i class="fa fa-undo"></i> Restore</a>
[% END %]
</td>
</tr>
@ -265,6 +274,18 @@
//Start filtered
$('#filter_system').click();
$(".archive_button").on("click", function(e){
e.preventDefault();
var code = $(this).data('code');
$('#archive_'+code).submit();
});
$(".unarchive_button").on("click", function(e){
e.preventDefault();
var code = $(this).data('code');
$('#unarchive_'+code).submit();
});
});
</script>
[% END %]