Bug 34478: Fix various parameters on housebound details page

This patch converts the delivery delete buttons to a form and changes
the corresponding op check in the script.

The patch also fixes an error in the form markup and corrects the op
parameter name in several links.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2024-02-20 15:37:42 +00:00 committed by Jonathan Druart
parent 5bb56bd57a
commit 7947f7872b
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
2 changed files with 13 additions and 8 deletions

View File

@ -249,9 +249,8 @@
<!-- Create or edit housebound_visit -->
[% ELSIF ( op == 'visit_update_or_create' ) %]
<h4>Manage housebound deliveries</h4>
<form name="form" id="instance_form" method="post"
<form name="form" id="instance_form" method="post" action="/cgi-bin/koha/members/housebound.pl">
[% INCLUDE 'csrf-token.inc' %]
action="/cgi-bin/koha/members/housebound.pl">
[% IF ( visit ) %]
<input type="hidden" name="op" value="cud-editvisitconfirm" />
<input type="hidden" name="visit_id" value="[% visit.id | html %]" />
@ -381,7 +380,7 @@
<div class="page-section">
[% PROCESS 'homebound-details' %]
<div class="action">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% patron.borrowernumber | html %]&method=update_or_create"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% patron.borrowernumber | html %]&op=update_or_create"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
</div>
</div> <!-- /.page-section -->
@ -415,8 +414,14 @@
</a>
</td>
<td class="actions">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&visit_id=[% entry.id | html %]&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="delete btn btn-default btn-xs" href="/cgi-bin/koha/members/housebound.pl?method=visit_delete&visit_id=[% entry.id | html %]&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-trash-can"></i> Delete</a>
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/housebound.pl?op=visit_update_or_create&visit_id=[% entry.id | html %]&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<form action="/cgi-bin/koha/members/housebound.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-visit_delete" />
<input type="hidden" name="visit_id" value="[% entry.id | html %]" />
<input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<button class="delete btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</button>
</form>
</td>
</tr>
[% END %]
@ -424,7 +429,7 @@
</table>
[% END %]
<div class="action">
<a href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&borrowernumber=[% patron.borrowernumber | uri %]"
<a href="/cgi-bin/koha/members/housebound.pl?op=visit_update_or_create&borrowernumber=[% patron.borrowernumber | uri %]"
class="btn btn-default btn-sm">
<i class="fa fa-plus"></i> Add a new delivery
</a>
@ -449,7 +454,7 @@
[% INCLUDE 'columns_settings.inc' %]
<script>
$(document).ready(function() {
$("a.delete").click(function(){
$(".delete").click(function(){
return confirm(_("Are you sure you want to delete this delivery?"));
});
});

View File

@ -112,7 +112,7 @@ if ( $op eq 'cud-updateconfirm' and $houseboundprofile ) {
$deliverers = Koha::Patrons->search_housebound_deliverers;
$choosers = Koha::Patrons->search_housebound_choosers;
$houseboundvisit = $visit;
} elsif ( $op eq 'visit_delete' and $visit ) {
} elsif ( $op eq 'cud-visit_delete' and $visit ) {
# We want ot delete a specific visit.
my $success = eval { return $visit->delete };
push @messages, { type => 'error', code => 'error_on_visit_delete' }