2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ) %>
5 % my $custnum = $new->custnum;
6 % my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
9 % my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
10 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag" ) %>
14 my $curuser = $FS::CurrentUser::CurrentUser;
17 unless $curuser->access_right('Edit customer package dates')
18 or $curuser->access_right('Change package contract end date');
20 my $contract_only = $curuser->access_right('Edit customer package dates') ? 0 : 1;
21 $contract_only = 1 if $cgi->param('contract_only');
23 my $pkgnum = $cgi->param('pkgnum') or die;
24 my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
25 my %hash = $old->hash;
26 foreach ( $contract_only ? qw( contract_end ) : qw( start_date setup bill last_bill contract_end ) ) {
27 if ( $cgi->param($_) =~ /^(\d+)$/ ) {
32 # adjourn, expire, resume not editable this way
37 $new = new FS::cust_pkg \%hash;
38 $error = $new->replace($old);
41 my @supp_pkgs = $old->supplemental_pkgs;
42 foreach $new (@supp_pkgs) {
43 foreach ( $contract_only ? qw( contract_end ) : qw( start_date setup contract_end ) ) {
44 # propagate these to supplementals
45 $new->set($_, $hash{$_});
47 if (( $hash{'bill'} ne $old->get('bill') ) && !$contract_only ) {
48 if ( $hash{'bill'} and $old->get('bill') ) {
49 # adjust by the same interval
50 my $diff = $hash{'bill'} - $old->get('bill');
51 $new->set('bill', $new->get('bill') + $diff);
54 $new->set('bill', $hash{'bill'});
57 $error = $new->replace;
58 $error .= ' (supplemental package '.$new->pkgnum.')' if $error;