Bug 15006: Centralize timeout logic and allow zero client timeout
[koha.git] / serials / subscription-add.pl
index 1790866..31a6b6b 100755 (executable)
@@ -42,7 +42,6 @@ my $op = $query->param('op') || '';
 my $dbh = C4::Context->dbh;
 my $sub_length;
 
-my @budgets;
 
 # Permission needed if it is a modification : edit_subscription
 # Permission needed otherwise (nothing or dup) : create_subscription
@@ -147,7 +146,7 @@ for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{b
     };
 }
 
-my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
+my $locations_loop = GetAuthorisedValues("LOC");
 
 $template->param(branchloop => $branchloop,
     locations_loop=>$locations_loop,
@@ -237,6 +236,7 @@ if ($op eq 'addsubscription') {
 
 sub get_letter_loop {
     my ($selected_lettercode) = @_;
+    $selected_lettercode //= '';
     my $letters = GetLetters({ module => 'serial' });
     return [
         map {
@@ -294,7 +294,7 @@ sub redirect_add_subscription {
     my $cost           = $query->param('cost');
     my $aqbudgetid     = $query->param('aqbudgetid');
     my $periodicity    = $query->param('frequency');
-    my @irregularity   = $query->param('irregularity');
+    my @irregularity   = $query->multi_param('irregularity');
     my $numberpattern  = $query->param('numbering_pattern');
     my $locale         = $query->param('locale');
     my $graceperiod    = $query->param('graceperiod') || 0;
@@ -323,9 +323,9 @@ sub redirect_add_subscription {
     my $location          = $query->param('location');
     my $skip_serialseq    = $query->param('skip_serialseq');
 
-    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
-    my $enddate        = output_pref( { str => $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
-    my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
+    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
+    my $enddate        = output_pref( { str => scalar $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
+    my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
 
     if(!defined $enddate || $enddate eq '') {
         if($subtype eq "issues") {
@@ -355,18 +355,18 @@ sub redirect_add_subscription {
 
 sub redirect_mod_subscription {
     my $subscriptionid = $query->param('subscriptionid');
-    my @irregularity = $query->param('irregularity');
+    my @irregularity = $query->multi_param('irregularity');
     my $auser = $query->param('user');
-    my $librarian => $query->param('librarian'),
+    my $librarian => scalar $query->param('librarian'),
     my $branchcode = $query->param('branchcode');
     my $cost = $query->param('cost');
     my $aqbooksellerid = $query->param('aqbooksellerid');
     my $biblionumber = $query->param('biblionumber');
     my $aqbudgetid = $query->param('aqbudgetid');
 
-    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
-    my $enddate        = output_pref( { str => $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
-    my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
+    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
+    my $enddate        = output_pref( { str => scalar $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
+    my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
 
     my $nextacquidate  = $query->param('nextacquidate');
     $nextacquidate = $nextacquidate
@@ -437,7 +437,6 @@ sub redirect_mod_subscription {
 
 sub insert_additional_fields {
     my ( $additional_fields, $biblionumber, $subscriptionid ) = @_;
-    my @additional_field_values;
     my $record = GetMarcBiblio( $biblionumber, 1 );
     for my $field ( @$additional_fields ) {
         my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
@@ -452,7 +451,7 @@ sub insert_additional_fields {
             }
         } else {
             $af->{values} = {
-                $subscriptionid => $query->param('additional_field_' . $field->{id})
+                $subscriptionid => scalar $query->param('additional_field_' . $field->{id})
             } if defined $query->param('additional_field_' . $field->{id});
         }
         $af->insert_values;