Bugzilla – Attachment 74540 Details for
Bug 7910
Batch renewal of subscriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7910: Add the ability to renew several subscriptions at once
Bug-7910-Add-the-ability-to-renew-several-subscrip.patch (text/plain), 10.40 KB, created by
Jonathan Druart
on 2018-04-19 10:45:52 UTC
(
hide
)
Description:
Bug 7910: Add the ability to renew several subscriptions at once
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-04-19 10:45:52 UTC
Size:
10.40 KB
patch
obsolete
>From 12e6e7fe3861f2464fa6ef003edef9771fcca096 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 18 Apr 2018 14:01:18 -0300 >Subject: [PATCH] Bug 7910: Add the ability to renew several subscriptions at > once > >This patch adds a "Renew all selected subscriptions" action link on top >of the table of the "Check expiration" page. > >It will allow to auto-renew several subscriptions. > >Test plan: >Make sure this new link renew the selected subscriptions as expected. >--- > .../prog/en/modules/serials/checkexpiration.tt | 52 ++++++++++++++++++++++ > .../prog/en/modules/serials/subscription-renew.tt | 21 +++++---- > serials/subscription-renew.pl | 52 +++++++++++++--------- > 3 files changed, 96 insertions(+), 29 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 24a977c24b..d2bf124cc9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt >@@ -61,8 +61,20 @@ > [% END %] > will expire before <b>[% date | $KohaDates %]</b> > </p> >+ >+<div class="checkexpiration-table_table_controls"> >+ <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | >+ <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a> >+ <span class="itemselection_actions"> >+ | Actions: >+ <a class="itemselection_action_renew" title="Renew selected subscriptions"><i class="fa fa-refresh"></i> Renew selected subscriptions</a> >+ </span> >+</div> >+ >+ > <table> > <tr> >+ <th></th> > <th>ISSN</th> > <th>Title</th> > [% IF can_change_library %]<th>Library</th>[% END %] >@@ -73,6 +85,9 @@ > </tr> > [% FOREACH subscriptions_loo IN subscriptions_loop %] > <tr> >+ <td style="text-align:center;vertical-align:middle"> >+ <input type="checkbox" value="[% subscriptions_loo.subscriptionid %]" name="subscriptionid" /> >+ </td> > <td> > [% subscriptions_loo.issn %] > </td> >@@ -123,6 +138,43 @@ > var subscriptionid = $(this).data("subscriptionid"); > popup( subscriptionid ); > }); >+ function itemSelectionBuildRenewLink() { >+ var subscription_ids= new Array(); >+ $("input[name='subscriptionid'][type='checkbox']:checked").each(function() { >+ subscription_ids.push($(this).val()); >+ }); >+ if (subscription_ids.length > 0) { >+ var url = '/cgi-bin/koha/serials/subscription-renew.pl?op=multi_renew'; >+ url += '&subscriptionid=' + subscription_ids.join('&subscriptionid='); >+ $('a.itemselection_action_renew').attr('href', url); >+ } else { >+ return false; >+ } >+ return true; >+ } >+ >+ function itemSelectionBuildActionLinks() { >+ var export_link_ok = itemSelectionBuildRenewLink(); >+ if (export_link_ok) { >+ $('.itemselection_actions').show(); >+ } else { >+ $('.itemselection_actions').hide(); >+ } >+ } >+ >+ itemSelectionBuildActionLinks(); >+ >+ $("input[name='subscriptionid'][type='checkbox']").change(function() { >+ itemSelectionBuildActionLinks(); >+ }); >+ >+ $(".SelectAll, .ClearAll").on("click",function(e){ >+ e.preventDefault(); >+ var checkboxes = $(this).parent().siblings('table').first().find('input[type="checkbox"]'); >+ checkboxes.prop('checked', $(this).hasClass('SelectAll')); >+ itemSelectionBuildActionLinks(); >+ }); >+ > }); > function popup(subscriptionid) { > newin=window.open("subscription-renew.pl?mode=popup&subscriptionid="+subscriptionid,'popup','width=590,height=440,toolbar=false,scrollbars=yes,resize=yes'); >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 6f854e7f0b..3639e57961 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 >@@ -1,18 +1,23 @@ > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Serials subscription renew #[% subscriptionid %]</title> >+[% IF subscription %] >+<title>Koha › Serials subscription renew #[% subscription.subscriptionid %]</title> >+[% ELSE %] >+<title>Koha › Serials subscription renew</title> >+[% END %] > [% INCLUDE 'doc-head-close.inc' %] > </head> > > <body id="ser_subscription-renew" class="ser"> > <div class="container-fluid"> > >-[% IF ( renew ) %] >+[% IF op == 'renew' %] > Subscription renewed. > > <script type="text/javascript"> > //<![CDATA[ >- opener.document.location.reload(); >+ //opener.document.location.reload(); >+ window.opener.location.reload(false); > self.close(); > //]]> > </script> >@@ -20,8 +25,8 @@ > <div id="bd"> > <form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post"> > <input type="hidden" name="op" value="renew" /> >- <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" /> >- <fieldset class="rows"><legend>Subscription renewal for [% bibliotitle %]</legend> >+ <input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid %]" /> >+ <fieldset class="rows"><legend>Subscription renewal for [% subscription.bibliotitle %]</legend> > <ol> > <li> > <label for="startdate">Start date: </label> >@@ -30,9 +35,9 @@ > </li> > <li><fieldset> > <legend>Subscription length:</legend> >- <ol><li><label for="numberlength">Number of num:</label><input type="text" id="numberlength" name="numberlength" value="[% numberlength %]" /></li> >- <li><label for="weeklength">Number of weeks: </label><input type="text" id="weeklength" name="weeklength" value="[% weeklength %]" /></li> >- <li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% monthlength %]" /></li></ol></fieldset></li> >+ <ol><li><label for="numberlength">Number of num:</label><input type="text" id="numberlength" name="numberlength" value="[% subscription.numberlength %]" /></li> >+ <li><label for="weeklength">Number of weeks: </label><input type="text" id="weeklength" name="weeklength" value="[% subscription.weeklength %]" /></li> >+ <li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% subscription.monthlength %]" /></li></ol></fieldset></li> > <li><label for="note">Note for the librarian that will manage your renewal request: </label> > <textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset> > <fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset> >diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl >index 06b03e2d35..836e612344 100755 >--- a/serials/subscription-renew.pl >+++ b/serials/subscription-renew.pl >@@ -60,7 +60,7 @@ my $dbh = C4::Context->dbh; > > my $mode = $query->param('mode') || q{}; > my $op = $query->param('op') || 'display'; >-my $subscriptionid = $query->param('subscriptionid'); >+my @subscriptionids = $query->multi_param('subscriptionid'); > my $done = 0; # for after form has been submitted > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -73,34 +73,44 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > if ( $op eq "renew" ) { >+ # Do not use this script with op=renew and @subscriptionids > 1! >+ my $subscriptionid = $subscriptionids[0]; > my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); > ReNewSubscription( > $subscriptionid, $loggedinuser, >- $startdate, $query->param('numberlength'), >- $query->param('weeklength'), $query->param('monthlength'), >- $query->param('note') >+ $startdate, scalar $query->param('numberlength'), >+ scalar $query->param('weeklength'), scalar $query->param('monthlength'), >+ scalar $query->param('note') > ); >-} >+} elsif ( $op eq 'multi_renew' ) { >+ for my $subscriptionid ( @subscriptionids ) { >+ my $subscription = GetSubscription( $subscriptionid ); >+ next unless $subscription; >+ ReNewSubscription( >+ $subscriptionid, $loggedinuser, >+ $subscription->{enddate}, $subscription->{numberlength}, >+ $subscription->{weeklength}, $subscription->{monthlength}, >+ ); >+ } >+} else { >+ my $subscriptionid = $subscriptionids[0]; >+ my $subscription = GetSubscription($subscriptionid); >+ if ($subscription->{'cannotedit'}){ >+ carp "Attempt to renew subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; >+ print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); >+ } > >-my $subscription = GetSubscription($subscriptionid); >-if ($subscription->{'cannotedit'}){ >- carp "Attempt to renew subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; >- print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); >-} >+ my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) >+ or output_pref( { dt => dt_from_string, dateonly => 1 } ); > >-my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) >- or output_pref( { dt => dt_from_string, dateonly => 1 } ); >+ $template->param( >+ startdate => $newstartdate, >+ subscription => $subscription, >+ ); >+} > > $template->param( >- startdate => $newstartdate, >- numberlength => $subscription->{numberlength}, >- weeklength => $subscription->{weeklength}, >- monthlength => $subscription->{monthlength}, >- subscriptionid => $subscriptionid, >- bibliotitle => $subscription->{bibliotitle}, >- $op => 1, >- popup => ($mode eq 'popup'), >+ op => $op, > ); > >-# Print the page > output_html_with_http_headers $query, $cookie, $template->output; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7910
:
9905
|
10717
|
10737
|
74501
|
74502
|
74540
|
74541
|
74545
|
74546
|
74547
|
74687
|
75269