Skip to content

Commit

Permalink
Bug 36193: cud- treatment for debit_types.pl
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Cohen Arazi <[email protected]>
Signed-off-by: Nick Clemens <[email protected]>
Signed-off-by: Katrin Fischer <[email protected]>
  • Loading branch information
tomascohen authored and kfischer committed Mar 12, 2024
1 parent 9e352b8 commit 7961ac0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions admin/debit_types.pl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
};
$op = 'list';
}
elsif ( $op eq 'archive' ) {
elsif ( $op eq 'cud-archive' ) {
try {
$debit_type->archived(1)->store();
push @messages, { code => 'success_on_archive', type => 'message' };
Expand All @@ -110,7 +110,7 @@
};
$op = 'list';
}
elsif ( $op eq 'unarchive' ) {
elsif ( $op eq 'cud-unarchive' ) {
try {
$debit_type->archived(0)->store();
push @messages, { code => 'success_on_restore', type => 'message' };
Expand Down
26 changes: 24 additions & 2 deletions koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,20 @@
[% IF !debit_type.archived %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form&amp;code=[% debit_type.code | uri %]&type=debit"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
[% IF !debit_type.is_system %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=archive&amp;code=[% debit_type.code | uri %]"><i class="fa fa-archive"></i> Archive</a>
<form id="archive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-archive" />
<input type="hidden" name="code" value="[% debit_type.code | html %]" />
</form>
<a class="btn btn-default btn-xs archive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-archive"></i> Archive</a>
[% END %]
[% ELSIF debit_type.archived %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=unarchive&amp;code=[% debit_type.code | uri %]"><i class="fa fa-undo"></i> Restore</a>
<form id="unarchive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-unarchive" />
<input type="hidden" name="code" value="[% debit_type.code | html %]" />
</form>
<a class="btn btn-default btn-xs unarchive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-undo"></i> Restore</a>
[% END %]
</td>
</tr>
Expand Down Expand Up @@ -284,6 +294,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 %]
Expand Down

0 comments on commit 7961ac0

Please sign in to comment.