Fix for Bug 4416, renew all and return all buttons too close together
[koha_fer] / serials / subscription-add.pl
index 46fd88d..f87dae5 100755 (executable)
@@ -11,9 +11,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
 use warnings;
@@ -115,7 +115,6 @@ my $branches = GetBranches($onlymine);
 my $branchloop;
 for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
     my $selected = 0;
-    $selected = 1 if ($thisbranch eq C4::Context->userenv->{'branch'});
     $selected = 1 if (defined($subs) && $thisbranch eq $subs->{'branchcode'});
     push @{$branchloop}, {
         value => $thisbranch,
@@ -178,6 +177,16 @@ sub letter_loop {
     return;
 }
 
+sub _get_sub_length {
+    my ($type, $length) = @_;
+    return
+        (
+            $type eq 'numberlength' ? $length : 0,
+            $type eq 'weeklength'   ? $length : 0,
+            $type eq 'monthlength'  ? $length : 0,
+        );
+}
+
 sub redirect_add_subscription {
     my $auser           = $query->param('user');
     my $branchcode      = $query->param('branchcode');
@@ -187,21 +196,11 @@ sub redirect_add_subscription {
     my $periodicity     = $query->param('periodicity');
     my $dow             = $query->param('dow');
     my @irregularity    = $query->param('irregularity_select');
-    my $numberlength    = 0;
-    my $weeklength      = 0;
-    my $monthlength     = 0;
     my $numberpattern   = $query->param('numbering_pattern');
-    my $sublength       = $query->param('sublength');
-    my $subtype         = $query->param('subtype');
     my $graceperiod     = $query->param('graceperiod') || 0;
 
-    if ($subtype eq 'months'){
-        $monthlength = $sublength;
-    } elsif ($subtype eq 'weeks'){
-        $weeklength = $sublength;
-    } else {
-        $numberlength = $sublength;
-    }
+    my ($numberlength, $weeklength, $monthlength)
+        = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
     my $add1 = $query->param('add1');
     my $every1 = $query->param('every1');
     my $whenmorethan1 = $query->param('whenmorethan1');
@@ -274,17 +273,9 @@ sub redirect_mod_subscription {
     my $enddate = format_date_in_iso($query->param('enddate'));
     my $periodicity = $query->param('periodicity');
     my $dow = $query->param('dow');
-    my $sublength = $query->param('sublength');
-    my $subtype = $query->param('subtype');
 
-    my ($monthlength, $weeklength, $numberlength);
-    if($subtype eq 'months'){
-        $monthlength = $sublength;
-    } elsif ($subtype eq 'weeks'){
-        $weeklength = $sublength;
-    } else {
-        $numberlength = $sublength;
-    }
+    my ($numberlength, $weeklength, $monthlength)
+        = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
     my $numberpattern = $query->param('numbering_pattern');
     my $add1 = $query->param('add1');
     my $every1 = $query->param('every1');