suspend later just like expire (#1487)
[freeside.git] / httemplate / edit / process / REAL_cust_pkg.cgi
1 %
2 %
3 %my $pkgnum = $cgi->param('pkgnum') or die;
4 %my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
5 %my %hash = $old->hash;
6 %$hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : '';
7 %$hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : '';
8 %$hash{'last_bill'} =
9 %  $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : '';
10 %$hash{'adjourn'} = $cgi->param('adjourn') ? str2time($cgi->param('adjourn')) : '';
11 %$hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : '';
12 %
13 %my $new;
14 %my $error;
15 %if ( $hash{'bill'} != $old->bill        # if the next bill date was changed
16 %     && $hash{'bill'} < time            # to a date in the past
17 %     && ! $cgi->param('bill_areyousure') # and it wasn't confirmed
18 %   )
19 %{
20 %  $error = '_bill_areyousure';
21 %} else {
22 %  $new = new FS::cust_pkg \%hash;
23 %  $error = $new->replace($old);
24 %}
25 %
26 %if ( $error ) {
27 %  $cgi->param('error', $error);
28 %  print $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string );
29 %} else { 
30 %  my $custnum = $new->custnum;
31 %  print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum".
32 %                       "#cust_pkg$pkgnum" );
33 %}
34 %
35 %
36