From eeab9ccf77191c4a467817d33777a9dd437475a2 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 2 Mar 2026 08:11:02 +0000 Subject: [PATCH] Bug 4858: (QA follow-up) Fix high-priority issues - Remove duplicate 'use Scalar::Util' import introduced by this patch; the import already existed at line 26 of Koha/Patron.pm. - Pass notice_code as the note field on the add_debit call in add_print_notice_charge_if_needed. Previously the notice_code parameter was accepted but silently dropped, meaning all print notice charges looked identical in the account with no way to identify which letter triggered the charge. - Add print transport column to the OPAC messaging preferences table (opac-messaging.tt). The original patch added a print notice charging warning in the OPAC that told patrons to "uncheck print notice options" but never actually gave them a column to do so. This adds the print column to the OPAC table header and body rows (mirroring the staff messaging-preference-form.inc implementation), and adds a pmp_print JS click handler for the toggle_digest function, so patrons can opt out of print notices themselves. - Align PRINT_NOTICE debit type default_amount between fresh install and upgrade: account_debit_types.yml correctly set this to NULL (charge amount is per patron category, not a global default) but the atomicupdate was inserting 0.50. Changed atomicupdate to NULL. Sponsored-by: OpenFifth Signed-off-by: Jackie Usher --- Koha/Patron.pm | 20 ++++--- .../bug_4858-print-notice-charge.pl | 2 +- .../bootstrap/en/modules/opac-messaging.tt | 55 ++++++++++++++++--- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 52532a45ead..7927c9a5108 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -21,7 +21,6 @@ package Koha::Patron; use Modern::Perl; use List::MoreUtils qw( any none uniq notall zip6); -use Scalar::Util qw( looks_like_number ); use JSON qw( to_json ); use Scalar::Util qw(looks_like_number); use Unicode::Normalize qw( NFKD ); @@ -1692,17 +1691,20 @@ sub add_print_notice_charge_if_needed { return unless Scalar::Util::looks_like_number($charge_amount); return unless $charge_amount > 0; - my $userenv = C4::Context->userenv; - my $library_id = $params->{library_id} || ($userenv ? $userenv->{branch} : undef); + my $userenv = C4::Context->userenv; + my $library_id = $params->{library_id} || ( $userenv ? $userenv->{branch} : undef ); my $result; try { - $result = $self->account->add_debit({ - amount => $charge_amount, - type => 'PRINT_NOTICE', - interface => C4::Context->interface, - library_id => $library_id, - }); + $result = $self->account->add_debit( + { + amount => $charge_amount, + type => 'PRINT_NOTICE', + interface => C4::Context->interface, + library_id => $library_id, + note => $params->{notice_code}, + } + ); } catch { return; }; diff --git a/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl b/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl index d6f25bd7653..b6583a6b1bc 100755 --- a/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl +++ b/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl @@ -20,7 +20,7 @@ return { $dbh->do( q{ INSERT IGNORE INTO account_debit_types (code, description, can_be_invoiced, can_be_sold, default_amount, is_system, restricts_checkouts) - VALUES ('PRINT_NOTICE', 'Print notice charge', 0, 0, 0.50, 1, 0) + VALUES ('PRINT_NOTICE', 'Print notice charge', 0, 0, NULL, 1, 0) } ); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index bb6c2c6224f..5bb3499c809 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -47,8 +47,7 @@ [% IF print_notice_charging && !patron_has_email %]

Print Notice Charges

-

Important: Print notices incur a charge of - [% print_notice_charge_amount | $Price %] each to cover postage and processing costs.

+

Important: Print notices incur a charge of [% print_notice_charge_amount | $Price %] each to cover postage and processing costs.

To avoid these charges, please:

  • Provide an email address in your account details
  • @@ -63,6 +62,10 @@ [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) %] + [% SET has_print_transport = 0 %] + [% FOREACH pref IN messaging_preferences %] + [% IF pref.transport_print %][% SET has_print_transport = 1 %][% LAST %][% END %] + [% END %] @@ -73,6 +76,14 @@ [% IF ( TalkingTechItivaPhone ) %][% END %] [% IF Koha.Preference('PhoneNotification') %][% END %] + [% IF has_print_transport %] + + [% END %] + [% ELSE %] + + [% END %] + [% END %] + [% IF ( messaging_preference.has_digest ) %]
    Your messaging settings
    PhonePhoneEmailPrint + [% IF print_notice_charging %] + ([% print_notice_charge_amount | $Price %] charge) + [% END %] + Digests only - [% END %] + [% IF has_print_transport %] + [% IF ( messaging_preference.transport_print ) %] + + [% IF ( messaging_preference.transports_print ) %] + + [% ELSE %] + + [% END %] + - [% IF ( messaging_preference.digest ) %] @@ -294,16 +334,14 @@ [% IF print_notice_charging %]
    About Print Notice Charges
    -

    Print notices incur a charge of - [% IF print_notice_charge_amount %][% print_notice_charge_amount | $Price %][% ELSE %]0.00[% END %] - each to cover postage and processing costs.

    +

    Print notices incur a charge of [% IF print_notice_charge_amount %][% print_notice_charge_amount | $Price %][% ELSE %]0.00[% END %] each to cover postage and processing costs.

    To avoid these charges:

      [% IF !patron_has_email %]
    • Add an email address to your account details
    • [% END %] -
    • Select "Email" instead of any print options for your notice preferences above
    • -
    • Ask library staff to disable print notices for your account
    • +
    • Select "Email" instead of "Print" for your notice preferences above
    • +
    • Uncheck any enabled print notice preferences above
    [% IF patron_has_email %]

    ✓ You have an email address on file. Make sure to select email delivery for notices to avoid print charges.

    @@ -427,6 +465,9 @@ $(".pmp_phone").click(function(){ toggle_digest(Number($(this).attr("id").replace("phone", ""))); }); + $(".pmp_print").click(function(){ + toggle_digest(Number($(this).attr("id").replace("print", ""))); + }); }); -- 2.53.0