From 941a57e967be29883f0400c80c4c609d541bedca Mon Sep 17 00:00:00 2001 From: Lisette Scheer Date: Thu, 2 Oct 2025 17:51:54 +0000 Subject: [PATCH] Bug 40795: Fix +add note function on payment table This patch updates the table on members/pay.pl to have consistant ui with the transactions table, using a modal. On members/pay.pl if there's no note, a note can still be added without the edit permission to allow for notes at time of payment, consistent with current behavior. I also updated the logic with the buttons on both pages to show as "add" when there's not a note present. To test: 1. Before applying patches, navigate to a user in your test environment (I used 23529000035676) 2. Click "Accounting" in the left hand link list 3. Create manual invoice, give it an amount but no note 4. Create another manual invoice, give it an amount and any note. 5. Navigate to "Transactions" observe both notes have an edit button. 6. Click edit on the one with a note, update it, and save. Note it has been updated. 7. Navigate to "Make a payment" Observe both columns have a text box that's immediately editable. The note should be filled on the charge with a note. 8. Apply the patch 9. Repeat step 5, observe the column with no note says "Add" now. 10. Repeat step 7, observe the payment note field matches the "note" field on transactions. 11. Edit the existing note and save 12. Add a new note for the other transaction and save. Signed-off-by: David Nind --- .../prog/en/modules/members/boraccount.tt | 2 +- .../prog/en/modules/members/pay.tt | 78 +++++++++++++++++-- members/pay.pl | 20 +++++ 3 files changed, 91 insertions(+), 9 deletions(-) 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 d4a337786e..7909d221a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -144,7 +144,7 @@ data-accountline="[% account.accountlines_id | html %]" data-note="[% account.note | html %]" data-member="[% account.borrowernumber | html %]" - > Edit[% IF account.note %] Edit[% ELSE %]Add[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index 7cf5df0e4b..14f2c2c279 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -170,15 +170,30 @@ [% IF line.note %] - - + [% line.note | html_line_break %] + [% IF CAN_user_updatecharges_edit_accountline_notes %] + + [% END %] [% ELSE %] - Add note - + [% END %] [% line.amount | $Price %] @@ -228,7 +243,47 @@ [% END %] + + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] @@ -296,6 +351,13 @@ table_settings ); }); + $("#editNoteModal").on("shown.bs.modal", function(e) { + var button = $(e.relatedTarget); + var accountline = button.data('accountline'); + $('#noteline').val(accountline); + var note = button.data('note'); + $('#payment_note').val(note); + }); [% END %] diff --git a/members/pay.pl b/members/pay.pl index 8e013f414c..d6b8b4ad3c 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -98,7 +98,27 @@ if ( $op eq 'cud-paycollect' ) { } elsif ( $op eq 'cud-apply_credits' ) { apply_credits( { patron => $patron, cgi => $input } ); } +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 $schema = Koha::Database->new->schema; + 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(); + } + ); +} for (@names) { if ( $op =~ /^cud-pay_indiv_(\d+)$/ ) { my $line_no = $1; -- 2.47.3