View | Details | Raw Unified | Return to bug 8956
Collapse All | Expand All

(-)a/serials/subscription-add.pl (-188 / +187 lines)
Lines 27-33 use C4::Dates qw/format_date format_date_in_iso/; Link Here
27
use C4::Acquisition;
27
use C4::Acquisition;
28
use C4::Output;
28
use C4::Output;
29
use C4::Context;
29
use C4::Context;
30
use C4::Branch; # GetBranches
30
use C4::Branch;    # GetBranches
31
use C4::Serials;
31
use C4::Serials;
32
use C4::Letters;
32
use C4::Letters;
33
use Carp;
33
use Carp;
Lines 43-116 my @budgets; Link Here
43
43
44
# Permission needed if it is a modification : edit_subscription
44
# Permission needed if it is a modification : edit_subscription
45
# Permission needed otherwise (nothing or dup) : create_subscription
45
# Permission needed otherwise (nothing or dup) : create_subscription
46
my $permission = ($op eq "modify") ? "edit_subscription" : "create_subscription";
46
my $permission = ( $op eq "modify" ) ? "edit_subscription" : "create_subscription";
47
48
my ($template, $loggedinuser, $cookie)
49
= get_template_and_user({template_name => "serials/subscription-add.tmpl",
50
				query => $query,
51
				type => "intranet",
52
				authnotrequired => 0,
53
				flagsrequired => {serials => $permission},
54
				debug => 1,
55
				});
56
57
47
48
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
49
    {   template_name   => "serials/subscription-add.tmpl",
50
        query           => $query,
51
        type            => "intranet",
52
        authnotrequired => 0,
53
        flagsrequired   => { serials => $permission },
54
        debug           => 1,
55
    }
56
);
58
57
59
my $sub_on;
58
my $sub_on;
60
my @subscription_types = (
59
my @subscription_types = ( 'issues', 'weeks', 'months' );
61
            'issues', 'weeks', 'months'
62
        );
63
my @sub_type_data;
60
my @sub_type_data;
64
61
65
my $subs;
62
my $subs;
66
my $firstissuedate;
63
my $firstissuedate;
67
64
68
if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
65
if ( $op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription' ) {
69
66
70
    my $subscriptionid = $query->param('subscriptionid');
67
    my $subscriptionid = $query->param('subscriptionid');
71
    $subs = GetSubscription($subscriptionid);
68
    $subs = GetSubscription($subscriptionid);
72
## FIXME : Check rights to edit if mod. Could/Should display an error message.
69
## FIXME : Check rights to edit if mod. Could/Should display an error message.
73
    if ($subs->{'cannotedit'} && $op eq 'modify'){
70
    if ( $subs->{'cannotedit'} && $op eq 'modify' ) {
74
      carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
71
        carp "Attempt to modify subscription $subscriptionid by " . C4::Context->userenv->{'id'} . " not allowed";
75
      print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
72
        print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
76
    }
73
    }
77
    $firstissuedate = $subs->{firstacquidate};  # in iso format.
74
    $firstissuedate = $subs->{firstacquidate};    # in iso format.
78
    for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
75
    for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
79
        next unless defined $subs->{$_};
76
        next unless defined $subs->{$_};
80
	# TODO : Handle date formats properly.
77
81
         if ($subs->{$_} eq '0000-00-00') {
78
        # TODO : Handle date formats properly.
82
            $subs->{$_} = ''
79
        if ( $subs->{$_} eq '0000-00-00' ) {
83
    	} else {
80
            $subs->{$_} = '';
84
            $subs->{$_} = format_date($subs->{$_});
81
        } else {
82
            $subs->{$_} = format_date( $subs->{$_} );
85
        }
83
        }
86
	  }
84
    }
87
      if (!defined $subs->{letter}) {
85
    if ( !defined $subs->{letter} ) {
88
          $subs->{letter}= q{};
86
        $subs->{letter} = q{};
89
      }
87
    }
90
    letter_loop($subs->{'letter'}, $template);
88
    letter_loop( $subs->{'letter'}, $template );
91
    my $nextexpected = GetNextExpected($subscriptionid);
89
    my $nextexpected = GetNextExpected($subscriptionid);
92
    $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate}->output('iso') eq $firstissuedate ;
90
    $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate}->output('iso') eq $firstissuedate;
93
    $subs->{nextacquidate} = $nextexpected->{planneddate}->output()  if($op eq 'modify');
91
    $subs->{nextacquidate} = $nextexpected->{planneddate}->output() if ( $op eq 'modify' );
94
    unless($op eq 'modsubscription') {
92
    unless ( $op eq 'modsubscription' ) {
95
		foreach my $length_unit qw(numberlength weeklength monthlength){
93
        foreach my $length_unit qw(numberlength weeklength monthlength) {
96
			if ($subs->{$length_unit}){
94
            if ( $subs->{$length_unit} ) {
97
				$sub_length=$subs->{$length_unit};
95
                $sub_length = $subs->{$length_unit};
98
				$sub_on=$length_unit;
96
                $sub_on     = $length_unit;
99
				last;
97
                last;
100
			}
98
            }
101
		}
99
        }
102
100
103
        $template->param( %{$subs} );
101
        $template->param( %{$subs} );
104
        $template->param("dow".$subs->{'dow'} => 1) if defined $subs->{'dow'};
102
        $template->param( "dow" . $subs->{'dow'} => 1 ) if defined $subs->{'dow'};
105
        $template->param(
103
        $template->param(
106
                    $op => 1,
104
            $op               => 1,
107
                    "subtype_$sub_on" => 1,
105
            "subtype_$sub_on" => 1,
108
                    sublength =>$sub_length,
106
            sublength         => $sub_length,
109
                    history => ($op eq 'modify'),
107
            history => ( $op eq 'modify' ),
110
                    "periodicity".$subs->{'periodicity'} => 1,
108
            "periodicity" . $subs->{'periodicity'}     => 1,
111
                    "numberpattern".$subs->{'numberpattern'} => 1,
109
            "numberpattern" . $subs->{'numberpattern'} => 1,
112
                    firstacquiyear => substr($firstissuedate,0,4),
110
            firstacquiyear => substr( $firstissuedate, 0, 4 ),
113
                    );
111
        );
114
    }
112
    }
115
113
116
    if ( $op eq 'dup' ) {
114
    if ( $op eq 'dup' ) {
Lines 120-205 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
120
    }
118
    }
121
}
119
}
122
120
123
my $onlymine=C4::Context->preference('IndependantBranches') &&
121
my $onlymine =
124
             C4::Context->userenv &&
122
     C4::Context->preference('IndependantBranches')
125
             C4::Context->userenv->{flags} % 2 !=1 &&
123
  && C4::Context->userenv
126
             C4::Context->userenv->{branch};
124
  && C4::Context->userenv->{flags} % 2 != 1
125
  && C4::Context->userenv->{branch};
127
my $branches = GetBranches($onlymine);
126
my $branches = GetBranches($onlymine);
128
my $branchloop;
127
my $branchloop;
129
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
128
for my $thisbranch ( sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches} ) {
130
    my $selected = 0;
129
    my $selected = 0;
131
    $selected = 1 if (defined($subs) && $thisbranch eq $subs->{'branchcode'});
130
    $selected = 1 if ( defined($subs) && $thisbranch eq $subs->{'branchcode'} );
132
    push @{$branchloop}, {
131
    push @{$branchloop},
133
        value => $thisbranch,
132
      { value      => $thisbranch,
134
        selected => $selected,
133
        selected   => $selected,
135
        branchname => $branches->{$thisbranch}->{'branchname'},
134
        branchname => $branches->{$thisbranch}->{'branchname'},
136
    };
135
      };
137
}
136
}
138
137
139
my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
138
my $locations_loop = GetAuthorisedValues( "LOC", $subs->{'location'} );
140
139
141
$template->param(branchloop => $branchloop,
140
$template->param(
142
    locations_loop=>$locations_loop,
141
    branchloop     => $branchloop,
142
    locations_loop => $locations_loop,
143
);
143
);
144
144
# prepare template variables common to all $op conditions:
145
# prepare template variables common to all $op conditions:
145
if ($op!~/^mod/) {
146
if ( $op !~ /^mod/ ) {
146
    letter_loop(q{}, $template);
147
    letter_loop( q{}, $template );
147
}
148
}
148
149
149
if ($op eq 'addsubscription') {
150
if ( $op eq 'addsubscription' ) {
150
    redirect_add_subscription();
151
    redirect_add_subscription();
151
} elsif ($op eq 'modsubscription') {
152
} elsif ( $op eq 'modsubscription' ) {
152
    redirect_mod_subscription();
153
    redirect_mod_subscription();
153
} else {
154
} else {
154
        while (@subscription_types) {
155
    while (@subscription_types) {
155
           my $sub_type = shift @subscription_types;
156
        my $sub_type = shift @subscription_types;
156
           my %row = ( 'name' => $sub_type );
157
        my %row = ( 'name' => $sub_type );
157
           if ( defined $sub_on and $sub_on eq $sub_type ) {
158
        if ( defined $sub_on and $sub_on eq $sub_type ) {
158
	     $row{'selected'} = ' selected';
159
            $row{'selected'} = ' selected';
159
           } else {
160
        } else {
160
	     $row{'selected'} = '';
161
            $row{'selected'} = '';
161
           }
162
           push( @sub_type_data, \%row );
163
        }
162
        }
164
    $template->param(subtype => \@sub_type_data);
163
        push( @sub_type_data, \%row );
164
    }
165
    $template->param( subtype => \@sub_type_data );
165
166
166
    letter_loop( '', $template ) if ($op ne 'modsubscription' && $op ne 'dup' && $op ne 'modify');
167
    letter_loop( '', $template ) if ( $op ne 'modsubscription' && $op ne 'dup' && $op ne 'modify' );
167
168
168
    my $new_biblionumber = $query->param('biblionumber_for_new_subscription');
169
    my $new_biblionumber = $query->param('biblionumber_for_new_subscription');
169
    if (defined $new_biblionumber) {
170
    if ( defined $new_biblionumber ) {
170
        my $bib = GetBiblioData($new_biblionumber);
171
        my $bib = GetBiblioData($new_biblionumber);
171
        if (defined $bib) {
172
        if ( defined $bib ) {
172
            $template->param(bibnum      => $new_biblionumber);
173
            $template->param( bibnum      => $new_biblionumber );
173
            $template->param(bibliotitle => $bib->{title});
174
            $template->param( bibliotitle => $bib->{title} );
174
        }
175
        }
175
    }
176
    }
176
        $template->param((uc(C4::Context->preference("marcflavour"))) => 1);
177
    $template->param( ( uc( C4::Context->preference("marcflavour") ) ) => 1 );
177
	output_html_with_http_headers $query, $cookie, $template->output;
178
    output_html_with_http_headers $query, $cookie, $template->output;
178
}
179
}
179
180
180
sub letter_loop {
181
sub letter_loop {
181
    my ($selected_letter, $templte) = @_;
182
    my ( $selected_letter, $templte ) = @_;
182
    my $letters = GetLetters('serial');
183
    my $letters = GetLetters('serial');
183
    my $letterloop;
184
    my $letterloop;
184
    foreach my $thisletter (keys %{$letters}) {
185
    foreach my $thisletter ( keys %{$letters} ) {
185
        push @{$letterloop}, {
186
        push @{$letterloop},
186
            value => $thisletter,
187
          { value      => $thisletter,
187
            selected => $thisletter eq $selected_letter,
188
            selected   => $thisletter eq $selected_letter,
188
            lettername => $letters->{$thisletter},
189
            lettername => $letters->{$thisletter},
189
        };
190
          };
190
    }
191
    }
191
    $templte->param(letterloop => $letterloop);
192
    $templte->param( letterloop => $letterloop );
192
    return;
193
    return;
193
}
194
}
194
195
195
sub _get_sub_length {
196
sub _get_sub_length {
196
    my ($type, $length) = @_;
197
    my ( $type, $length ) = @_;
197
    return
198
    return ( $type eq 'numberlength' ? $length : 0, $type eq 'weeklength' ? $length : 0, $type eq 'monthlength' ? $length : 0, );
198
        (
199
            $type eq 'numberlength' ? $length : 0,
200
            $type eq 'weeklength'   ? $length : 0,
201
            $type eq 'monthlength'  ? $length : 0,
202
        );
203
}
199
}
204
200
205
sub redirect_add_subscription {
201
sub redirect_add_subscription {
Lines 214-221 sub redirect_add_subscription { Link Here
214
    my $numberpattern  = $query->param('numbering_pattern');
210
    my $numberpattern  = $query->param('numbering_pattern');
215
    my $graceperiod    = $query->param('graceperiod') || 0;
211
    my $graceperiod    = $query->param('graceperiod') || 0;
216
212
217
    my ( $numberlength, $weeklength, $monthlength )
213
    my ( $numberlength, $weeklength, $monthlength ) = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
218
        = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
219
    my $add1              = $query->param('add1');
214
    my $add1              = $query->param('add1');
220
    my $every1            = $query->param('every1');
215
    my $every1            = $query->param('every1');
221
    my $whenmorethan1     = $query->param('whenmorethan1');
216
    my $whenmorethan1     = $query->param('whenmorethan1');
Lines 247-271 sub redirect_add_subscription { Link Here
247
    my $staffdisplaycount = $query->param('staffdisplaycount');
242
    my $staffdisplaycount = $query->param('staffdisplaycount');
248
    my $opacdisplaycount  = $query->param('opacdisplaycount');
243
    my $opacdisplaycount  = $query->param('opacdisplaycount');
249
    my $location          = $query->param('location');
244
    my $location          = $query->param('location');
250
    my $startdate = format_date_in_iso( $query->param('startdate') );
245
    my $startdate         = format_date_in_iso( $query->param('startdate') );
251
    my $enddate = format_date_in_iso( $query->param('enddate') );
246
    my $enddate           = format_date_in_iso( $query->param('enddate') );
252
    my $firstacquidate  = format_date_in_iso($query->param('firstacquidate'));
247
    my $firstacquidate    = format_date_in_iso( $query->param('firstacquidate') );
253
    my $histenddate = format_date_in_iso($query->param('histenddate'));
248
    my $histenddate       = format_date_in_iso( $query->param('histenddate') );
254
    my $histstartdate = format_date_in_iso($query->param('histstartdate'));
249
    my $histstartdate     = format_date_in_iso( $query->param('histstartdate') );
255
    my $recievedlist = $query->param('recievedlist');
250
    my $recievedlist      = $query->param('recievedlist');
256
    my $missinglist = $query->param('missinglist');
251
    my $missinglist       = $query->param('missinglist');
257
    my $opacnote = $query->param('opacnote');
252
    my $opacnote          = $query->param('opacnote');
258
    my $librariannote = $query->param('librariannote');
253
    my $librariannote     = $query->param('librariannote');
259
	my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
254
    my $subscriptionid    = NewSubscription(
260
					$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
255
        $auser,         $branchcode,   $aqbooksellerid,  $cost,
261
					$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
256
        $aqbudgetid,    $biblionumber, $startdate,       $periodicity,
262
					$add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
257
        $dow,           $numberlength, $weeklength,      $monthlength,
263
					$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
258
        $add1,          $every1,       $whenmorethan1,   $setto1,
264
					$numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity),
259
        $lastvalue1,    $innerloop1,   $add2,            $every2,
265
                    $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes,
260
        $whenmorethan2, $setto2,       $lastvalue2,      $innerloop2,
266
                    $serialsadditems,$staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate
261
        $add3,          $every3,       $whenmorethan3,   $setto3,
267
				);
262
        $lastvalue3,    $innerloop3,   $numberingmethod, $status,
268
    ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
263
        $notes, $letter, $firstacquidate, join( ",", @irregularity ),
264
        $numberpattern, $callnumber, $hemisphere, ( $manualhistory ? $manualhistory : 0 ),
265
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
266
        $graceperiod,   $location,        $enddate
267
    );
268
    ModSubscriptionHistory( $subscriptionid, $histstartdate, $histenddate, $recievedlist, $missinglist, $opacnote, $librariannote );
269
269
270
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
270
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
271
    return;
271
    return;
Lines 273-357 sub redirect_add_subscription { Link Here
273
273
274
sub redirect_mod_subscription {
274
sub redirect_mod_subscription {
275
    my $subscriptionid = $query->param('subscriptionid');
275
    my $subscriptionid = $query->param('subscriptionid');
276
	  my @irregularity = $query->param('irregularity_select');
276
    my @irregularity   = $query->param('irregularity_select');
277
    my $auser = $query->param('user');
277
    my $auser          = $query->param('user');
278
    my $librarian => $query->param('librarian'),
278
    my $librarian => $query->param('librarian'),
279
    my $branchcode = $query->param('branchcode');
279
      my $branchcode   = $query->param('branchcode');
280
    my $cost = $query->param('cost');
280
    my $cost           = $query->param('cost');
281
    my $aqbooksellerid = $query->param('aqbooksellerid');
281
    my $aqbooksellerid = $query->param('aqbooksellerid');
282
    my $biblionumber = $query->param('biblionumber');
282
    my $biblionumber   = $query->param('biblionumber');
283
    my $aqbudgetid = $query->param('aqbudgetid');
283
    my $aqbudgetid     = $query->param('aqbudgetid');
284
    my $startdate = format_date_in_iso($query->param('startdate'));
284
    my $startdate      = format_date_in_iso( $query->param('startdate') );
285
    my $nextacquidate = $query->param('nextacquidate') ?
285
    my $nextacquidate =
286
                            format_date_in_iso($query->param('nextacquidate')):
286
      $query->param('nextacquidate')
287
                            format_date_in_iso($query->param('startdate'));
287
      ? format_date_in_iso( $query->param('nextacquidate') )
288
    my $enddate = format_date_in_iso($query->param('enddate'));
288
      : format_date_in_iso( $query->param('startdate') );
289
    my $enddate     = format_date_in_iso( $query->param('enddate') );
289
    my $periodicity = $query->param('periodicity');
290
    my $periodicity = $query->param('periodicity');
290
    my $dow = $query->param('dow');
291
    my $dow         = $query->param('dow');
291
292
292
    my ($numberlength, $weeklength, $monthlength)
293
    my ( $numberlength, $weeklength, $monthlength ) = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
293
        = _get_sub_length( $query->param('subtype'), $query->param('sublength') );
294
    my $numberpattern   = $query->param('numbering_pattern');
294
    my $numberpattern = $query->param('numbering_pattern');
295
    my $add1            = $query->param('add1');
295
    my $add1 = $query->param('add1');
296
    my $every1          = $query->param('every1');
296
    my $every1 = $query->param('every1');
297
    my $whenmorethan1   = $query->param('whenmorethan1');
297
    my $whenmorethan1 = $query->param('whenmorethan1');
298
    my $setto1          = $query->param('setto1');
298
    my $setto1 = $query->param('setto1');
299
    my $lastvalue1      = $query->param('lastvalue1');
299
    my $lastvalue1 = $query->param('lastvalue1');
300
    my $innerloop1      = $query->param('innerloop1');
300
    my $innerloop1 = $query->param('innerloop1');
301
    my $add2            = $query->param('add2');
301
    my $add2 = $query->param('add2');
302
    my $every2          = $query->param('every2');
302
    my $every2 = $query->param('every2');
303
    my $whenmorethan2   = $query->param('whenmorethan2');
303
    my $whenmorethan2 = $query->param('whenmorethan2');
304
    my $setto2          = $query->param('setto2');
304
    my $setto2 = $query->param('setto2');
305
    my $lastvalue2      = $query->param('lastvalue2');
305
    my $lastvalue2 = $query->param('lastvalue2');
306
    my $innerloop2      = $query->param('innerloop2');
306
    my $innerloop2 = $query->param('innerloop2');
307
    my $add3            = $query->param('add3');
307
    my $add3 = $query->param('add3');
308
    my $every3          = $query->param('every3');
308
    my $every3 = $query->param('every3');
309
    my $whenmorethan3   = $query->param('whenmorethan3');
309
    my $whenmorethan3 = $query->param('whenmorethan3');
310
    my $setto3          = $query->param('setto3');
310
    my $setto3 = $query->param('setto3');
311
    my $lastvalue3      = $query->param('lastvalue3');
311
    my $lastvalue3 = $query->param('lastvalue3');
312
    my $innerloop3      = $query->param('innerloop3');
312
    my $innerloop3 = $query->param('innerloop3');
313
    my $numberingmethod = $query->param('numberingmethod');
313
    my $numberingmethod = $query->param('numberingmethod');
314
    my $status = 1;
314
    my $status          = 1;
315
    my $callnumber = $query->param('callnumber');
315
    my $callnumber      = $query->param('callnumber');
316
    my $notes = $query->param('notes');
316
    my $notes           = $query->param('notes');
317
    my $internalnotes = $query->param('internalnotes');
317
    my $internalnotes   = $query->param('internalnotes');
318
    my $hemisphere = $query->param('hemisphere');
318
    my $hemisphere      = $query->param('hemisphere');
319
    my $letter = $query->param('letter');
319
    my $letter          = $query->param('letter');
320
    my $manualhistory = $query->param('manualhist');
320
    my $manualhistory   = $query->param('manualhist');
321
    my $serialsadditems = $query->param('serialsadditems');
321
    my $serialsadditems = $query->param('serialsadditems');
322
322
    # subscription history
323
    # subscription history
323
    my $histenddate = format_date_in_iso($query->param('histenddate'));
324
    my $histenddate       = format_date_in_iso( $query->param('histenddate') );
324
    my $histstartdate = format_date_in_iso($query->param('histstartdate'));
325
    my $histstartdate     = format_date_in_iso( $query->param('histstartdate') );
325
    my $recievedlist = $query->param('recievedlist');
326
    my $recievedlist      = $query->param('recievedlist');
326
    my $missinglist = $query->param('missinglist');
327
    my $missinglist       = $query->param('missinglist');
327
    my $opacnote = $query->param('opacnote');
328
    my $opacnote          = $query->param('opacnote');
328
    my $librariannote = $query->param('librariannote');
329
    my $librariannote     = $query->param('librariannote');
329
	my $staffdisplaycount = $query->param('staffdisplaycount');
330
    my $staffdisplaycount = $query->param('staffdisplaycount');
330
	my $opacdisplaycount = $query->param('opacdisplaycount');
331
    my $opacdisplaycount  = $query->param('opacdisplaycount');
331
    my $graceperiod     = $query->param('graceperiod') || 0;
332
    my $graceperiod       = $query->param('graceperiod') || 0;
332
    my $location = $query->param('location');
333
    my $location          = $query->param('location');
333
    my $nextexpected = GetNextExpected($subscriptionid);
334
    my $nextexpected      = GetNextExpected($subscriptionid);
334
	#  If it's  a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary.
335
336
    #  If it's  a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary.
335
    if ( $nextacquidate ne $nextexpected->{planneddate}->output('iso') ) {
337
    if ( $nextacquidate ne $nextexpected->{planneddate}->output('iso') ) {
336
        ModNextExpected($subscriptionid,C4::Dates->new($nextacquidate,'iso'));
338
        ModNextExpected( $subscriptionid, C4::Dates->new( $nextacquidate, 'iso' ) );
339
337
        # if we have not received any issues yet, then we also must change the firstacquidate for the subs.
340
        # if we have not received any issues yet, then we also must change the firstacquidate for the subs.
338
        $firstissuedate = $nextacquidate if($nextexpected->{isfirstissue});
341
        $firstissuedate = $nextacquidate if ( $nextexpected->{isfirstissue} );
339
    }
342
    }
340
343
341
        ModSubscription(
344
    ModSubscription(
342
            $auser,           $branchcode,   $aqbooksellerid, $cost,
345
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
343
            $aqbudgetid,      $startdate,    $periodicity,    $firstissuedate,
346
        $periodicity,       $firstissuedate,   $dow,             join( q{,},     @irregularity ), $numberpattern, $numberlength,
344
            $dow,             join(q{,},@irregularity), $numberpattern,  $numberlength,
347
        $weeklength,        $monthlength,      $add1,            $every1,        $whenmorethan1,  $setto1,
345
            $weeklength,      $monthlength,  $add1,           $every1,
348
        $lastvalue1,        $innerloop1,       $add2,            $every2,        $whenmorethan2,  $setto2,
346
            $whenmorethan1,   $setto1,       $lastvalue1,     $innerloop1,
349
        $lastvalue2,        $innerloop2,       $add3,            $every3,        $whenmorethan3,  $setto3,
347
            $add2,            $every2,       $whenmorethan2,  $setto2,
350
        $lastvalue3,        $innerloop3,       $numberingmethod, $status,        $biblionumber,   $callnumber,
348
            $lastvalue2,      $innerloop2,   $add3,           $every3,
351
        $notes,             $letter,           $hemisphere,      $manualhistory, $internalnotes,  $serialsadditems,
349
            $whenmorethan3,   $setto3,       $lastvalue3,     $innerloop3,
352
        $staffdisplaycount, $opacdisplaycount, $graceperiod,     $location,      $enddate,        $subscriptionid
350
            $numberingmethod, $status,       $biblionumber,   $callnumber,
353
    );
351
            $notes,           $letter,       $hemisphere,     $manualhistory,$internalnotes,
354
    ModSubscriptionHistory( $subscriptionid, $histstartdate, $histenddate, $recievedlist, $missinglist, $opacnote, $librariannote );
352
            $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid
353
        );
354
        ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
355
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
355
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
356
    return;
356
    return;
357
}
357
}
358
- 

Return to bug 8956