Bug 7046: Preselect dropdown option and prefill input
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 8 Apr 2020 08:42:41 +0000 (10:42 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 8 Apr 2020 10:50:25 +0000 (11:50 +0100)
With previous renew values

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt
serials/subscription-add.pl
serials/subscription-renew.pl

index 614e4d5..e5f121e 100644 (file)
     <li>
     <label>Subscription length:</label>
     <select name="subtype" id="subtype">
-        [% FOREACH st IN subtypes %]
-            [% SWITCH st %]
-                [% CASE 'numberlength'%]
-                    [% IF st == subtype %]
-                        <option value="issues" selected="selected">
-                    [% ELSE %]
-                        <option value="issues">
-                    [% END %]
-                    issues
-                [% CASE 'weeklength' %]
-                    [% IF st == subtype %]
-                        <option value="weeks" selected="selected">
-                    [% ELSE %]
-                        <option value="weeks">
-                    [% END %]
-                    weeks
-                [% CASE 'monthlength' %]
-                    [% IF st == subtype %]
-                        <option value="months" selected="selected">
-                    [% ELSE %]
-                        <option value="months">
-                    [% END %]
-                    months
-                [% CASE %][% st | html %]
+        [% FOREACH st IN [['numberlength', 'issues'], ['weeklength', 'weeks'], ['monthlength', 'months']] %]
+            [% SET subtype = st.0 %]
+            [% SET value = st.1 %]
+            [% IF subscription.$subtype %]
+                <option value="[% value %]" selected="selected">
+            [% ELSE %]
+                <option value="[% value %]">
+            [% END %]
+            [% SWITCH subtype %]
+                [% CASE 'numberlength'%]issues
+                [% CASE 'weeklength'  %]weeks
+                [% CASE 'monthlength' %]months
             [% END %]
             </option>
         [% END %]
     </select>
-    <input type="text" name="sublength" id="sublength" size="3" />(enter amount in numerals)
+    <input type="text" name="sublength" id="sublength" size="3" value="[% subscription.numberlength || subscription.weeklength || subscription.monthlength %]" />(enter amount in numerals)
     <input type="hidden" name="issuelengthcount">
     </li>
 
index 6fdc1b2..f0cb7b5 100755 (executable)
@@ -434,7 +434,6 @@ sub redirect_mod_subscription {
     my $subtype = $query->param('subtype');
     my $sublength = $query->param('sublength');
     my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength );
-    my $numberpattern = $query->param('numbering_pattern');
     my $locale = $query->param('locale');
     my $lastvalue1 = $query->param('lastvalue1');
     my $innerloop1 = $query->param('innerloop1');
index 954b007..1889f9a 100755 (executable)
@@ -135,7 +135,6 @@ my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
 $template->param(
     op => $op,
     libraries      => $libraries,
-    subtypes => [ qw( numberlength weeklength monthlength ) ],
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;