From 710401ec34bfc366367b349c182e3b0bfc80179b Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Thu, 27 Jun 2024 17:06:32 +0000 Subject: [PATCH] Bug 37211: Make notes in patron transactions table editable This patch adds an edit button to each notes field in an accountline entry. This feature is controlled by a new staff permision under the 'updatecharges' permision called 'edit_notes'. To test: 1) Apply patch, updatedatabase, restart_all 2) In the staff interface, give your logged in user superlibrarian permissions. 3) Visit a patron's accounting tab. Create a manual invoice for some amount and enter a note. 4) Create another manual invoice, this time do not enter a note. 5) Click on the transactions tab to view the table. 6) See that the notes column now has edit buttons. 7) Attempt to edit the note that is not blank. 8) A modal should pop up prompting you to edit your note. The previous note should be in the text box. 9) Edit this note and press confirm. 10) Ensure the note was updated and the updated column was filled with the correct time. 11) Now attempt to edit the blank note. 12) Again, you should see a modal but no prefilled message. Update this note and ensure correct changes. 13) Go back to the permissions for your logged in user and remove the 'edit_notes' subpermission under the 'updatecharges' permissions. 14) Go back to the patron's accounting tab. This time, there should not be any edit buttons in the notes column. --- .../prog/en/modules/members/boraccount.tt | 48 ++++++++++++++++++- members/boraccount.pl | 18 +++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index 57b11a693e..8ab355042d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -132,7 +132,12 @@ [% END %] [% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %] - [% account.note | html_line_break %] + + [% account.note | html_line_break %] + [% IF CAN_user_updatecharges_edit_notes %] + + [% END %] + [% IF account.amount <= 0 %][% ELSE %][% END %][% account.amount | $Price %] [% IF account.amountoutstanding <= 0 %][% ELSE %][% END %][% account.amountoutstanding | $Price %] @@ -448,6 +453,37 @@ + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] @@ -537,6 +573,16 @@ $('#accountlines_id').val(item); }); + $("#editNoteModal").on("shown.bs.modal", function(e){ + var button = $(e.relatedTarget); + var item = button.data('item'); + $("#item + span").replaceWith(item); + var accountline = button.data('accountline'); + $('#noteline').val(accountline); + var note = button.data('note'); + $('#edited_note').val(note); + }); + $(".receipt-email-action").on("click", function(e){ e.preventDefault(); return $(this).siblings('form').submit(); diff --git a/members/boraccount.pl b/members/boraccount.pl index 6e9cd60047..844c83554b 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -226,6 +226,24 @@ if ( $op eq 'cud-send_receipt' ) { } } +if ( $op eq 'cud-edit_note' ) { + output_and_exit_if_error( $input, $cookie, $template, { check => 'csrf_token' } ); + my $payment_id = scalar $input->param('accountlines_id'); + my $note = scalar $input->param('edited_note'); + my $payment = Koha::Account::Lines->find($payment_id); + $schema->txn_do( + sub { + # Update the note and date in the account line + $payment->set( + { + date => \'NOW()', + note => $note + } + )->store(); + } + ); +} + #get account details my $total = $patron->account->balance; -- 2.39.2