From 84da78796e8bc385274aa5a1c72c2f33aaf442a4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 27 Feb 2024 13:23:09 +0100 Subject: [PATCH] Bug 34478: Adjust 'op' on serials/subscription-renew multi_renew now has a validation step This patch also removes 2 variables that were not used ($mode and $done) Signed-off-by: Jonathan Druart --- .../en/modules/serials/checkexpiration.tt | 4 ++-- .../en/modules/serials/serials-collection.tt | 2 +- .../prog/en/modules/serials/serials-edit.tt | 2 +- .../en/modules/serials/subscription-renew.tt | 23 ++++++++++++++++--- .../intranet-tmpl/prog/js/serials-toolbar.js | 2 +- serials/subscription-renew.pl | 20 ++++++++++++---- 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt index 2c7bbd1c8e..66c066fe6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt @@ -133,7 +133,7 @@ Edit - Renew + Renew [% END %] @@ -159,7 +159,7 @@ $(".renew_subscription").on("click",function(e){ e.preventDefault(); var subscriptionid = $(this).data("subscriptionid"); - newin=window.open("/cgi-bin/koha/serials/subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes'); + newin=window.open("/cgi-bin/koha/serials/subscription-renew.pl?op=renew&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes'); }); $('a.itemselection_action_renew').on("click", function(e){ e.preventDefault(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index a52c54f19d..ea9775f66a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -125,7 +125,7 @@ [% END %] [% END %] [% IF ( subscription.abouttoexpire || subscription.subscriptionexpired) %] - Renew + Renew [% END %] [% ELSE %]   diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt index 6aa953b859..b20db8cba4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt @@ -15,7 +15,7 @@ }); function popup(subscriptionid) { - window.open("subscription-renew.pl?subscriptionid="+subscriptionid,"subscription_renewal",'width=700,height=400,toolbar=false,scrollbars=yes'); + window.open("subscription-renew.pl?op=renew&subscriptionid="+subscriptionid,"subscription_renewal",'width=700,height=400,toolbar=false,scrollbars=yes'); } function unHideItems(index,labelindex, serialId) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt index cb2940cfcb..caaa664d25 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt @@ -17,8 +17,8 @@ [% INCLUDE 'blocking_errors.inc' %] -[% IF op == 'renew' OR op =='multi_renew' %] - [% IF op == 'renew' %] +[% IF op == 'cud-renew' OR op =='cud-multi_renew' %] + [% IF op == 'cud-renew' %] Subscription renewed. [% ELSE %] Subscriptions renewed. @@ -27,7 +27,24 @@ -[% ELSE %] +[% ELSIF op == 'multi_renew' %] + +
+ [% INCLUDE 'csrf-token.inc' %] + + Subscription renewal for: +
    + [% FOR subscription IN subscriptions %] +
  • + + [% subscription.bibliotitle | html %] +
  • + [% END %] +
+
+
+ +[% ELSIF op == 'renew' %]
[% INCLUDE 'csrf-token.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js b/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js index 1c4bb69538..2ebaf6ad2f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js +++ b/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js @@ -1,7 +1,7 @@ /* global subscriptionid __ */ function popup(subscriptionid) { - newin=window.open("subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes'); + newin=window.open("subscription-renew.pl?op=renew&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes'); } $(document).ready(function() { diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 5fd285b014..982cb9dd4d 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -58,7 +58,6 @@ use Koha::DateUtils qw( dt_from_string output_pref ); my $query = CGI->new; my $dbh = C4::Context->dbh; -my $mode = $query->param('mode') || q{}; my $op = $query->param('op') || 'display'; my @subscriptionids = $query->multi_param('subscriptionid'); my $branchcode = $query->param('branchcode'); @@ -66,7 +65,6 @@ my $sublength = $query->param('sublength'); my $subtype = $query->param('subtype'); my ($numberlength, $weeklength, $monthlength); -my $done = 0; # for after form has been submitted my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "serials/subscription-renew.tt", @@ -101,7 +99,7 @@ if ( $op eq "cud-renew" ) { branchcode => $branchcode } ); -} elsif ( $op eq 'multi_renew' ) { +} elsif ( $op eq 'cud-multi_renew' ) { for my $subscriptionid ( @subscriptionids ) { my $subscription = GetSubscription( $subscriptionid ); next unless $subscription; @@ -117,7 +115,21 @@ if ( $op eq "cud-renew" ) { } ); } -} else { +} +elsif ( $op eq 'multi_renew' ) { + my @subscriptions; + for my $subscriptionid ( @subscriptionids ) { + my $subscription = GetSubscription( $subscriptionid ); + next unless $subscription; + next if $subscription->{cannotedit}; + push @subscriptions, $subscription; + } + + $template->param( + subscriptions => \@subscriptions, + ); +} +else { my $subscriptionid = $subscriptionids[0]; my $subscription = GetSubscription($subscriptionid); output_and_exit( $query, $cookie, $template, 'unknown_subscription') unless $subscription; -- 2.39.5