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 <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2024-02-27 13:23:09 +01:00
parent 8c3a25bf1f
commit 84da78796e
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0
6 changed files with 41 additions and 12 deletions

View file

@ -133,7 +133,7 @@
</td>
<td class="actions">
<a href="/cgi-bin/koha/serials/subscription-add.pl?op=modify&amp;subscriptionid=[% subscriptions_loo.subscriptionid | uri %]" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscriptions_loo.subscriptionid | uri %]" data-subscriptionid="[% subscriptions_loo.subscriptionid | html %]" class="btn btn-default btn-xs renew_subscription"><i class="fa-solid fa-rotate"></i> Renew</a>
<a href="#" data-subscriptionid="[% subscriptions_loo.subscriptionid | html %]" class="btn btn-default btn-xs renew_subscription"><i class="fa-solid fa-rotate"></i> Renew</a>
</td>
</tr>
[% 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();

View file

@ -125,7 +125,7 @@
[% END %]
[% END %]
[% IF ( subscription.abouttoexpire || subscription.subscriptionexpired) %]
<a class="btn btn-default btn-xs subscription_renew" data-subscriptionid="[% subscription.subscriptionid | html %]" href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa-solid fa-rotate"></i> Renew</a>
<a class="btn btn-default btn-xs subscription_renew" data-subscriptionid="[% subscription.subscriptionid | html %]" href="/cgi-bin/koha/serials/subscription-renew.pl?op=renew&subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa-solid fa-rotate"></i> Renew</a>
[% END %]
[% ELSE %]
&nbsp;

View file

@ -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) {

View file

@ -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' %]
<span>Subscription renewed.<span>
[% ELSE %]
<span>Subscriptions renewed.<span>
@ -27,7 +27,24 @@
<div id="closewindow">
<a class="btn btn-default btn-default close" href="#">Close</a>
</div>
[% ELSE %]
[% ELSIF op == 'multi_renew' %]
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-multi_renew" />
Subscription renewal for:
<ul>
[% FOR subscription IN subscriptions %]
<li>
<input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid | html %]" />
[% subscription.bibliotitle | html %]
</li>
[% END %]
</ul>
<fieldset class="action"><input type="submit" class="btn btn-primary" value="Submit" /></fieldset>
</form>
[% ELSIF op == 'renew' %]
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]

View file

@ -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() {

View file

@ -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;